use of org.apache.wiki.WikiEngine in project jspwiki by apache.
the class AtomFeed method getItems.
private Collection getItems() {
ArrayList<Element> list = new ArrayList<Element>();
WikiEngine engine = m_wikiContext.getEngine();
ServletContext servletContext = null;
if (m_wikiContext.getHttpRequest() != null)
servletContext = m_wikiContext.getHttpRequest().getSession().getServletContext();
for (Iterator i = m_entries.iterator(); i.hasNext(); ) {
Entry e = (Entry) i.next();
WikiPage p = e.getPage();
Element entryEl = getElement("entry");
//
// Mandatory elements
//
entryEl.addContent(getElement("id").setText(getEntryID(e)));
entryEl.addContent(getElement("title").setAttribute("type", "html").setText(e.getTitle()));
entryEl.addContent(getElement("updated").setText(DateFormatUtils.formatUTC(p.getLastModified(), RFC3339FORMAT)));
//
// Optional elements
//
entryEl.addContent(getElement("author").addContent(getElement("name").setText(e.getAuthor())));
entryEl.addContent(getElement("link").setAttribute("rel", "alternate").setAttribute("href", e.getURL()));
entryEl.addContent(getElement("content").setAttribute("type", "html").setText(e.getContent()));
if (engine.getAttachmentManager().hasAttachments(p) && servletContext != null) {
try {
Collection c = engine.getAttachmentManager().listAttachments(p);
for (Iterator a = c.iterator(); a.hasNext(); ) {
Attachment att = (Attachment) a.next();
Element attEl = getElement("link");
attEl.setAttribute("rel", "enclosure");
attEl.setAttribute("href", engine.getURL(WikiContext.ATTACH, att.getName(), null, true));
attEl.setAttribute("length", Long.toString(att.getSize()));
attEl.setAttribute("type", getMimeType(servletContext, att.getFileName()));
entryEl.addContent(attEl);
}
} catch (ProviderException ex) {
// FIXME: log.info("Can't get attachment data",ex);
}
}
list.add(entryEl);
}
return list;
}
use of org.apache.wiki.WikiEngine in project jspwiki by apache.
the class ContentEncodingTag method doWikiStartTag.
/**
* {@inheritDoc}
*/
public final int doWikiStartTag() throws IOException {
WikiEngine engine = m_wikiContext.getEngine();
pageContext.getOut().print(engine.getContentEncoding());
return SKIP_BODY;
}
use of org.apache.wiki.WikiEngine in project jspwiki by apache.
the class EditLinkTag method doWikiStartTag.
public final int doWikiStartTag() throws IOException {
WikiEngine engine = m_wikiContext.getEngine();
WikiPage page = null;
String versionString = "";
String pageName = null;
//
if (m_pageName == null) {
page = m_wikiContext.getPage();
if (page == null) {
// You can't call this on the page itself anyways.
return SKIP_BODY;
}
pageName = page.getName();
} else {
pageName = m_pageName;
}
//
if (m_version != null) {
if ("this".equalsIgnoreCase(m_version)) {
if (page == null) {
// No page, so go fetch according to page name.
page = engine.getPage(m_pageName);
}
if (page != null) {
versionString = "version=" + page.getVersion();
}
} else {
versionString = "version=" + m_version;
}
}
//
// Finally, print out the correct link, according to what
// user commanded.
//
JspWriter out = pageContext.getOut();
switch(m_format) {
case ANCHOR:
out.print("<a href=\"" + m_wikiContext.getURL(WikiContext.EDIT, pageName, versionString) + "\" accesskey=\"" + m_accesskey + "\" title=\"" + m_title + "\">");
break;
case URL:
out.print(m_wikiContext.getURL(WikiContext.EDIT, pageName, versionString));
break;
}
return EVAL_BODY_INCLUDE;
}
use of org.apache.wiki.WikiEngine in project jspwiki by apache.
the class EditorTag method doEndTag.
public int doEndTag() throws JspException {
WikiEngine engine = m_wikiContext.getEngine();
EditorManager mgr = engine.getEditorManager();
String editorPath = mgr.getEditorPath(m_wikiContext);
try {
String page = engine.getTemplateManager().findJSP(pageContext, m_wikiContext.getTemplate(), editorPath);
if (page == null) {
// FIXME: should be I18N ...
pageContext.getOut().println("Unable to find editor '" + editorPath + "'");
} else {
pageContext.include(page);
}
} catch (ServletException e) {
log.error("Failed to include editor", e);
throw new JspException("Failed to include editor: " + e.getMessage());
} catch (IOException e) {
throw new JspException("Could not print Editor tag: " + e.getMessage());
}
return EVAL_PAGE;
}
use of org.apache.wiki.WikiEngine in project jspwiki by apache.
the class FeedDiscoveryTag method doWikiStartTag.
public final int doWikiStartTag() throws IOException {
WikiEngine engine = m_wikiContext.getEngine();
WikiPage page = m_wikiContext.getPage();
String encodedName = engine.encodeName(page.getName());
String rssURL = engine.getGlobalRSSURL();
String rssFeedURL = engine.getURL(WikiContext.NONE, "rss.jsp", "page=" + encodedName + "&mode=wiki", true);
if (rssURL != null) {
String siteName = Feed.getSiteName(m_wikiContext);
siteName = TextUtil.replaceEntities(siteName);
pageContext.getOut().print("<link rel=\"alternate\" type=\"application/rss+xml\" title=\"RSS wiki feed for the entire site.\" href=\"" + rssURL + "\" />\n");
pageContext.getOut().print("<link rel=\"alternate\" type=\"application/rss+xml\" title=\"RSS wiki feed for page " + siteName + ".\" href=\"" + rssFeedURL + "\" />\n");
// FIXME: This does not work always, as plugins are not initialized until the first fetch
if ("true".equals(page.getAttribute(WeblogPlugin.ATTR_ISWEBLOG))) {
String blogFeedURL = engine.getURL(WikiContext.NONE, "rss.jsp", "page=" + encodedName, true);
String atomFeedURL = engine.getURL(WikiContext.NONE, "rss.jsp", "page=" + encodedName + "&type=atom", true);
pageContext.getOut().print("<link rel=\"alternate\" type=\"application/rss+xml\" title=\"RSS feed for weblog " + siteName + ".\" href=\"" + blogFeedURL + "\" />\n");
pageContext.getOut().print("<link rel=\"service.feed\" type=\"application/atom+xml\" title=\"Atom 1.0 weblog feed for " + siteName + "\" href=\"" + atomFeedURL + "\" />\n");
}
}
return SKIP_BODY;
}
Aggregations