From b46d8aa7a5df3a26968e16a3e554a74071da70f3 Mon Sep 17 00:00:00 2001
From: Peter Molnar
Date: Mon, 12 Aug 2019 10:49:51 +0100
Subject: [PATCH] redirects and gone cleanup, step 2
---
keys.dist.py | 8 +++----
meta.py | 2 +-
templates/404.j2.php | 25 +++++++---------------
templates/Singular.j2.html | 44 +++++++++++++++++++-------------------
templates/nginx.j2.conf | 24 +++++++++++++++++++++
templates/style.css | 18 ++++++++++------
templates/symbols.svg | 3 +++
7 files changed, 73 insertions(+), 51 deletions(-)
create mode 100644 templates/nginx.j2.conf
diff --git a/keys.dist.py b/keys.dist.py
index 960cc82..ed473ba 100644
--- a/keys.dist.py
+++ b/keys.dist.py
@@ -1,9 +1,9 @@
webmentionio = {
- 'domain': 'example.com',
- 'token': 'https://webmention.io/settings -> API key',
- 'secret': 'https://webmention.io/settings/webhooks -> callback secret'
+ "domain": "example.com",
+ "token": "https://webmention.io/settings -> API key",
+ "secret": "https://webmention.io/settings/webhooks -> callback secret",
}
telegraph = {
- 'token': 'https://telegraph.p3k.io/ -> select site under avatar -> settings gear icon -> API key'
+ "token": "https://telegraph.p3k.io/ -> select site under avatar -> settings gear icon -> API key"
}
diff --git a/meta.py b/meta.py
index 03e10cf..e40932f 100644
--- a/meta.py
+++ b/meta.py
@@ -30,7 +30,7 @@ class CachedMeta(dict):
fname = os.path.basename(os.path.dirname(self.fpath))
return os.path.join(
- os.path.dirname(self.fpath),
+ settings.tmpdir,
"%s.%s.%s" % (fname, self.__class__.__name__, self.suffix),
)
diff --git a/templates/404.j2.php b/templates/404.j2.php
index e44b7d0..2d7f79b 100644
--- a/templates/404.j2.php
+++ b/templates/404.j2.php
@@ -6,13 +6,10 @@ $redirects = array(
{% endfor %}
);
-$redirects_re = array(
- '^(?:sysadmin|it|linux-tech-coding|sysadmin-blog)\/?(page.*)?$' => 'category/article/',
- '^(?:fotography|photoblog)\/?(page.*)?$' => '/category/photo/$1',
- '^blog\/?(page.*)?$' => '/category/journal/',
- '^blips\/?(page.*)?$' => '/category/note/$1',
- '^r\/?(page.*)?$' => '/category/note/$1',
- '^(?:linux-tech-coding|it|sysadmin-blog|sysadmin|fotography|blips|blog|photoblog|article|journal|photo|note|r)\/((?!page).*)' => '/$1',
+$rewrites = array(
+{% for from, to in rewrites.items() %}
+ "{{ from }}" => "{{ to }}",
+{% endfor %}
);
$gone = array(
@@ -22,12 +19,9 @@ $gone = array(
);
$gone_re = array(
- '^cache\/.*$',
- '^tag\/.*$',
- '^comment\/.*$',
- '^files\/.*$',
- '^wp-content\/.*$',
- '^broadcast\/wp-ffpc\.message$',
+{% for gone in gone_re %}
+ "{{ gone }}",
+{% endfor %}
);
function redirect_to($uri) {
@@ -103,7 +97,7 @@ foreach ($gone_re as $pattern) {
}
}
-foreach ($redirects_re as $pattern => $target) {
+foreach ($rewrites as $pattern => $target) {
$maybe = preg_match(sprintf('/%s/i', $pattern), $uri, $matches);
if ($maybe) {
$target = str_replace('$1', $matches[1], $target);
@@ -117,9 +111,6 @@ if (isset($gone[$uri])) {
elseif (isset($redirects[$uri])) {
redirect_to($redirects[$uri]);
}
-elseif (preg_match('/^\.well-known\/(host-meta|webfinger).*$/', $uri)) {
- redirect_to("https://fed.brid.gy/{$uri}");
-}
elseif (strstr($uri, '_')) {
maybe_redirect(str_replace('_', '-', $uri));
}
diff --git a/templates/Singular.j2.html b/templates/Singular.j2.html
index 57961bb..36f7ab9 100644
--- a/templates/Singular.j2.html
+++ b/templates/Singular.j2.html
@@ -62,11 +62,29 @@
{% block content %}
- {% if memento %}
-
- {% if post.sameAs|length %}
-
- This post was also syndicated to:
-
- {% for url in post.sameAs %}
- - {{ url }}
- {% endfor %}
-
-
- {% endif %}
{% if post.subjectOf %}
diff --git a/templates/nginx.j2.conf b/templates/nginx.j2.conf
new file mode 100644
index 0000000..c0b7db3
--- /dev/null
+++ b/templates/nginx.j2.conf
@@ -0,0 +1,24 @@
+{% for location in gones %}
+location /{{ location }} {
+ return 410;
+}
+
+{% endfor %}
+
+{% for location in gones_re %}
+location ~ {{ location }} {
+ return 410;
+}
+
+{% endfor %}
+
+{% for from, to in redirects.items() %}
+location /{{ from }} {
+ return 301 {{ to }};
+}
+
+{% endfor %}
+
+{% for source, target in rewrites.items() %}
+#rewrite {{ source }} {{ target}} permanent;
+{% endfor %}
diff --git a/templates/style.css b/templates/style.css
index db201f5..e177872 100644
--- a/templates/style.css
+++ b/templates/style.css
@@ -6,7 +6,7 @@
margin: 0;
padding: 0;
line-height: 1.5em;
- letter-spacing: 0.02em;
+ letter-spacing: 0.03em;
}
article, aside, footer, header, nav, section {
@@ -291,8 +291,10 @@ li p {
}
#header > *,
-#footer > * {
- max-width: 54em;
+#footer > *,
+#pagination,
+#main {
+ max-width: 58em;
margin: 0 auto;
}
@@ -302,8 +304,6 @@ li p {
#pagination,
#main {
- margin:0 auto;
- max-width: 54em;
padding: 1em 0.3em;
}
@@ -361,7 +361,11 @@ li p {
margin:0;
}
-@media all and (max-width: 47em) {
+#syndication {
+ float:right;
+}
+
+@media all and (max-width: 51em) {
#header > * {
display: block;
text-align:center;
@@ -386,4 +390,4 @@ li p {
display: block;
margin: 0 auto;
}
-}
\ No newline at end of file
+}
diff --git a/templates/symbols.svg b/templates/symbols.svg
index 17f97e1..d0585e2 100644
--- a/templates/symbols.svg
+++ b/templates/symbols.svg
@@ -219,4 +219,7 @@
+
+
+