diff options
author | James Moger <james.moger@gitblit.com> | 2011-05-20 17:49:55 -0400 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2011-05-20 17:49:55 -0400 |
commit | e0054b802b46ee82716aa946a70892ed6128d5a7 (patch) | |
tree | 4c6455fac84cf66f1908c9b59879c739713ed5db | |
parent | f90dc635928f367f9078f814488c7e385ebc4e2e (diff) | |
download | gitblit-e0054b802b46ee82716aa946a70892ed6128d5a7.tar.gz gitblit-e0054b802b46ee82716aa946a70892ed6128d5a7.zip |
Documentation filename-linkname aliases.
-rw-r--r-- | build.xml | 3 | ||||
-rw-r--r-- | docs/00_index.mkd (renamed from docs/00_overview.mkd) | 0 | ||||
-rw-r--r-- | docs/00_setup.mkd (renamed from docs/01_configuration.mkd) | 0 | ||||
-rw-r--r-- | src/com/gitblit/BuildSite.java | 30 |
4 files changed, 29 insertions, 4 deletions
@@ -163,6 +163,9 @@ <arg value="--pageFooter" />
<arg value="${basedir}/docs/page_footer.html" />
+
+ <arg value="--alias" />
+ <arg value="index=overview" />
</java>
</target>
diff --git a/docs/00_overview.mkd b/docs/00_index.mkd index 6fdc0a1d..6fdc0a1d 100644 --- a/docs/00_overview.mkd +++ b/docs/00_index.mkd diff --git a/docs/01_configuration.mkd b/docs/00_setup.mkd index 415ad474..415ad474 100644 --- a/docs/01_configuration.mkd +++ b/docs/00_setup.mkd diff --git a/src/com/gitblit/BuildSite.java b/src/com/gitblit/BuildSite.java index e122bc22..6ea8048c 100644 --- a/src/com/gitblit/BuildSite.java +++ b/src/com/gitblit/BuildSite.java @@ -10,8 +10,12 @@ import java.io.OutputStreamWriter; import java.nio.charset.Charset;
import java.text.MessageFormat;
import java.text.SimpleDateFormat;
+import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import com.beust.jcommander.JCommander;
import com.beust.jcommander.Parameter;
@@ -41,17 +45,28 @@ public class BuildSite { });
Arrays.sort(markdownFiles);
+ Map<String, String> aliasMap = new HashMap<String, String>();
+ for (String alias:params.aliases) {
+ String [] values = alias.split("=");
+ aliasMap.put(values[0], values[1]);
+ }
+
System.out.println(MessageFormat.format("Generating site from {0} Markdown Docs in {1} ", markdownFiles.length, sourceFolder.getAbsolutePath()));
String linkPattern = "<a href=''{0}''>{1}</a>";
StringBuilder sb = new StringBuilder();
for (File file : markdownFiles) {
- String displayName = getDocumentName(file);
- String fileName = displayName + ".html";
+ String documentName = getDocumentName(file);
+ String displayName = documentName;
+ if (aliasMap.containsKey(documentName)) {
+ displayName = aliasMap.get(documentName);
+ }
+ String fileName = documentName + ".html";
sb.append(MessageFormat.format(linkPattern, fileName, displayName));
sb.append(" | ");
}
sb.setLength(sb.length() - 3);
sb.trimToSize();
+
String html_header = readContent(new File(params.pageHeader));
String html_footer = readContent(new File(params.pageFooter));
final String links = sb.toString();
@@ -60,8 +75,12 @@ public class BuildSite { final String footer = MessageFormat.format(html_footer, "generated " + date);
for (File file : markdownFiles) {
try {
- String displayName = getDocumentName(file);
- String fileName = displayName + ".html";
+ String documentName = getDocumentName(file);
+ String displayName = documentName;
+ if (aliasMap.containsKey(documentName)) {
+ displayName = aliasMap.get(documentName);
+ }
+ String fileName = documentName + ".html";
System.out.println(MessageFormat.format(" {0} => {1}", file.getName(), fileName));
InputStreamReader reader = new InputStreamReader(new FileInputStream(file), Charset.forName("UTF-8"));
String content = MarkdownUtils.transformMarkdown(reader);
@@ -132,5 +151,8 @@ public class BuildSite { @Parameter(names = { "--pageFooter" }, description = "Page Footer HTML Snippet", required = true)
public String pageFooter;
+ @Parameter(names = { "--alias" }, description = "Filename=Linkname aliases", required = false)
+ public List<String> aliases = new ArrayList<String>();
+
}
}
|