~ecs/ecs.d2evs.net

06335993641a88e582c68ce563f3b6b3923b5526 — Eyal Sawady a month ago 56408cc
Remove HTTP support

I now serve https://ecs.d2evs.net using kineto.
13 files changed, 22 insertions(+), 320 deletions(-)

M .gitignore
M Makefile
M README.md
M _config.sh
A _templates/page.gmi.w
D _templates/page.html.w
D _templates/webring-in.html
M feed.xml.w
M index.gmi.w
D index.md.w
D nginx.conf
D static/style.css
D tohtml.awk
M .gitignore => .gitignore +1 -3
@@ 1,3 1,1 @@
_html
_gemini
_templates/webring-out.html
_site

M Makefile => Makefile +5 -23
@@ 1,34 1,16 @@
.POSIX:

blogs=\
	https://xkcd.com/atom.xml \
	https://drewdevault.com/feed.xml \
	https://www.youtube.com/feeds/videos.xml?channel_id=UCqJ-Xo29CKyLTjn6z2XwYAw \
	https://emersion.fr/blog/rss.xml \
	https://danluu.com/atom.xml \
	https://aphyr.com/posts.atom \
	https://sourcehut.org/blog/index.xml \
	https://tonsky.me/blog/atom.xml \

local: gen
	doas cp -r _html/* /var/www/localhost
	doas cp -r _gemini/* /srv/gemini/localhost
	doas cp -r _site/* /srv/gemini/localhost

upload: gen
	rsync -r _html/ ecs@ecs.d2evs.net:/var/www/ecs.d2evs.net
	rsync -r _gemini/ ecs@ecs.d2evs.net:/srv/gemini/ecs.d2evs.net
	rsync -r _site/ ecs@ecs.d2evs.net:/srv/gemini/ecs.d2evs.net

gen:
	@printf "openring <_templates/webring-in.html >_templates/webring-out.html\n"
	@openring $$(for blog in $(blogs); do echo "-s $$blog"; done) \
		<_templates/webring-in.html \
		>_templates/webring-out.html
	@echo "wersh . _html"
	@output_format=html wersh . _html
	@echo "wersh . _gemini"
	@output_format=gemini wersh . _gemini
	@echo "wersh . _site"
	@wersh . _site

clean:
	rm -rf _html _gemini
	rm -rf _site

.PHONY: clean

M README.md => README.md +5 -7
@@ 1,16 1,14 @@
# My blog

The code behind <https://ecs.d2evs.net>.
The code behind <gemini://ecs.d2evs.net>.

## Technical details

I use [wersh](https://git.sr.ht/~ecs/wersh) and
[discount](http://www.pell.portland.or.us/~orc/Code/discount/), you may
have luck with [the original wersh](https://git.sr.ht/~sircmpwn/wersh)
and different markdown preprocessor.
I use [wersh](https://git.sr.ht/~ecs/wersh), you may have luck with
[the original wersh](https://git.sr.ht/~sircmpwn/wersh).

nginx.conf is the nginx configuration used in prod, you will probably
need to modify it.
Serve \_site with your favorite gemini server. I also run
[kineto](https://git.sr.ht/~sircmpwn/kineto) for <https://ecs.d2evs.net>.

## Licensing


M _config.sh => _config.sh +3 -19
@@ 1,15 1,3 @@
title=""
get_title() {
	case $1 in
		*.gmi.w)
			./title.awk <"$1"
			;;
		*.md.w)
			echo "ecs's blog"
			;;
	esac
}

get_description() {
	# TODO: is this good enough?
	_rendering="t" wsource "$1" | escape


@@ 41,14 29,10 @@ get_date() {
}

case $input in
	*.md.w)
		preprocessor="markdown -f fencedcode -f footnote"
		wsource _templates/page.html.w
	index.gmi.w)
		# This space intentionally left blank
		;;
	*.gmi.w)
		if [ "z$output_format" = "zhtml" ]; then
			preprocessor="./tohtml.awk"
			wsource _templates/page.html.w
		fi
		wsource _templates/page.gmi.w
		;;
esac

A _templates/page.gmi.w => _templates/page.gmi.w +6 -0
@@ 0,0 1,6 @@
% render() {
% cat


=> / Back to the home page
% }

D _templates/page.html.w => _templates/page.html.w +0 -21
@@ 1,21 0,0 @@
% render() {
<!doctype html>
<html lang="en" charset="utf-8">
<head>
	<meta name="viewport" content="width=device-width, initial-scale=1">
% echo "<title>$(get_title $input)</title>"
	<link type="text/css" rel="stylesheet" href="/static/style.css">
</head>
<body>
	<div class="navbar">
		<a href="/">Home</a>
		<div class="recent">Recent:</div>
% for i in $(ls "$root/posts" | sort -rn | head -n3); do
%     echo "<a href=\"/posts/${i%\.w}\">$(get_title "$root/posts/$i")</a>"
% done
	</div>
	<main>
% cat
	</main>
</body>
% }

D _templates/webring-in.html => _templates/webring-in.html +0 -54
@@ 1,54 0,0 @@
<section class="webring">
  <h4>Posts from RSS feeds I follow around the net</h4>
  <section class="articles">
    {{range .Articles}}
    <div class="article">
      <h5 class="title">
        <a href="{{.Link}}" target="_blank" rel="noopener">{{.Title}}</a>
      </h5>
      <p class="summary">{{.Summary}}</p>
      <small class="source">
        via <a href="{{.SourceLink}}">{{.SourceTitle}}</a>
      </small>
      <small class="date">{{.Date | date}}</small>
    </div>
    {{end}}
  </section>
  <p class="attribution">
    Generated by
    <a href="https://git.sr.ht/~sircmpwn/openring">openring</a>
  </p>
</section>
<style>
.webring {
  font-size: 80%;
}
.webring .articles {
  display: flex;
}
.webring .title {
  margin: 0;
}
.webring .article {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  margin: 0 0.5rem;
  padding: 0.5rem;
}
.webring .article:first-child {
  margin-left: 0;
}
.webring .article:last-child {
  margin-right: 0;
}
.webring .summary {
  font-size: 0.8rem;
  flex: 1 1 0;
}
.webring .attribution {
  text-align: right;
  font-size: 0.8rem;
  color: #777;
}
</style>

M feed.xml.w => feed.xml.w +1 -1
@@ 8,7 8,7 @@
		<atom:link href="https://ecs.d2evs.net/feed.xml" rel="self" type="application/rss+xml" />
% for i in $(ls "$root/posts" | sort -rn | head -n10); do
%     emit '<item>'
%     emit "<title>$(get_title "$root/posts/$i")</title>"
%     emit "<title>$(./title.awk <"$root/posts/$i")</title>"
%     emit "<description>$(get_description "$root/posts/$i")</description>"
%     emit "<pubDate>$(get_date "$root/posts/$i")</pubDate>"
%     emit "<link>https://ecs.d2evs.net/posts/${i%\.w}</link>"

M index.gmi.w => index.gmi.w +1 -1
@@ 16,5 16,5 @@ If you find a bug, please send a patch to ~ecs/public-inbox@lists.sr.ht:
=> /feed.xml RSS feed

% for i in $(ls "$root/posts" | sort -rn); do
%     emit "=> /posts/${i%\.w} $(printf "%s" "$i" | cut -d- -f-3): $(get_title "$root/posts/$i")"
%     emit "=> /posts/${i%\.w} $(printf "%s" "$i" | cut -d- -f-3): $(./title.awk <"$root/posts/$i")"
% done

D index.md.w => index.md.w +0 -36
@@ 1,36 0,0 @@
<link rel="alternate" type="application/rss+xml" title="RSS feed for ecs's blog" href="/feed.xml">

# ecs's blog

I do stuff, most of which does not involve writing blog posts.

Note that the HTML version of this blog is automatically generated from the
Gemini version, [gemini://ecs.d2evs.net](gemini://ecs.d2evs.net) will probably provide a better UX.

sourcehut: [~ecs](https://git.sr.ht/~ecs) on [sr.ht](https://sr.ht)
<br>
email: [ecs@d2evs.net](mailto:ecs@d2evs.net)
<br>
fediverse: [@ecs@social.d2evs.net](https://social.d2evs.net/ecs)
<br>
irc: ecs on most networks
<br>
pgp: [9604D3459E53A9952](/publickey.txt)

This site is licensed CC-BY-SA, you can view the code at
<https://git.sr.ht/~ecs/ecs.d2evs.net>. If you find a bug, please [send
a patch](https://git-send-email.io) to
[~ecs/public-inbox@lists.sr.ht](mailto:~ecs/public-inbox@lists.sr.ht).

An RSS version of this site is available at [/feed.xml](/feed.xml).

<big>
% for i in $(ls "$root/posts" | sort -rn); do
%     emit "<span class="time">$(printf "%s" "$i" | cut -d- -f-3)</span>"
%     emit "<a href=\"/posts/${i%\.w}\">$(get_title "$root/posts/$i")</a>"
  <br>
  <br>
% done
</big>

% cat "$root/_templates/webring-out.html"

D nginx.conf => nginx.conf +0 -37
@@ 1,37 0,0 @@
server {
	listen 80;
	listen [::]:80;
	server_name ecs.d2evs.net;

	location / {
		return 302 https://$server_name$request_uri;
	}

	location ^~ /.well-known {
		root /var/www;
	}
}

server {
	listen 443 ssl http2;
	listen [::]:443 ssl http2;
	server_name ecs.d2evs.net;
	ssl_certificate /etc/ssl/uacme/d2evs.net/cert.pem;
	ssl_certificate_key /etc/ssl/uacme/private/d2evs.net/key.pem;
	charset utf-8;

	gzip on;

	location / {
		root /var/www/ecs.d2evs.net;
		try_files $uri $uri/index.md $uri/index.html 404.html;
	}

	location = /404.html {
		internal;
	}
}

types {
	text/html				md gmi;
}

D static/style.css => static/style.css +0 -55
@@ 1,55 0,0 @@
body {
  background-color: black;
  color: white;
}

pre {
  background-color: #111;
}

code {
  background-color: #111;
}

a:link {
  color: #888;
}

a:visited {
  color: #888;
}

a:hover {
  background-color: #111;
  color: #fff;
}

.navbar {
  overflow: hidden;
  font-size: 12px;
  font-family: monospace;
}

.navbar a {
  float: left;
  text-align: center;
  padding: 5px 8px;
  text-decoration: none;
}

.navbar div {
  float: left;
  background-color: #111;
  color: #888;
  text-align: center;
  padding: 5px 9px;
}

.time {
  color: #777;
}

.webring {
	position: absolute;
	bottom: 0;
}

D tohtml.awk => tohtml.awk +0 -63
@@ 1,63 0,0 @@
#!/usr/bin/awk -f
BEGIN { preformatted="off"; list="off"; title=""; }
{
	gsub(/&/, "\\&amp;");
	gsub(/</, "\\&lt;");
	gsub(/>/, "\\&gt;");
	gsub(/^=&gt;/, "=>");
	gsub(/"/, "\\&quot;");
	gsub(/'/, "\\&#39;");
	if (preformatted == "off") {
		if ($0 !~ /^\*/) {
			if (list == "on") {
				print "</ul>";
			}
			list="off";
		}
		if ($0 ~ /^\*/) {
			sub(/^\*[ \t]*/, "");
			if (list == "off") {
				print "<ul>";
			}
			print "<li>" $0 "</li>";
			list="on";
		} else if ($0 ~ /^###/) {
			sub(/^###[ \t]*/, "");
			print "<h3>" $0 "</h3>";
		} else if ($0 ~ /^##/) {
			sub(/^##[ \t]*/, "");
			print "<h2>" $0 "</h2>";
		} else if ($0 ~ /^#/) {
			sub(/^#[ \t]*/, "");
			if (title == "") {
				title = $0;
				print "<title>" $0 "</title>"
			}
			print "<h1>" $0 "</h1>";
		} else if ($0 ~ /^>/) {
			sub(/^>[ \t]*/, "");
			print "<q>" $0 "</q>";
		} else if ($0 ~ /^```/) {
			# TODO: alt text?
			preformatted="on";
			print "<pre>";
		} else if ($0 ~ /^=>/) {
			sub(/^=>[ \t]*/, "");
			printf "<a href=" $1 ">";
			sub(/^[^ \t]*[ \t*]/, "");
			print $0 "</a>";
		} else {
			print $0;
		}
		if (list == "off") {
			print "<br>";
		}
	} else {
		if ($0 ~ /^```/) {
			preformatted="off";
			print "</pre>";
		} else {
			print $0;
		}
	}
}