| | |
| | | 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;
|
| | |
| | | });
|
| | | 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();
|
| | |
| | | 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);
|
| | |
| | | @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>();
|
| | |
|
| | | }
|
| | | }
|