redirects and gone cleanup, step 2
This commit is contained in:
parent
137522c23d
commit
b46d8aa7a5
7 changed files with 73 additions and 51 deletions
|
@ -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"
|
||||
}
|
||||
|
|
2
meta.py
2
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),
|
||||
)
|
||||
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
|
|
@ -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 @@
|
|||
</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 @@
|
|||
{% 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">
|
||||
|
|
24
templates/nginx.j2.conf
Normal file
24
templates/nginx.j2.conf
Normal file
|
@ -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 %}
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -219,4 +219,7 @@
|
|||
<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>
|
||||
|
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
Loading…
Reference in a new issue