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 %} -