# 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
# 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
# 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
*/\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
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
*/\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
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
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
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
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
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
@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