Browse Source

parallized rss build

exp-with-scrum
parent
commit
fb993d8928
Signed by: yogsototh GPG Key ID: 7B19A4C650D59646
  1. 7
      .gitignore
  2. 18
      Makefile
  3. 2
      engine/mk-index.sh
  4. 11
      engine/mk-rss-entry.sh
  5. 19
      engine/mkrss.sh

7
.gitignore

@ -1,8 +1,3 @@
_cache/
.cache/
_site/
_optim/
src/archive.org
.direnv/
_shake/
.shake/
dist-newstyle/

18
Makefile

@ -56,17 +56,18 @@ $(HTML_INDEX): $(DST_PANDOC_FILES) $(MKINDEX)
ALL += $(HTML_INDEX)
# RSS
SRC_POSTS_DIR ?= $(SRC_DIR)/posts
SRC_POST_FILES ?= $(shell find $(SRC_POSTS_DIR) -type f -name "*$(EXT)")
DST_POSTS_DIR ?= $(DST_DIR)/posts
SRC_POSTS_FILES ?= $(shell find $(SRC_POSTS_DIR) -type f -name "*$(EXT)")
RSS_CACHE_DIR ?= $(CACHE_DIR)/rss
DST_RSS_FILES ?= $(subst .$(EXT),.rss, \
DST_RSS_FILES ?= $(patsubst %.org,%.rss, \
$(patsubst $(SRC_POSTS_DIR)/%,$(RSS_CACHE_DIR)/%, \
$(SRC_POSTS_FILES)))
MK_RSS_ENTRY := ./engine/mk-rss-entry.sh
$(RSS_CACHE_DIR)/%.rss: $(DST_DIR)/posts/%.html $(MK_RSS_ENTRY)
$(RSS_CACHE_DIR)/%.rss: $(DST_POSTS_DIR)/%.html $(MK_RSS_ENTRY)
@mkdir -p $(RSS_CACHE_DIR)
$(MK_RSS_ENTRY) $@
$(MK_RSS_ENTRY) "$<" "$@"
ALL += $(DST_RSS_FILES)
RSS := $(DST_DIR)/rss.xml
MKRSS := engine/mkrss.sh
@ -74,11 +75,14 @@ $(RSS): $(DST_RSS_FILES) $(MKRSS)
$(MKRSS)
ALL += $(RSS)
rss: $(DST_RSS_FILES) $(RSS)
# ORG -> GEMINI
EXT := .org
SRC_GMI_FILES ?= $(shell find $(SRC_DIR) -type f -name "*$(EXT)" $(NO_DRAFT))
DST_GMI_FILES ?= $(subst $(EXT),.gmi, \
$(subst $(SRC_DIR),$(DST_DIR), \
$(patsubst $(SRC_DIR)/%,$(DST_DIR)/%, \
$(SRC_GMI_FILES)))
GMI := engine/org2gemini.sh
$(DST_DIR)/%.gmi: $(SRC_DIR)/%.org $(GMI) engine/org2gemini_step1.sh
@ -101,6 +105,8 @@ $(GEM_ATOM): $(DST_GMI_FILES) $(MK_GEMINI_ATOM)
$(MK_GEMINI_ATOM)
ALL += $(GEM_ATOM)
gemini: $(DST_GMI_FILES) $(GMI_INDEX) $(GEM_ATOM)
# Images
SRC_IMG_FILES ?= $(shell find $(SRC_DIR) -type f -name "*.jpg" -or -name "*.jpeg" -or -name "*.gif" -or -name "*.png")
DST_IMG_FILES ?= $(patsubst $(SRC_DIR)/%,$(DST_DIR)/%, $(SRC_IMG_FILES))

2
engine/mk-index.sh

@ -145,4 +145,4 @@ template=$(< templates/post.html | perl -pe 's#(\$[^\$]*)\$#$1#g' )
} > "$indexfile"
rm -rf $tmpdir
echo "* RSS [done]"
echo "* HTML INDEX [done]"

11
engine/mk-rss-entry.sh

@ -8,6 +8,7 @@ indexdir=".cache/rss"
# file to handle
fic="$1"
dst="$2"
# RSS Metas
websiteurl="https://her.esy.fun"
@ -41,15 +42,10 @@ mkcategories(){
autoload -U colors && colors
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'/##')"
printf "%-30s" $postfile
xfic="$indexdir/$fic.xml"
mkdir -p $(dirname $xfic)
xfic="${dst:r}.xml"
hxclean $fic > $xfic
d=$(finddate $xfic)
echo -n " [$d]"
@ -59,7 +55,6 @@ keywords=( $(findkeywords $xfic) )
printf ": %-55s" "$title ($keywords)"
categories=$(mkcategories $keywords)
absoluteurl="${websiteurl}/${blogfile}"
dst="$indexdir/$fic.rss"
mkdir -p $(dirname $dst)
{ printf "\\n<item>"
printf "\\n<title>%s</title>" "$title"
@ -68,5 +63,5 @@ mkdir -p $(dirname $dst)
printf "%s" "$categories"
printf "\\n<description><![CDATA[\\n%s\\n]]></description>" "$(getcontent "$xfic" "$absoluteurl")"
printf "\\n</item>\\n\\n"
} >> "$dst"
} > "$dst"
echo " [${fg[green]}OK${reset_color}]"

19
engine/mkrss.sh

@ -32,28 +32,29 @@ formatdate() {
isodate() {
# format the date for sorting
local d="$1"
# echo "DEBUG DATE: $d" >&2
LC_TIME=en_US date --date $d +'%Y-%m-%dT%H:%M:%S'
echo "DEBUG DATE: $d" >&2
LC_TIME=en_US date --date "$d" +'%Y-%m-%dT%H:%M:%S'
}
finddate(){ < $1 hxselect -c $dateaccessor | sed 's/\[//g;s/\]//g;s/ .*$//' }
finddate(){ < $1 hxselect -c $dateaccessor }
autoload -U colors && colors
typeset -a dates
dates=( )
tmpdir=$(mktemp -d)
for fic in $indexdir/*.rss; do
rssdate=$(finddate $xfic)
echo -n "${fic:t} [$d]"
for fic in $indexdir/**/*.rss; do
rssdate=$(finddate $fic)
echo -n "${fic:r} [$d]"
d=$(isodate $rssdate)
dates=( $d $dates )
echo " [${fg[green]}OK${reset_color}]"
cp $fic $tmpdir/$d-${fic:t}.rss
cp $fic $tmpdir/$d-${${fic:h}:t}.rss
done
echo "Publishing"
n=1
for fic in $(ls $tmpdir/*.rss | sort -r | head -n $maxarticles ); do
echo "${fic:t}"
echo "$((n++)) ${fic:t}"
cat $fic >> $tmpdir/rss
done
@ -97,6 +98,8 @@ END
# HACK TO UPDATE OLD RSS FEEDS
legacyenrss="$webdir/Scratch/en/blog/feed/feed.xml"
legacyfrrss="$webdir/Scratch/fr/blog/feed/feed.xml"
mkdir -p "${legacyenrss:h}"
mkdir -p "${legacyfrrss:h}"
cp -f "$rssfile" "$legacyenrss"
cp -f "$rssfile" "$legacyfrrss"

Loading…
Cancel
Save