From: David ‘Bombe’ Roden Date: Sat, 2 Apr 2011 14:57:11 +0000 (+0200) Subject: Send out header exposing the OpenSearchDescription document. X-Git-Tag: 0.6^2~4 X-Git-Url: https://git.pterodactylus.net/?a=commitdiff_plain;h=2ee1747f28b213da04a98456aac925f315f52dac;p=Sone.git Send out header exposing the OpenSearchDescription document. --- diff --git a/src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java b/src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java index f969208..d6c41c1 100644 --- a/src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java +++ b/src/main/java/net/pterodactylus/sone/web/SoneTemplatePage.java @@ -21,11 +21,15 @@ import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.Arrays; import java.util.Collection; +import java.util.List; +import java.util.Map; import net.pterodactylus.sone.data.Sone; import net.pterodactylus.sone.main.SonePlugin; import net.pterodactylus.sone.web.page.Page; import net.pterodactylus.sone.web.page.FreenetTemplatePage; +import net.pterodactylus.util.collection.ListBuilder; +import net.pterodactylus.util.collection.MapBuilder; import net.pterodactylus.util.template.Template; import net.pterodactylus.util.template.TemplateContext; import freenet.clients.http.SessionManager.Session; @@ -209,6 +213,14 @@ public class SoneTemplatePage extends FreenetTemplatePage { * {@inheritDoc} */ @Override + protected List> getAdditionalLinkNodes(Request request) { + return new ListBuilder>().add(new MapBuilder().put("rel", "search").put("type", "application/opensearchdescription+xml").put("title", "Sone").put("href", "http://" + request.getHttpRequest().getHeader("host") + "/Sone/OpenSearch.xml").get()).get(); + } + + /** + * {@inheritDoc} + */ + @Override protected Collection getStyleSheets() { return Arrays.asList("css/sone.css"); } diff --git a/src/main/java/net/pterodactylus/sone/web/WebInterface.java b/src/main/java/net/pterodactylus/sone/web/WebInterface.java index 6341f2c..acfdc7f 100644 --- a/src/main/java/net/pterodactylus/sone/web/WebInterface.java +++ b/src/main/java/net/pterodactylus/sone/web/WebInterface.java @@ -86,6 +86,7 @@ import net.pterodactylus.sone.web.ajax.UntrustAjaxPage; import net.pterodactylus.sone.web.page.PageToadlet; import net.pterodactylus.sone.web.page.PageToadletFactory; import net.pterodactylus.sone.web.page.StaticPage; +import net.pterodactylus.sone.web.page.TemplatePage; import net.pterodactylus.util.cache.Cache; import net.pterodactylus.util.cache.CacheException; import net.pterodactylus.util.cache.CacheItem; @@ -537,6 +538,7 @@ public class WebInterface implements CoreListener { Template invalidTemplate = TemplateParser.parse(createReader("/templates/invalid.html")); Template postTemplate = TemplateParser.parse(createReader("/templates/include/viewPost.html")); Template replyTemplate = TemplateParser.parse(createReader("/templates/include/viewReply.html")); + Template openSearchTemplate = TemplateParser.parse(createReader("/templates/xml/OpenSearch.xml")); PageToadletFactory pageToadletFactory = new PageToadletFactory(sonePlugin.pluginRespirator().getHLSimpleClient(), "/Sone/"); pageToadlets.add(pageToadletFactory.createPageToadlet(new IndexPage(indexTemplate, this), "Index")); @@ -576,6 +578,7 @@ public class WebInterface implements CoreListener { pageToadlets.add(pageToadletFactory.createPageToadlet(new StaticPage("css/", "/static/css/", "text/css"))); pageToadlets.add(pageToadletFactory.createPageToadlet(new StaticPage("javascript/", "/static/javascript/", "text/javascript"))); pageToadlets.add(pageToadletFactory.createPageToadlet(new StaticPage("images/", "/static/images/", "image/png"))); + pageToadlets.add(pageToadletFactory.createPageToadlet(new TemplatePage("OpenSearch.xml", "application/opensearchdescription+xml", templateContextFactory, openSearchTemplate))); pageToadlets.add(pageToadletFactory.createPageToadlet(new GetTranslationPage(this))); pageToadlets.add(pageToadletFactory.createPageToadlet(new GetStatusAjaxPage(this))); pageToadlets.add(pageToadletFactory.createPageToadlet(new DismissNotificationAjaxPage(this))); diff --git a/src/main/resources/templates/xml/OpenSearch.xml b/src/main/resources/templates/xml/OpenSearch.xml new file mode 100644 index 0000000..37f0d35 --- /dev/null +++ b/src/main/resources/templates/xml/OpenSearch.xml @@ -0,0 +1,7 @@ + + + Sone + Search Sone Profiles and Posts + http://<%request.httpRequest.host>/Sone/images/icon.png + +