- Updated default binary and Lucene ignore extensions
- Change the WAR baseFolder context parameter to a JNDI env-entry to improve enterprise deployments
- Removed internal Gitblit ref exclusions in the upload pack
+ - Removed "show readme" setting in favor of automatic detection
+ - Support plain text "readme" files
additions:
- Added branch graph image servlet based on EGit's branch graph renderer (issue-194)
- Added option to render Markdown commit messages (issue-203)
model.verifyCommitter = getConfig(config, "verifyCommitter", false);
model.showRemoteBranches = getConfig(config, "showRemoteBranches", hasOrigin);
model.isFrozen = getConfig(config, "isFrozen", false);
- model.showReadme = getConfig(config, "showReadme", false);
model.skipSizeCalculation = getConfig(config, "skipSizeCalculation", false);
model.skipSummaryMetrics = getConfig(config, "skipSummaryMetrics", false);
model.commitMessageRenderer = CommitMessageRenderer.fromName(getConfig(config, "commitMessageRenderer",
config.setBoolean(Constants.CONFIG_GITBLIT, null, "verifyCommitter", repository.verifyCommitter);
config.setBoolean(Constants.CONFIG_GITBLIT, null, "showRemoteBranches", repository.showRemoteBranches);
config.setBoolean(Constants.CONFIG_GITBLIT, null, "isFrozen", repository.isFrozen);
- config.setBoolean(Constants.CONFIG_GITBLIT, null, "showReadme", repository.showReadme);
config.setBoolean(Constants.CONFIG_GITBLIT, null, "skipSizeCalculation", repository.skipSizeCalculation);
config.setBoolean(Constants.CONFIG_GITBLIT, null, "skipSummaryMetrics", repository.skipSummaryMetrics);
config.setString(Constants.CONFIG_GITBLIT, null, "federationStrategy",
\r
private JCheckBox showRemoteBranches;\r
\r
- private JCheckBox showReadme;\r
-\r
private JCheckBox skipSizeCalculation;\r
\r
private JCheckBox skipSummaryMetrics;\r
showRemoteBranches = new JCheckBox(\r
Translation.get("gb.showRemoteBranchesDescription"),\r
anRepository.showRemoteBranches);\r
- showReadme = new JCheckBox(Translation.get("gb.showReadmeDescription"),\r
- anRepository.showReadme);\r
skipSizeCalculation = new JCheckBox(\r
Translation.get("gb.skipSizeCalculationDescription"),\r
anRepository.skipSizeCalculation);\r
.add(newFieldPanel(Translation.get("gb.enableIncrementalPushTags"), useIncrementalPushTags));\r
fieldsPanel.add(newFieldPanel(Translation.get("gb.showRemoteBranches"),\r
showRemoteBranches));\r
- fieldsPanel.add(newFieldPanel(Translation.get("gb.showReadme"),\r
- showReadme));\r
fieldsPanel\r
.add(newFieldPanel(Translation.get("gb.skipSizeCalculation"),\r
skipSizeCalculation));\r
repository.useDocs = useDocs.isSelected();\r
repository.useIncrementalPushTags = useIncrementalPushTags.isSelected();\r
repository.showRemoteBranches = showRemoteBranches.isSelected();\r
- repository.showReadme = showReadme.isSelected();\r
repository.skipSizeCalculation = skipSizeCalculation.isSelected();\r
repository.skipSummaryMetrics = skipSummaryMetrics.isSelected();\r
repository.maxActivityCommits = (Integer) maxActivityCommits.getSelectedItem();\r
public AuthorizationControl authorizationControl;\r
public boolean allowAuthenticated;\r
public boolean isFrozen;\r
- public boolean showReadme;\r
public FederationStrategy federationStrategy;\r
public List<String> federationSets;\r
public boolean isFederated;\r
clone.accessRestriction = AccessRestrictionType.PUSH;\r
clone.authorizationControl = AuthorizationControl.NAMED;\r
clone.federationStrategy = federationStrategy;\r
- clone.showReadme = showReadme;\r
clone.showRemoteBranches = false;\r
clone.allowForks = false;\r
clone.useDocs = useDocs;\r
*/\r
public class MarkdownUtils {\r
\r
+ /**\r
+ * Returns the html version of the plain source text.\r
+ *\r
+ * @param text\r
+ * @return html version of plain text\r
+ * @throws java.text.ParseException\r
+ */\r
+ public static String transformPlainText(String text) {\r
+ // url auto-linking\r
+ text = text.replaceAll("((http|https)://[0-9A-Za-z-_=\\?\\.\\$#&/]*)", "<a href=\"$1\">$1</a>");\r
+ String html = "<pre>" + text + "</pre>";\r
+ return html;\r
+ }\r
+\r
+\r
/**\r
* Returns the html version of the markdown source text.\r
*\r
<tr><th><wicket:message key="gb.enableDocs"></wicket:message></th><td class="edit"><label class="checkbox"><input type="checkbox" wicket:id="useDocs" tabindex="8" /> <span class="help-inline"><wicket:message key="gb.useDocsDescription"></wicket:message></span></label></td></tr>\r
<tr><th><wicket:message key="gb.enableIncrementalPushTags"></wicket:message></th><td class="edit"><label class="checkbox"><input type="checkbox" wicket:id="useIncrementalPushTags" tabindex="8" /> <span class="help-inline"><wicket:message key="gb.useIncrementalPushTagsDescription"></wicket:message></span></label></td></tr>\r
<tr><th><wicket:message key="gb.showRemoteBranches"></wicket:message></th><td class="edit"><label class="checkbox"><input type="checkbox" wicket:id="showRemoteBranches" tabindex="9" /> <span class="help-inline"><wicket:message key="gb.showRemoteBranchesDescription"></wicket:message></span></label></td></tr>\r
- <tr><th><wicket:message key="gb.showReadme"></wicket:message></th><td class="edit"><label class="checkbox"><input type="checkbox" wicket:id="showReadme" tabindex="10" /> <span class="help-inline"><wicket:message key="gb.showReadmeDescription"></wicket:message></span></label></td></tr>\r
- <tr><th><wicket:message key="gb.skipSizeCalculation"></wicket:message></th><td class="edit"><label class="checkbox"><input type="checkbox" wicket:id="skipSizeCalculation" tabindex="11" /> <span class="help-inline"><wicket:message key="gb.skipSizeCalculationDescription"></wicket:message></span></label></td></tr>\r
- <tr><th><wicket:message key="gb.skipSummaryMetrics"></wicket:message></th><td class="edit"><label class="checkbox"><input type="checkbox" wicket:id="skipSummaryMetrics" tabindex="12" /> <span class="help-inline"><wicket:message key="gb.skipSummaryMetricsDescription"></wicket:message></span></label></td></tr>\r
- <tr><th><wicket:message key="gb.maxActivityCommits"></wicket:message></th><td class="edit"><select class="span2" wicket:id="maxActivityCommits" tabindex="13" /> <span class="help-inline"><wicket:message key="gb.maxActivityCommitsDescription"></wicket:message></span></td></tr>\r
- <tr><th><wicket:message key="gb.metricAuthorExclusions"></wicket:message></th><td class="edit"><input class="span8" type="text" wicket:id="metricAuthorExclusions" size="40" tabindex="14" /></td></tr>\r
- <tr><th><wicket:message key="gb.commitMessageRenderer"></wicket:message></th><td class="edit"><select class="span2" wicket:id="commitMessageRenderer" tabindex="15" /></td></tr>\r
+ <tr><th><wicket:message key="gb.skipSizeCalculation"></wicket:message></th><td class="edit"><label class="checkbox"><input type="checkbox" wicket:id="skipSizeCalculation" tabindex="10" /> <span class="help-inline"><wicket:message key="gb.skipSizeCalculationDescription"></wicket:message></span></label></td></tr>\r
+ <tr><th><wicket:message key="gb.skipSummaryMetrics"></wicket:message></th><td class="edit"><label class="checkbox"><input type="checkbox" wicket:id="skipSummaryMetrics" tabindex="11" /> <span class="help-inline"><wicket:message key="gb.skipSummaryMetricsDescription"></wicket:message></span></label></td></tr>\r
+ <tr><th><wicket:message key="gb.maxActivityCommits"></wicket:message></th><td class="edit"><select class="span2" wicket:id="maxActivityCommits" tabindex="12" /> <span class="help-inline"><wicket:message key="gb.maxActivityCommitsDescription"></wicket:message></span></td></tr>\r
+ <tr><th><wicket:message key="gb.metricAuthorExclusions"></wicket:message></th><td class="edit"><input class="span8" type="text" wicket:id="metricAuthorExclusions" size="40" tabindex="13" /></td></tr>\r
+ <tr><th><wicket:message key="gb.commitMessageRenderer"></wicket:message></th><td class="edit"><select class="span2" wicket:id="commitMessageRenderer" tabindex="14" /></td></tr>\r
<tr><th colspan="2"><hr/></th></tr>\r
- <tr><th><wicket:message key="gb.mailingLists"></wicket:message></th><td class="edit"><input class="span8" type="text" wicket:id="mailingLists" size="40" tabindex="16" /></td></tr>\r
+ <tr><th><wicket:message key="gb.mailingLists"></wicket:message></th><td class="edit"><input class="span8" type="text" wicket:id="mailingLists" size="40" tabindex="15" /></td></tr>\r
</tbody>\r
</table>\r
</div>\r
<div class="tab-pane" id="permissions">\r
<table class="plain">\r
<tbody class="settings">\r
- <tr><th><wicket:message key="gb.owners"></wicket:message></th><td class="edit"><span wicket:id="owners" tabindex="17" /> </td></tr>\r
+ <tr><th><wicket:message key="gb.owners"></wicket:message></th><td class="edit"><span wicket:id="owners" tabindex="16" /> </td></tr>\r
<tr><th colspan="2"><hr/></th></tr>\r
- <tr><th><wicket:message key="gb.accessRestriction"></wicket:message></th><td class="edit"><select class="span4" wicket:id="accessRestriction" tabindex="18" /></td></tr>\r
+ <tr><th><wicket:message key="gb.accessRestriction"></wicket:message></th><td class="edit"><select class="span4" wicket:id="accessRestriction" tabindex="17" /></td></tr>\r
<tr><th colspan="2"><hr/></th></tr>\r
<tr><th><wicket:message key="gb.authorizationControl"></wicket:message></th><td style="padding:2px;"><span class="authorizationControl" wicket:id="authorizationControl"></span></td></tr>\r
<tr><th colspan="2"><hr/></th></tr>\r
- <tr><th><wicket:message key="gb.isFrozen"></wicket:message></th><td class="edit"><label class="checkbox"><input type="checkbox" wicket:id="isFrozen" tabindex="19" /> <span class="help-inline"><wicket:message key="gb.isFrozenDescription"></wicket:message></span></label></td></tr>\r
- <tr><th><wicket:message key="gb.allowForks"></wicket:message></th><td class="edit"><label class="checkbox"><input type="checkbox" wicket:id="allowForks" tabindex="20" /> <span class="help-inline"><wicket:message key="gb.allowForksDescription"></wicket:message></span></label></td></tr>\r
- <tr><th><wicket:message key="gb.verifyCommitter"></wicket:message></th><td class="edit"><label class="checkbox"><input type="checkbox" wicket:id="verifyCommitter" tabindex="21" /> <span class="help-inline"><wicket:message key="gb.verifyCommitterDescription"></wicket:message></span><br/><span class="help-inline" style="padding-left:10px;"><wicket:message key="gb.verifyCommitterNote"></wicket:message></span></label></td></tr>\r
+ <tr><th><wicket:message key="gb.isFrozen"></wicket:message></th><td class="edit"><label class="checkbox"><input type="checkbox" wicket:id="isFrozen" tabindex="18" /> <span class="help-inline"><wicket:message key="gb.isFrozenDescription"></wicket:message></span></label></td></tr>\r
+ <tr><th><wicket:message key="gb.allowForks"></wicket:message></th><td class="edit"><label class="checkbox"><input type="checkbox" wicket:id="allowForks" tabindex="19" /> <span class="help-inline"><wicket:message key="gb.allowForksDescription"></wicket:message></span></label></td></tr>\r
+ <tr><th><wicket:message key="gb.verifyCommitter"></wicket:message></th><td class="edit"><label class="checkbox"><input type="checkbox" wicket:id="verifyCommitter" tabindex="20" /> <span class="help-inline"><wicket:message key="gb.verifyCommitterDescription"></wicket:message></span><br/><span class="help-inline" style="padding-left:10px;"><wicket:message key="gb.verifyCommitterNote"></wicket:message></span></label></td></tr>\r
<tr><th colspan="2"><hr/></th></tr>\r
<tr><th><wicket:message key="gb.userPermissions"></wicket:message></th><td style="padding:2px;"><span wicket:id="users"></span></td></tr>\r
<tr><th colspan="2"><hr/></th></tr>\r
<div class="tab-pane" id="federation">\r
<table class="plain">\r
<tbody class="settings">\r
- <tr><th><wicket:message key="gb.federationStrategy"></wicket:message></th><td class="edit"><select class="span4" wicket:id="federationStrategy" tabindex="22" /></td></tr>\r
+ <tr><th><wicket:message key="gb.federationStrategy"></wicket:message></th><td class="edit"><select class="span4" wicket:id="federationStrategy" tabindex="21" /></td></tr>\r
<tr><th><wicket:message key="gb.federationSets"></wicket:message></th><td style="padding:2px;"><span wicket:id="federationSets"></span></td></tr>\r
</tbody>\r
</table>\r
form.add(new CheckBox("useDocs"));\r
form.add(new CheckBox("useIncrementalPushTags"));\r
form.add(new CheckBox("showRemoteBranches"));\r
- form.add(new CheckBox("showReadme"));\r
form.add(new CheckBox("skipSizeCalculation"));\r
form.add(new CheckBox("skipSummaryMetrics"));\r
List<Integer> maxActivityCommits = Arrays.asList(-1, 0, 25, 50, 75, 100, 150, 200, 250, 500 );\r
\r
// conditional links\r
// per-repository extra page links\r
- if (model.showReadme || model.useDocs) {\r
+ if (model.useDocs) {\r
pages.put("docs", new PageRegistration("gb.docs", DocsPage.class, params, true));\r
}\r
if (JGitUtils.getPagesBranch(r) != null) {\r
<div wicket:id="readmeContent" class="markdown"></div>\r
</div>\r
</wicket:fragment>\r
- \r
+\r
+ <wicket:fragment wicket:id="plaintextPanel">\r
+ <div class="header" style="margin-top:0px;" >\r
+ <i style="vertical-align: middle;" class="icon-book"></i>\r
+ <span style="font-weight:bold;vertical-align:middle;" wicket:id="readmeFile"></span>\r
+ </div>\r
+ <div style="border:1px solid #ddd;border-radius: 0 0 3px 3px;padding: 20px;">\r
+ <div wicket:id="readmeContent"></div>\r
+ </div>\r
+ </wicket:fragment> \r
<wicket:fragment wicket:id="ownersFragment">\r
\r
</wicket:fragment>\r
add(new TagsPanel("tagsPanel", repositoryName, r, numberRefs).hideIfEmpty());\r
add(new BranchesPanel("branchesPanel", getRepositoryModel(), r, numberRefs, false).hideIfEmpty());\r
\r
- if (getRepositoryModel().showReadme) {\r
- String htmlText = null;\r
- String markdownText = null;\r
- String readme = null;\r
- try {\r
- RevCommit head = JGitUtils.getCommit(r, null);\r
- List<String> markdownExtensions = GitBlit.getStrings(Keys.web.markdownExtensions);\r
- List<PathModel> paths = JGitUtils.getFilesInPath(r, null, head);\r
- for (PathModel path : paths) {\r
- if (!path.isTree()) {\r
- String name = path.name.toLowerCase();\r
-\r
- if (name.startsWith("readme")) {\r
- if (name.indexOf('.') > -1) {\r
- String ext = name.substring(name.lastIndexOf('.') + 1);\r
- if (markdownExtensions.contains(ext)) {\r
- readme = path.name;\r
- break;\r
- }\r
+ String htmlText = null;\r
+ String markdownText = null;\r
+ String readme = null;\r
+ boolean isMarkdown = false;\r
+ try {\r
+ RevCommit head = JGitUtils.getCommit(r, null);\r
+ List<String> markdownExtensions = GitBlit.getStrings(Keys.web.markdownExtensions);\r
+ List<PathModel> paths = JGitUtils.getFilesInPath(r, null, head);\r
+ for (PathModel path : paths) {\r
+ if (!path.isTree()) {\r
+ String name = path.name.toLowerCase();\r
+ if (name.equals("readme") || name.equals("readme.txt")) {\r
+ readme = path.name;\r
+ isMarkdown = false;\r
+ } else if (name.startsWith("readme")) {\r
+ if (name.indexOf('.') > -1) {\r
+ String ext = name.substring(name.lastIndexOf('.') + 1);\r
+ if (markdownExtensions.contains(ext)) {\r
+ readme = path.name;\r
+ isMarkdown = true;\r
+ break;\r
}\r
}\r
}\r
}\r
- if (!StringUtils.isEmpty(readme)) {\r
- String [] encodings = GitBlit.getEncodings();\r
- markdownText = JGitUtils.getStringContent(r, head.getTree(), readme, encodings);\r
+ }\r
+ if (!StringUtils.isEmpty(readme)) {\r
+ String [] encodings = GitBlit.getEncodings();\r
+ markdownText = JGitUtils.getStringContent(r, head.getTree(), readme, encodings);\r
+ if (isMarkdown) {\r
htmlText = MarkdownUtils.transformMarkdown(markdownText);\r
+ } else {\r
+ htmlText = MarkdownUtils.transformPlainText(markdownText);\r
}\r
- } catch (Exception e) {\r
- logger.error("failed to transform markdown", e);\r
- markdownText = MessageFormat.format("<div class=\"alert alert-error\"><strong>{0}:</strong> {1}</div>{2}", getString("gb.error"), getString("gb.markdownFailure"), markdownText);\r
- htmlText = StringUtils.breakLinesForHtml(markdownText);\r
}\r
- Fragment fragment = new Fragment("readme", "markdownPanel");\r
+ } catch (Exception e) {\r
+ logger.error("failed to transform markdown", e);\r
+ markdownText = MessageFormat.format("<div class=\"alert alert-error\"><strong>{0}:</strong> {1}</div>{2}", getString("gb.error"), getString("gb.markdownFailure"), markdownText);\r
+ htmlText = MarkdownUtils.transformPlainText(markdownText);\r
+ }\r
+\r
+ if (StringUtils.isEmpty(htmlText)) {\r
+ add(new Label("readme").setVisible(false));\r
+ } else {\r
+ Fragment fragment = new Fragment("readme", isMarkdown ? "markdownPanel" : "plaintextPanel");\r
fragment.add(new Label("readmeFile", readme));\r
// Add the html to the page\r
Component content = new Label("readmeContent", htmlText).setEscapeModelStrings(false);\r
fragment.add(content.setVisible(!StringUtils.isEmpty(htmlText)));\r
add(fragment);\r
- } else {\r
- add(new Label("readme").setVisible(false));\r
}\r
\r
// Display an activity line graph\r