]> source.dussan.org Git - gitblit.git/commitdiff
Documentation. Generate properties site page at build time.
authorJames Moger <james.moger@gitblit.com>
Thu, 7 Jul 2011 22:02:55 +0000 (18:02 -0400)
committerJames Moger <james.moger@gitblit.com>
Thu, 7 Jul 2011 22:02:55 +0000 (18:02 -0400)
build.xml
distrib/gitblit.properties
docs/.gitignore [new file with mode: 0644]
docs/03_properties.mkd
docs/site_header.html
src/com/gitblit/build/BuildSite.java

index 406fbd99bb3aefaa13e3c369a8a8d0ce6ba376ff..954bc03f6b9a59c963535da8c72fd2e50fc1278b 100644 (file)
--- a/build.xml
+++ b/build.xml
                        </fileset>\r
                </copy>\r
 \r
-               <!-- Copy google-code-prettify -->\r
-               <mkdir dir="${basedir}/src/com/gitblit/wicket/pages/prettify" />\r
-               <copy todir="${project.site.dir}/prettify">\r
-                       <fileset dir="${basedir}/src/com/gitblit/wicket/pages/prettify">\r
-                               <exclude name="thumbs.db" />\r
-                       </fileset>\r
-               </copy>\r
-\r
                <!-- Generate thumbnails of screenshots -->\r
                <java classpath="${project.build.dir}" classname="com.gitblit.build.BuildThumbnails">\r
                        <classpath refid="master-classpath" />\r
                        <arg value="--substitute" />\r
                        <arg value="%JGIT%=${jgit.version}" />\r
 \r
-                       <arg value="--load" />\r
+                       <arg value="--properties" />\r
                        <arg value="%PROPERTIES%=${basedir}/distrib/gitblit.properties" />\r
 \r
-               </java>\r
+               </java> \r
        </target>\r
                \r
 \r
index 93b306a2bfd601bad1e7a204de4c1a23f208d930..953baa1cf43efb12e0264a4525922d4590a7a5a4 100644 (file)
@@ -22,7 +22,7 @@ git.searchRepositoriesSubfolders = true
 # Allow push/pull over http/https with JGit servlet.\r
 # If you do NOT want to allow Git clients to clone/push to Gitblit set this\r
 # to false.  You might want to do this if you are only using ssh:// or git://.\r
-# If you set this false, consider changing the [web.otherUrls] setting to\r
+# If you set this false, consider changing the *web.otherUrls* setting to\r
 # indicate your clone/push urls.\r
 #\r
 # SINCE 0.5.0\r
@@ -78,10 +78,10 @@ realm.minPasswordLength = 5
 # SINCE 0.5.0\r
 web.siteName =\r
 \r
-# If web.authenticateAdminPages=true, users with "admin" role can create\r
+# If *web.authenticateAdminPages*=true, users with "admin" role can create\r
 # repositories, create users, and edit repository metadata.\r
 #\r
-# If web.authenticateAdminPages=false, any user can execute the aforementioned\r
+# If *web.authenticateAdminPages*=false, any user can execute the aforementioned\r
 # functions. \r
 #\r
 # SINCE 0.5.0 \r
@@ -113,16 +113,23 @@ web.repositoriesMessage = gitblit
 # RESTART REQUIRED\r
 web.useClientTimezone = false\r
 \r
-# Date and Time formats\r
-# http://download.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html\r
+# Short date format\r
+# <http://download.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html>\r
 #\r
 # SINCE 0.5.0\r
 web.datestampShortFormat = yyyy-MM-dd\r
+\r
+# Long timestamp format\r
+# <http://download.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html>\r
+#\r
+# SINCE 0.5.0\r
 web.datetimestampLongFormat = EEEE, MMMM d, yyyy h:mm a z\r
 \r
-# Mount parameters\r
-# true: http://localhost/commit/myrepo/abcdef\r
-# false: http://localhost/commit/?r=myrepo&h=abcdef\r
+# Mount URL parameters\r
+# This setting controls if pretty or parameter URLs are used.\r
+# i.e.\r
+# if true: http://localhost/commit/myrepo/abcdef\r
+# if false: http://localhost/commit/?r=myrepo&h=abcdef\r
 #\r
 # SINCE 0.5.0\r
 # RESTART REQUIRED\r
diff --git a/docs/.gitignore b/docs/.gitignore
new file mode 100644 (file)
index 0000000..45d8a39
--- /dev/null
@@ -0,0 +1,3 @@
+/site_ad.html
+/site_analytics.html
+/site_ads.html
index 3a1dec1784030695a255a476a29ddfd8d3d20cdf..2b0151bb8ac38d5e6f00c51b42d70ef570d1d6ad 100644 (file)
@@ -1,4 +1,2 @@
 ## gitblit.properties\r
-<pre class='prettyprint'>\r
 %PROPERTIES%\r
-</pre>
\ No newline at end of file
index 51552209a89932ad0e121e0da26696aac8a5a080..636511725353b7bc3b0f0f04c9013c0a9be12a50 100644 (file)
                \r
                <script type="text/javascript" src="prettify/prettify.js"></script>\r
                <link href="prettify/prettify.css" type="text/css" rel="stylesheet" />\r
+               \r
+               <!-- Place this tag in your head or just before your close body tag -->\r
+               <script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>\r
+               \r
                <!-- ANALYTICS -->\r
        </head>\r
        <body style="width:900px"  onload="prettyPrint()">\r
@@ -36,6 +40,8 @@
                                <img src="./gitblt_25.png" width="79" height="25" alt="gitblit" class="logo"/>\r
                        </a>\r
                        <span style="color:black;">{0}</span>\r
+                       <!-- Google Plus One -->\r
+                       <g:plusone></g:plusone>\r
                </div>\r
                <div class="page_nav">{1}</div>\r
                <div class="markdown">
\ No newline at end of file
index a2f6431642cbd2f34572a4a734725e32190e0ccd..97615f83a838b16e649ea4bdd2261a76455bd1a3 100644 (file)
  */\r
 package com.gitblit.build;\r
 \r
+import java.io.BufferedReader;\r
 import java.io.File;\r
 import java.io.FileInputStream;\r
 import java.io.FileOutputStream;\r
+import java.io.FileReader;\r
 import java.io.FilenameFilter;\r
 import java.io.InputStreamReader;\r
 import java.io.OutputStreamWriter;\r
 import java.nio.charset.Charset;\r
 import java.text.MessageFormat;\r
+import java.text.ParseException;\r
 import java.text.SimpleDateFormat;\r
 import java.util.ArrayList;\r
 import java.util.Arrays;\r
@@ -30,6 +33,7 @@ import java.util.Date;
 import java.util.HashMap;\r
 import java.util.List;\r
 import java.util.Map;\r
+import java.util.Vector;\r
 \r
 import com.beust.jcommander.JCommander;\r
 import com.beust.jcommander.Parameter;\r
@@ -53,6 +57,12 @@ import com.gitblit.utils.StringUtils;
  */\r
 public class BuildSite {\r
 \r
+       private final static String CASE_SENSITIVE = "CASE-SENSITIVE";\r
+\r
+       private final static String RESTART_REQUIRED = "RESTART REQUIRED";\r
+\r
+       private final static String SINCE = "SINCE";\r
+\r
        public static void main(String... args) {\r
                Params params = new Params();\r
                JCommander jc = new JCommander(params);\r
@@ -99,7 +109,7 @@ public class BuildSite {
                sb.trimToSize();\r
 \r
                String htmlHeader = FileUtils.readContent(new File(params.pageHeader), "\n");\r
-               \r
+\r
                String htmlAdSnippet = null;\r
                if (!StringUtils.isEmpty(params.adSnippet)) {\r
                        File snippet = new File(params.adSnippet);\r
@@ -116,7 +126,7 @@ public class BuildSite {
                                String htmlSnippet = FileUtils.readContent(snippet, "\n");\r
                                header = header.replace("<!-- ANALYTICS -->", htmlSnippet);\r
                        }\r
-               }               \r
+               }\r
                final String date = new SimpleDateFormat("yyyy-MM-dd").format(new Date());\r
                final String footer = MessageFormat.format(htmlFooter, "generated " + date);\r
                for (File file : markdownFiles) {\r
@@ -133,6 +143,11 @@ public class BuildSite {
                                                String[] kv = token.split("=");\r
                                                content = content.replace(kv[0], kv[1]);\r
                                        }\r
+                                       for (String alias : params.properties) {\r
+                                               String[] kv = alias.split("=");\r
+                                               String loadedContent = generatePropertiesContent(new File(kv[1]));\r
+                                               content = content.replace(kv[0], loadedContent);\r
+                                       }\r
                                        for (String alias : params.loads) {\r
                                                String[] kv = alias.split("=");\r
                                                String loadedContent = FileUtils.readContent(new File(kv[1]), "\n");\r
@@ -169,6 +184,63 @@ public class BuildSite {
                return displayName;\r
        }\r
 \r
+       private static String generatePropertiesContent(File propertiesFile) throws Exception {\r
+               // Read the current Gitblit properties\r
+               BufferedReader propertiesReader = new BufferedReader(new FileReader(propertiesFile));\r
+\r
+               Vector<Setting> settings = new Vector<Setting>();\r
+               List<String> comments = new ArrayList<String>();\r
+               String line = null;\r
+               while ((line = propertiesReader.readLine()) != null) {\r
+                       if (line.length() == 0) {\r
+                               Setting s = new Setting("", "", comments);\r
+                               settings.add(s);\r
+                               comments.clear();\r
+                       } else {\r
+                               if (line.charAt(0) == '#') {\r
+                                       comments.add(line.substring(1).trim());\r
+                               } else {\r
+                                       String[] kvp = line.split("=", 2);\r
+                                       String key = kvp[0].trim();\r
+                                       Setting s = new Setting(key, kvp[1].trim(), comments);\r
+                                       settings.add(s);\r
+                                       comments.clear();\r
+                               }\r
+                       }\r
+               }\r
+               propertiesReader.close();\r
+\r
+               StringBuilder sb = new StringBuilder();\r
+               for (Setting setting : settings) {\r
+                       for (String comment : setting.comments) {\r
+                               if (comment.contains(SINCE) || comment.contains(RESTART_REQUIRED)\r
+                                               || comment.contains(CASE_SENSITIVE)) {\r
+                                       sb.append(MessageFormat.format("<span style=\"color:#004000;\"># <i>{0}</i></span>", transformMarkdown(comment)));\r
+                               } else {\r
+                                       sb.append(MessageFormat.format("<span style=\"color:#004000;\"># {0}</span>", transformMarkdown(comment)));\r
+                               }\r
+                               sb.append("<br/>\n");\r
+                       }\r
+                       if (!StringUtils.isEmpty(setting.name)) {\r
+                               sb.append(MessageFormat.format("<span style=\"color:#000080;\">{0}</span> = <span style=\"color:#800000;\">{1}</span>", setting.name, StringUtils.escapeForHtml(setting.value, false)));\r
+                       }\r
+                       sb.append("<br/>\n");\r
+               }\r
+\r
+               return sb.toString();\r
+       }\r
+       \r
+       private static String transformMarkdown(String comment) throws ParseException {\r
+               String md = MarkdownUtils.transformMarkdown(comment);\r
+               if (md.startsWith("<p>")) {\r
+                       md = md.substring(3);\r
+               }\r
+               if (md.endsWith("</p>")) {\r
+                       md = md.substring(0, md.length() - 4);\r
+               }\r
+               return md;\r
+       }\r
+\r
        private static void usage(JCommander jc, ParameterException t) {\r
                System.out.println(Constants.getGitBlitVersion());\r
                System.out.println();\r
@@ -182,6 +254,18 @@ public class BuildSite {
                System.exit(0);\r
        }\r
 \r
+       private static class Setting {\r
+               final String name;\r
+               final String value;\r
+               final List<String> comments;\r
+\r
+               Setting(String name, String value, List<String> comments) {\r
+                       this.name = name;\r
+                       this.value = value;\r
+                       this.comments = new ArrayList<String>(comments);\r
+               }\r
+       }\r
+\r
        @Parameters(separators = " ")\r
        private static class Params {\r
 \r
@@ -215,5 +299,8 @@ public class BuildSite {
                @Parameter(names = { "--load" }, description = "%TOKEN%=filename", required = false)\r
                public List<String> loads = new ArrayList<String>();\r
 \r
+               @Parameter(names = { "--properties" }, description = "%TOKEN%=filename", required = false)\r
+               public List<String> properties = new ArrayList<String>();\r
+\r
        }\r
 }\r