01: /*
02: JSPWiki - a JSP-based WikiWiki clone.
03:
04: Copyright (C) 2001-2004 Janne Jalkanen (Janne.Jalkanen@iki.fi)
05:
06: This program is free software; you can redistribute it and/or modify
07: it under the terms of the GNU Lesser General Public License as published by
08: the Free Software Foundation; either version 2.1 of the License, or
09: (at your option) any later version.
10:
11: This program is distributed in the hope that it will be useful,
12: but WITHOUT ANY WARRANTY; without even the implied warranty of
13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14: GNU Lesser General Public License for more details.
15:
16: You should have received a copy of the GNU Lesser General Public License
17: along with this program; if not, write to the Free Software
18: Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19: */
20: package com.ecyrd.jspwiki.tags;
21:
22: import java.io.IOException;
23:
24: import com.ecyrd.jspwiki.WikiEngine;
25: import com.ecyrd.jspwiki.WikiPage;
26: import com.ecyrd.jspwiki.plugin.WeblogPlugin;
27: import com.ecyrd.jspwiki.util.BlogUtil;
28: import com.ecyrd.jspwiki.TextUtil;
29:
30: /**
31: * Outputs links to all the site feeds and APIs this Wiki/blog supports.
32: *
33: * @author Janne Jalkanen
34: * @since 2.2
35: */
36: public class FeedDiscoveryTag extends WikiTagBase {
37:
38: public final int doWikiStartTag() throws IOException {
39: WikiEngine engine = m_wikiContext.getEngine();
40: WikiPage page = m_wikiContext.getPage();
41:
42: String encodedName = engine.encodeName(page.getName());
43:
44: String rssURL = engine.getGlobalRSSURL();
45: String atomPostURL = engine.getBaseURL() + "atom/"
46: + encodedName;
47: String rssFeedURL = engine.getBaseURL() + "rss.jsp?page="
48: + encodedName + "&mode=wiki";
49:
50: if (rssURL != null) {
51: String siteName = BlogUtil.getSiteName(m_wikiContext);
52: siteName = TextUtil.replaceEntities(siteName);
53:
54: pageContext.getOut().print(
55: "<link rel=\"alternate\" type=\"application/rss+xml\" title=\""
56: + m_wikiContext
57: .translate("rss_feed_for_site")
58: + "\" href=\"" + rssURL + "\" />\n");
59: pageContext.getOut().print(
60: "<link rel=\"alternate\" type=\"application/rss+xml\" title=\""
61: + m_wikiContext
62: .translate("rss_feed_for_page")
63: + " " + siteName + ".\" href=\""
64: + rssFeedURL + "\" />\n");
65:
66: // TODO: Enable this
67: /*
68: pageContext.getOut().print("<link rel=\"service.post\" type=\"application/atom+xml\" title=\""+
69: siteName+"\" href=\""+atomPostURL+"\" />\n");
70: */
71: // FIXME: This does not work always, as plugins are not initialized until the first fetch
72: if ("true".equals(page
73: .getAttribute(WeblogPlugin.ATTR_ISWEBLOG))) {
74: String blogFeedURL = engine.getBaseURL()
75: + "rss.jsp?page=" + encodedName;
76: String atomFeedURL = engine.getBaseURL()
77: + "atom.jsp?page=" + encodedName;
78:
79: pageContext
80: .getOut()
81: .print(
82: "<link rel=\"alternate\" type=\"application/rss+xml\" title=\""
83: + m_wikiContext
84: .translate("rss_feed_for_weblog")
85: + " " + siteName
86: + ".\" href=\"" + blogFeedURL
87: + "\" />\n");
88:
89: pageContext.getOut().print(
90: "<link rel=\"service.feed\" type=\"application/atom+xml\" title=\""
91: + siteName + "\" href=\"" + atomFeedURL
92: + "\" />\n");
93: }
94: }
95:
96: return SKIP_BODY;
97: }
98: }
|