Created
November 8, 2012 06:50
-
-
Save thedod/4037292 to your computer and use it in GitHub Desktop.
Shorter permalinks for Tahoe-LAFS/TiddlyWiki sites like https://dubiousdod.org
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
# ... | |
location ^~ /go/ { | |
limit_except HEAD GET { deny all; } | |
# /go/SomeHash redirects to front page with #SomeHash as hash (for browser that don't preserve hashes in redirects) | |
rewrite ^/go/(.*)$ /uri/URI:DIR2-RO:LONG_TWIDDLYWIKI_FOLDER_READ_CAPABILITY_URL/index.html#$1 redirect; | |
} | |
location ^~ / { | |
limit_except HEAD GET { deny all; } | |
# Redirect / to the site's front page capability (as long as the method is HEAD or GET): | |
rewrite ^/?$ /uri/URI:DIR2-RO:LONG_TWIDDLYWIKI_FOLDER_READ_CAPABILITY_URL/index.html redirect; | |
# fallback to static | |
root /PATH_TO/allmydata/web/static; | |
} | |
location / | |
{ | |
# Deny all other locations. Actually, nothing should get here, but it's a tradition :) | |
return 403; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- orig/wiki.html 2011-11-16 12:42:06.000000000 +0700 | |
+++ new/wiki.html 2012-11-08 13:18:42.831290734 +0700 | |
@@ -3738,6 +3252,7 @@ | |
var t = encodeURIComponent(String.encodeTiddlyLink(title)); | |
if(window.location.hash != t) | |
window.location.hash = t; | |
+ prompt("Permalink for this tiddler",window.location.protocol+'//'+window.location.host+'/go/'+t); | |
return false; | |
}; | |
@@ -5348,6 +4863,7 @@ | |
links.push(String.encodeTiddlyLink(title)); | |
}); | |
var t = encodeURIComponent(links.join(" ")); | |
+ prompt("Permalink for currently visible tiddlers",window.location.protocol+'//'+window.location.host+'/go/'+t); | |
if(t == "") | |
t = "#"; | |
if(window.location.hash != t) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Fo details, see https://dubiousdod.org/blog/shorter-urls.html