Compare commits
No commits in common. "main" and "transclude_edittime" have entirely different histories.
main
...
transclude
10 changed files with 128 additions and 450 deletions
|
@ -13,6 +13,7 @@ IndentCaseLabels: true
|
|||
SpaceBeforeParens: ControlStatements
|
||||
AlignAfterOpenBracket: AlwaysBreak
|
||||
BinPackArguments: false
|
||||
BinPackArguments: false
|
||||
PointerAlignment: Left
|
||||
BreakBeforeBraces: Attach
|
||||
SortIncludes: false
|
||||
|
|
2
LICENSE
2
LICENSE
|
@ -1,4 +1,4 @@
|
|||
Copyright 2021 Iris Lightshard
|
||||
Copyright 2021 Derek Stevens
|
||||
Copyright 2021 Devine Lu Linvega
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
|
43
README.md
43
README.md
|
@ -17,8 +17,6 @@ Eureka also parses a [twtxt](https://twtxt.readthedocs.io/en/latest/) file at `S
|
|||
5. Create a new page, eg `inc/my_first_page.htm` (see the markup section below).
|
||||
6. Edit your `inc/meta.nav.htm` again to reference your new page.
|
||||
7. Run `./build.sh` again! You will be warned of any orphaned files.
|
||||
8. Deploy with `./deploy.sh`. `--syndicate` will syndicate the latest twtxt to the honknet.
|
||||
9. Revert changes and restore local with the live site with `./deploy.sh --resync`.
|
||||
|
||||
## build options
|
||||
|
||||
|
@ -36,8 +34,6 @@ Combined argument format like `./build.sh -rdt "twt stuff"` is not supported. Us
|
|||
|
||||
If you run into issues with your markup crashing `eureka`, edit the `build.sh` file to uncomment the linux debug build line and comment the fast build; this will show you a stack trace of where you are running into buffer overflows, and give you a hint of where your markup is messed up. To see the individual file that has the error, also uncomment the line in `fpinject()` that prints the file names.
|
||||
|
||||
If you find a bug, let me know.
|
||||
|
||||
# markup
|
||||
|
||||
There is a markup language which makes writing long blog posts, memex entries, etc easier by reducing the need for typing out HTML tags:
|
||||
|
@ -85,7 +81,7 @@ There is a markup language which makes writing long blog posts, memex entries, e
|
|||
{@bold text}
|
||||
|
||||
// shorthand for italic
|
||||
{\italic text}
|
||||
{~italic text}
|
||||
|
||||
// shorthand for code
|
||||
{`short code}
|
||||
|
@ -100,7 +96,7 @@ There is a markup language which makes writing long blog posts, memex entries, e
|
|||
{>longer quote}
|
||||
|
||||
// shorthand for strikethrough
|
||||
{~crossed-out text}
|
||||
{\crossed-out text}
|
||||
|
||||
// shorthand for level 3 heading
|
||||
{!heading text}
|
||||
|
@ -108,25 +104,8 @@ There is a markup language which makes writing long blog posts, memex entries, e
|
|||
// shorthand for level 4 heading
|
||||
{.heading text}
|
||||
|
||||
// shorthand for tables
|
||||
{[column 1 header|column 2 header|column 3 header}
|
||||
{|simple data|{@bold data}|{*https://nilfm.cc|link data}}
|
||||
{|more|and more|and more data!}
|
||||
{;}
|
||||
|
||||
// shorthand for publish date (renders as <time class='publish-date'>)
|
||||
{+2022-02-22}
|
||||
|
||||
// shorthand for explicit monospace, sans, and serif font respecively:
|
||||
{=some mono text}
|
||||
{(some sans serif text}
|
||||
{)some serif text}
|
||||
|
||||
// shorthand for a pictured directory/list item
|
||||
{%page name|picture}
|
||||
|
||||
// shorthand for a shop listing
|
||||
{^payment-link|description|img1|alttext1|...|imgn|alttextn}
|
||||
```
|
||||
|
||||
# configuration
|
||||
|
@ -137,16 +116,12 @@ The following macros are available in `config.h` to customize to your liking.
|
|||
- **TAG\_BODY\_SIZE**: max size for an individual markup body (ie, a markup token as above, minus the curly brackets and the rune), in bytes
|
||||
- **NAME**: the title of the site
|
||||
- **DOMAIN**: currently unused
|
||||
- **LOGO_HTML**: HTML to put in the header h1 verbatim
|
||||
- **ABOUT_HTML**: HTML content for the front page
|
||||
- **CONTACT_HTML**: the contact info line at the bottom of every page (except the front page, where it would typically already be in **@ABOUT**
|
||||
- **FOOTER_HTML**: arbitrary footer HTML
|
||||
- **LICENSE_HTML**: the license link at the bottom of every page
|
||||
- **SITEROOT**: the path where the rendered HTML is placed; include trailing slash
|
||||
- **LOGO**: HTML to put in the header h1 verbatim
|
||||
- **ABOUT**: HTML content for the front page, placed between `<header>` and `<nav>`
|
||||
- **CONTACT**: the contact info line at the bottom of every page (except the front page, where it would typically already be in **@ABOUT**
|
||||
- **FOOTER**: arbitrary footer HTML
|
||||
- **LICENSE**: the license link at the bottom of every page
|
||||
- **SITEROOT**: the path where the rendered HTML is placed
|
||||
- **MAINCSS** and **FRONTCSS**: to differentiate styles used for the landing page and the rest of the site
|
||||
- **TWTXT**: path to the twtxt file relative to the SITEROOT; if you don't want twtxt on the front page, use a nonexistent filename
|
||||
- **IS_HTML5_VIDEO_ENABLED**: if videos are embedded or just linked to with a poster image
|
||||
- **IS_NAV_IN_HEADER**: if the nav is inside the header or its sibling
|
||||
- **DEPLOY_DEST** and **DEPLOOY_IDENT**: ssh location (host:path) and key name for deployment
|
||||
- **CONTACT_ADDRESS** email address for ecommerce and can be interpolated in CONTACT_HTML
|
||||
|
||||
|
||||
|
|
6
build.sh
6
build.sh
|
@ -16,15 +16,13 @@ if [ ! -e inc/meta.nav.htm ]; then
|
|||
fi
|
||||
|
||||
# Lint
|
||||
if which clang-format > /dev/null; then
|
||||
clang-format -i main.c config.h
|
||||
fi
|
||||
clang-format -i main.c config.h
|
||||
|
||||
# Cleanup
|
||||
rm -f ./main
|
||||
|
||||
# Linux(debug)
|
||||
# cc -std=c89 -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wuninitialized -Wextra -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Wvla -g -Og -fsanitize=address -fsanitize=undefined main.c -o main
|
||||
#cc -std=c89 -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wuninitialized -Wextra -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Wvla -g -Og -fsanitize=address -fsanitize=undefined main.c -o main
|
||||
|
||||
# Linux(fast)
|
||||
cc main.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -o main
|
||||
|
|
55
config.def.h
55
config.def.h
|
@ -1,22 +1,37 @@
|
|||
/* clang-format off */
|
||||
#define SITEMAP "all_pages"
|
||||
#define DOMAIN "https://amotherfucking.website"
|
||||
#define DEPLOY_DEST "usr@amotherfucking.website:/opt/site/"
|
||||
#define DEPLOY_IDENT "id_sub"
|
||||
#define TAG_BODY_SIZE 4096
|
||||
#define LOGO_HTML "<img src='/img/logo.png' alt='a website'/>"
|
||||
#define MAINCSS "/main.css"
|
||||
#define FOOTER_HTML "peekaboo"
|
||||
#define LICENSE_HTML "<a rel='license' target='_blank' href='/legal.html'>legal</a>"
|
||||
#define DESC "website eeeeeeee"
|
||||
#define IS_NAV_IN_HEADER 01
|
||||
#define DESC "lair of drkste aka nilix: artist, programmer, philosopher"
|
||||
#define LEXICON_SIZE 1024
|
||||
#define CONTACT_HTML "<a href='mailto:person@domain.net' class='mono'contact me</a>"
|
||||
#define FRONTCSS "/front.css"
|
||||
#define MAINCSS "/new.css"
|
||||
#define FOOTER \
|
||||
"<a href='/git/'><img src='/img/git.svg' alt='visit the nilFM hack " \
|
||||
"lab.'/></a> \n" \
|
||||
"<a rel='me' href='https://cafe.nilfm.cc/u/nilix'><img src='/img/honk.svg' " \
|
||||
"alt='visit me on the Fediverse.'/></a> \n" \
|
||||
"<a href='https://webring.xxiivv.com'><img src='/img/webring.svg' " \
|
||||
"alt='visit the Webring.'/></a><br/>\n" \
|
||||
"<a href='/sitemap.html'>sitemap</a><br/>\n"
|
||||
#define LICENSE \
|
||||
"<a rel='license' " \
|
||||
"href='https://creativecommons.org/licenses/by-nc/4.0/" \
|
||||
"legalcode.txt'>CC-BY-NC 4</a><br/>\n" \
|
||||
"<a href='/legal_disclaimer.html'>opinions are my own</a>"
|
||||
#define SITEROOT "../www/"
|
||||
#define TWTXT "/twtxt.txt"
|
||||
#define ABOUT_HTML "<h2>Welcome to this website</h2>"
|
||||
#define NAME "a website"
|
||||
#define IS_HTML5_VIDEO_ENABLED 0
|
||||
#define CONTACT_ADDRESS "contact@amotherfuckingwebsite.com"
|
||||
/* clang-format on */
|
||||
#define TAG_BODY_SIZE 4096
|
||||
#define CONTACT \
|
||||
"contact: <a href='mailto:nilix@nilfm.cc'>nilix@nilfm.cc</a> (<a " \
|
||||
"href='keys.html'>keys</a>)<br/>\n" \
|
||||
""
|
||||
#define DOMAIN "https://nilfm.cc"
|
||||
#define FRONTCSS "/front.css"
|
||||
#define ABOUT \
|
||||
"Derek Stevens <<a " \
|
||||
"href='mailto:nilix@nilfm.cc'>nilix@nilfm.cc</a>><br/>\n" \
|
||||
"artist, programmer, philosopher<br/><br/>\n" \
|
||||
"verify my signature: <a " \
|
||||
"href='/serv/90587A740FA4FFA0971575383B7FBC22144E6398.asc'>signing public " \
|
||||
"key</a><br/>\n" \
|
||||
"send me an encrypted message: <a " \
|
||||
"href='/serv/F5672E001CC962BE3B6C8887C65B677280C66DE5.asc'>encryption " \
|
||||
"public key</a>\n" \
|
||||
""
|
||||
#define LOGO "<img src='/img/nilfm_blackHole_96.png' alt='blackHole://server'/>"
|
||||
#define NAME "nilFM"
|
||||
|
|
16
deploy.sh
16
deploy.sh
|
@ -1,15 +1,3 @@
|
|||
#!/bin/sh
|
||||
DEST="nilix@lynx.uberspace.de:~/lib/nilfm/"
|
||||
|
||||
DEST=$(grep "#define DEPLOY_DEST" config.h | awk '{print $3}' | sed -e 's/"//g')
|
||||
IDENT=$(grep "#define DEPLOY_IDENT" config.h | awk '{print $3}' | sed -e 's/"//g')
|
||||
SITEROOT=$(grep "#define SITEROOT" config.h | awk '{print $3}' | sed -e 's/"//g')
|
||||
TWTXT=$(grep "#define TWTXT" config.h | awk '{print $3}' | sed -e 's/"//g')
|
||||
|
||||
if [ "$1" = "--resync" ]; then
|
||||
rsync -avk -e "ssh -i ~/.ssh/${IDENT}" --delete ${DEST} ../
|
||||
else
|
||||
rsync -avK -e "ssh -i ~/.ssh/${IDENT}" --delete ../ ${DEST}
|
||||
if [ "$1" = "--syndicate" ] && [ $? -eq 0 ]; then
|
||||
./underbbs.sh honk "$(cat ${SITEROOT}/${TWTXT} | head -n 1 | cut -f 2)"
|
||||
fi
|
||||
fi
|
||||
rsync -avK --delete ../ ${DEST}
|
||||
|
|
376
main.c
376
main.c
|
@ -2,14 +2,14 @@
|
|||
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <dirent.h>
|
||||
#include <sys/dir.h>
|
||||
#include <sys/stat.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
/*
|
||||
Copyright (c) 2021 Iris Lightshard
|
||||
Copyright (c) 2021 Derek Stevens
|
||||
Copyright (c) 2021 Devine Lu Linvega
|
||||
|
||||
Permission to use, copy, modify, and distribute this software for any
|
||||
|
@ -46,20 +46,12 @@ int clin(char *str, char c) {int i = -1; int j = 0; while(str[j] != '\0'){if(str
|
|||
/* clang-format on */
|
||||
|
||||
int fpinject(FILE* f, Lexicon* l, char* filepath);
|
||||
int fptemplate(FILE*, Lexicon*, char*);
|
||||
int fpmetatemplate(FILE*, Lexicon*, char*);
|
||||
|
||||
int error(char* msg, char* val) {
|
||||
printf("Error: %s(%s)\n", msg, val);
|
||||
return 0;
|
||||
}
|
||||
|
||||
void clearstr(char* s) {
|
||||
while (*s) {
|
||||
*s++ = 0;
|
||||
}
|
||||
}
|
||||
|
||||
time_t getlater(time_t a, time_t b) { return a > b ? a : b; }
|
||||
|
||||
int ismetanav(char* name) { return scmp(name, "meta.nav"); }
|
||||
|
@ -75,25 +67,20 @@ int findf(Lexicon* l, char* f) {
|
|||
}
|
||||
|
||||
int gettwtxt(FILE* f) {
|
||||
|
||||
char buf[1024] = {0};
|
||||
char line[256];
|
||||
char datebuf[16] = {0};
|
||||
char msgbuf[240] = {0};
|
||||
char urlbuf[256] = {0};
|
||||
char* l;
|
||||
FILE* twtxt = fopen(SITEROOT TWTXT, "r");
|
||||
char *l, *d, *m;
|
||||
FILE* twtxt = fopen(SITEROOT "twtxt.txt", "r");
|
||||
|
||||
scat(buf, "<div id='twtxtFeed'><h2>recent activity</h2>\n<table>\n");
|
||||
scat(buf, "<div id='twtxtFeed'><h2>recent activity:</h2>\n<table>\n");
|
||||
if (!twtxt) {
|
||||
return 1;
|
||||
error("Get twtxt feed", "no twtxt.txt");
|
||||
return 0;
|
||||
} else {
|
||||
int i = 0;
|
||||
while (fgets(line, 256, twtxt) && i < 3) {
|
||||
int has_url = 0;
|
||||
if (*line == '#') {
|
||||
continue;
|
||||
}
|
||||
l = line;
|
||||
while (*l != 'T') {
|
||||
ccat(datebuf, *l++);
|
||||
|
@ -101,39 +88,24 @@ int gettwtxt(FILE* f) {
|
|||
while (*l != '\t') {
|
||||
l++;
|
||||
}
|
||||
while (*l) {
|
||||
if (*l == '|') {
|
||||
has_url = 1;
|
||||
break;
|
||||
}
|
||||
ccat(msgbuf, *l++);
|
||||
}
|
||||
l++;
|
||||
scat(urlbuf, l);
|
||||
scat(
|
||||
buf,
|
||||
"<tr><td class='twtxt-date' style='white-space:nowrap;vertical-align: "
|
||||
"top;'>");
|
||||
scat(msgbuf, l);
|
||||
scat(buf, "<tr><td style='white-space:nowrap;vertical-align: top;'>");
|
||||
scat(buf, datebuf);
|
||||
scat(buf, "</td><td class='twtxt-twt'> ");
|
||||
|
||||
if (has_url) {
|
||||
scat(buf, "<a href='");
|
||||
scat(buf, urlbuf);
|
||||
scat(buf, "'>");
|
||||
scat(buf, ":</td><td> ");
|
||||
scat(buf, msgbuf);
|
||||
scat(buf, "</a>");
|
||||
} else {
|
||||
scat(buf, msgbuf);
|
||||
}
|
||||
scat(buf, "</td></tr>\n");
|
||||
clearstr(datebuf);
|
||||
clearstr(msgbuf);
|
||||
clearstr(urlbuf);
|
||||
d = datebuf;
|
||||
while (*d) {
|
||||
*d++ = 0;
|
||||
}
|
||||
m = msgbuf;
|
||||
while (*m) {
|
||||
*m++ = 0;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
fclose(twtxt);
|
||||
scat(buf, "</table><a href='" TWTXT "'>see all</a>\n");
|
||||
scat(buf, "</table><a href='/twtxt.txt'>see all</a>\n");
|
||||
scat(buf, "</div>\n");
|
||||
fputs(buf, f);
|
||||
return 1;
|
||||
|
@ -142,7 +114,7 @@ int gettwtxt(FILE* f) {
|
|||
|
||||
void fpedited(FILE* f) {
|
||||
struct tm timebuf;
|
||||
char strbuf[16] = {0};
|
||||
char strbuf[16] = "\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0";
|
||||
|
||||
timebuf = *localtime(&edittime);
|
||||
strftime(strbuf, 16, "%Y-%m-%d", &timebuf);
|
||||
|
@ -256,69 +228,6 @@ int fpimg(FILE* f, char* s) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
int fpthead(FILE* f, char* s) {
|
||||
char sbuf[TAG_BODY_SIZE] = {0};
|
||||
char* c = s;
|
||||
int data = 0;
|
||||
|
||||
fputs("<table><thead><tr>\n", f);
|
||||
while (*c) {
|
||||
data = 1;
|
||||
if (*c != '|') {
|
||||
ccat(sbuf, *c);
|
||||
} else {
|
||||
fprintf(f, "<th>%s</th>\n", sbuf);
|
||||
sbuf[0] = 0;
|
||||
}
|
||||
c++;
|
||||
}
|
||||
if (data) {
|
||||
fprintf(f, "<th>%s</th>\n", sbuf);
|
||||
}
|
||||
fputs("</tr></thead>\n<tbody>", f);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int fptbody(FILE* f, Lexicon* l, char* s) {
|
||||
char sbuf[TAG_BODY_SIZE] = {0};
|
||||
char* c = s;
|
||||
int data = 0;
|
||||
int bopen = 0;
|
||||
int bclose = 0;
|
||||
|
||||
fputs("<tr>\n", f);
|
||||
while (*c) {
|
||||
data = 1;
|
||||
if (*c == '{') {
|
||||
bopen++;
|
||||
}
|
||||
if (*c == '}') {
|
||||
bclose++;
|
||||
}
|
||||
if (*c != '|' || bopen != bclose) {
|
||||
ccat(sbuf, *c);
|
||||
} else {
|
||||
fputs("<td>", f);
|
||||
fpmetatemplate(f, l, sbuf);
|
||||
fputs("</td>\n", f);
|
||||
sbuf[0] = 0;
|
||||
}
|
||||
c++;
|
||||
}
|
||||
if (data) {
|
||||
fputs("<td>", f);
|
||||
fpmetatemplate(f, l, sbuf);
|
||||
fputs("</td>\n", f);
|
||||
}
|
||||
fputs("</tr>", f);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int fptfoot(FILE* f) {
|
||||
fputs("</tbody></table>", f);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int fphimg(FILE* f, char* s) {
|
||||
char id[1024] = {0};
|
||||
char href[1024] = {0};
|
||||
|
@ -390,19 +299,14 @@ int fpvideo(FILE* f, char* s) {
|
|||
}
|
||||
thumbtrans(src, thumb);
|
||||
|
||||
if (IS_HTML5_VIDEO_ENABLED) {
|
||||
fprintf(
|
||||
f,
|
||||
"<video id='%s' src='%s' controls preload='metadata' poster='%s'>\n",
|
||||
id,
|
||||
href,
|
||||
thumb);
|
||||
}
|
||||
|
||||
fprintf(f, "<a href='%s'><img src='%s' alt='%s'></a>\n", href, thumb, alt);
|
||||
if (IS_HTML5_VIDEO_ENABLED) {
|
||||
fprintf(f, "<a href='%s'><img src='%s' alt=''%s'></a>\n", href, thumb, alt);
|
||||
fprintf(f, "</video>\n");
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -417,46 +321,28 @@ int fpaudio(FILE* f, char* s) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
int fpmono(FILE* f, Lexicon* l, char* s) {
|
||||
fputs("<span style='font-family:monospace;'>", f);
|
||||
int ret = fpmetatemplate(f, l, s);
|
||||
fputs("</span>", f);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int fpserif(FILE* f, Lexicon* l, char* s) {
|
||||
fputs("<span style='font-family:serif;'>", f);
|
||||
int ret = fpmetatemplate(f, l, s);
|
||||
fputs("</span>", f);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int fpsans(FILE* f, Lexicon* l, char* s) {
|
||||
fputs("<span style='font-family:sans;'>", f);
|
||||
int ret = fpmetatemplate(f, l, s);
|
||||
fputs("</span>", f);
|
||||
return ret;
|
||||
}
|
||||
int fptemplate(FILE*, Lexicon*, char*);
|
||||
int fpmetatemplate(FILE*, Lexicon*, char*);
|
||||
|
||||
int fppara(FILE* f, Lexicon* l, char* s) {
|
||||
fputs("<p>", f);
|
||||
int ret = fpmetatemplate(f, l, s);
|
||||
fpmetatemplate(f, l, s);
|
||||
fputs("</p>", f);
|
||||
return ret;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int fpul(FILE* f, Lexicon* l, char* s) {
|
||||
fputs("<ul>", f);
|
||||
int ret = fpmetatemplate(f, l, s);
|
||||
fpmetatemplate(f, l, s);
|
||||
fputs("</ul>", f);
|
||||
return ret;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int fpol(FILE* f, Lexicon* l, char* s) {
|
||||
fputs("<ol>", f);
|
||||
int ret = fpmetatemplate(f, l, s);
|
||||
fpmetatemplate(f, l, s);
|
||||
fputs("</ol>", f);
|
||||
return ret;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int fppublish(FILE* f, char* s) {
|
||||
|
@ -468,9 +354,9 @@ int fppublish(FILE* f, char* s) {
|
|||
|
||||
int fpli(FILE* f, Lexicon* l, char* s) {
|
||||
fputs("<li>", f);
|
||||
int ret = fpmetatemplate(f, l, s);
|
||||
fpmetatemplate(f, l, s);
|
||||
fputs("</li>", f);
|
||||
return ret;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int fph3(FILE* f, char* s) {
|
||||
|
@ -510,9 +396,9 @@ int fpitalic(FILE* f, char* s) {
|
|||
|
||||
int fpstrike(FILE* f, Lexicon* l, char* s) {
|
||||
fputs("<s>", f);
|
||||
int ret = fpmetatemplate(f, l, s);
|
||||
fpmetatemplate(f, l, s);
|
||||
fputs("</s>", f);
|
||||
return ret;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int fppre(FILE* f, char* s) {
|
||||
|
@ -536,139 +422,6 @@ int fpblock(FILE* f, char* s) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
int fppiclisting(FILE* f, Lexicon* l, char* s) {
|
||||
char desc[1024] = {0};
|
||||
char href[1024] = {0};
|
||||
char img[1024] = {0};
|
||||
char metaimg[1024] = {0};
|
||||
int target = 0;
|
||||
|
||||
char* c = s;
|
||||
int i = 0;
|
||||
while (i < 2) {
|
||||
if (*c == '|' || !(*c)) {
|
||||
i++;
|
||||
c++;
|
||||
continue;
|
||||
}
|
||||
switch (i) {
|
||||
case 0:
|
||||
ccat(desc, *c++);
|
||||
break;
|
||||
case 1:
|
||||
ccat(img, *c++);
|
||||
break;
|
||||
}
|
||||
}
|
||||
scpy(desc, href, slen(desc) + 1);
|
||||
scsw(stlc(href), ' ', '_');
|
||||
scat(metaimg, href);
|
||||
scat(metaimg, "|/");
|
||||
scat(metaimg, href);
|
||||
scat(metaimg, ".html|");
|
||||
scat(metaimg, img);
|
||||
scat(metaimg, desc);
|
||||
|
||||
fputs("<li>", f);
|
||||
fphimg(f, metaimg);
|
||||
target = findf(l, desc);
|
||||
if (target < 0) {
|
||||
return error("Missing link", s);
|
||||
}
|
||||
|
||||
fprintf(f, "<a href='/%s.html' class='local'>", scsw(stlc(desc), ' ', '_'));
|
||||
fprintf(f, "%s</a>", scsw(stlc(desc), '_', ' '));
|
||||
l->refs[target]++;
|
||||
fputs("</li>", f);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int fpshop(FILE* f, Lexicon* l, char* s) {
|
||||
|
||||
char paylink[1024] = {0};
|
||||
char desc[1024] = {0};
|
||||
|
||||
char img[1024] = {0};
|
||||
char alt[1024] = {0};
|
||||
|
||||
char metaimg[1024] = {0};
|
||||
char imgcountbuf[12] = {0};
|
||||
int imgcount = 0;
|
||||
|
||||
char* c = s;
|
||||
|
||||
int i = 0;
|
||||
|
||||
while (i < 2) {
|
||||
if (*c == '|' || !(*c)) {
|
||||
i++;
|
||||
c++;
|
||||
continue;
|
||||
}
|
||||
switch (i) {
|
||||
case 0:
|
||||
ccat(paylink, *c++);
|
||||
break;
|
||||
case 1:
|
||||
ccat(desc, *c++);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
fputs("<div class='product'><div class='product-imgs'>", f);
|
||||
|
||||
for (;;) {
|
||||
|
||||
if (*c == '|' || !(*c)) {
|
||||
if (i % 2 == 0) {
|
||||
clearstr(metaimg);
|
||||
sprintf(imgcountbuf, "%d", ++imgcount);
|
||||
scat(metaimg, "img");
|
||||
scat(metaimg, imgcountbuf);
|
||||
scat(metaimg, "|");
|
||||
scat(metaimg, img);
|
||||
scat(metaimg, "|");
|
||||
} else {
|
||||
scat(metaimg, alt);
|
||||
|
||||
fpimg(f, metaimg);
|
||||
|
||||
clearstr(imgcountbuf);
|
||||
clearstr(img);
|
||||
clearstr(alt);
|
||||
}
|
||||
|
||||
if (!(*c)) {
|
||||
if (i % 2 == 0) {
|
||||
return error("Needs even number of args", s);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
i++;
|
||||
c++;
|
||||
continue;
|
||||
}
|
||||
if (i % 2 == 0) {
|
||||
ccat(img, *c++);
|
||||
} else {
|
||||
ccat(alt, *c++);
|
||||
}
|
||||
}
|
||||
|
||||
fputs("</div>", f);
|
||||
|
||||
fppara(f, l, desc);
|
||||
fprintf(
|
||||
f,
|
||||
"<div class='cta'><a href='%s'>purchase</a><a href='mailto:" CONTACT_ADDRESS
|
||||
"'>inquire</a></div>",
|
||||
paylink);
|
||||
fputs("</div>", f);
|
||||
return 1;
|
||||
}
|
||||
|
||||
int fptemplate(FILE* f, Lexicon* l, char* s) {
|
||||
int target = 0;
|
||||
switch (s[0]) {
|
||||
|
@ -686,7 +439,7 @@ int fptemplate(FILE* f, Lexicon* l, char* s) {
|
|||
return fpaudio(f, s + 1);
|
||||
case '`':
|
||||
return fpcode(f, s + 1);
|
||||
case '\\':
|
||||
case '~':
|
||||
return fpitalic(f, s + 1);
|
||||
case '>':
|
||||
return fpblock(f, s + 1);
|
||||
|
@ -696,7 +449,7 @@ int fptemplate(FILE* f, Lexicon* l, char* s) {
|
|||
return fppre(f, s + 1);
|
||||
case '@':
|
||||
return fpbold(f, s + 1);
|
||||
case '~':
|
||||
case '\\':
|
||||
return fpstrike(f, l, s + 1);
|
||||
case '!':
|
||||
return fph3(f, s + 1);
|
||||
|
@ -712,22 +465,6 @@ int fptemplate(FILE* f, Lexicon* l, char* s) {
|
|||
return fpli(f, l, s + 1);
|
||||
case '&':
|
||||
return fppara(f, l, s + 1);
|
||||
case '[':
|
||||
return fpthead(f, s + 1);
|
||||
case '|':
|
||||
return fptbody(f, l, s + 1);
|
||||
case ';':
|
||||
return fptfoot(f);
|
||||
case '=':
|
||||
return fpmono(f, l, s + 1);
|
||||
case '(':
|
||||
return fpsans(f, l, s + 1);
|
||||
case ')':
|
||||
return fpserif(f, l, s + 1);
|
||||
case '%':
|
||||
return fppiclisting(f, l, s + 1);
|
||||
case '^':
|
||||
return fpshop(f, l, s + 1);
|
||||
}
|
||||
if (s[0]) {
|
||||
target = findf(l, s);
|
||||
|
@ -735,7 +472,7 @@ int fptemplate(FILE* f, Lexicon* l, char* s) {
|
|||
if (target < 0) {
|
||||
return error("Missing link", s);
|
||||
}
|
||||
fprintf(f, "<a href='/%s.html' class='local'>", scsw(stlc(s), ' ', '_'));
|
||||
fprintf(f, "<a href='./%s.html' class='local'>", scsw(stlc(s), ' ', '_'));
|
||||
fprintf(f, "%s</a>", scsw(stlc(s), '_', ' '));
|
||||
l->refs[target]++;
|
||||
return 1;
|
||||
|
@ -837,10 +574,10 @@ int fpfooter(FILE* f, char* name) {
|
|||
fputs("<footer>", f);
|
||||
if (!ismetanav(name)) {
|
||||
fpedited(f);
|
||||
fputs(CONTACT_HTML, f);
|
||||
fputs(CONTACT, f);
|
||||
}
|
||||
fputs(FOOTER_HTML, f);
|
||||
fputs(LICENSE_HTML, f);
|
||||
fputs(FOOTER, f);
|
||||
fputs(LICENSE, f);
|
||||
fputs("</footer>", f);
|
||||
return 1;
|
||||
}
|
||||
|
@ -873,23 +610,22 @@ FILE* build(FILE* f, Lexicon* l, char* name, char* srcpath) {
|
|||
fputs("<body>\n", f);
|
||||
/* header */
|
||||
fputs("<header>\n", f);
|
||||
fputs("<a href='/'><h1>" LOGO_HTML "</h1></a>\n", f);
|
||||
if (IS_NAV_IN_HEADER) {
|
||||
/* nav */
|
||||
fputs("<nav>\n", f);
|
||||
if (!fpportal(f, l, "meta.nav", 0))
|
||||
printf(">>> Building failed: %s\n", name);
|
||||
fputs("</nav>\n", f);
|
||||
fputs("</header>\n", f);
|
||||
if (ismetanav(name)) {
|
||||
fputs("<h1>" LOGO "</h1>\n", f);
|
||||
} else {
|
||||
fputs("</header>\n", f);
|
||||
/* nav */
|
||||
fputs("<nav>\n", f);
|
||||
if (!fpportal(f, l, "meta.nav", 0))
|
||||
printf(">>> Building failed: %s\n", name);
|
||||
fputs("</nav>\n", f);
|
||||
fputs("<a href='/'><h1>" LOGO "</h1></a>\n", f);
|
||||
}
|
||||
|
||||
fputs("</header>\n", f);
|
||||
/* about (main page only) */
|
||||
if (ismetanav(name)) {
|
||||
fputs("<div id='about'>" ABOUT "</div>\n", f);
|
||||
}
|
||||
/* nav */
|
||||
fputs("<nav>\n", f);
|
||||
if (!fpportal(f, l, "meta.nav", 0))
|
||||
printf(">>> Building failed: %s\n", name);
|
||||
fputs("</nav>\n", f);
|
||||
/* main */
|
||||
stat(srcpath, &attr);
|
||||
edittime = attr.st_mtime;
|
||||
|
@ -900,8 +636,6 @@ FILE* build(FILE* f, Lexicon* l, char* name, char* srcpath) {
|
|||
printf(">>> Building failed: %s\n", name);
|
||||
fputs("\n</main>", f);
|
||||
} else {
|
||||
/* about & twtxt (main page only) */
|
||||
fputs("<div id='about'>" ABOUT_HTML "</div>\n", f);
|
||||
gettwtxt(f);
|
||||
}
|
||||
/* footer */
|
||||
|
@ -962,7 +696,6 @@ void inspect(Lexicon* l) {
|
|||
void map(Lexicon* l) {
|
||||
char dstpath[64];
|
||||
char srcpath[64];
|
||||
char sitemapName[] = SITEMAP "\0";
|
||||
struct dirent** d;
|
||||
FILE* siteMap;
|
||||
int n, i = 0;
|
||||
|
@ -972,7 +705,7 @@ void map(Lexicon* l) {
|
|||
dstpath[0] = 0;
|
||||
srcpath[0] = 0;
|
||||
scat(dstpath, SITEROOT);
|
||||
scat(dstpath, SITEMAP ".html");
|
||||
scat(dstpath, "sitemap.html");
|
||||
scat(srcpath, "map.htm");
|
||||
siteMap = fopen("map.htm", "w");
|
||||
/* don't use shorthand for the <ul> tag because it will easily overflow
|
||||
|
@ -995,8 +728,7 @@ void map(Lexicon* l) {
|
|||
free(d);
|
||||
fprintf(siteMap, "</ul>\n");
|
||||
fclose(siteMap);
|
||||
fclose(build(fopen(dstpath, "w"), l, scsw(sitemapName, '_', ' '), srcpath));
|
||||
remove("map.htm");
|
||||
fclose(build(fopen(dstpath, "w"), l, "sitemap", srcpath));
|
||||
printf("Created sitemap\n");
|
||||
}
|
||||
|
||||
|
|
|
@ -5,12 +5,14 @@ SIZE=500
|
|||
|
||||
# transform path to /img/*/.thumb/
|
||||
pathtrans() {
|
||||
filename=$(basename "${1%.*}")
|
||||
pathname="${1%/*}"
|
||||
if [ ! -d ${pathname}/.thumb ]; then
|
||||
mkdir ${pathname}/.thumb/
|
||||
filename=$(echo $1 | awk -F/ '{print $NF}')
|
||||
filename=$(echo ${filename} | awk 'BEGIN{FS=OFS="."}{NF--; print $0}')
|
||||
transform=$(echo $1 | awk 'BEGIN{FS=OFS="/"}{NF--; print $0}')
|
||||
if [ ! -d ${transform}/.thumb ]; then
|
||||
mkdir ${transform}/.thumb/
|
||||
fi
|
||||
echo "${pathname}/.thumb/${filename}.png"
|
||||
transform=${transform}/.thumb/${filename}.png
|
||||
echo ${transform}
|
||||
}
|
||||
|
||||
# generate thumbnails in /img/*/.thumb/
|
||||
|
@ -21,19 +23,19 @@ resize() {
|
|||
fi
|
||||
if [ ! -f ${output} ]; then
|
||||
echo "Stripping metadata from $1"
|
||||
convert "$1" -strip "$1"
|
||||
convert $1 -strip $1
|
||||
echo "Generating thumbnail for $1"
|
||||
convert "$1" -strip -auto-orient -resize ${SIZE} -dither FloydSteinberg -colors 16 ${output}
|
||||
convert $1 -strip -auto-orient -resize ${SIZE} -dither FloydSteinberg -colors 16 ${output}
|
||||
fi
|
||||
}
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
if [ -z $1 ]; then
|
||||
echo "usage: $0 [build|clean]"
|
||||
else
|
||||
case $1 in
|
||||
"build")
|
||||
echo "Updating thumbnails cache"
|
||||
for x in $(find ${SRC}/*/*); do resize "$x"; done;;
|
||||
for x in $(find ${SRC}/*/*); do resize $x; done;;
|
||||
"clean")
|
||||
echo "Cleaning thumbnails cache"
|
||||
rm -rf ${SRC}/*/.thumb
|
||||
|
|
10
tw.sh
10
tw.sh
|
@ -1,13 +1,13 @@
|
|||
#!/bin/sh
|
||||
|
||||
siteroot=$(grep "#define SITEROOT" config.h | awk '{print $3}' | sed -e 's/"//g')
|
||||
twtxt=$(grep "#define TWTXT" config.h | awk '{print $3}' | sed -e 's/"//g')
|
||||
twtxt=../www/twtxt.txt
|
||||
|
||||
twt(){
|
||||
self=$(mktemp)
|
||||
new=$(mktemp)
|
||||
echo "$(/sbin/date -Is)\t$@" > ${self}
|
||||
cat ${self} ${siteroot}${twtxt} > ${new}
|
||||
cp ${new} ${siteroot}${twtxt}
|
||||
echo "$(date -Is)\t$@" > ${self}
|
||||
cat ${self} ${twtxt} > ${new}
|
||||
cp ${new} ${twtxt}
|
||||
rm ${new}
|
||||
rm ${self}
|
||||
}
|
||||
|
|
33
underbbs.sh
33
underbbs.sh
|
@ -1,33 +0,0 @@
|
|||
#!/bin/sh
|
||||
|
||||
. ~/.config/underbbs/cli
|
||||
|
||||
helpme() {
|
||||
echo "later"
|
||||
}
|
||||
|
||||
syndicate_honk() {
|
||||
# authenticate to the honknet
|
||||
local token=$(curl -X POST -F "username=${HONK_USERNAME}" -F "password=${HONK_PASSWORD}" -F "gettoken=1" ${HONK_URL}/dologin)
|
||||
# it's gonna be honked
|
||||
local result=$(curl -X POST -F "action=honk" -F "token=${token}" -F "noise=$@" ${HONK_URL}/api)
|
||||
echo $result
|
||||
}
|
||||
|
||||
if [ -z "$2" ]; then
|
||||
helpme
|
||||
exit
|
||||
fi
|
||||
|
||||
adapter=$1
|
||||
|
||||
shift
|
||||
|
||||
case $adapter in
|
||||
honk)
|
||||
noise=$(echo "$@" | sed -e 's/|/\|/')
|
||||
syndicate_honk "$noise"
|
||||
;;
|
||||
*)
|
||||
helpme ;;
|
||||
esac
|
Loading…
Reference in a new issue