cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1494683 - in /cxf/web: src/main/java/org/apache/cxf/cwiki/AbstractPage.java src/main/java/org/apache/cxf/cwiki/Page.java template/template.vm
Date Wed, 19 Jun 2013 16:32:39 GMT
Author: dkulp
Date: Wed Jun 19 16:32:38 2013
New Revision: 1494683

URL: http://svn.apache.org/r1494683
Log:
Update to get the code formatting working

Modified:
    cxf/web/src/main/java/org/apache/cxf/cwiki/AbstractPage.java
    cxf/web/src/main/java/org/apache/cxf/cwiki/Page.java
    cxf/web/template/template.vm

Modified: cxf/web/src/main/java/org/apache/cxf/cwiki/AbstractPage.java
URL: http://svn.apache.org/viewvc/cxf/web/src/main/java/org/apache/cxf/cwiki/AbstractPage.java?rev=1494683&r1=1494682&r2=1494683&view=diff
==============================================================================
--- cxf/web/src/main/java/org/apache/cxf/cwiki/AbstractPage.java (original)
+++ cxf/web/src/main/java/org/apache/cxf/cwiki/AbstractPage.java Wed Jun 19 16:32:38 2013
@@ -98,6 +98,10 @@ public class AbstractPage implements Ser
     public String getURL() {
         return url;
     }
+    
+    public boolean getHasCode() {
+        return false;
+    }
 
     public String toString() {
         return "AbstractPage[id=" + id + ",title=" + title + ",url=" + url + "]";

Modified: cxf/web/src/main/java/org/apache/cxf/cwiki/Page.java
URL: http://svn.apache.org/viewvc/cxf/web/src/main/java/org/apache/cxf/cwiki/Page.java?rev=1494683&r1=1494682&r2=1494683&view=diff
==============================================================================
--- cxf/web/src/main/java/org/apache/cxf/cwiki/Page.java (original)
+++ cxf/web/src/main/java/org/apache/cxf/cwiki/Page.java Wed Jun 19 16:32:38 2013
@@ -22,6 +22,7 @@ package org.apache.cxf.cwiki;
 
 import java.io.Serializable;
 import java.io.StringReader;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -42,6 +43,7 @@ import org.xml.sax.SAXException;
 import org.xml.sax.XMLReader;
 
 
+import org.apache.cxf.common.util.StringUtils;
 import org.apache.cxf.helpers.DOMUtils;
 import org.ccil.cowan.tagsoup.Parser;
 
@@ -52,6 +54,61 @@ public class Page extends AbstractPage i
     
 
     private static final long serialVersionUID = 1L;
+    private static final Map<String, String> CODE_TYPE_MAP = new HashMap<String,
String>();
+    static {
+        CODE_TYPE_MAP.put("applescript", "shBrushAppleScript.js");
+        CODE_TYPE_MAP.put("actionscript3", "shBrushAS3.js");
+        CODE_TYPE_MAP.put("as3", "shBrushAS3.js");
+        CODE_TYPE_MAP.put("bash", "shBrushBash.js");
+        CODE_TYPE_MAP.put("shell", "shBrushBash.js");
+        CODE_TYPE_MAP.put("coldfusion", "shBrushColdFusion.js");
+        CODE_TYPE_MAP.put("cpp", "shBrushCpp.js");
+        CODE_TYPE_MAP.put("c", "shBrushCpp.js");
+        CODE_TYPE_MAP.put("c#", "shBrushCSharp.js");
+        CODE_TYPE_MAP.put("c-sharp", "shBrushCSharp.js");
+        CODE_TYPE_MAP.put("csharp", "shBrushCSharp.js");
+        CODE_TYPE_MAP.put("css", "shBrushCss.js");
+        CODE_TYPE_MAP.put("delphi", "shBrushDelphi.js");
+        CODE_TYPE_MAP.put("pascal", "shBrushDelphi.js");
+        CODE_TYPE_MAP.put("diff", "shBrushDiff.js");
+        CODE_TYPE_MAP.put("patch", "shBrushDiff.js");
+        CODE_TYPE_MAP.put("pas", "shBrushDiff.js");
+        CODE_TYPE_MAP.put("erl", "shBrushErlang.js");
+        CODE_TYPE_MAP.put("erlang", "shBrushErlang.js");
+        CODE_TYPE_MAP.put("groovy", "shBrushGroovy.js");
+        CODE_TYPE_MAP.put("java", "shBrushJava.js");
+        CODE_TYPE_MAP.put("jfx", "shBrushJavaFX.js");
+        CODE_TYPE_MAP.put("javafx", "shBrushJavaFX.js");
+        CODE_TYPE_MAP.put("js", "shBrushJScript.js");
+        CODE_TYPE_MAP.put("jscript", "shBrushJScript.js");
+        CODE_TYPE_MAP.put("javascript", "shBrushJScript.js");
+        CODE_TYPE_MAP.put("perl", "shBrushPerl.js");
+        CODE_TYPE_MAP.put("pl", "shBrushPerl.js");
+        CODE_TYPE_MAP.put("php", "shBrushPhp.js");
+        CODE_TYPE_MAP.put("text", "shBrushPlain.js");
+        CODE_TYPE_MAP.put("plain", "shBrushPlain.js");
+        CODE_TYPE_MAP.put("none", "shBrushPlain.js");
+        CODE_TYPE_MAP.put("py", "shBrushPython.js");
+        CODE_TYPE_MAP.put("python", "shBrushPython.js");
+        CODE_TYPE_MAP.put("powershell", "shBrushPowerShell.js");
+        CODE_TYPE_MAP.put("ps", "shBrushPowerShell.js");
+        CODE_TYPE_MAP.put("posh", "shBrushPowerShell.js");
+        CODE_TYPE_MAP.put("ruby", "shBrushRuby.js");
+        CODE_TYPE_MAP.put("rails", "shBrushRuby.js");
+        CODE_TYPE_MAP.put("ror", "shBrushRuby.js");
+        CODE_TYPE_MAP.put("rb", "shBrushRuby.js");
+        CODE_TYPE_MAP.put("sass", "shBrushSass.js");
+        CODE_TYPE_MAP.put("scss", "shBrushSass.js");
+        CODE_TYPE_MAP.put("scala", "shBrushScala.js");
+        CODE_TYPE_MAP.put("sql", "shBrushSql.js");
+        CODE_TYPE_MAP.put("vb", "shBrushVb.js");
+        CODE_TYPE_MAP.put("vbnet", "shBrushVb.js");
+        CODE_TYPE_MAP.put("xml", "shBrushXml.js");
+        CODE_TYPE_MAP.put("xhtml", "shBrushXml.js");
+        CODE_TYPE_MAP.put("xslt", "shBrushXml.js");
+        CODE_TYPE_MAP.put("html", "shBrushXml.js");
+        CODE_TYPE_MAP.put("html/xml", "shBrushXml.js");
+    }
     
     final XMLGregorianCalendar modified;
     final String parent;
@@ -60,6 +117,7 @@ public class Page extends AbstractPage i
     Set<String> includes;
     Map<String, Integer> childrenOf;
     boolean hasBlog;
+    Set<String> codeTypes;
     
     transient String renderedContent;
     transient String renderedDivContent;
@@ -105,11 +163,12 @@ public class Page extends AbstractPage i
         this.childrenOf = source.childrenOf;
         this.exporter = source.exporter;
         this.hasBlog = source.hasBlog;
+        this.codeTypes = source.codeTypes;
     }
     
     private void checkContentV2(final String c) {
         try {
-            //if ("Book In One Page".equals(title)) {
+            //if ("JAX-WS Dispatch API".equals(title)) {
             //    System.out.println(c);
             //}
             
@@ -279,6 +338,32 @@ public class Page extends AbstractPage i
     public boolean hasBlog() {
         return hasBlog;
     }
+    
+    public boolean getHasCode() {
+        return hasCode();
+    }
+
+    public boolean hasCode() {
+        return codeTypes == null ? false : !codeTypes.isEmpty();
+    }
+    
+    public List<String> getCodeScripts() {
+        List<String> scripts = new ArrayList<String>();
+        if (codeTypes != null) {
+            for (String s : codeTypes) {
+                String sc = CODE_TYPE_MAP.get(s);
+                if (sc == null) {
+                    System.out.println("HELP: " + s);
+                }
+                scripts.add(CODE_TYPE_MAP.get(s));
+            }
+        }
+        if (scripts.isEmpty()) {
+            scripts.add(CODE_TYPE_MAP.get("java"));
+            scripts.add(CODE_TYPE_MAP.get("plain"));
+        }
+        return scripts;
+    }
 
     
     static class V2ContentHandler implements ContentHandler {
@@ -289,6 +374,7 @@ public class Page extends AbstractPage i
             CHILDREN,
             INCLUDE,
             BLOG_POSTS,
+            CODE,
         };
         private State state = State.NONE;
         private Map<String, String> params = new HashMap<String, String>();
@@ -323,6 +409,17 @@ public class Page extends AbstractPage i
                     state = State.INCLUDE;
                 } else if ("blog-posts".equals(s)) {
                     state = State.BLOG_POSTS;
+                } else if ("code".equals(s)) {
+                    state = State.CODE;
+                } else if ("unmigrated-wiki-markup".equals(s)) {
+                    System.out.println("WARNING: Page " + page.title + " has unmigrated wiki
content.");
+                    //no idea what is in there, lets just turn on the code highlighting
+                    if (page.codeTypes == null) {
+                        page.codeTypes = new CopyOnWriteArraySet<String>();
+                    }
+                    page.codeTypes.add("java");
+                    page.codeTypes.add("xml");
+                    page.codeTypes.add("plain");
                 } else {
                     //System.out.println("Unknown macro: " + s);
                 }
@@ -365,6 +462,31 @@ public class Page extends AbstractPage i
                 case BLOG_POSTS:
                     page.hasBlog = true;
                     break;
+                case CODE: {
+                    if (page.codeTypes == null) {
+                        page.codeTypes = new CopyOnWriteArraySet<String>();
+                    }
+                    String lang = null;
+                    for (Map.Entry<String, String> ent : params.entrySet()) {
+                        if ("language".equals(ent.getKey())) {
+                            lang = ent.getValue();
+                        } else if (ent.getKey().contains(":")) {
+                            String parts[] = ent.getKey().split(":");
+                            for (String s : parts) {
+                                if (("title".equals(s) && !params.containsKey("title"))
+                                    || (!params.containsKey("language") 
+                                        && ("xml".equals(s) || "java".equals(s))))
{
+                                    System.out.println("WARNING Page " + page.title + " has
a broken code block");
+                                }
+                            }
+                        }
+                    }
+                    if (StringUtils.isEmpty(lang)) {
+                        lang = "java";
+                    }
+                    page.codeTypes.add(lang);
+                    break;
+                }                    
                 default:
                     state = State.NONE;
                     break;

Modified: cxf/web/template/template.vm
URL: http://svn.apache.org/viewvc/cxf/web/template/template.vm?rev=1494683&r1=1494682&r2=1494683&view=diff
==============================================================================
--- cxf/web/template/template.vm (original)
+++ cxf/web/template/template.vm Wed Jun 19 16:32:38 2013
@@ -25,6 +25,21 @@
 <meta http-equiv="Content-type" content="text/html;charset=UTF-8">
 <meta name="keywords" content="business integration, EAI, SOA, Service Oriented Architecture,
web services, SOAP, JBI, JMS, WSDL, XML, EDI, Electronic Data Interchange, standards support,
integration standards, application integration, middleware, software, solutions, services,
CXF, open source">
 <meta name="description" content="Apache CXF, Services Framework - $page.title">
+
+#if($page.hasCode)
+  <link href='http://cxf.apache.org/resources/highlighter/styles/shCore.css' rel='stylesheet'
type='text/css' />
+  <link href='http://cxf.apache.org/resources/highlighter/styles/shThemeEclipse.css' rel='stylesheet'
type='text/css' />
+  <script src='http://cxf.apache.org/resources/highlighter/scripts/shCore.js' type='text/javascript'></script>
+#foreach ($hscript in $page.CodeScripts)
+  <script src='http://cxf.apache.org/resources/highlighter/scripts/$hscript' type='text/javascript'></script>
+#end
+  
+  <script type="text/javascript">
+  SyntaxHighlighter.defaults['toolbar'] = false;
+  SyntaxHighlighter.all();
+  </script>
+ #end
+
     <title>
 Apache CXF -- $page.title
     </title>



Mime
View raw message