#!/bin/sh # MIT License # Copyright (c) 2022 Angel Jumbo # # Permission is hereby granted, free of charge, to any person obtaining a copy # of this software and associated documentation files (the "Software"), to deal # in the Software without restriction, including without limitation the rights # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell # copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # The above copyright notice and this permission notice shall be included in all # copies or substantial portions of the Software. # # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # 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 " Gruvbox wallpapers

Wallpapers for gruvbox

" > $1 } write_section_header(){ echo "

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

" >> $3 } write_img(){ echo " $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 } #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 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 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 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 done echo "
" >> "${subhtml}" write_footer $subhtml #break current loop and continue to the next section break fi done echo "
" >> ./index.html color=$((color+1)) #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 write_footer ./index.html