Initial commit

This commit is contained in:
tim 2021-11-11 11:31:29 +10:30
parent 5d8d84bb81
commit 6a13a9bc04
1 changed files with 40 additions and 0 deletions

40
manga2web.sh Executable file
View File

@ -0,0 +1,40 @@
#!/bin/bash
chapter_loop () {
echo '<!DOCTYPE html><head>'"<title>$1 - Manga2Web</title>"'<meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><style>body{background-color:black;color:lightgrey;max-width:60em;font:1.1em/1.2em sans-serif;}h1,h2,h3{line-height:1.2em;}@media print{body{max-width:none}}</style></head><body>'"<h1>$1 - Manga2Web</h1><hr><p>"
for i in "$1"/*{jpg,jpeg,png}; do
if [ -f "$i" ]; then
echo "<img width=\"100%\" src=\"$(basename "$i")\"><br>"
fi
done
if [ ! -z "$previous_chapter_dir" ]; then
echo '<a href="'"../$previous_chapter_dir/index.html"'">&lt;-- previous chapter</a>'
fi
}
manga_index () {
echo '<!DOCTYPE html><head>'"<title>${PWD##*/} - Manga2Web</title>"'<meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1"><style>body{background-color:lightgrey;max-width:60em;font:1.1em/1.2em sans-serif;}h1,h2,h3{line-height:1.2em;}@media print{body{max-width:none}}</style></head><body>'"<h1>${PWD##*/} - Manga2Web</h1><hr><p>"
for i in *; do
if [ -d "$i" ]; then
echo "<a href=\"$i/index.html\">$i</a><br>"
fi
done
echo '</p><hr></body>'
}
main () {
manga_index > index.html
for chapter_dir in *; do
if [ -d "$chapter_dir" ]; then
if [ ! -z "$previous_chapter_dir" ]; then
echo '<a href="'"../$chapter_dir/index.html"'">next chapter --&gt;</a></p><hr></body>' >> "$previous_chapter_dir/index.html"
fi
chapter_loop "$chapter_dir" > "$chapter_dir/index.html"
previous_chapter_dir=$chapter_dir
fi
done
echo '</p><hr></body>' >> "$previous_chapter_dir/index.html"
}
main