slweb

Једноставни генератор статичких веб страна
Дневник | Датотеке | Референце | ПРОЧИТАЈМЕ | ЛИЦЕНЦА

чување 476caaf8ef2ba1ee832a0e88e1a14c8c350c6eed
родитељ e16ddcac801d2669053260a426bd04ca092716b4
Аутор: Страхиња Радић <contact@strahinja.org>
Датум:   Fri,  8 Oct 2021 19:47:07 +0200

Standardize the way version is handled; remove index.slw, version.in

Signed-off-by: Страхиња Радић <contact@strahinja.org>

Diffstat:
M.gitignore | 1+
Mall.do | 3+--
Adefault.h.do | 12++++++++++++
Mdefs.h | 5++---
Dindex.slw | 185-------------------------------------------------------------------------------
Mslweb.c | 2+-
Mversion.do | 6+++---
Aversion.h.in | 3+++
Dversion.in | 1-
измењених датотека: 9, додавања: 23(+), брисања: 195(-)

diff --git a/.gitignore b/.gitignore @@ -23,3 +23,4 @@ compile_commands.json examples/*/*.html date version +version.h diff --git a/all.do b/all.do @@ -1,2 +1 @@ -redo-ifchange slweb -redo-ifchange slweb.1.gz index.html examples/all +redo-ifchange version.h slweb slweb.1.gz examples/all diff --git a/default.h.do b/default.h.do @@ -0,0 +1,12 @@ +if [ -r $1.in ]; then + redo-ifchange $1.in version date + read VERSION <version + read DATE <date + sed -e "s/%VERSION%/$VERSION/g" \ + -e "s/%DATE%/$DATE/g" <$1.in +else + if [ -f $2.def.h ]; then + redo-ifchange $2.def.h + cat $2.def.h > $3 + fi +fi diff --git a/defs.h b/defs.h @@ -19,12 +19,11 @@ #include <sys/wait.h> #include <unistd.h> +#include "version.h" #include "utf8.h" -#define PROGRAMNAME "slweb" -#define VERSION "0.4" #define COPYRIGHTYEAR "2020, 2021" -#define MADEBY_URL "https://strahinja.srht.site/slweb/index.html" +#define MADEBY_URL "https://strahinja.srht.site/slweb" #define BUFSIZE 1024 #define KEYSIZE 256 diff --git a/index.slw b/index.slw @@ -1,185 +0,0 @@ ---- -site-name: slweb - Simple static website generator -site-desc: Simple static website generator -stylesheet: /slweb/index.css -stylesheet: /slweb/katex.min.css -favicon-url: /slweb/favicon.ico -image: https://strahinja.srht.site/slweb/logo-social.webp -canonical: https://strahinja.srht.site/slweb/ -meta: index-meta.tsv ---- -{main} -# slweb - -**slweb** is a static website generator which aims at being simplistic. It -transforms custom Markdown-like syntax into HTML. - - -## Q&A - -{dl} -{dt} -**Q:** Is this suckless?{/dt} -{dd} -**A:** No. SGML, and by extension, HTML, isn't suckless.{/dd} - -{dt} -**Q:** Why do you call it &ldquo;simple&rdquo; then?{/dt} -{dd} -**A:** Because one is not the synonym for the other.{/dd} - -{dt} -**Q:** Why not make a website generator as a shell script?{/dt} -{dd} -**A:** slweb _was_ a shell script in its conception (check its history of -commits in git). However, I wanted to implement Markdown links with link ids -`\[like]\[this]`. This requires multiple passes by the parser and is better -implemented as a full-blown program in C anyway. The other reason was that sed -and awk have limits, which some of my pages hit. - -`\[this]: https://some.site`{/dd} - -{dt} -**Q:** My static website generator is &ldquo;truly simple&rdquo;, this is not -simple!{/dt} -{dd} -**A:** Good for you. By the way, that is a statement and not a question.{/dd} -{/dl} - - -## Prerequisites - -* C compiler (**GCC**-compatible) - `${SLWEB_CC:-gcc -g}` -* **gzip** - - -## Optional dependencies - -* [KaTeX][katex] for math mode -* **git** (for `{git-log}`) -* **identify** from [ImageMagick][imgmg] (for `<img width="" height="">`) - - -## Install - -``` -$ git clone https://git.sr.ht/~strahinja/slweb -$ cd slweb -$ su -``` - -Then, if you have [apenwarr/redo][aredo]: - -``` -# redo install -``` - -if you don't: - -``` -# ./do install -``` - -You can specify any compiler which uses (or tolerates) `-Wall`, `-std=c99`, -`-c`, `-g` and `-o` like GNU C, most notably **tcc**(1), by setting the -`SLWEB_CC` environment variable. For example: - -``` -$ SLWEB_CC=tcc redo -j10 -``` - -In the case of **tcc**, the tradeoff is that the debug information is limited -compared to **gcc**, but the compilation time is significantly shorter. - - -## Examples - -See the [`examples/`][examp] directory in this repository. - -Given the file `index.slw` in the current directory: - -``` ---- -site-name: Test website -site-desc: My first website in slweb ---- - -{main} -# Hello world - -This is an \_example_ of a statically generated HTML. - -{/main} -``` - -after using the command: - -``` -$ slweb index.slw > index.html -``` - -file `index.html` contains: - -``` -&lt;!DOCTYPE html&gt; -&lt;html lang="en"&gt; -&lt;head&gt; - &lt;title&gt;Test website&lt;/title&gt; - &lt;meta charset="utf-8" /&gt; - &lt;meta name="description" content="My first website in slweb" /&gt; - &lt;meta name="viewport" content="width=device-width, initial-scale=1" /&gt; - &lt;meta name="generator" content="slweb" /&gt; -&lt;/head&gt; -&lt;body&gt; - -&lt;main&gt; -&lt;h1&gt;Hello world&lt;/h1&gt; - -&lt;p&gt;This is an &lt;em&gt;example&lt;/em&gt; of a statically generated HTML.&lt;/p&gt; - -&lt;/main&gt; -&lt;/body&gt; -&lt;/html&gt; -``` - -## TODO (checklist) - -See the file [`TODO`][mtodo] for more information. - - -## Bugs and limitations - -Bugs can be reported using the [ticket tracker][issue]. See the manpage (`man -slweb`) after installing **slweb** for more information. - - -## License - -slweb - Simple static website generator. -Copyright (C) 2020, 2021 Страхиња Радић - -This program is free software: you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free Software -Foundation, either version 3 of the License, or (at your option) any later -version. - -This program is distributed in the hope that it will be useful, but WITHOUT ANY -WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A -PARTICULAR PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along with -this program. If not, see &lt;[https://www.gnu.org/licenses/][licen]&gt;. - -{git-log} - -{made-by} -{/main} - - -[aredo]: https://github.com/apenwarr/redo -[examp]: https://git.sr.ht/~strahinja/slweb/tree/master/item/examples -[imgmg]: https://imagemagick.org -[issue]: https://todo.sr.ht/~strahinja/slweb -[mtodo]: https://git.sr.ht/~strahinja/slweb/tree/master/item/TODO -[katex]: https://katex.org -[licen]: https://www.gnu.org/licenses diff --git a/slweb.c b/slweb.c @@ -90,7 +90,7 @@ static ULLONG state = ST_NONE; int version() { - printf("%s v%s\n", PROGRAMNAME, VERSION); + printf("%s %s\n", PROGRAMNAME, VERSION); return 0; } diff --git a/version.do b/version.do @@ -1,5 +1,5 @@ -if ! git describe 2>/dev/null >$3; then - cat version.in >$3 -fi +FALLBACKVER=${FALLBACKVER:-unknown} +{ command -v git >/dev/null 2>&1 && git describe >/dev/null 2>&1; } && \ + git describe 2>/dev/null | sed 's/^v//' >$3 || echo $FALLBACKVER >$3 redo-always redo-stamp <$3 diff --git a/version.h.in b/version.h.in @@ -0,0 +1,3 @@ +#define PROGRAMNAME "slweb" +#define DATE "%DATE%" +#define VERSION "%VERSION%" diff --git a/version.in b/version.in @@ -1 +0,0 @@ -v0.4