makefile in progress
This commit is contained in:
parent
b74e8e401a
commit
f89c62a6d4
59
Makefile
59
Makefile
|
@ -1,35 +1,46 @@
|
|||
# Generate my website out of org-mode/gemini files
|
||||
#
|
||||
# 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
|
||||
output := _site
|
||||
sources := $(shell find $(source) -name '*.org')
|
||||
htmls := $(patsubst %.org,%.html,$(subst $(source),$(output),$(sources)))
|
||||
all: allatend
|
||||
SRC_DIR ?= src
|
||||
DST_DIR ?= _site
|
||||
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')
|
||||
assets := $(subst $(source),$(output),$(assetssources))
|
||||
$(DST_DIR)/% : $(SRC_DIR)/%
|
||||
mkdir -p "$(dir $@)"
|
||||
cp "$<" "$@"
|
||||
|
||||
all: $(htmls) $(assets)
|
||||
|
||||
$(output)/%.css: $(source)/%.css
|
||||
mkdir -p $(shell dirname $@)
|
||||
cp $< $@
|
||||
EXT := .org
|
||||
SRC_PANDOC_FILES ?= $(shell find $(SRC_DIR) -type f -name "*$(EXT)")
|
||||
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
|
||||
# $(output)/%.html: $(source)/%.org
|
||||
# mkdir -p $(shell dirname $@)
|
||||
# pandoc \
|
||||
# --from org \
|
||||
# --to html5 \
|
||||
# --css=/css/y.css \
|
||||
# --toc \
|
||||
# -s \
|
||||
# --standalone \
|
||||
# $< \
|
||||
# -o $@
|
||||
ALL += $(DST_PANDOC_FILES)
|
||||
|
||||
.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:
|
||||
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"
|
||||
|
||||
# HTML Accessors (similar to CSS accessors)
|
||||
dateaccessor='.article-date'
|
||||
dateaccessor='.yyydate'
|
||||
contentaccessor='#content'
|
||||
# title and keyword shouldn't be changed
|
||||
titleaccessor='title'
|
||||
|
@ -27,11 +27,12 @@ keywordsaccessor='meta[name=keywords]::attr(content)'
|
|||
|
||||
formatdate() {
|
||||
# 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'
|
||||
}
|
||||
|
||||
finddate(){ < $1 hxselect -c $dateaccessor }
|
||||
finddate(){ < $1 hxselect -c $dateaccessor | sed 's/\[//g;s/\]//g;s/ .*$//' }
|
||||
findtitle(){ < $1 hxselect -c $titleaccessor }
|
||||
getcontent(){
|
||||
< $1 hxselect $contentaccessor | \
|
||||
|
|
|
@ -16,7 +16,7 @@ retrieve_classes_in_css () {
|
|||
classes=( $( {retrieve_classes_in_html; retrieve_classes_in_css}| \
|
||||
egrep "^CLASS: [^ ]*$" |\
|
||||
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 | \
|
||||
awk '{print $2}') )
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ type -a filelist
|
|||
if (($#>0)); then
|
||||
filelist=( $* )
|
||||
else
|
||||
filelist=( $webdir/**/*.html(.) )
|
||||
filelist=( $webdir/*/*.html(.) $webdir/posts/*.html )
|
||||
fi
|
||||
|
||||
for fic in $filelist; do
|
||||
|
@ -73,6 +73,6 @@ for fic in $filelist; do
|
|||
gzsizeinfos="$gzsizeinfos)"
|
||||
fi
|
||||
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
|
||||
rm -rf $tmpdir
|
||||
|
|
|
@ -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>
|
||||
<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="{{#tags}}{{.}}{{^last}} {{/last}}{{/tags}}">
|
||||
<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">
|
||||
|
@ -18,21 +18,21 @@
|
|||
<div class="content">
|
||||
<h1>{{title}}</h1>
|
||||
<div class="meta">
|
||||
<span class="article-date">{{date}}</span> on
|
||||
<span class="article-date">$date$</span> on
|
||||
<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="{{txtsource}}">gmi</a> -
|
||||
<a href="{{pdf}}">pdf</a> -
|
||||
<a class="permalink" href="{{permalink}}">§permalink</a>
|
||||
</div>
|
||||
<div class="abstract">
|
||||
{{description}}
|
||||
$description$
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="content">
|
||||
{{{body}}}
|
||||
$body$
|
||||
<br/>
|
||||
<a href="{{geminiurl}}"><code>=> This article is also available on gemini</code></a>
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue