From: David ‘Bombe’ Roden Date: Fri, 16 Sep 2011 20:15:33 +0000 (+0200) Subject: Add possibility to have an extra file path after the target. X-Git-Tag: 0.0.7^2~4 X-Git-Url: https://git.pterodactylus.net/?p=WoTNS.git;a=commitdiff_plain;h=9288c73f25d0ce121b574812d71b9d4c41d529ba Add possibility to have an extra file path after the target. --- diff --git a/src/main/java/net/pterodactylus/wotns/ui/web/ResolverPage.java b/src/main/java/net/pterodactylus/wotns/ui/web/ResolverPage.java index 6db3b6a..d26d1aa 100644 --- a/src/main/java/net/pterodactylus/wotns/ui/web/ResolverPage.java +++ b/src/main/java/net/pterodactylus/wotns/ui/web/ResolverPage.java @@ -62,11 +62,19 @@ public class ResolverPage extends BasicPage { protected void processTemplate(FreenetRequest request, TemplateContext templateContext) throws RedirectException { String uri = request.getUri().getPath(); String path = uri.substring(uri.indexOf('/', 1) + 1); - FreenetURI targetUri; + + /* look for path after target. */ + int firstSlash = path.indexOf('/'); + int secondSlash = path.indexOf('/', firstSlash + 1); + String filePath = ""; + if (secondSlash != -1) { + filePath = path.substring(secondSlash); + path = path.substring(0, secondSlash); + } try { - targetUri = resolver.resolveURI(path); + FreenetURI targetUri = resolver.resolveURI(path); if (targetUri != null) { - throw new RedirectException("/" + targetUri.toString()); + throw new RedirectException("/" + targetUri.toString() + filePath); } } catch (MalformedURLException mue1) { /* TODO - do something. */ diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html index 6c4f6ee..5fb6a86 100644 --- a/src/main/resources/templates/index.html +++ b/src/main/resources/templates/index.html @@ -1,11 +1,13 @@ <%include include/head.html>

WoTNS

The Web of Trust Name Service uses properties of Web of Trust identities to implement a DNS-like scheme on top of Freenet.

-

The general syntax is: http://<%request.host>/tns/identity[@start-of-key]/target.

+

The general syntax is: http://<%request.host>/tns/identity[@start-of-key]/target[/path].

identity is the nickname of a Web of Trust identity, such as “WoTNS”. It is also possible to include the beginning of the identity’s key into identity, in the form of nickname@start-of-key, such as “WoTNS@DAx”.

The target consists of a name chosen by the remote identity. It can consist of latin latters, digits, and periods (and the final name has to fulfill the Web of Trust’s requirement for a valid property name.

+

The target can be followed by a path, such as “more_content.html”, that will be appended to whatever the target is set to, +including the slash between target and path.

To be able to add targets for one of your identities, you first have to create an identity using the Web of Trust, and you have to enable the identity here.