From 4fe1d7c5b765c45f5044d46dd5db616e61f8e861 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 20 Apr 2014 19:25:51 +0000 Subject: [PATCH] documentation improvements, HTML page --- .gitignore | 5 ++++ Documentation/.gitignore | 3 --- Documentation/{GNUmakefile => include.mk} | 33 ++++++++++++++++++++--- Documentation/txt2pre | 26 ++++++++++++++++++ MANIFEST | 5 ++-- Makefile.PL | 15 +---------- 6 files changed, 64 insertions(+), 23 deletions(-) delete mode 100644 Documentation/.gitignore rename Documentation/{GNUmakefile => include.mk} (57%) create mode 100755 Documentation/txt2pre diff --git a/.gitignore b/.gitignore index 0c5ad52..bba4787 100644 --- a/.gitignore +++ b/.gitignore @@ -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 index 56fdc90..0000000 --- a/Documentation/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -*.1 -*.5 -*.7 diff --git a/Documentation/GNUmakefile b/Documentation/include.mk similarity index 57% rename from Documentation/GNUmakefile rename to Documentation/include.mk index 4c808e0..b4865b5 100644 --- a/Documentation/GNUmakefile +++ b/Documentation/include.mk @@ -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 index 0000000..f84f9c0 --- /dev/null +++ b/Documentation/txt2pre @@ -0,0 +1,26 @@ +#!/usr/bin/env perl +# Copyright (C) 2014, Eric Wong 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 > for escape so our s!! to add href works. +# there's probably a way to do this with only a single s!! ... +$str =~ s!>!\e!g; +$str =~ s!\b(https?://[\w+\+\&\?\.\%\;/-]+)!$1!g; +$str =~ s!\e!>!g; # swap escapes back to > + +print '', + '', + "$title", + "\n
",  $str , '
'; diff --git a/MANIFEST b/MANIFEST index 1a53078..27283c9 100644 --- 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 diff --git a/Makefile.PL b/Makefile.PL index f500cc0..30abfea 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -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) -- 2.26.2