@Override @Nonnull protected String filter (final @Nonnull Matcher matcher) { final ResourcePath relativePath = new ResourcePath(matcher.group(1)); return siteProvider.get().getSite().createLink(relativePath); } }
@Override @Nonnull protected String filter (final @Nonnull Matcher matcher) { final ResourcePath relativePath = new ResourcePath(matcher.group(1)).prependedWith("media"); return siteProvider.get().getSite().createLink(relativePath); } }
@Override public boolean apply (final @Nonnull SiteNode rssSiteNode) { try { final String title = rssSiteNode.getProperties().getProperty(PROPERTY_TITLE, "RSS"); builder.append(String.format("<link rel=\"alternate\" type=\"%s\" title=\"%s\" href=\"%s\" />%n", RSS_MIME_TYPE, title, site.createLink(rssSiteNode.getRelativeUri()))); } catch (IOException e) { log.warn("", e); // shouldn't occur } return false; }
/******************************************************************************************************************* * * * ******************************************************************************************************************/ private void appendYearSelector (final @Nonnull StringBuilder builder, final @Nonnegative int firstYear, final @Nonnegative int lastYear, final @Nonnegative int selectedYear) { builder.append("<div class='nw-calendar-yearselector'>\n"); String separator = ""; for (int year = firstYear; year <= lastYear; year++) { builder.append(separator); separator = " | "; if (year != selectedYear) { final String url = site.createLink(siteNode.getRelativeUri().appendedWith("" + year)); builder.append(String.format("<a href='%s'>%d</a>%n", url, year)); } else { builder.append(year); } } builder.append("</div>\n"); }
/******************************************************************************************************************* * * . * ******************************************************************************************************************/ @Nonnull private String computeScreenCssSection() { final StringBuilder builder = new StringBuilder(); try { for (final String relativeUri : getViewProperties().getProperty(PROPERTY_SCREEN_STYLE_SHEETS, Collections.<String>emptyList())) { final String link = relativeUri.startsWith("http") ? relativeUri : site.createLink(new ResourcePath(relativeUri)); builder.append(String.format(LINK_RELSTYLESHEET_MEDIASCREEN_HREF, link)); } } catch (IOException e) { log.error("", e); } return builder.toString(); }
/******************************************************************************************************************* * * . * ******************************************************************************************************************/ @Nonnull private String computePrintCssSection() { final StringBuilder builder = new StringBuilder(); try { for (final String relativeUri : getViewProperties().getProperty(PROPERTY_PRINT_STYLE_SHEETS, Collections.<String>emptyList())) { final String link = relativeUri.startsWith("http") ? relativeUri : site.createLink(new ResourcePath(relativeUri)); final String template = "<link rel=\"stylesheet\" media=\"print\" href=\"%s\" type=\"text/css\" />\n"; builder.append(String.format(template, link)); } } catch (IOException e) { log.error("", e); } return builder.toString(); }
/******************************************************************************************************************* * * . * ******************************************************************************************************************/ @Nonnull private String computeScriptsSection() { final StringBuilder builder = new StringBuilder(); try { for (final String relativeUri : getViewProperties().getProperty(PROPERTY_SCRIPTS, Collections.<String>emptyList())) { // Always use </script> to close, as some browsers break without builder.append(String.format("<script type=\"text/javascript\" src=\"%s\"></script>%n", site.createLink(new ResourcePath(relativeUri)))); } } catch (IOException e) { log.error("", e); } return builder.toString(); }
@Override @Nonnull protected String filter (final @Nonnull Matcher matcher) throws NotFoundException { final String relativePath = matcher.group(1); final Site site = siteProvider.get().getSite(); final SiteNode siteNode = site.find(SiteNode.class).withRelativePath(relativePath).result(); return site.createLink(siteNode.getRelativeUri()); } }
/******************************************************************************************************************* * * ******************************************************************************************************************/ private void appendUrl (final @Nonnull StringBuilder builder, final @Nonnull SiteNode siteNode, final @Nullable SiteNode childSiteNode) throws IOException { final SiteNode n = (childSiteNode != null) ? childSiteNode : siteNode; final DateTimeFormatter dateTimeFormatter = DateTimeFormat.forPattern("yyyy-MM-dd"); final ResourceProperties properties = n.getProperties(); // // FIXME: if you put the sitemap property straightly into the child site node, you can simplify a lot, // just using a single property and only peeking into a single node final Key<String> priorityKey = (childSiteNode == null) ? PROPERTY_SITEMAP_PRIORITY : PROPERTY_SITEMAP_CHILDREN_PRIORITY; final float sitemapPriority = Float.parseFloat(siteNode.getProperties().getProperty(priorityKey, "0.5")); if (sitemapPriority > 0) { builder.append(" <url>\n"); builder.append(String.format(" <loc>%s</loc>%n", site.createLink(n.getRelativeUri()))); builder.append(String.format(" <lastmod>%s</lastmod>%n", dateTimeFormatter.print(getSiteNodeDateTime(properties)))); builder.append(String.format(" <changefreq>%s</changefreq>%n", properties.getProperty(PROPERTY_SITEMAP_CHANGE_FREQUENCY, "daily"))); builder.append(String.format(" <priority>%s</priority>%n", Float.toString(sitemapPriority))); builder.append(" </url>\n"); } }
@Override @Nonnull protected String filter (final @Nonnull Matcher matcher) throws NotFoundException, IOException { final String relativePath = matcher.group(1); final String contentRelativePath = matcher.group(2); final String language = matcher.group(4); final Site site = siteProvider.get().getSite(); final SiteNode siteNode = site.find(SiteNode.class).withRelativePath(relativePath).result(); final Content content = site.find(Content.class).withRelativePath(contentRelativePath).result(); final ResourcePath path = siteNode.getRelativeUri().appendedWith(content.getExposedUri()); final String link = site.createLink(path); return ((language == null) || (postProcessor == null)) ? link : postProcessor.postProcess(link, language); }
final String link = site.createLink(new ResourcePath(node.getAttributes().getNamedItem("link").getNodeValue()));
@BeforeClass // FIXME: should be BeforeMethod? public void setUp() { context = new ClassPathXmlApplicationContext(contextName); siteProvider = context.getBean(SiteProvider.class); site = context.getBean(Site.class); when(siteProvider.getSite()).thenReturn(site); when(site.find(eq(Content.class))).thenReturn(new MockContentSiteFinder()); when(site.find(eq(SiteNode.class))).thenReturn(new MockSiteNodeSiteFinder()); when(site.createLink(any(ResourcePath.class))).thenAnswer(new Answer<String>() { @Override @Nonnull public String answer (final @Nonnull InvocationOnMock invocation) { return "/LINK" + ((ResourcePath)invocation.getArguments()[0]).asString(); // return ((ResourcePath)invocation.getArguments()[0]).prepend("LINK").asString(); } }); } }
final String navigationTitle = targetSiteNode.getProperties().getProperty(PROPERTY_NAVIGATION_LABEL, "no nav. label"); view.addLink(navigationTitle, site.createLink(targetSiteNode.getRelativeUri()));