Almost done

This commit is contained in:
Yann Esposito (Yogsototh) 2021-04-27 15:02:02 +02:00
parent f89c62a6d4
commit f512d18a59
Signed by untrusted user who does not match committer: yogsototh
GPG key ID: 7B19A4C650D59646
8 changed files with 192 additions and 5 deletions

View file

@ -11,11 +11,13 @@ SRC_RAW_FILES := $(shell find $(SRC_DIR) -type f)
DST_RAW_FILES := $(patsubst $(SRC_DIR)/%,$(DST_DIR)/%,$(SRC_RAW_FILES))
ALL += $(DST_RAW_FILES)
# COPY EVERYTHING
$(DST_DIR)/% : $(SRC_DIR)/%
mkdir -p "$(dir $@)"
cp "$<" "$@"
# ORG -> HTML
EXT := .org
SRC_PANDOC_FILES ?= $(shell find $(SRC_DIR) -type f -name "*$(EXT)")
DST_PANDOC_FILES ?= $(subst $(EXT),.html, \
@ -40,6 +42,32 @@ $(DST_DIR)/%.html: $(SRC_DIR)/%.org $(TEMPLATE)
$(PANDOC) $< \
--output $@
# HTML INDEX
HTML_INDEX := $(DST_DIR)/index.html
$(HTML_INDEX): $(SRC_PANDOC_FILES)
mkdir -p $(DST_DIR)
engine/mk-index.sh
ALL += $(HTML_INDEX)
# ORG -> GEMINI
EXT := .org
SRC_GMI_FILES ?= $(shell find $(SRC_DIR) -type f -name "*$(EXT)")
DST_GMI_FILES ?= $(subst $(EXT),.gmi, \
$(subst $(SRC_DIR),$(DST_DIR), \
$(SRC_GMI_FILES)))
ALL += $(DST_GMI_FILES)
GMI := engine/org2gemini.sh
$(DST_DIR)/%.gmi: $(SRC_DIR)/%.org
mkdir -p $(dir $@)
$(GMI) "$<" "$@"
allatend: $(ALL)
clean:

156
engine/mk-index.sh Executable file
View file

@ -0,0 +1,156 @@
#!/usr/bin/env zsh
cd "$(git rev-parse --show-toplevel)" || exit 1
# Directory
webdir="_site"
postsdir="$webdir/posts"
indexfile="$webdir/index.html"
# maximal number of articles to put in the RSS file
maxarticles=10
# RSS Metas
rsstitle="her.esy.fun"
rssurl="https://her.esy.fun/rss.xml"
websiteurl="https://her.esy.fun"
rssdescription="her.esy.fun articles, mostly random personal thoughts"
rsslang="en"
rssauthor="yann@esposito.host (Yann Esposito)"
rssimgurl="https://her.esy.fun/img/FlatAvatar.png"
# HTML Accessors (similar to CSS accessors)
dateaccessor='.yyydate'
contentaccessor='#content'
# title and keyword shouldn't be changed
titleaccessor='title'
keywordsaccessor='meta[name=keywords]::attr(content)'
formatdate() {
# format the date for RSS
local d="$1"
# echo "DEBUG DATE: $d" >&2
LC_TIME=en_US date --date $d +'%a, %d %b %Y %H:%M:%S %z'
}
finddate(){ < $1 hxselect -c $dateaccessor | sed 's/\[//g;s/\]//g;s/ .*$//' }
findtitle(){ < $1 hxselect -c $titleaccessor }
getcontent(){
< $1 hxselect $contentaccessor | \
perl -pe 'use URI; $base="'$2'"; s# (href|src)="((?!https?://)[^"]*)"#" ".$1."=\"".URI->new_abs($2,$base)->as_string."\""#eig' }
findkeywords(){ < $1 hxselect -c $keywordsaccessor | sed 's/,/ /g' }
mkcategories(){
for keyword in $*; do
printf "\\n<span class=\"tag\">%s</span>" $keyword
done
}
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'/##')"
printf "%-30s" $postfile
xfic="$tmpdir/$fic.xml"
mkdir -p $(dirname $xfic)
hxclean $fic > $xfic
d=$(finddate $xfic)
echo -n " [$d]"
rssdate=$(formatdate $d)
title=$(findtitle $xfic)
keywords=( $(findkeywords $xfic) )
printf ": %-55s" "$title ($keywords)"
categories=$(mkcategories $keywords)
absoluteurl="${websiteurl}/${blogfile}"
{ printf "\\n<li>"
printf "\\n<a href=\"%s\">%s</a>" "${blogfile}" "$title"
printf "\\n<span class=\"pubDate\">%s</span>%s" "$rssdate"
printf "<span class=\"tags\">%s</span>" "$categories"
printf "\\n</li>\\n\\n"
} >> "$tmpdir/${d}-$(basename $fic).index"
dates=( $d $dates )
echo " [${fg[green]}OK${reset_color}]"
done
echo "Publishing"
for fic in $(ls $tmpdir/*.index | sort -r | head -n $maxarticles ); do
echo "${fic:t}"
cat $fic >> $tmpdir/index
done
rssmaxdate=$(formatdate $(for d in $dates; do echo $d; done | sort -r | head -n 1))
rssbuilddate=$(formatdate $(date))
title="Index"
description="Index of latest posts."
author="Yann Esposito"
{
cat <<END
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>$title</title>
<meta name="author" content="$author">
<link rel="stylesheet" href="/css/y.css"/>
<link rel="alternate" type="application/rss+xml" href="/rss.xml" />
<link rel="icon" href="/favicon.ico">
</head>
<body>
<div id="labels">
<div class="content">
<span id="logo">
<a href="/">
<svg width="5em" viewBox="0 0 64 64">
<circle cx="32" cy="32" r="30" stroke="var(--b2)" stroke-width="2" fill="var(--b03)"/>
<circle cx="32" cy="32" r="12" stroke="var(--r)" stroke-width="2" fill="var(--o)"/>
<circle cx="32" cy="32" r="6" stroke-width="0" fill="var(--y)"/>
<ellipse cx="32" cy="14" rx="14" ry="8" stroke-width="0" fill="var(--b3)"/>
</svg>
</a>
</div>
</div>
<div class="main">
<div id="preamble" class="status">
<div class="content">
<h1>$title</h1>
<div class="meta">
<span class="yyydate">$date</span> on
<a href="https://her.esy.fun">
<span class="author">$author</span>'s blog</a>
</div>
<div class="abstract">
$description
</div>
</div>
</div>
<div id="content">
END
cat $tmpdir/index
cat <<END
</div>
<div id="postamble" class="status">
<div class="content">
<nav>
<a href="/index.html">Home</a> |
<a href="/slides.html">Slides</a> |
<a href="/about-me.html">About</a>
<span class="details"> (<a href="https://gitea.esy.fun/yogsototh">code</a>
<a href="https://espial.esy.fun/u:yogsototh">bookmarks</a>
<a href="https://espial.esy.fun/u:yogsototh/notes">notes</a>)</span> |
<a href="#preamble">↑ Top ↑</a>
</nav>
</div>
</div>
</div>
</body>
</html>
END
} > "$indexfile"
rm -rf $tmpdir
echo "* RSS [done]"

View file

@ -266,3 +266,6 @@ code { background: var(--rbg); }
.kw { color:var(--y); }
.st { color:var(--g); }
.co { color:var(--fg0); }
.pubDate { font-size: .7em; color: var(--b1); }
.tag { font-size: .7em; background-color: var(--b1); }

View file

@ -2,7 +2,7 @@
#+AUTHOR: Yann Esposito
#+EMAIL: yann@esposito.host
#+DATE: [2021-01-10 Sun]
#+KEYWORDS: haskell, clojure, architecture, programming
#+KEYWORDS: haskell clojure architecture programming
#+DESCRIPTION: Here is a simple description on how to architect a big functional programming application.
#+OPTIONS: auto-id:t toc:nil

View file

@ -2,7 +2,7 @@
#+AUTHOR: Yann Esposito
#+EMAIL: yann@esposito.host
#+DATE: [2019-11-10 Sun]
#+KEYWORDS: self-hosting, chat, irc
#+KEYWORDS: self-hosting chat irc
#+DESCRIPTION: Change the profile of iTerm in sync with macOS preferences.
#+OPTIONS: auto-id:t toc:nil

View file

@ -2,7 +2,7 @@
#+AUTHOR: Yann Esposito
#+EMAIL: yann@esposito.host
#+DATE: [2019-12-06 Fri]
#+KEYWORDS: blog, shell, script
#+KEYWORDS: blog shell script
#+DESCRIPTION: Optimize the size of a full static website by taking advantage
#+DESCRIPTION: of information found in both HTML and CSS.
#+OPTIONS: auto-id:t toc:nil

View file

@ -3,7 +3,7 @@
#+date: [2019-12-15 Sun]
#+author: Yann Esposito
#+EMAIL: yann@esposito.host
#+keywords: Haskell, programming, functional, tutorial
#+keywords: Haskell programming functional tutorial
#+DESCRIPTION: A short and intense introduction to Haskell. This is an update of my old (2012) article. A lot of things have changed since then. Mostly I changed my approach about the easiest way to install a Haskell playground. I removed the not as important part, and added a short introduction about starting a new project.
#+OPTIONS: auto-id:t toc:t
#+STARTUP: overview

View file

@ -2,7 +2,7 @@
#+date: [2020-02-29 Sat]
#+author: Yann Esposito
#+EMAIL: yann@esposito.host
#+keywords: org-mode, blog
#+keywords: org-mode blog
#+DESCRIPTION: Add links to code block during orgmode export.
#+OPTIONS: auto-id:t toc:t
#+STARTUP: overview