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 = {
|
webmentionio = {
|
||||||
'domain': 'example.com',
|
"domain": "example.com",
|
||||||
'token': 'https://webmention.io/settings -> API key',
|
"token": "https://webmention.io/settings -> API key",
|
||||||
'secret': 'https://webmention.io/settings/webhooks -> callback secret'
|
"secret": "https://webmention.io/settings/webhooks -> callback secret",
|
||||||
}
|
}
|
||||||
|
|
||||||
telegraph = {
|
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))
|
fname = os.path.basename(os.path.dirname(self.fpath))
|
||||||
|
|
||||||
return os.path.join(
|
return os.path.join(
|
||||||
os.path.dirname(self.fpath),
|
settings.tmpdir,
|
||||||
"%s.%s.%s" % (fname, self.__class__.__name__, self.suffix),
|
"%s.%s.%s" % (fname, self.__class__.__name__, self.suffix),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -6,13 +6,10 @@ $redirects = array(
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
);
|
);
|
||||||
|
|
||||||
$redirects_re = array(
|
$rewrites = array(
|
||||||
'^(?:sysadmin|it|linux-tech-coding|sysadmin-blog)\/?(page.*)?$' => 'category/article/',
|
{% for from, to in rewrites.items() %}
|
||||||
'^(?:fotography|photoblog)\/?(page.*)?$' => '/category/photo/$1',
|
"{{ from }}" => "{{ to }}",
|
||||||
'^blog\/?(page.*)?$' => '/category/journal/',
|
{% endfor %}
|
||||||
'^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',
|
|
||||||
);
|
);
|
||||||
|
|
||||||
$gone = array(
|
$gone = array(
|
||||||
|
@ -22,12 +19,9 @@ $gone = array(
|
||||||
);
|
);
|
||||||
|
|
||||||
$gone_re = array(
|
$gone_re = array(
|
||||||
'^cache\/.*$',
|
{% for gone in gone_re %}
|
||||||
'^tag\/.*$',
|
"{{ gone }}",
|
||||||
'^comment\/.*$',
|
{% endfor %}
|
||||||
'^files\/.*$',
|
|
||||||
'^wp-content\/.*$',
|
|
||||||
'^broadcast\/wp-ffpc\.message$',
|
|
||||||
);
|
);
|
||||||
|
|
||||||
function redirect_to($uri) {
|
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);
|
$maybe = preg_match(sprintf('/%s/i', $pattern), $uri, $matches);
|
||||||
if ($maybe) {
|
if ($maybe) {
|
||||||
$target = str_replace('$1', $matches[1], $target);
|
$target = str_replace('$1', $matches[1], $target);
|
||||||
|
@ -117,9 +111,6 @@ if (isset($gone[$uri])) {
|
||||||
elseif (isset($redirects[$uri])) {
|
elseif (isset($redirects[$uri])) {
|
||||||
redirect_to($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, '_')) {
|
elseif (strstr($uri, '_')) {
|
||||||
maybe_redirect(str_replace('_', '-', $uri));
|
maybe_redirect(str_replace('_', '-', $uri));
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,11 +62,29 @@
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<main id="main">
|
<main id="main">
|
||||||
<article class="h-entry hentry" lang="{{ post.inLanguage }}" id="article">
|
<article class="h-entry hentry" lang="{{ post.inLanguage }}" id="article">
|
||||||
{% if memento %}
|
<aside id="entry-meta">
|
||||||
<aside id="memento">
|
{% if memento %}
|
||||||
<span>current version</span> | <a href="{{ memento|relurl(baseurl) }}">how it originally looked in {{ post.copyrightYear }}</a>
|
<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>
|
</aside>
|
||||||
{% endif %}
|
|
||||||
<h1 class="p-name entry-title">
|
<h1 class="p-name entry-title">
|
||||||
{% if post.mentions %}
|
{% if post.mentions %}
|
||||||
<span>
|
<span>
|
||||||
|
@ -119,14 +137,6 @@
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
{% if 'WebPage' != post['@type'] %}
|
{% 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 %}
|
{% if post.comment|length %}
|
||||||
<section class="comments">
|
<section class="comments">
|
||||||
<h2><a id="comments"></a>Responses</h2>
|
<h2><a id="comments"></a>Responses</h2>
|
||||||
|
@ -206,16 +216,6 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</p>
|
</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 %}
|
{% if post.subjectOf %}
|
||||||
<p class="h-event vevent">
|
<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;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
line-height: 1.5em;
|
line-height: 1.5em;
|
||||||
letter-spacing: 0.02em;
|
letter-spacing: 0.03em;
|
||||||
}
|
}
|
||||||
|
|
||||||
article, aside, footer, header, nav, section {
|
article, aside, footer, header, nav, section {
|
||||||
|
@ -291,8 +291,10 @@ li p {
|
||||||
}
|
}
|
||||||
|
|
||||||
#header > *,
|
#header > *,
|
||||||
#footer > * {
|
#footer > *,
|
||||||
max-width: 54em;
|
#pagination,
|
||||||
|
#main {
|
||||||
|
max-width: 58em;
|
||||||
margin: 0 auto;
|
margin: 0 auto;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -302,8 +304,6 @@ li p {
|
||||||
|
|
||||||
#pagination,
|
#pagination,
|
||||||
#main {
|
#main {
|
||||||
margin:0 auto;
|
|
||||||
max-width: 54em;
|
|
||||||
padding: 1em 0.3em;
|
padding: 1em 0.3em;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -361,7 +361,11 @@ li p {
|
||||||
margin:0;
|
margin:0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@media all and (max-width: 47em) {
|
#syndication {
|
||||||
|
float:right;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media all and (max-width: 51em) {
|
||||||
#header > * {
|
#header > * {
|
||||||
display: block;
|
display: block;
|
||||||
text-align:center;
|
text-align:center;
|
||||||
|
|
|
@ -219,4 +219,7 @@
|
||||||
<path d="m47 5h1v1h1v1h1v1h1v-3h1v5h-1v-1h-1v-1h-1v-1h-1v3h-1z"/>
|
<path d="m47 5h1v1h1v1h1v1h1v-3h1v5h-1v-1h-1v-1h-1v-1h-1v3h-1z"/>
|
||||||
</g>
|
</g>
|
||||||
</symbol>
|
</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>
|
</svg>
|
||||||
|
|
Before Width: | Height: | Size: 22 KiB After Width: | Height: | Size: 22 KiB |
Loading…
Reference in a new issue