diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/Makefile | 25 | ||||
-rw-r--r-- | tools/README | 8 | ||||
-rwxr-xr-x | tools/publish.sh | 4 | ||||
-rw-r--r-- | tools/xml-to-html.xsl | 36 |
4 files changed, 58 insertions, 15 deletions
diff --git a/tools/Makefile b/tools/Makefile index c69df0a..841f093 100644 --- a/tools/Makefile +++ b/tools/Makefile @@ -1,8 +1,8 @@ all: $(patsubst src/%,%,$(wildcard src/notes/*.xhtml src/*.xhtml)) \ - notes/atom.xml + notes/atom.xml blog/index.xhtml blog/gophermap # Index page -index.xhtml: src/index.xhtml build/notes-by-modification-date.xml tools/xml-to-html.xsl +index.xhtml: src/index.xhtml build/notes-by-modification-date.xml build/blog.xml tools/xml-to-html.xsl xsltproc -o $@ tools/xml-to-html.xsl $< # Note index page @@ -17,6 +17,27 @@ notes/%.xhtml: src/notes/%.xhtml tools/xml-to-html.xsl %.xhtml: src/%.xhtml tools/xml-to-html.xsl xsltproc -o $@ tools/xml-to-html.xsl $< +# Blog and phlog indexes. Assuming that the blog post file names are +# prefixed with dates in a format that makes sense to sort in the +# lexiographic order. +blog/index.xhtml: src/blog/index.xhtml build/blog.xml tools/xml-to-html.xsl + xsltproc -o $@ tools/xml-to-html.xsl $< + +build/blog.xml: blog/*.txt + (echo '<?xml version="1.0" encoding="UTF-8"?>' && \ + echo '<files>' && \ + ls -r blog/*.txt | \ + sed -e "sS^blog/\(.*\)S <file src=\"\\1\" />S" && \ + echo '</files>') \ + > build/blog.xml + +blog/gophermap: blog/*.txt + (echo "!defanor's phlog" && \ + ls -r blog/*.txt | \ + sed -e "sS^blog/\(.*\)S0\\1\t\\1S" && \ + echo '.') \ + > $@ + # A single-file dump of all notes build/notes-dump.xml: src/notes/*.xhtml tools/xml-notes-dump.xsl (echo '<?xml version="1.0" encoding="UTF-8"?>' && \ diff --git a/tools/README b/tools/README index bbd251d..f4c1de3 100644 --- a/tools/README +++ b/tools/README @@ -21,20 +21,22 @@ Editing is done with the emacs html-mode, with Indexing: -- xml-notes-dump.xsl (with some help from publish.sh) is used to +- xml-notes-dump.xsl (with some help from Makefile) is used to create notes-dump.xml in the build directory. - xml-notes-sort.xsl sorts that to create notes-by-publication-date.xml and notes-by-modification-date.xml. - xml-notes-limit.xsl is used to extract the most recent notes. +Opaque files can be indexed externally, as done with build/blog.xml. + HTML: - xml-to-html.xsl is used to translate source files into actual (X)HTML in ~/homepage/. -Indexes can be included into those using the <notes> element (so it -should run after those are built, if they are used). +Indexes can be included into those using the <notes> or <file> element +(so it should run after those are built, if they are used). Atom feed: diff --git a/tools/publish.sh b/tools/publish.sh index aa01628..56055ba 100755 --- a/tools/publish.sh +++ b/tools/publish.sh @@ -2,5 +2,5 @@ make -f tools/Makefile -rsync -avz *.xhtml notes pictures files uberspace.net:public_html/ -rsync -avz *.xhtml notes pictures files thunix.net:public_html/ +rsync -avz *.xhtml gophermap notes pictures files blog uberspace.net:public_html/ +rsync -avz *.xhtml gophermap notes pictures files blog thunix.net:public_html/ diff --git a/tools/xml-to-html.xsl b/tools/xml-to-html.xsl index 5785c7e..96c94c8 100644 --- a/tools/xml-to-html.xsl +++ b/tools/xml-to-html.xsl @@ -82,19 +82,18 @@ <xsl:apply-templates mode="body" select="xhtml:body/@*" /> <xsl:apply-templates mode="body" select="xhtml:body/*" /> <footer> + defanor, <a + href="https://creativecommons.org/licenses/by-sa/4.0/">CC + BY-SA 4.0</a>, <xsl:if test="not(//notes) and @created and @modified"> - defanor, <a - href="https://creativecommons.org/licenses/by-sa/4.0/">CC - BY-SA 4.0</a>, <time><xsl:copy-of - select="substring(@created,0,8)" /></time> <xsl:if - test="substring(@created,0,8) != + <time><xsl:copy-of select="substring(@created,0,8)" + /></time> <xsl:if test="substring(@created,0,8) != substring(@modified,0,8)"> to <time><xsl:copy-of - select="substring(@modified,0,8)" /></time></xsl:if>, at - <a + select="substring(@modified,0,8)" /></time></xsl:if>, + </xsl:if>at <a href="https://defanor.uberspace.net/">defanor.uberspace.net</a> or <a href="https://www.thunix.net/~defanor/">thunix.net/~defanor</a> - </xsl:if> </footer> </body> </html> @@ -141,6 +140,27 @@ </dd> </xsl:template> + <xsl:template mode="body" match="files"> + <xsl:variable name="files" select="document(@src)" /> + <xsl:variable name="number" select="@number" /> + <ul> + <xsl:apply-templates mode="file-index" + select="$files/files/file[$number=0 or position()<=$number]"> + <xsl:with-param name="prefix" + select="@prefix" /> + </xsl:apply-templates> + </ul> + </xsl:template> + + <xsl:template mode="file-index" match="file"> + <xsl:param name="prefix" /> + <li> + <a href="{$prefix}/{@src}"> + <xsl:value-of select="@src" /> + </a> + </li> + </xsl:template> + <xsl:template mode="body" match="xhtml:h1|xhtml:h2|xhtml:h3|xhtml:h4|xhtml:h5"> <xsl:copy> <xsl:attribute name="id"> |