redirects and gone cleanup, step 2
Peter Molnar hello@petermolnar.eu
Mon, 12 Aug 2019 10:49:51 +0100
7 files changed,
73 insertions(+),
51 deletions(-)
M
keys.dist.py
→
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" }
M
templates/404.j2.php
→
templates/404.j2.php
@@ -6,13 +6,10 @@ "{{ from }}" => "{{ to }}",
{% 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 @@ {% endfor %}
); $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 @@ gone($uri);
} } -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);@@ -116,9 +110,6 @@ 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));
M
templates/Singular.j2.html
→
templates/Singular.j2.html
@@ -62,11 +62,29 @@
{% block content %} <main id="main"> <article class="h-entry hentry" lang="{{ post.inLanguage }}" id="article"> - {% if memento %} - <aside id="memento"> - <span>current version</span> | <a href="{{ memento|relurl(baseurl) }}">how it originally looked in {{ post.copyrightYear }}</a> + <aside id="entry-meta"> + {% if memento %} + <span id="memento"> + <a href="{{ memento|relurl(baseurl) }}">How this entry originally looked in {{ post.copyrightYear }}</a> + </span> + {% endif %} + {% if post.sameAs|length %} + <span id="syndication"> + Post syndicated to: + {% for url in post.sameAs %} + <a class="u-syndication" href="{{ url }}"><svg width="16" height="16" aria-label="{{ url|extractdomain }}"><use xlink:href="#icon-{{ url|extractdomain }}"</svg></a> + {% endfor %} + </span> + {% endif %} + {% if 'WebPage' != post['@type'] %} + {% for action in post.potentialAction %} + {% if 'InteractAction' == action['@type'] %} + <a href="{{ action.url }}"></a> + {% endif %} + {% endfor %} + {% endif %} </aside> - {% endif %} + <h1 class="p-name entry-title"> {% if post.mentions %} <span>@@ -119,14 +137,6 @@ {{ post.text|relurl(baseurl) }}
</section> {% if 'WebPage' != post['@type'] %} - <section class="syndication"> - {% for action in post.potentialAction %} - {% if 'InteractAction' == action['@type'] %} - <a href="{{ action.url }}"></a> - {% endif %} - {% endfor %} - </section> - {% if post.comment|length %} <section class="comments"> <h2><a id="comments"></a>Responses</h2>@@ -206,16 +216,6 @@ </a>
{% endif %} {% endif %} </p> - {% if post.sameAs|length %} - <p> - This post was also syndicated to: - <ul> - {% for url in post.sameAs %} - <li><a class="u-syndication" href="{{ url }}">{{ url }}</a></li> - {% endfor %} - </ul> - </p> - {% endif %} {% if post.subjectOf %} <p class="h-event vevent">
A
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 %}
M
templates/style.css
→
templates/style.css
@@ -6,7 +6,7 @@ font-family: "Ubuntu", "Roboto", "Segoe UI", "San Francisco", "Droid Sans", "Tahoma", "Helvetica Neue", "Lucida Grande", sans-serif;
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 @@ padding: 1em;
} #header > *, -#footer > * { - max-width: 54em; +#footer > *, +#pagination, +#main { + max-width: 58em; margin: 0 auto; }@@ -302,8 +304,6 @@ }
#pagination, #main { - margin:0 auto; - max-width: 54em; padding: 1em 0.3em; }@@ -361,7 +361,11 @@ .h-feed .h-entry h3 {
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 @@ #header a svg {
display: block; margin: 0 auto; } -} +}
M
templates/symbols.svg
→
templates/symbols.svg
@@ -219,4 +219,7 @@ <path d="m53 5h3v1h-2v1h2v1h-2v1h2v1h-3z"/>
<path d="m47 5h1v1h1v1h1v1h1v-3h1v5h-1v-1h-1v-1h-1v-1h-1v3h-1z"/> </g> </symbol> + <symbol id="icon-flickr.com" viewBox="0 0 16 16"> + <path fill="#0063dc" d="M0 8c0 2.049 1.663 3.709 3.71 3.709 2.050 0 3.713-1.66 3.713-3.709s-1.662-3.709-3.713-3.709c-2.047 0-3.71 1.66-3.71 3.709zM8.577 8c0 2.049 1.662 3.709 3.711 3.709 2.042 0 3.711-1.66 3.711-3.709s-1.661-3.709-3.709-3.709c-2.050 0-3.713 1.66-3.713 3.709z"></path> + </symbol> </svg>