slweb

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

чување edf38bc5c8699804f399846241391d31e2a66293
родитељ a1379441db65286bfd4ae5ec76f95b8f8631ea3b
Аутор: Страхиња Радић <contact@strahinja.org>
Датум:   Thu, 10 Dec 2020 13:09:26 +0100

lsdir improvements; added note about the planned migration to C

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

Diffstat:
MMakefile | 4++--
MREADME | 27+++++++++++++++++++++++++++
Mslweb.in | 15++++++++++++---
измењених датотека: 3, додавања: 41(+), брисања: 5(-)

diff --git a/Makefile b/Makefile @@ -1,5 +1,5 @@ -SLWVERSION = v0.2.7-beta -SLWDATE = 8 Dec 2020 +SLWVERSION = v0.2.8-beta +SLWDATE = 10 Dec 2020 BINDIR = /usr/local/bin MANDIR = /usr/local/share/man/man1 BROWSER = surf diff --git a/README b/README @@ -1,3 +1,30 @@ + **IMPORTANT NOTE** + ================== + +Version v0.2.8-beta is the last version of slweb using sed. I decided to switch +to C because of the limitation of sed(1) when used to parse the entire file as a +single string (the -z option), as listed in + + https://www.gnu.org/software/sed/manual/sed.html#Limitations + + > For those who want to write portable sed scripts, be aware that some + > implementations have been known to limit line lengths (for the pattern + > and hold spaces) to be no more than 4000 bytes. The POSIX standard + > specifies that conforming sed implementations shall support at least + > 8192 byte line lengths. GNU sed has no built-in limit on line length; + > as long as it can malloc() more (virtual) memory, you can feed or + > construct lines as long as you like. + +When processed through slweb, some of the test pages using the cyrillic text in +UTF-8 would be rendered incorrectly, even when using GNU sed. I suspect this is +the result of the mentioned limitation. + + The next version of slweb is going to be written in C from scratch and +labeled v0.3.0. + + -- Strahinya + + slweb ===== diff --git a/slweb.in b/slweb.in @@ -6,6 +6,7 @@ INFILE=index.slw OUTFILE=index.html VERSION=%VERSION% LSDIRS_MAX_SUBDIRS=5 +LSDIRS_PERMALINK_PATTERN='\3.\2.\1.' function throw() { @@ -267,7 +268,7 @@ INDIR=$(dirname $INFILE 2>/dev/null) lsdirs_commands=$(echo "$DOC" | \ grep -e '{lsdirs\( [0-9]\+\)\?}' \ -e '{lsdirs\( [0-9]\+\)\? =[^}]\+}') -shopt -s extglob +#shopt -s extglob #shopt -s nullglob lsdirs_subdir_count=$(echo "$lsdirs_commands" | \ sed -e 's/{lsdirs\( \([0-9]\+\)\)\?}/\2/g' \ @@ -299,7 +300,13 @@ while IFS= read -r lsdirs_command; do find $lsdirs_subdir -mindepth 1 -name '*.slw' -print) while IFS= read -r lsdirscontent_file; do [ -z "$lsdirscontent_file" ] && continue + lsdirscontent_file_html=$(echo "$lsdirscontent_file" | \ + sed -e 's/\.slw/\.html/g') + lsdirscontent_file_date=$(grep '^date:' $lsdirscontent_file | \ + sed -E "s/^date: ([0-9]{4})-([0-9]{2})-([0-9]{2})T.*/$LSDIRS_PERMALINK_PATTERN/g" | \ + sed 1q) lsdirs_html="$lsdirs_html\ + <a href=\"$INDIR/$lsdirscontent_file_html\">$lsdirscontent_file_date</a>\ $($0 -b -d $INDIR $INDIR/$lsdirscontent_file)" done <<< "$lsdirscontent_files" @@ -310,8 +317,10 @@ while IFS= read -r lsdirs_command; do done <<< "$lsdirs_subdirs" lsdirs_html="$lsdirs_html\n</ul><!--dir-->\n" lsdirs_html=$(echo "$lsdirs_html" | \ - sed -z -e's/\//\\\//g' -e's/\[/\\\[/g' -e's/\]/\\\]/g' -e's/\./\\\./g' \ - -e's/\"/\\\"/g' -e's/\n/\\n/g') + sed -e's/\//\\\//g' -e's/\[/\\\[/g' -e's/\]/\\\]/g' -e's/\./\\\./g' \ + -e's/\"/\\\"/g' | \ + sed -ze 's/\n/\\n/g') + # -e's/\n/\\n/g') DOC=$(echo "$DOC" | \ sed -e "s/$lsdirs_command/$lsdirs_html/g") done <<< "$lsdirs_commands"