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