documentation improvements, HTML page
authorEric Wong <normalperson@yhbt.net>
Sun, 20 Apr 2014 19:25:51 +0000 (19:25 +0000)
committerEric Wong <normalperson@yhbt.net>
Sun, 20 Apr 2014 19:30:33 +0000 (19:30 +0000)
.gitignore
Documentation/.gitignore [deleted file]
Documentation/include.mk [moved from Documentation/GNUmakefile with 57% similarity]
Documentation/txt2pre [new file with mode: 0755]
MANIFEST
Makefile.PL

index 0c5ad52886469b6900f5f6b4586771c260f0a8c7..bba47878b27f5f57b75bdb6eddae4db7c6274896 100644 (file)
@@ -5,3 +5,8 @@
 /blib
 /cover_db
 *.gz
+*.1
+*.5
+*.7
+*.html
+*.gz
diff --git a/Documentation/.gitignore b/Documentation/.gitignore
deleted file mode 100644 (file)
index 56fdc90..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-*.1
-*.5
-*.7
similarity index 57%
rename from Documentation/GNUmakefile
rename to Documentation/include.mk
index 4c808e0b389a0046fe5f741dcfc10d4d287bb0b2..b4865b59566cf54673cf25c4d1eb065fd15157bb 100644 (file)
@@ -2,6 +2,9 @@
 # License: AGPLv3 or later (https://www.gnu.org/licenses/agpl-3.0.txt)
 all::
 
+RSYNC = rsync
+RSYNC_DEST = ssoma.public-inbox.org:/srv/ssoma/
+docs := README COPYING INSTALL $(shell git ls-files 'Documentation/*.txt')
 INSTALL = install
 PANDOC = pandoc
 PANDOC_OPTS = -f markdown --email-obfuscation=none
@@ -21,7 +24,7 @@ man1 := $(addsuffix .1, $(m1))
 man5 := $(addsuffix .5, $(m5))
 man7 := $(addsuffix .7, $(m7))
 
-all:: man
+all:: man html
 
 man: $(man1) $(man5) $(man7)
 
@@ -38,8 +41,30 @@ install-man: man
        test -z "$(man1)" || $(INSTALL) -m 644 $(man1) $(DESTDIR)$(man1dir)
        test -z "$(man5)" || $(INSTALL) -m 644 $(man5) $(DESTDIR)$(man5dir)
        test -z "$(man7)" || $(INSTALL) -m 644 $(man7) $(DESTDIR)$(man7dir)
-%.1 %.5 %.7 : %.txt
+%.1 %.5 %.7 : Documentation/%.txt
        $(pandoc) -s -t man < $< > $@+ && mv $@+ $@
 
-clean::
-       $(RM) $(man1) $(man5) $(man7)
+txt2pre = ./Documentation/txt2pre < $< > $@+ && touch -r $< $@+ && mv $@+ $@
+txt = INSTALL README COPYING
+
+INSTALL.html: INSTALL
+       $(txt2pre)
+index.html: README
+       $(txt2pre)
+
+docs_html := index.html INSTALL.html
+html: $(docs_html)
+gz_docs := $(addsuffix .gz, $(docs) $(docs_html))
+rsync_docs := $(gz_docs) $(docs) $(txt) $(docs_html)
+%.gz: %
+       gzip -9 --rsyncable < $< > $@+
+       touch -r $< $@+
+       mv $@+ $@
+
+gz-doc: $(gz_docs)
+rsync-doc:
+       git set-file-times $(docs) $(txt)
+       $(MAKE) gz-doc
+       $(RSYNC) --chmod=Fugo=r -av $(rsync_docs) $(RSYNC_DEST)
+clean-doc:
+       $(RM) $(man1) $(man5) $(man7) $(gz_docs) $(docs_html)
diff --git a/Documentation/txt2pre b/Documentation/txt2pre
new file mode 100755 (executable)
index 0000000..f84f9c0
--- /dev/null
@@ -0,0 +1,26 @@
+#!/usr/bin/env perl
+# Copyright (C) 2014, Eric Wong <normalperson@yhbt.net> and all contributors
+# License: AGPLv3 or later (https://www.gnu.org/licenses/agpl-3.0.txt)
+#
+# Stupid script to make HTML from preformatted, utf-8 text versions,
+# only generating links for http(s).  Markdown does too much
+# and requires indentation to output preformatted text.
+use strict;
+use warnings;
+use CGI qw/escapeHTML/;
+use Encode qw/encode/;
+my $str = eval { local $/; <> };
+$str = escapeHTML($str);
+$str = encode('us-ascii', $str, Encode::HTMLCREF);
+my ($title) = ($str =~ /\A([^\n]+)/);
+
+# temporarily swap &gt; for escape so our s!! to add href works.
+# there's probably a way to do this with only a single s!! ...
+$str =~ s!&gt;!\e!g;
+$str =~ s!\b(https?://[\w+\+\&\?\.\%\;/-]+)!<a\nhref="$1"\n>$1</a>!g;
+$str =~ s!\e!&gt;!g; # swap escapes back to &gt;
+
+print '<html><head>',
+  '<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />',
+  "<title>$title</title>",
+  "</head><body>\n<pre>",  $str , '</pre></body></html>';
index 1a530788cf38df3fa3bff713fdb8ad4c336df4c8..27283c9b7b700ad55bc051e4f68919d6181c37b0 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -1,12 +1,13 @@
 .gitignore
 COPYING
-Documentation/.gitignore
-Documentation/GNUmakefile
+Documentation/include.mk
 Documentation/ssoma-mda.txt
 Documentation/ssoma-rm.txt
 Documentation/ssoma.txt
 Documentation/ssoma_repository.txt
+Documentation/txt2pre
 INSTALL
+MANIFEST
 Makefile.PL
 README
 lib/Ssoma/Extractor.pm
index f500cc04a21101fa30edc5a11299f3903ac5467a..30abfea5eb741ac1f4316924fbeee3c301323376 100644 (file)
@@ -24,20 +24,7 @@ WriteMakefile(
 
 sub MY::postamble {
   <<'EOF';
-RSYNC_DEST = ssoma.public-inbox.org:/srv/ssoma/
-docs = INSTALL README COPYING $(shell git ls-files Documentation/ '*.txt')
-gz_docs = $(addsuffix .gz, $(docs))
-%.gz: %
-       gzip -9 --rsyncable < $< > $@+
-       touch -r $< $@+
-       mv $@+ $@
-
-gz-docs: $(gz_docs)
-rsync-docs:
-       git set-file-times $(docs)
-       $(MAKE) gz-docs
-       rsync --chmod=Fugo=r -av $(gz_docs) $(docs) $(RSYNC_DEST)
-
+-include Documentation/include.mk
 N = $(shell echo $$(( $$(nproc 2>/dev/null || echo 2) + 1)))
 check:: pure_all
        prove -lv -j$(N)