main: update footer, add webring/lieu icons; thumbnailer: skip zips too, update printed messages
This commit is contained in:
parent
2b5d9a3416
commit
0c61181734
2 changed files with 39 additions and 20 deletions
46
main.c
46
main.c
|
@ -79,9 +79,7 @@ int findf(Lexicon* l, char* f) {
|
|||
void fpedited(FILE* f, char* path) {
|
||||
struct stat attr;
|
||||
stat(path, &attr);
|
||||
fputs("<span style='float:right'>", f);
|
||||
fprintf(f, "Edited on %s ", ctime(&attr.st_mtime));
|
||||
fputs("</span>", f);
|
||||
fprintf(f, "Edited on %s<br/>", ctime(&attr.st_mtime));
|
||||
}
|
||||
|
||||
int fpportal(FILE* f, Lexicon* l, char* s, int head) {
|
||||
|
@ -283,6 +281,34 @@ int fpinject(FILE* f, Lexicon* l, char* filepath) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
int fpfooter(FILE* f, char* name, char* path) {
|
||||
if (!f || !name || !path)
|
||||
return 0;
|
||||
fputs("<footer>", f);
|
||||
if (!ismetanav(name)) {
|
||||
fpedited(f, path);
|
||||
fputs(
|
||||
"contact: <a href='mailto://drkste@zoho.com'>drkste@zoho.com</a> ",
|
||||
f);
|
||||
fputs("(<a href='keys.html'>keys</a>)<br/>", f);
|
||||
}
|
||||
fputs(
|
||||
"<a href='https://webring.xxiivv.com'><img width='24' height='24' "
|
||||
"src='/img/webring.svg' alt='visit the webring'/></a> ",
|
||||
f);
|
||||
fputs(
|
||||
"<a href='https://lieu.cblgh.org'><img width='24' height='24' "
|
||||
"src='/img/lieu.svg' alt='search the webring'/></a><br/>",
|
||||
f);
|
||||
fputs(
|
||||
"<a rel='license' "
|
||||
"href='https://creativecommons.org/licenses/by-nc/4.0/"
|
||||
"legalcode.txt'>CC-BY-NC 4</a>",
|
||||
f);
|
||||
fputs("</footer>", f);
|
||||
return 1;
|
||||
}
|
||||
|
||||
FILE* build(FILE* f, Lexicon* l, char* name, char* srcpath) {
|
||||
if (!f)
|
||||
return f;
|
||||
|
@ -333,16 +359,12 @@ FILE* build(FILE* f, Lexicon* l, char* name, char* srcpath) {
|
|||
if (!fpinject(f, l, srcpath))
|
||||
printf(">>> Building failed: %s\n", name);
|
||||
fputs("\n\n</main>", f);
|
||||
/* footer */
|
||||
fputs("<footer>", f);
|
||||
fpedited(f, srcpath);
|
||||
fputs(
|
||||
"contact: <a href='mailto://drkste@zoho.com'>drkste@zoho.com</a> ",
|
||||
f);
|
||||
fputs("(<a href='keys.html'>keys</a>)", f);
|
||||
/* fputs("<a href='" LICENSE "' target='_blank'>BY-NC-SA 4.0</a>", f) */;
|
||||
fputs("</footer>", f);
|
||||
}
|
||||
/* footer */
|
||||
if (!fpfooter(f, name, srcpath)) {
|
||||
printf(">>> Building failed: footer(%s)\n", name);
|
||||
}
|
||||
|
||||
/* end */
|
||||
fputs("</body></html>", f);
|
||||
return f;
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
#!/bin/sh
|
||||
|
||||
ROOT=../www
|
||||
SRC=../www/img
|
||||
SIZE=500
|
||||
|
||||
|
@ -19,27 +18,25 @@ pathtrans() {
|
|||
# generate thumbnails in /img/*/.thumb/
|
||||
resize() {
|
||||
output=$(pathtrans $1)
|
||||
if echo $1 | grep .gif > /dev/null; then
|
||||
if echo $1 | grep -e .gif -e .zip > /dev/null; then
|
||||
return
|
||||
fi
|
||||
if [ ! -f ${output} ]; then
|
||||
echo "generating thumbnail for $1"
|
||||
echo "Generating thumbnail for $1"
|
||||
convert $1 -strip -auto-orient -resize ${SIZE} -dither FloydSteinberg -colors 16 ${output}
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
|
||||
if [ -z $1 ]; then
|
||||
echo "usage: $0 [build|clean]"
|
||||
else
|
||||
case $1 in
|
||||
"build")
|
||||
echo "creating new thumbnails"
|
||||
echo "Updating thumbnails cache"
|
||||
for x in $(find ${SRC}/*/*); do resize $x; done;;
|
||||
"clean")
|
||||
echo "cleaning thumbnails cache"
|
||||
echo "Cleaning thumbnails cache"
|
||||
rm -rf ${SRC}/*/.thumb
|
||||
echo "cleaned";;
|
||||
echo "Cleaned";;
|
||||
esac
|
||||
fi
|
||||
|
|
Loading…
Reference in a new issue