From 31048baa6f9b0eb75bfc8a28d0dc933953965c0b Mon Sep 17 00:00:00 2001 From: AngelJumbo <31261193+AngelJumbo@users.noreply.github.com> Date: Sun, 27 Nov 2022 17:50:08 -0500 Subject: [PATCH] Cleaner script --- build.sh | 80 +++++++++++++++++++++++++++++--------------------------- 1 file changed, 42 insertions(+), 38 deletions(-) diff --git a/build.sh b/build.sh index 015e97f..2356d8f 100755 --- a/build.sh +++ b/build.sh @@ -20,9 +20,8 @@ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. -touch ./index.html - -echo " +write_header(){ + echo " @@ -32,15 +31,41 @@ echo " -

Wallpapers for gruvbox

" > ./index.html +

Wallpapers for gruvbox

" > $1 +} + +write_section_header(){ + + echo "

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

" >> "$3" +} + +write_img(){ + echo " +$1" >> "$2" +} + + +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" + +} + +touch ./index.html + +write_header ./index.html color=1 for subdir in ./wallpapers/* do - echo "

" >> ./index.html - echo "${subdir##*/}" | tr a-z A-Z >> ./index.html - echo "

" >> ./index.html + write_section_header $color "${subdir##*/}" ./index.html echo "
" >> ./index.html @@ -48,49 +73,33 @@ do for wallpaper in ${subdir}/* do if [ "$count" -lt 9 ]; then #limit the amount of images per section in index - echo " - $wallpaper" >> ./index.html + 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" nimgs=$(ls "${subdir}" | wc -l) + echo "
show all ${nimgs} ${subdir##*/} wallpapers
" >> ./index.html + touch "${subhtml}" - echo " - - - - - - Gruvbox wallpapers - - - -

Wallpapers for gruvbox

" > "${subhtml}" + write_header $subhtml - echo "

" >> "${subhtml}" - echo "${subdir##*/}" | tr a-z A-Z >> "${subhtml}" - echo "

" >> "${subhtml}" - + write_section_header $color "${subdir##*/}" $subhtml + + echo "
" >> "${subhtml}" for wallpaper2 in ${subdir}/* do - echo " - $wallpaper2" >> "${subhtml}" + write_img $wallpaper2 $subhtml done echo "
" >> "${subhtml}" - 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.

- -" >> "${subhtml}" + write_footer $subhtml break fi @@ -104,9 +113,4 @@ do fi done -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.

- -" >> ./index.html +write_footer ./index.html