From: James Moger Date: Tue, 2 Oct 2012 02:29:56 +0000 (-0400) Subject: Tweaking forks page X-Git-Tag: v1.2.0~201 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=d683ddfbfbb4a0bec8c98167b399b05801b8062a;p=gitblit.git Tweaking forks page --- diff --git a/resources/gitblit.css b/resources/gitblit.css index 66387d1e..1d17dc84 100644 --- a/resources/gitblit.css +++ b/resources/gitblit.css @@ -173,6 +173,13 @@ navbar div>ul .menu-dropdown li a:hover,.nav .menu-dropdown li a:hover,.navbar d padding: 2px 0px; } +.forkSource .forks, .forkEntry .forks { + font-size: 10px; + padding-left: 5px; + text-decoration: underline; + vertical-align: middle; +} + div.page_footer { clear: both; height: 17px; diff --git a/src/com/gitblit/wicket/GitBlitWebApp.properties b/src/com/gitblit/wicket/GitBlitWebApp.properties index 50c43fec..d30f5710 100644 --- a/src/com/gitblit/wicket/GitBlitWebApp.properties +++ b/src/com/gitblit/wicket/GitBlitWebApp.properties @@ -332,4 +332,5 @@ gb.canFork = can fork gb.canForkDescription = user is permitted to fork authorized repositories gb.myFork = view my fork gb.forksProhibited = forks prohibited -gb.forksProhibitedWarning = this repository forbids forks \ No newline at end of file +gb.forksProhibitedWarning = this repository forbids forks +gb.noForks = {0} has no forks \ No newline at end of file diff --git a/src/com/gitblit/wicket/pages/ForksPage.html b/src/com/gitblit/wicket/pages/ForksPage.html index 68f84895..f59f9ca2 100644 --- a/src/com/gitblit/wicket/pages/ForksPage.html +++ b/src/com/gitblit/wicket/pages/ForksPage.html @@ -8,17 +8,26 @@
- - - [a project] / [a fork] +
+ + + [a project] / [a fork] +
+
[origin repository]
-
+
[a project] / [a fork] +
+ + +

[forked from] [origin repository]

+
+ \ No newline at end of file diff --git a/src/com/gitblit/wicket/pages/ForksPage.java b/src/com/gitblit/wicket/pages/ForksPage.java index 54c2c82a..44f0ed14 100644 --- a/src/com/gitblit/wicket/pages/ForksPage.java +++ b/src/com/gitblit/wicket/pages/ForksPage.java @@ -15,12 +15,14 @@ */ package com.gitblit.wicket.pages; +import java.text.MessageFormat; import java.util.ArrayList; import java.util.List; import org.apache.wicket.Component; import org.apache.wicket.PageParameters; import org.apache.wicket.markup.html.basic.Label; +import org.apache.wicket.markup.html.panel.Fragment; import org.apache.wicket.markup.repeater.Item; import org.apache.wicket.markup.repeater.data.DataView; import org.apache.wicket.markup.repeater.data.ListDataProvider; @@ -98,6 +100,27 @@ public class ForksPage extends RepositoryPage { // user can not view the origin add(new Label("forkSource", StringUtils.stripDotGit(source))); } + + // superOrigin? + if (StringUtils.isEmpty(origin.originRepository)) { + // origin is root + add(new Label("forkSourceOrigin").setVisible(false)); + } else { + // origin has an origin + RepositoryModel superOrigin = GitBlit.self().getRepositoryModel(origin.originRepository); + if (!user.canViewRepository(superOrigin)) { + // show superOrigin repository without link + Fragment forkFrag = new Fragment("forkSourceOrigin", "originFragment", this); + forkFrag.add(new Label("originRepository", StringUtils.stripDotGit(superOrigin.name))); + add(forkFrag); + } else { + // link to superOrigin repository + Fragment forkFrag = new Fragment("forkSourceOrigin", "originFragment", this); + forkFrag.add(new LinkPanel("originRepository", null, StringUtils.stripDotGit(superOrigin.name), + SummaryPage.class, WicketUtils.newRepositoryParameter(superOrigin.name))); + add(forkFrag); + } + } // only display user-accessible forks List forks = new ArrayList(); @@ -129,7 +152,15 @@ public class ForksPage extends RepositoryPage { String repo = StringUtils.getLastPathElement(fork.name); item.add(new LinkPanel("aFork", null, StringUtils.stripDotGit(repo), SummaryPage.class, WicketUtils.newRepositoryParameter(fork.name))); - WicketUtils.setCssStyle(item, "margin-left:25px;"); + if (ArrayUtils.isEmpty(fork.forks)) { + // repository is a leaf + Component icon = new Label("anIcon", "").setEscapeModelStrings(false); + WicketUtils.setHtmlTooltip(icon, MessageFormat.format(getString("gb.noForks"), fork.name)); + item.add(icon); + } else { + // show forks link + item.add(new LinkPanel("anIcon", null, "(" + getString("gb.forks") + ")", ForksPage.class, WicketUtils.newRepositoryParameter(fork.name))); + } } };