Source Code Cross Referenced for JAMWikiModel.java in  » Wiki-Engine » JAMWiki » org » jamwiki » parser » bliki » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Wiki Engine » JAMWiki » org.jamwiki.parser.bliki 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package org.jamwiki.parser.bliki;
002:
003:        import org.apache.commons.lang.StringUtils;
004:        import org.jamwiki.WikiBase;
005:        import org.jamwiki.model.Topic;
006:        import org.jamwiki.parser.ParserOutput;
007:        import org.jamwiki.parser.ParserInput;
008:        import org.jamwiki.utils.LinkUtil;
009:        import org.jamwiki.utils.NamespaceHandler;
010:        import org.jamwiki.utils.Utilities;
011:        import org.jamwiki.utils.WikiLogger;
012:        import info.bliki.wiki.filter.AbstractWikiModel;
013:        import info.bliki.wiki.filter.Encoder;
014:        import info.bliki.wiki.filter.ImageFormat;
015:
016:        /**
017:         * Standard model implementation
018:         *
019:         */
020:        public class JAMWikiModel extends AbstractWikiModel {
021:            private static final WikiLogger logger = WikiLogger
022:                    .getLogger(JAMWikiModel.class.getName());
023:
024:            private static final int DEFAULT_THUMBNAIL_SIZE = 180;
025:
026:            protected String fExternalImageBaseURL;
027:
028:            protected String fExternalWikiBaseURL;
029:
030:            protected ParserInput fParserInput;
031:
032:            protected ParserOutput fDocument;
033:
034:            public JAMWikiModel(ParserInput parserInput, ParserOutput document,
035:                    String imageBaseURL, String linkBaseURL) {
036:                super ();
037:                fParserInput = parserInput;
038:                fDocument = document;
039:                fExternalImageBaseURL = imageBaseURL;
040:                fExternalWikiBaseURL = linkBaseURL;
041:            }
042:
043:            public void parseInternalImageLink(StringBuffer writer,
044:                    String imageNamespace, String name) {
045:                if (fExternalImageBaseURL != null) {
046:                    ImageFormat imageFormat = ImageFormat.getImageFormat(name,
047:                            imageNamespace);
048:
049:                    String imageName = imageFormat.getFilename();
050:                    imageName = imageName.replaceAll("_", " ");
051:                    int maxDimension = imageFormat.getSize();
052:                    String type = imageFormat.getType();
053:                    boolean frame = type == null ? false : type.equals("frame");
054:                    boolean thumb = type == null ? false : type.equals("thumb");
055:                    if (thumb && maxDimension <= 0) {
056:                        maxDimension = DEFAULT_THUMBNAIL_SIZE;
057:                    }
058:                    try {
059:                        writer.append(LinkUtil.buildImageLinkHtml(fParserInput
060:                                .getContext(), fParserInput.getVirtualWiki(),
061:                                getImageNamespace()
062:                                        + NamespaceHandler.NAMESPACE_SEPARATOR
063:                                        + imageName, frame, thumb, imageFormat
064:                                        .getLocation(), imageFormat
065:                                        .getCaption(), maxDimension, false,
066:                                null, false));
067:                    } catch (Exception e) {
068:                        e.printStackTrace();
069:                    }
070:                }
071:            }
072:
073:            public void appendInternalLink(StringBuffer writer, String link,
074:                    String hashSection, String linkText) {
075:                String hrefLink = fExternalWikiBaseURL;
076:                String encodedtopic = Encoder.encodeTitleUrl(link);
077:                hrefLink = StringUtils.replace(hrefLink, "${title}",
078:                        encodedtopic);
079:                super .appendInternalLink(writer, hrefLink, hashSection,
080:                        linkText);
081:            }
082:
083:            public void addCategory(String categoryName, String sortKey) {
084:                fDocument.addCategory(getCategoryNamespace()
085:                        + NamespaceHandler.NAMESPACE_SEPARATOR + categoryName,
086:                        sortKey);
087:            }
088:
089:            public void addLink(String topic) {
090:                fDocument.addLink(topic);
091:            }
092:
093:            public void addTemplate(String template) {
094:                fDocument.addTemplate(template);
095:            }
096:
097:            public String getRawWikiContent(String namespace, String topicName) {
098:                String result = super .getRawWikiContent(namespace, topicName);
099:                if (result != null) {
100:                    return result;
101:                }
102:                try {
103:                    topicName = topicName.replaceAll("_", " ");
104:                    Topic topic = WikiBase.getDataHandler().lookupTopic(
105:                            fParserInput.getVirtualWiki(),
106:                            namespace + ':' + topicName, false, null);
107:                    if (topic == null) {
108:                        return null;
109:                    }
110:                    return topic.getTopicContent();
111:                } catch (Exception e) {
112:                    // TODO Auto-generated catch block
113:                    e.printStackTrace();
114:                }
115:                return result;
116:            }
117:
118:            public String buildEditLinkUrl(int section) {
119:                if (fParserInput.getAllowSectionEdit()) {
120:
121:                    // FIXME - template inclusion causes section edits to break, so disable
122:                    // for now
123:                    // String inclusion =
124:                    // (String)fParserInput.getTempParams().get(TemplateTag.TEMPLATE_INCLUSION);
125:                    // boolean disallowInclusion = (inclusion != null &&
126:                    // inclusion.equals("true"));
127:                    // if (disallowInclusion) return "";
128:                    String output = "<div style=\"font-size:90%;float:right;margin-left:5px;\">[";
129:                    String url = "";
130:                    try {
131:                        url = LinkUtil.buildEditLinkUrl(fParserInput
132:                                .getContext(), fParserInput.getVirtualWiki(),
133:                                fParserInput.getTopicName(), null, section);
134:                    } catch (Exception e) {
135:                        logger.severe("Failure while building link for topic "
136:                                + fParserInput.getVirtualWiki() + " / "
137:                                + fParserInput.getTopicName(), e);
138:                    }
139:                    output += "<a href=\"" + url + "\">";
140:                    output += Utilities.formatMessage("common.sectionedit",
141:                            fParserInput.getLocale());
142:                    output += "</a>]</div>";
143:                    return output;
144:                }
145:                return "";
146:            }
147:
148:            public boolean parseBBCodes() {
149:                return false;
150:            }
151:
152:            public boolean replaceColon() {
153:                return false;
154:            }
155:
156:            public String getCategoryNamespace() {
157:                return NamespaceHandler.NAMESPACE_CATEGORY;
158:            }
159:
160:            public String getImageNamespace() {
161:                return NamespaceHandler.NAMESPACE_IMAGE;
162:            }
163:
164:            public String getTemplateNamespace() {
165:                return NamespaceHandler.NAMESPACE_TEMPLATE;
166:            }
167:
168:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.