/** * Returns the page name. * * @return page name */ public PageName getPageName() { return getExtension(PageName.class); }
/** * Returns the template sites link. * * @return Template sites link or {@code null} for none. */ public Link getTemplateLink() { return getLink(SitesLink.Rel.TEMPLATE, Link.Type.ATOM); }
/** * Returns whether it has the page name. * * @return whether it has the page name */ public boolean hasPageName() { return hasExtension(PageName.class); }
/** * Sets the page name. * * @param pageName page name or <code>null</code> to reset */ public void setPageName(PageName pageName) { if (pageName == null) { removeExtension(PageName.class); } else { setExtension(pageName); } }
@Override public String toString() { return "{AnnouncementsPageEntry " + super.toString() + "}"; }
@Override public void declareExtensions(ExtensionProfile extProfile) { if (extProfile.isDeclared(FileCabinetPageEntry.class)) { return; } super.declareExtensions(extProfile); extProfile.declare(FileCabinetPageEntry.class, new ExtensionDescription(FeedLink.class, new XmlNamespace("gd", "http://schemas.google.com/g/2005"), "feedLink", true, false, false)); new FeedLink().declareExtensions(extProfile); }
@Override public void exportRevision(BasePageEntry<?> revision, Appendable out) throws IOException { XmlElement html = new XmlElement("html"); XmlElement head = new XmlElement("head"); XmlElement title = new XmlElement("title"); title.addText(revision.getTitle().getPlainText() + " (Version " + revision.getRevision().getValue() + ")"); html.addElement(head.addElement(title)); XmlElement body = new XmlElement("body"); XmlElement mainDiv = new XmlElement("div"); mainDiv.setAttribute("class", "hentry " + getType(revision).toString()); mainDiv.setAttribute("id", revision.getId()); mainDiv.addElement(titleRenderer.renderTitle(revision)); mainDiv.addElement(revisionRenderer.renderRevision(revision)); if (getType(revision) == LIST_PAGE) { List<ListItemEntry> items = Lists.newArrayList(); // TODO(gk5885): remove extra cast for // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6302214 mainDiv.addElement(listRenderer.renderList((ListPageEntry) revision, items)); } html.addElement(body.addElement(mainDiv)); html.appendTo(out); } }
@Override public XmlElement renderSubpageLinks(List<BasePageEntry<?>> subpages) { XmlElement div = new XmlElement("div"); div.addText("Subpages (" + subpages.size() + "):"); for (BasePageEntry<?> subpage : subpages) { String href = subpage.getPageName().getValue() + "/index.html"; div.addText(" "); div.addElement(RendererUtils.getHyperLink(href, subpage.getTitle().getPlainText())); } return div; } }
str = ancestors.get(ancestorIndex).getPageName().getValue() + "/" + str; ancestorIndex--; blob.setBlob(content); TextConstruct textConstruct = new XhtmlTextConstruct(blob); entry.setContent(textConstruct);
/** * Returns the site-relative folder path corresponding to the given page, or * {@code null} if any of the page's ancestors are missing. */ private File getPath(BaseContentEntry<?> entry, EntryStore entryStore) { String parentId = getParentId(entry); if (parentId == null) { return new File(((BasePageEntry<?>) entry).getPageName().getValue()); } BasePageEntry<?> parent = (BasePageEntry<?>) entryStore.getEntry(parentId); if (parent == null) { return null; } return new File(getPath(parent, entryStore), ((BasePageEntry<?>) entry).getPageName().getValue()); } }
private void exportRevision(BasePageEntry<?> revision, File revisionsDirectory) { int number = revision.getRevision().getValue(); File file = new File(revisionsDirectory, number + ".html"); Appendable out = null; try { out = appendableFactory.getAppendable(file); revisionExporter.exportRevision(revision, out); } catch(IOException e) { LOGGER.log(Level.WARNING, "Failed writing to file: " + file, e); } finally { if (out instanceof Closeable) { try { ((Closeable) out).close(); } catch (IOException e) { LOGGER.log(Level.SEVERE, "Failed closing file: " + file, e); } } } } }
@Override public String toString() { return "{ListPageEntry " + super.toString() + "}"; }
/** * Sets the page name. * * @param pageName page name or <code>null</code> to reset */ public void setPageName(PageName pageName) { if (pageName == null) { removeExtension(PageName.class); } else { setExtension(pageName); } }
@Override public void declareExtensions(ExtensionProfile extProfile) { if (extProfile.isDeclared(AnnouncementsPageEntry.class)) { return; } super.declareExtensions(extProfile); extProfile.declare(AnnouncementsPageEntry.class, new ExtensionDescription(FeedLink.class, new XmlNamespace("gd", "http://schemas.google.com/g/2005"), "feedLink", true, false, false)); new FeedLink().declareExtensions(extProfile); }
private XmlElement getSideBar(BaseContentEntry<?> entry, EntryStore entryStore) { XmlElement table = new XmlElement("table"); table.addElement(new XmlElement("tr").addElement(new XmlElement("th") .addText("Navigation").setAttribute("align", "left"))); Set<BasePageEntry<?>> pages = Sets.newTreeSet(titleComparator); pages.addAll(entryStore.getTopLevelEntries()); String pathToRoot = getPathToRoot(entry, entryStore); for (BasePageEntry<?> page : pages) { String text = page.getTitle().getPlainText(); if (page.equals(entry)) { table.addElement(new XmlElement("tr").addElement(new XmlElement("td") .addElement(new XmlElement("small").addText(text)))); } else { String href = pathToRoot + page.getPageName().getValue() + "/index.html"; XmlElement link = new XmlElement("a").addText(text) .setAttribute("href", href); table.addElement(new XmlElement("tr").addElement(new XmlElement("td") .addElement(new XmlElement("small").addElement(link)))); } } return table; }
/** * Returns the site-relative path to the given entry. */ private String getPath(BaseContentEntry<?> entry, List<BasePageEntry<?>> ancestors) { String name; if (isPage(entry)) { name = ((BasePageEntry<?>) entry).getPageName().getValue(); } else { name = entry.getTitle().getPlainText().replaceAll(" ", "%20"); } String path = "/"; for (BasePageEntry<?> ancestor : ancestors) { path += ancestor.getPageName().getValue() + "/"; } return path + name; }
@Override public String toString() { return "{AnnouncementsPageEntry " + super.toString() + "}"; }
@Override public void declareExtensions(ExtensionProfile extProfile) { if (extProfile.isDeclared(AnnouncementsPageEntry.class)) { return; } super.declareExtensions(extProfile); extProfile.declare(AnnouncementsPageEntry.class, new ExtensionDescription(FeedLink.class, new XmlNamespace("gd", "http://schemas.google.com/g/2005"), "feedLink", true, false, false)); new FeedLink().declareExtensions(extProfile); }
/** * Returns the page name. * * @return page name */ public PageName getPageName() { return getExtension(PageName.class); }