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;
* {@inheritDoc}
*/
@Override
+ protected List<Map<String, String>> getAdditionalLinkNodes(Request request) {
+ return new ListBuilder<Map<String, String>>().add(new MapBuilder<String, String>().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<String> getStyleSheets() {
return Arrays.asList("css/sone.css");
}
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;
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"));
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)));
--- /dev/null
+<?xml version="1.0" encoding="utf-8" ?>
+<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
+ <ShortName>Sone</ShortName>
+ <Description>Search Sone Profiles and Posts</Description>
+ <Image width="32" height="32" type="image/png">http://<%request.httpRequest.host>/Sone/images/icon.png</Image>
+ <Url type="text/html" method="get" template="http://<%request.httpRequest.host>/Sone/search.html?query={searchTerms}" />
+</OpenSearchDescription>