From ea486d626a527ab661bf5aabc20de16dad7d6e29 Mon Sep 17 00:00:00 2001 From: /dev/urandom Date: Sat, 14 Mar 2020 09:03:43 +0300 Subject: [PATCH] added upload.sh --- Makefile | 4 ++-- README.md | 2 +- static/style.css | 22 ++++++++++++++++++++++ upload.sh | 30 ++++++++++++++++++++++++++++++ 4 files changed, 55 insertions(+), 3 deletions(-) create mode 100755 upload.sh diff --git a/Makefile b/Makefile index b7256ba..f9528e3 100644 --- a/Makefile +++ b/Makefile @@ -20,14 +20,14 @@ OUT_STATIC = $(patsubst static/%,out/%,$(_STATIC)) all: $(PAGES_HTML) $(OUT_STATIC) -$(OUTDIR)/%.html: $(PAGEDIR)/%.md $(TPLDIR)/default.tpl +$(OUTDIR)/%.html: $(PAGEDIR)/%.md $(TPLDIR)/default.tpl $(OUTDIR) theme -t $(TPLDIR)/default.tpl -o $@ $< $(OUTDIR)/%: static/% cp -r $< $@ $(OUTDIR): - mkdir $(OUTDIR) + mkdir -p $(OUTDIR) clean: rm -rf out/* diff --git a/README.md b/README.md index 8ad82d9..5b44e1a 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ # Simple site template -An attempt to use makefiles, markdown and maybe a bit of C preprocessing to make a static website. \ No newline at end of file +An attempt to use makefiles, markdown and a bit of bash to make a simple static website and easily upload it to neocities. diff --git a/static/style.css b/static/style.css index 371c3f3..3962d84 100644 --- a/static/style.css +++ b/static/style.css @@ -41,3 +41,25 @@ body a:visited { font-family: sans-serif: font-size: 0.8em; } + +.info { + border-left: 4px solid #3465a4; + background:#729fcf; +} + +.warning { + border-left: 4px solid #c4a000; + background:#fce94f; +} + +.error { + border-left: 4px solid #a40000; + background:#cc0000; + color:white; +} + +.error a, .error a:visited { + color: white; +} + + diff --git a/upload.sh b/upload.sh new file mode 100755 index 0000000..2609021 --- /dev/null +++ b/upload.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +if ! [[ -f upload.pwd ]]; then + echo "You need a file named upload.pwd with the following format:" + echo "N_USER=[your neocities username]" + echo "N_PWD=[your neocities password]" + exit 1 +fi + +source ./upload.pwd + +LASTUPLOAD=`stat -c %Y upload.lasttime 2>/dev/null` +if [[ -z $LASTUPLOAD ]]; then LASTUPLOAD=0; fi + +echo "Last upload at $LASTUPLOAD" + +FILES=`find out/ -type f` + +for f in $FILES; do + MTIME=`stat -c %Y $f` + #echo "MTIME for $f: $MTIME" + if [[ $MTIME -gt $LASTUPLOAD ]]; then + REMOTENAME="${f#out/}" + echo "Uploading $REMOTENAME..." + curl -F "$REMOTENAME=@$f" "https://$N_USER:$N_PWD@neocities.org/api/upload" + fi +done + +touch upload.lasttime +