makefile in progress
This commit is contained in:
parent
b74e8e401a
commit
f89c62a6d4
7 changed files with 112 additions and 38 deletions
59
Makefile
59
Makefile
|
@ -1,35 +1,46 @@
|
||||||
# Generate my website out of org-mode/gemini files
|
# Generate my website out of org-mode/gemini files
|
||||||
#
|
#
|
||||||
# maybe check https://themattchan.com/blog/2017-02-28-make-site-generator.html
|
# maybe check https://themattchan.com/blog/2017-02-28-make-site-generator.html
|
||||||
|
# From https://github.com/fcanas/bake/blob/master/Makefile
|
||||||
|
# Finally https://www.arsouyes.org/blog/2017/10_Static_website/
|
||||||
|
|
||||||
source := src
|
all: allatend
|
||||||
output := _site
|
SRC_DIR ?= src
|
||||||
sources := $(shell find $(source) -name '*.org')
|
DST_DIR ?= _site
|
||||||
htmls := $(patsubst %.org,%.html,$(subst $(source),$(output),$(sources)))
|
SRC_RAW_FILES := $(shell find $(SRC_DIR) -type f)
|
||||||
|
DST_RAW_FILES := $(patsubst $(SRC_DIR)/%,$(DST_DIR)/%,$(SRC_RAW_FILES))
|
||||||
|
ALL += $(DST_RAW_FILES)
|
||||||
|
|
||||||
assetssources := $(shell find $(source) -type f ! -path '*.org')
|
$(DST_DIR)/% : $(SRC_DIR)/%
|
||||||
assets := $(subst $(source),$(output),$(assetssources))
|
mkdir -p "$(dir $@)"
|
||||||
|
cp "$<" "$@"
|
||||||
|
|
||||||
all: $(htmls) $(assets)
|
|
||||||
|
|
||||||
$(output)/%.css: $(source)/%.css
|
EXT := .org
|
||||||
mkdir -p $(shell dirname $@)
|
SRC_PANDOC_FILES ?= $(shell find $(SRC_DIR) -type f -name "*$(EXT)")
|
||||||
cp $< $@
|
DST_PANDOC_FILES ?= $(subst $(EXT),.html, \
|
||||||
|
$(subst $(SRC_DIR),$(DST_DIR), \
|
||||||
|
$(SRC_PANDOC_FILES)))
|
||||||
|
|
||||||
# # recipe for converting an org-mode file into html using Pandoc
|
ALL += $(DST_PANDOC_FILES)
|
||||||
# $(output)/%.html: $(source)/%.org
|
|
||||||
# mkdir -p $(shell dirname $@)
|
|
||||||
# pandoc \
|
|
||||||
# --from org \
|
|
||||||
# --to html5 \
|
|
||||||
# --css=/css/y.css \
|
|
||||||
# --toc \
|
|
||||||
# -s \
|
|
||||||
# --standalone \
|
|
||||||
# $< \
|
|
||||||
# -o $@
|
|
||||||
|
|
||||||
.PHONY: clean
|
|
||||||
|
TEMPLATE ?= templates/post.html
|
||||||
|
CSS = /css/y.css
|
||||||
|
PANDOC := pandoc \
|
||||||
|
-c $(CSS) \
|
||||||
|
--template=$(TEMPLATE) \
|
||||||
|
--from org \
|
||||||
|
--to html5 \
|
||||||
|
--standalone
|
||||||
|
|
||||||
|
|
||||||
|
$(DST_DIR)/%.html: $(SRC_DIR)/%.org $(TEMPLATE)
|
||||||
|
mkdir -p $(dir $@)
|
||||||
|
$(PANDOC) $< \
|
||||||
|
--output $@
|
||||||
|
|
||||||
|
allatend: $(ALL)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf $(output)/*
|
rm -rf $(DST_DIR)/*
|
||||||
|
|
|
@ -19,7 +19,7 @@ rssauthor="yann@esposito.host (Yann Esposito)"
|
||||||
rssimgurl="https://her.esy.fun/img/FlatAvatar.png"
|
rssimgurl="https://her.esy.fun/img/FlatAvatar.png"
|
||||||
|
|
||||||
# HTML Accessors (similar to CSS accessors)
|
# HTML Accessors (similar to CSS accessors)
|
||||||
dateaccessor='.article-date'
|
dateaccessor='.yyydate'
|
||||||
contentaccessor='#content'
|
contentaccessor='#content'
|
||||||
# title and keyword shouldn't be changed
|
# title and keyword shouldn't be changed
|
||||||
titleaccessor='title'
|
titleaccessor='title'
|
||||||
|
@ -27,11 +27,12 @@ keywordsaccessor='meta[name=keywords]::attr(content)'
|
||||||
|
|
||||||
formatdate() {
|
formatdate() {
|
||||||
# format the date for RSS
|
# format the date for RSS
|
||||||
local d=$1
|
local d="$1"
|
||||||
|
# echo "DEBUG DATE: $d" >&2
|
||||||
LC_TIME=en_US date --date $d +'%a, %d %b %Y %H:%M:%S %z'
|
LC_TIME=en_US date --date $d +'%a, %d %b %Y %H:%M:%S %z'
|
||||||
}
|
}
|
||||||
|
|
||||||
finddate(){ < $1 hxselect -c $dateaccessor }
|
finddate(){ < $1 hxselect -c $dateaccessor | sed 's/\[//g;s/\]//g;s/ .*$//' }
|
||||||
findtitle(){ < $1 hxselect -c $titleaccessor }
|
findtitle(){ < $1 hxselect -c $titleaccessor }
|
||||||
getcontent(){
|
getcontent(){
|
||||||
< $1 hxselect $contentaccessor | \
|
< $1 hxselect $contentaccessor | \
|
||||||
|
|
|
@ -16,7 +16,7 @@ retrieve_classes_in_css () {
|
||||||
classes=( $( {retrieve_classes_in_html; retrieve_classes_in_css}| \
|
classes=( $( {retrieve_classes_in_html; retrieve_classes_in_css}| \
|
||||||
egrep "^CLASS: [^ ]*$" |\
|
egrep "^CLASS: [^ ]*$" |\
|
||||||
sort -u | \
|
sort -u | \
|
||||||
awk 'length($2)>2 && $2 !~ /(web-file-size|article-date|example|src)/ {print length($2),$2}'|\
|
awk 'length($2)>2 && $2 !~ /(gzwebfilesize|webfilesize|yyydate|example|src)/ {print length($2),$2}'|\
|
||||||
sort -rn | \
|
sort -rn | \
|
||||||
awk '{print $2}') )
|
awk '{print $2}') )
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ type -a filelist
|
||||||
if (($#>0)); then
|
if (($#>0)); then
|
||||||
filelist=( $* )
|
filelist=( $* )
|
||||||
else
|
else
|
||||||
filelist=( $webdir/**/*.html(.) )
|
filelist=( $webdir/*/*.html(.) $webdir/posts/*.html )
|
||||||
fi
|
fi
|
||||||
|
|
||||||
for fic in $filelist; do
|
for fic in $filelist; do
|
||||||
|
@ -73,6 +73,6 @@ for fic in $filelist; do
|
||||||
gzsizeinfos="$gzsizeinfos)"
|
gzsizeinfos="$gzsizeinfos)"
|
||||||
fi
|
fi
|
||||||
print -- $sizeinfos
|
print -- $sizeinfos
|
||||||
perl -pi -e 's#(<span class="?web-file-size"?>)[^<]*(</span>)#$1'"$sizeinfos"'$2#;s#(<span class="?gzweb-file-size"?>)[^<]*(</span>)#$1'"$gzsizeinfos"'$2#' $fic
|
perl -pi -e 's#(<span class="?webfilesize"?>)[^<]*(</span>)#$1'"$sizeinfos"'$2#;s#(<span class="?gzwebfilesize"?>)[^<]*(</span>)#$1'"$gzsizeinfos"'$2#' $fic
|
||||||
done
|
done
|
||||||
rm -rf $tmpdir
|
rm -rf $tmpdir
|
||||||
|
|
62
templates/post.html
Normal file
62
templates/post.html
Normal file
|
@ -0,0 +1,62 @@
|
||||||
|
<!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$">
|
||||||
|
<meta name="description" content="$description$">
|
||||||
|
<meta name="keywords" content="$keywords$">
|
||||||
|
<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">
|
||||||
|
$body$
|
||||||
|
<br/>
|
||||||
|
<a href="$geminiurl$"><code>=> This article is also available on gemini</code></a>
|
||||||
|
</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>
|
|
@ -3,10 +3,10 @@
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
<title>{{title}}</title>
|
<title>$title$</title>
|
||||||
<meta name="author" content="{{author}}">
|
<meta name="author" content="$author$">
|
||||||
<meta name="description" content="{{description}}">
|
<meta name="description" content="$description$">
|
||||||
<meta name="keywords" content="{{#tags}}{{.}}{{^last}} {{/last}}{{/tags}}">
|
<meta name="keywords" content="$keywords$">
|
||||||
<link rel="stylesheet" href="/css/y.css"/>
|
<link rel="stylesheet" href="/css/y.css"/>
|
||||||
<link rel="alternate" type="application/rss+xml" href="/rss.xml" />
|
<link rel="alternate" type="application/rss+xml" href="/rss.xml" />
|
||||||
<link rel="icon" href="/favicon.ico">
|
<link rel="icon" href="/favicon.ico">
|
||||||
|
@ -18,21 +18,21 @@
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<h1>{{title}}</h1>
|
<h1>{{title}}</h1>
|
||||||
<div class="meta">
|
<div class="meta">
|
||||||
<span class="article-date">{{date}}</span> on
|
<span class="article-date">$date$</span> on
|
||||||
<a href="https://her.esy.fun">
|
<a href="https://her.esy.fun">
|
||||||
<span class="author">{{author}}</span>'s blog</a> -
|
<span class="author">$author$</span>'s blog</a> -
|
||||||
<a href="{{orgsource}}">source</a> -
|
<a href="{{orgsource}}">source</a> -
|
||||||
<a href="{{txtsource}}">gmi</a> -
|
<a href="{{txtsource}}">gmi</a> -
|
||||||
<a href="{{pdf}}">pdf</a> -
|
<a href="{{pdf}}">pdf</a> -
|
||||||
<a class="permalink" href="{{permalink}}">§permalink</a>
|
<a class="permalink" href="{{permalink}}">§permalink</a>
|
||||||
</div>
|
</div>
|
||||||
<div class="abstract">
|
<div class="abstract">
|
||||||
{{description}}
|
$description$
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="content">
|
<div id="content">
|
||||||
{{{body}}}
|
$body$
|
||||||
<br/>
|
<br/>
|
||||||
<a href="{{geminiurl}}"><code>=> This article is also available on gemini</code></a>
|
<a href="{{geminiurl}}"><code>=> This article is also available on gemini</code></a>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in a new issue