diff --git a/Makefile b/Makefile index 11a7d41..64b1018 100644 --- a/Makefile +++ b/Makefile @@ -46,18 +46,7 @@ $(DST_DIR)/%.html: $(SRC_DIR)/%.org $(TEMPLATE) ALL += $(DST_PANDOC_FILES) html: $(DST_PANDOC_FILES) - -# HTML INDEX -HTML_INDEX := $(DST_DIR)/index.html -MKINDEX := engine/mk-index.sh -$(HTML_INDEX): $(DST_PANDOC_FILES) $(MKINDEX) $(TEMPLATE) - @mkdir -p $(DST_DIR) - $(MKINDEX) -ALL += $(HTML_INDEX) - -index: $(HTML_INDEX) - -# RSS +# INDEXES SRC_POSTS_DIR ?= $(SRC_DIR)/posts DST_POSTS_DIR ?= $(DST_DIR)/posts SRC_POSTS_FILES ?= $(shell find $(SRC_POSTS_DIR) -type f -name "*$(EXT)") @@ -70,6 +59,17 @@ $(RSS_CACHE_DIR)/%.xml: $(DST_POSTS_DIR)/%.html @mkdir -p "$(dir $@)" hxclean "$<" > "$@" +# HTML INDEX +HTML_INDEX := $(DST_DIR)/index.html +MKINDEX := engine/mk-index.sh +$(HTML_INDEX): $(DST_XML_FILES) $(MKINDEX) $(TEMPLATE) + @mkdir -p $(DST_DIR) + $(MKINDEX) +ALL += $(HTML_INDEX) + +index: $(HTML_INDEX) + +# RSS DST_RSS_FILES ?= $(patsubst %.xml,%.rss, $(DST_XML_FILES)) ALL += $(DST_RSS_FILES) diff --git a/engine/mk-index.sh b/engine/mk-index.sh index 47100c7..12f5da3 100755 --- a/engine/mk-index.sh +++ b/engine/mk-index.sh @@ -5,6 +5,7 @@ cd "$(git rev-parse --show-toplevel)" || exit 1 webdir="_site" postsdir="$webdir/posts" indexfile="$webdir/index.html" +indexdir=".cache/rss" # maximal number of articles to put in the index homepage maxarticles=1000 @@ -38,16 +39,10 @@ autoload -U colors && colors tmpdir=$(mktemp -d) typeset -a dates dates=( ) -for fic in $postsdir/**/*.html; do - if echo $fic|egrep -- '-(mk|min|sci|modern).html$'>/dev/null; then - continue - fi - postfile="$(echo "$fic"|sed 's#^'$postsdir'/##')" - blogfile="$(echo "$fic"|sed 's#^'$webdir'/##')" +for xfic in $indexdir/**/*.xml; do + postfile="$(echo "$xfic"|sed 's#^'$postsdir'/##')" + blogfile="$(echo "$xfic"|sed 's#.xml$#.html#;s#^'$indexdir'/#posts/#')" printf "%-30s" $postfile - xfic="$tmpdir/$fic.xml" - mkdir -p $(dirname $xfic) - hxclean $fic > $xfic d=$(finddate $xfic) echo -n " [$d]" rssdate=$(formatdate $d) @@ -60,7 +55,7 @@ for fic in $postsdir/**/*.html; do printf "\\n%s%s" "$d" printf "%s" "$categories" printf "\\n\\n\\n" - } >> "$tmpdir/${d}-$(basename $fic).index" + } >> "$tmpdir/${d}-$(basename $xfic).index" dates=( $d $dates ) echo " [${fg[green]}OK${reset_color}]" done diff --git a/engine/mk-rss-entry.sh b/engine/mk-rss-entry.sh index 1ccabbe..b7a9746 100755 --- a/engine/mk-rss-entry.sh +++ b/engine/mk-rss-entry.sh @@ -42,10 +42,10 @@ mkcategories(){ autoload -U colors && colors -postfile="$(echo "$fic"|sed 's#^'$postsdir'/##')" -blogfile="$(echo "$fic"|sed 's#^'$webdir'/##')" -printf "%-30s" $postfile xfic="$fic" +postfile="$(echo "$fic"|sed 's#^'$postsdir'/##')" +blogfile="$(echo "$fic"|sed 's#.xml$#.html#;s#^'$indexdir'/#posts/#')" +printf "%-30s" $postfile d=$(finddate $xfic) echo -n " [$d]" rssdate=$(formatdate $d)