mirror of
https://github.com/AngelJumbo/gruvbox-wallpapers.git
synced 2026-10-20 08:06:19 +00:00
Cleaner script
This commit is contained in:
@@ -20,6 +20,8 @@
|
|||||||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
# SOFTWARE.
|
# SOFTWARE.
|
||||||
|
|
||||||
|
|
||||||
|
#not really a header, it's just the begining of the page.
|
||||||
write_header(){
|
write_header(){
|
||||||
echo "<!DOCTYPE html>
|
echo "<!DOCTYPE html>
|
||||||
<html lang=\"en\">
|
<html lang=\"en\">
|
||||||
@@ -35,36 +37,41 @@ write_header(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
write_section_header(){
|
write_section_header(){
|
||||||
|
echo "<h2 id=s"$1">" >> $3
|
||||||
echo "<h2 id=s"$1">" >> "$3"
|
echo "$2" | tr a-z A-Z >> $3
|
||||||
echo "$2" | tr a-z A-Z >> "$3"
|
echo "</h2>" >> $3
|
||||||
echo "</h2>" >> "$3"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
write_img(){
|
write_img(){
|
||||||
echo " <a target=\"_blank\" href=\"$1\">
|
echo " <a target=\"_blank\" href=\"$1\">
|
||||||
<img loading=\"lazy\" src=\"$1\" alt="$1" width=\"200\"></a>" >> "$2"
|
<img loading=\"lazy\" src=\"$1\" alt="$1" width=\"200\"></a>" >> $2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#not really a footer, it's just the end of the page.
|
||||||
write_footer(){
|
write_footer(){
|
||||||
echo "<p> Contributions <a href=\"https://github.com/AngelJumbo/gruvbox-wallpapers\">here</a>.</p>
|
echo "<p> Contributions <a href=\"https://github.com/AngelJumbo/gruvbox-wallpapers\">here</a>.</p>
|
||||||
<p> This images are from random sites or contributions so I don't have a way to know who are their original artist.</p>
|
<p> This images are from random sites or contributions so I don't have a way to know who are their original artist.</p>
|
||||||
<p> 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 <a href=\"https://github.com/AngelJumbo/gruvbox-wallpapers/issues\">here</a>.</p>
|
<p> 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 <a href=\"https://github.com/AngelJumbo/gruvbox-wallpapers/issues\">here</a>.</p>
|
||||||
<p> The same goes, if you want me to remove your art.</p>
|
<p> The same goes, if you want me to remove your art.</p>
|
||||||
</body>
|
</body>
|
||||||
</html>" >> "$1"
|
</html>" >> $1
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#create index file
|
||||||
touch ./index.html
|
touch ./index.html
|
||||||
|
|
||||||
|
#write the begining of the index file
|
||||||
write_header ./index.html
|
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
|
color=1
|
||||||
|
|
||||||
for subdir in ./wallpapers/*
|
for subdir in ./wallpapers/*
|
||||||
do
|
do
|
||||||
|
#for each folder in the wallpapers directory we first write a section header
|
||||||
write_section_header $color "${subdir##*/}" ./index.html
|
write_section_header $color "${subdir##*/}" ./index.html
|
||||||
|
|
||||||
echo "<div id=c>" >> ./index.html
|
echo "<div id=c>" >> ./index.html
|
||||||
@@ -72,18 +79,20 @@ do
|
|||||||
count=1;
|
count=1;
|
||||||
for wallpaper in ${subdir}/*
|
for wallpaper in ${subdir}/*
|
||||||
do
|
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
|
if [ "$count" -lt 9 ]; then #limit the amount of images per section in index
|
||||||
write_img $wallpaper ./index.html
|
write_img $wallpaper ./index.html
|
||||||
count=$((count+1))
|
count=$((count+1))
|
||||||
else #if the limit is exceeded then create a new html with all the images of the section
|
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)
|
|
||||||
|
|
||||||
|
subhtml="${subdir##*/}.html"
|
||||||
|
#count the amount of images in the folder
|
||||||
|
nimgs=$(ls "${subdir}" | wc -l)
|
||||||
|
#make a link to the new page
|
||||||
echo " <a target=\"_blank\" class = \"showmore\" href=\"${subhtml}\">
|
echo " <a target=\"_blank\" class = \"showmore\" href=\"${subhtml}\">
|
||||||
<div class = \"showmore\">show all ${nimgs} ${subdir##*/} wallpapers </div></a>" >> ./index.html
|
<div class = \"showmore\">show all ${nimgs} ${subdir##*/} wallpapers </div></a>" >> ./index.html
|
||||||
|
|
||||||
touch "${subhtml}"
|
touch "$subhtml"
|
||||||
|
|
||||||
write_header $subhtml
|
write_header $subhtml
|
||||||
|
|
||||||
@@ -91,7 +100,7 @@ do
|
|||||||
|
|
||||||
|
|
||||||
echo "<div id=c>" >> "${subhtml}"
|
echo "<div id=c>" >> "${subhtml}"
|
||||||
|
#write all the images of the current section
|
||||||
for wallpaper2 in ${subdir}/*
|
for wallpaper2 in ${subdir}/*
|
||||||
do
|
do
|
||||||
write_img $wallpaper2 $subhtml
|
write_img $wallpaper2 $subhtml
|
||||||
@@ -100,6 +109,7 @@ do
|
|||||||
echo "</div>" >> "${subhtml}"
|
echo "</div>" >> "${subhtml}"
|
||||||
|
|
||||||
write_footer $subhtml
|
write_footer $subhtml
|
||||||
|
#break current loop and continue to the next section
|
||||||
break
|
break
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -108,6 +118,8 @@ do
|
|||||||
echo "</div>" >> ./index.html
|
echo "</div>" >> ./index.html
|
||||||
|
|
||||||
color=$((color+1))
|
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
|
if [ "$color" -eq 8 ]; then
|
||||||
color=1
|
color=1
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user