diff options
author | James Moger <james.moger@gitblit.com> | 2011-06-01 20:19:51 -0400 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2011-06-01 20:19:51 -0400 |
commit | a1ea877042b93949ef244b96e8affd65cc3f89c1 (patch) | |
tree | cb0fd2c37b4d4415ba1bdf74e134243bc4280fc8 /src/com/gitblit/wicket/pages | |
parent | 424fe1b372d225d65eb42e6125b24cbb982c5969 (diff) | |
download | gitblit-a1ea877042b93949ef244b96e8affd65cc3f89c1.tar.gz gitblit-a1ea877042b93949ef244b96e8affd65cc3f89c1.zip |
Readme markdown on summary page per-repository.
Diffstat (limited to 'src/com/gitblit/wicket/pages')
-rw-r--r-- | src/com/gitblit/wicket/pages/EditRepositoryPage.html | 7 | ||||
-rw-r--r-- | src/com/gitblit/wicket/pages/EditRepositoryPage.java | 1 | ||||
-rw-r--r-- | src/com/gitblit/wicket/pages/MarkdownPage.html | 2 | ||||
-rw-r--r-- | src/com/gitblit/wicket/pages/SummaryPage.html | 8 | ||||
-rw-r--r-- | src/com/gitblit/wicket/pages/SummaryPage.java | 43 |
5 files changed, 56 insertions, 5 deletions
diff --git a/src/com/gitblit/wicket/pages/EditRepositoryPage.html b/src/com/gitblit/wicket/pages/EditRepositoryPage.html index 763d46fb..775a5d22 100644 --- a/src/com/gitblit/wicket/pages/EditRepositoryPage.html +++ b/src/com/gitblit/wicket/pages/EditRepositoryPage.html @@ -21,10 +21,11 @@ <tr><th><wicket:message key="gb.enableTickets"></wicket:message></th><td class="edit"><input type="checkbox" wicket:id="useTickets" tabindex="4" /> <i><wicket:message key="gb.useTicketsDescription"></wicket:message></i></td></tr>
<tr><th><wicket:message key="gb.enableDocs"></wicket:message></th><td class="edit"><input type="checkbox" wicket:id="useDocs" tabindex="5" /> <i><wicket:message key="gb.useDocsDescription"></wicket:message></i></td></tr>
<tr><th><wicket:message key="gb.showRemoteBranches"></wicket:message></th><td class="edit"><input type="checkbox" wicket:id="showRemoteBranches" tabindex="6" /> <i><wicket:message key="gb.showRemoteBranchesDescription"></wicket:message></i></td></tr>
- <tr><th><wicket:message key="gb.accessRestriction"></wicket:message></th><td class="edit"><select wicket:id="accessRestriction" tabindex="7" /></td></tr>
- <tr><th><wicket:message key="gb.isFrozen"></wicket:message></th><td class="edit"><input type="checkbox" wicket:id="isFrozen" tabindex="8" /> <i><wicket:message key="gb.isFrozenDescription"></wicket:message></i></td></tr>
+ <tr><th><wicket:message key="gb.showReadme"></wicket:message></th><td class="edit"><input type="checkbox" wicket:id="showReadme" tabindex="7" /> <i><wicket:message key="gb.showReadmeDescription"></wicket:message></i></td></tr>
+ <tr><th><wicket:message key="gb.accessRestriction"></wicket:message></th><td class="edit"><select wicket:id="accessRestriction" tabindex="8" /></td></tr>
+ <tr><th><wicket:message key="gb.isFrozen"></wicket:message></th><td class="edit"><input type="checkbox" wicket:id="isFrozen" tabindex="9" /> <i><wicket:message key="gb.isFrozenDescription"></wicket:message></i></td></tr>
<tr><th style="vertical-align: top;"><wicket:message key="gb.permittedUsers"></wicket:message></th><td style="padding:2px;"><span wicket:id="users"></span></td></tr>
- <tr><th></th><td class="editButton"><input type="submit" value="Save" wicket:message="value:gb.save" tabindex="9" /></td></tr>
+ <tr><th></th><td class="editButton"><input type="submit" value="Save" wicket:message="value:gb.save" tabindex="10" /></td></tr>
</tbody>
</table>
</form>
diff --git a/src/com/gitblit/wicket/pages/EditRepositoryPage.java b/src/com/gitblit/wicket/pages/EditRepositoryPage.java index a1a42d00..eb2a8e64 100644 --- a/src/com/gitblit/wicket/pages/EditRepositoryPage.java +++ b/src/com/gitblit/wicket/pages/EditRepositoryPage.java @@ -164,6 +164,7 @@ public class EditRepositoryPage extends BasePage { form.add(new CheckBox("useTickets"));
form.add(new CheckBox("useDocs"));
form.add(new CheckBox("showRemoteBranches"));
+ form.add(new CheckBox("showReadme"));
form.add(usersPalette);
add(form);
diff --git a/src/com/gitblit/wicket/pages/MarkdownPage.html b/src/com/gitblit/wicket/pages/MarkdownPage.html index b8c9cfba..a0f60904 100644 --- a/src/com/gitblit/wicket/pages/MarkdownPage.html +++ b/src/com/gitblit/wicket/pages/MarkdownPage.html @@ -19,7 +19,7 @@ </div>
<!-- markdown content -->
- <div class="markdown" wicket:id="markdownText">[markdown content]</div>
+ <div class="markdown" style="padding-bottom:5px;" wicket:id="markdownText">[markdown content]</div>
</wicket:extend>
</body>
</html>
\ No newline at end of file diff --git a/src/com/gitblit/wicket/pages/SummaryPage.html b/src/com/gitblit/wicket/pages/SummaryPage.html index ed94192a..7d5629b6 100644 --- a/src/com/gitblit/wicket/pages/SummaryPage.html +++ b/src/com/gitblit/wicket/pages/SummaryPage.html @@ -4,6 +4,12 @@ xml:lang="en"
lang="en">
+<wicket:head>
+ <wicket:link>
+ <link href="/com/gitblit/wicket/resources/markdown.css" type="text/css" rel="stylesheet" />
+ </wicket:link>
+</wicket:head>
+
<body>
<wicket:extend>
@@ -38,6 +44,8 @@ <div wicket:id="tagsPanel">[tags panel]</div>
</div>
+ <!-- markdown readme -->
+ <div wicket:id="readme" class="markdown" style="clear:both;padding-bottom:5px;"></div>
</wicket:extend>
</body>
</html>
\ No newline at end of file diff --git a/src/com/gitblit/wicket/pages/SummaryPage.java b/src/com/gitblit/wicket/pages/SummaryPage.java index f8206941..c054fcca 100644 --- a/src/com/gitblit/wicket/pages/SummaryPage.java +++ b/src/com/gitblit/wicket/pages/SummaryPage.java @@ -18,6 +18,7 @@ package com.gitblit.wicket.pages; import java.awt.Color;
import java.awt.Dimension;
import java.text.MessageFormat;
+import java.text.ParseException;
import java.util.ArrayList;
import java.util.List;
@@ -27,6 +28,7 @@ import org.apache.wicket.PageParameters; import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.protocol.http.WebRequest;
import org.eclipse.jgit.lib.Repository;
+import org.eclipse.jgit.revwalk.RevCommit;
import org.wicketstuff.googlecharts.Chart;
import org.wicketstuff.googlecharts.ChartAxis;
import org.wicketstuff.googlecharts.ChartAxisType;
@@ -42,7 +44,9 @@ import com.gitblit.Constants.AccessRestrictionType; import com.gitblit.GitBlit;
import com.gitblit.Keys;
import com.gitblit.models.Metric;
+import com.gitblit.models.PathModel;
import com.gitblit.utils.JGitUtils;
+import com.gitblit.utils.MarkdownUtils;
import com.gitblit.utils.MetricUtils;
import com.gitblit.utils.StringUtils;
import com.gitblit.utils.TimeUtils;
@@ -140,6 +144,42 @@ public class SummaryPage extends RepositoryPage { add(new TagsPanel("tagsPanel", repositoryName, r, numberRefs));
add(new BranchesPanel("branchesPanel", getRepositoryModel(), r, numberRefs));
+ if (getRepositoryModel().showReadme) {
+ String htmlText = null;
+ try {
+ RevCommit head = JGitUtils.getCommit(r, null);
+ List<String> markdownExtensions = GitBlit.getStrings(Keys.web.markdownExtensions);
+ List<PathModel> paths = JGitUtils.getFilesInPath(r, null, head);
+ String readme = null;
+ for (PathModel path : paths) {
+ if (!path.isTree()) {
+ String name = path.name.toLowerCase();
+
+ if (name.startsWith("readme")) {
+ if (name.indexOf('.') > -1) {
+ String ext = name.substring(name.lastIndexOf('.') + 1);
+ if (markdownExtensions.contains(ext)) {
+ readme = path.name;
+ break;
+ }
+ }
+ }
+ }
+ }
+ if (!StringUtils.isEmpty(readme)) {
+ String markdownText = JGitUtils.getRawContentAsString(r, head, readme);
+ htmlText = MarkdownUtils.transformMarkdown(markdownText);
+ }
+ } catch (ParseException p) {
+ error(p.getMessage());
+ }
+ // Add the html to the page
+ add(new Label("readme", htmlText).setEscapeModelStrings(false).setVisible(
+ !StringUtils.isEmpty(htmlText)));
+ } else {
+ add(new Label("readme").setVisible(false));
+ }
+
// Display an activity line graph
insertActivityGraph(metrics);
}
@@ -162,7 +202,8 @@ public class SummaryPage extends RepositoryPage { provider.addAxis(dateAxis);
ChartAxis commitAxis = new ChartAxis(ChartAxisType.LEFT);
- commitAxis.setLabels(new String[] { "", String.valueOf((int) WicketUtils.maxValue(metrics)) });
+ commitAxis.setLabels(new String[] { "",
+ String.valueOf((int) WicketUtils.maxValue(metrics)) });
provider.addAxis(commitAxis);
provider.setLineStyles(new LineStyle[] { new LineStyle(2, 4, 0), new LineStyle(0, 4, 1) });
|