From 20941c26f8c5d5b4f41fd53b1a6783ad9d4e7c72 Mon Sep 17 00:00:00 2001 From: AngelJumbo Date: Sun, 27 Nov 2022 18:21:44 -0500 Subject: [PATCH] Cleaner script --- build.sh | 42 +++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/build.sh b/build.sh index 2356d8f..f8e4285 100755 --- a/build.sh +++ b/build.sh @@ -20,6 +20,8 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. + +#not really a header, it's just the begining of the page. write_header(){ echo " @@ -35,36 +37,41 @@ write_header(){ } write_section_header(){ - - echo "

" >> "$3" - echo "$2" | tr a-z A-Z >> "$3" - echo "

" >> "$3" + echo "

" >> $3 + echo "$2" | tr a-z A-Z >> $3 + echo "

" >> $3 } write_img(){ echo " -$1" >> "$2" +$1" >> $2 } - +#not really a footer, it's just the end of the page. write_footer(){ echo "

Contributions here.

This images are from random sites or contributions so I don't have a way to know who are their original artist.

I want to keep this site as simple as possible, but if you are the creator of any of these images and you want acknowledgment I will happily add a section with your name. Just open an issue here.

The same goes, if you want me to remove your art.

-" >> "$1" +" >> $1 } +#create index file touch ./index.html +#write the begining of the index file write_header ./index.html +#color of the section headers +#there are 7 colors and these are defined in the style.css +#with the ids: s1, s2 .... s7 color=1 + for subdir in ./wallpapers/* do - + #for each folder in the wallpapers directory we first write a section header write_section_header $color "${subdir##*/}" ./index.html echo "
" >> ./index.html @@ -72,26 +79,28 @@ do count=1; for wallpaper in ${subdir}/* do + #write each image of each folder in the Wallpapers directory if [ "$count" -lt 9 ]; then #limit the amount of images per section in index write_img $wallpaper ./index.html count=$((count+1)) else #if the limit is exceeded then create a new html with all the images of the section - # TODO: make this part cleaner, this is really ugly!!. + subhtml="${subdir##*/}.html" + #count the amount of images in the folder nimgs=$(ls "${subdir}" | wc -l) - + #make a link to the new page echo " -
show all ${nimgs} ${subdir##*/} wallpapers
" >> ./index.html +
show all ${nimgs} ${subdir##*/} wallpapers
" >> ./index.html - touch "${subhtml}" + touch "$subhtml" write_header $subhtml - + write_section_header $color "${subdir##*/}" $subhtml echo "
" >> "${subhtml}" - + #write all the images of the current section for wallpaper2 in ${subdir}/* do write_img $wallpaper2 $subhtml @@ -100,6 +109,7 @@ do echo "
" >> "${subhtml}" write_footer $subhtml + #break current loop and continue to the next section break fi @@ -108,7 +118,9 @@ do echo "
" >> ./index.html color=$((color+1)) - if [ "$color" -eq 8 ]; then + #there are only 7 colors, if there are more than 7 folders in the wallpapers folder + #then repeat the colors + if [ "$color" -eq 8 ]; then color=1 fi done