From 82df524570e7bf27953b14f4797ff04daf89cc3a Mon Sep 17 00:00:00 2001 From: James Moger Date: Fri, 9 Dec 2011 08:50:18 -0500 Subject: [PATCH] Implemented empty repository page (issue 31) --- docs/04_releases.mkd | 5 +- resources/clipboard_13x13.png | Bin 0 -> 590 bytes resources/clipboard_16x16.png | Bin 0 -> 715 bytes .../gitblit/wicket/GitBlitWebApp.properties | 4 +- .../wicket/pages/EmptyRepositoryPage.html | 42 ++++++++++++++ .../wicket/pages/EmptyRepositoryPage.java | 54 ++++++++++++++++++ .../gitblit/wicket/pages/RepositoryPage.java | 4 ++ src/com/gitblit/wicket/pages/SummaryPage.html | 2 +- src/com/gitblit/wicket/pages/SummaryPage.java | 9 ++- src/com/gitblit/wicket/panels/BasePanel.java | 11 ++-- .../wicket/panels/RepositoriesPanel.java | 20 +++++-- .../wicket/panels/RepositoryUrlPanel.html | 13 +++++ .../wicket/panels/RepositoryUrlPanel.java | 35 ++++++++++++ 13 files changed, 183 insertions(+), 16 deletions(-) create mode 100644 resources/clipboard_13x13.png create mode 100644 resources/clipboard_16x16.png create mode 100644 src/com/gitblit/wicket/pages/EmptyRepositoryPage.html create mode 100644 src/com/gitblit/wicket/pages/EmptyRepositoryPage.java create mode 100644 src/com/gitblit/wicket/panels/RepositoryUrlPanel.html create mode 100644 src/com/gitblit/wicket/panels/RepositoryUrlPanel.java diff --git a/docs/04_releases.mkd b/docs/04_releases.mkd index 343f794c..bf709183 100644 --- a/docs/04_releases.mkd +++ b/docs/04_releases.mkd @@ -6,7 +6,7 @@ - added: new default user service implementation: com.gitblit.ConfigUserService (users.conf) This user service implementation allows for serialization and deserialization of more sophisticated Gitblit User objects and will open the door for more advanced Gitblit features. For upgrading installations, a `users.conf` file will automatically be created for you from your existing `users.properties` file on your first launch of Gitblit. You will have to manually set *realm.userService=users.conf* to switch to the new user service. The original `users.properties` file and it's corresponding implementation are deprecated. **New:** *realm.userService = users.conf* -- added: Teams for specifying user-repository access +- added: Teams for specifying user-repository access in bulk - added: Gitblit Express bundle to get started running Gitblit on RedHat's OpenShift cloud - added: optional Gravatar integration **New:** *web.allowGravatar = true* @@ -15,6 +15,9 @@ This user service implementation allows for serialization and deserialization of **New:** *web.timeFormat = HH:mm* **New:** *web.datestampLongFormat = EEEE, MMMM d, yyyy* - fixed: several a bugs in FileUserService related to cleaning up old repository permissions on a rename or delete +- added: primitive technique for manual *copy to clipboard* of the primary repository url +- improved: empty repositories now link to the *empty repository* page which gives some direction to the user for the next step in using Gitblit. This page displays the primary push/clone url of the repository and gives sample syntax for the git command-line client. (issue 31) +- improved: unit testing framework has been migrated to JUnit4 syntax and the test suite has been redesigned to run all unit tests, including rpc, federation, and git push/clone tests ### Older Releases diff --git a/resources/clipboard_13x13.png b/resources/clipboard_13x13.png new file mode 100644 index 0000000000000000000000000000000000000000..85f6cd7fa74c1175af79ceb2ed0212132ca21b62 GIT binary patch literal 590 zcmV-U0Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2ipt@ z3^XcbUMGS800GWPL_t(2&ux*vYZOrs$3OGl?j;s?7cZAmgNUGDVD{Xc zinp4L?1Etm;sC_*Hm9qXBxzwdFhxU2rka*a0Z2tCm9%Z z`J2r92erv~F{MAXz&N?-=SpCTssqKiW`Bn~&$++2$m`Wr@;pDt)hLa&i7_=FkLf_kJIBJp0%nG4 zlM@k~0Y$k@G9#H0)$rZ{;GEl^6TJ5ay==FPZ#F-Dn``_kaj)PQY`s`snNIreD2U)h caL$eX0B&pg5=BgTZ~y=R07*qoM6N<$g7TgGi~s-t literal 0 HcmV?d00001 diff --git a/resources/clipboard_16x16.png b/resources/clipboard_16x16.png new file mode 100644 index 0000000000000000000000000000000000000000..ee4bd3e94db2a21985dcdf4c54a90b5583f45bd6 GIT binary patch literal 715 zcmV;+0yO=JP)Q562}d-uh5XdBbk zO^X!4Av#qgigc=`RY*WrH#do+T_l4@3r^a(E`m;0(m_Oo#^NG%@P|~FB9@4Q_(Kw3 zUi04l@!b0!FY1s3H@WYgbH4MP?;Q5v#sU}=Tpgk@d>$<7XlMm62ihB9`QQm8%Rs|{ zc~?;vxw)J4AJ}iMl&onbN=io%BEp%I1!!_G0(iOgMo09f7^82#&LGQ>k@XXzH7=s4 zbn$WpOoeD}{6ubI5(EmzaWFbEigNiX0eEqGn*G32hh&Y>B?po2&P0;X3NjQadBd=!^1%wdo{ zuGLE1FbVw*LP1gSHJ$9Z(A$$|2#BAkZC2k3;)1 zxVO5BeEwLPTsVEo`b-2jzk7b0a$@wDff*ySK_2%|sa&&n<2O|WF^mz+c8~^v-y#hZ zA{t*r)k7iDK0VLF%F11AzNmw9j(UBA-gxTgre@G>Q&CdZ&^Fs9RT|)O7uOdTQwGKP zd15R30JeorD|t)+h+@)#Ww5-ogcCC}P*lLgohugm07eMEO8`2N#RL%>FF|l=-qmU~ zO)wh7TA9Hx@ZVjr+5GfvHrA9`24c_0Vb_UQ)p7ory%E>7V~u^L%ru?s|4UMP`uv&d xb;qUZkMu7TIOaG`hYeV?<3<7uHu*<@0RVmFQ(}77sv-aY002ovPDHLkV1i5dKS2Nh literal 0 HcmV?d00001 diff --git a/src/com/gitblit/wicket/GitBlitWebApp.properties b/src/com/gitblit/wicket/GitBlitWebApp.properties index 6f321687..c9afbc97 100644 --- a/src/com/gitblit/wicket/GitBlitWebApp.properties +++ b/src/com/gitblit/wicket/GitBlitWebApp.properties @@ -193,4 +193,6 @@ gb.teamName = team name gb.teamMembers = team members gb.teamMemberships = team memberships gb.newTeam = new team -gb.permittedTeams = permitted teams \ No newline at end of file +gb.permittedTeams = permitted teams +gb.emptyRepository = empty repository +gb.repositoryUrl = repository url \ No newline at end of file diff --git a/src/com/gitblit/wicket/pages/EmptyRepositoryPage.html b/src/com/gitblit/wicket/pages/EmptyRepositoryPage.html new file mode 100644 index 00000000..4f0b9bdb --- /dev/null +++ b/src/com/gitblit/wicket/pages/EmptyRepositoryPage.html @@ -0,0 +1,42 @@ + + + + + + + + + + + +
+

Empty Repository

+

+ [repository] is an empty repository and can not be viewed by Gitblit. +

+ Please push some commits to +

+

Git Command-Line Syntax

+

+		

+

Learn Git

+ If you are lost or don't know what to do with this information, consider reviewing the excellent Pro Git book for a better understanding on how to use Git. +

+

Open Source Git Clients

+
    +
  • Git - the official, command-line Git
  • +
  • TortoiseGit - Windows file explorer integration (requires official, command-line Git)
  • +
  • Eclipse/EGit - Git for the Eclipse IDE (based on JGit, like Gitblit)
  • +
+

+

Commercial Git Clients

+
    +
  • SmartGit - Java application (requires official, command-line Git)
  • +
+
+
+ + \ No newline at end of file diff --git a/src/com/gitblit/wicket/pages/EmptyRepositoryPage.java b/src/com/gitblit/wicket/pages/EmptyRepositoryPage.java new file mode 100644 index 00000000..b5f4a359 --- /dev/null +++ b/src/com/gitblit/wicket/pages/EmptyRepositoryPage.java @@ -0,0 +1,54 @@ +/* + * Copyright 2011 gitblit.com. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.gitblit.wicket.pages; + +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.List; + +import org.apache.wicket.PageParameters; +import org.apache.wicket.markup.html.basic.Label; + +import com.gitblit.Constants; +import com.gitblit.GitBlit; +import com.gitblit.Keys; +import com.gitblit.wicket.WicketUtils; +import com.gitblit.wicket.panels.RepositoryUrlPanel; + +public class EmptyRepositoryPage extends RootPage { + + public EmptyRepositoryPage(PageParameters params) { + super(params); + + String repositoryName = WicketUtils.getRepositoryName(params); + setupPage(repositoryName, getString("gb.emptyRepository")); + + List repositoryUrls = new ArrayList(); + + if (GitBlit.getBoolean(Keys.git.enableGitServlet, true)) { + StringBuilder sb = new StringBuilder(); + sb.append(WicketUtils.getGitblitURL(getRequestCycle().getRequest())); + sb.append(Constants.GIT_PATH); + sb.append(repositoryName); + repositoryUrls.add(sb.toString()); + } + repositoryUrls.addAll(GitBlit.self().getOtherCloneUrls(repositoryName)); + + add(new Label("repository", repositoryName)); + add(new RepositoryUrlPanel("pushurl", repositoryUrls.get(0))); + add(new Label("syntax", MessageFormat.format("git remote add gitblit {0}\ngit push gitblit master", repositoryUrls.get(0)))); + } +} diff --git a/src/com/gitblit/wicket/pages/RepositoryPage.java b/src/com/gitblit/wicket/pages/RepositoryPage.java index 4c417d95..85719f15 100644 --- a/src/com/gitblit/wicket/pages/RepositoryPage.java +++ b/src/com/gitblit/wicket/pages/RepositoryPage.java @@ -73,6 +73,10 @@ public abstract class RepositoryPage extends BasePage { error(MessageFormat.format("Repository not specified for {0}!", getPageName()), true); } + if (!getRepositoryModel().hasCommits) { + setResponsePage(EmptyRepositoryPage.class, params); + } + // register the available page links for this page and user registeredPages = registerPages(); diff --git a/src/com/gitblit/wicket/pages/SummaryPage.html b/src/com/gitblit/wicket/pages/SummaryPage.html index 35ad3477..132b8918 100644 --- a/src/com/gitblit/wicket/pages/SummaryPage.html +++ b/src/com/gitblit/wicket/pages/SummaryPage.html @@ -24,7 +24,7 @@ [owner][repository owner] [last change][repository last change] [stats][branch stats] [metrics] - [URL][repository clone url] + [URL][repository clone url]
diff --git a/src/com/gitblit/wicket/pages/SummaryPage.java b/src/com/gitblit/wicket/pages/SummaryPage.java index da573d5a..ed90a849 100644 --- a/src/com/gitblit/wicket/pages/SummaryPage.java +++ b/src/com/gitblit/wicket/pages/SummaryPage.java @@ -51,6 +51,7 @@ import com.gitblit.utils.TimeUtils; import com.gitblit.wicket.WicketUtils; import com.gitblit.wicket.panels.BranchesPanel; import com.gitblit.wicket.panels.LogPanel; +import com.gitblit.wicket.panels.RepositoryUrlPanel; import com.gitblit.wicket.panels.TagsPanel; public class SummaryPage extends RepositoryPage { @@ -66,6 +67,7 @@ public class SummaryPage extends RepositoryPage { Repository r = getRepository(); RepositoryModel model = getRepositoryModel(); + List metrics = null; Metric metricsTotal = null; if (!model.skipSummaryMetrics && GitBlit.getBoolean(Keys.web.generateActivityGraph, true)) { @@ -123,9 +125,12 @@ public class SummaryPage extends RepositoryPage { add(WicketUtils.newClearPixel("accessRestrictionIcon").setVisible(false)); } repositoryUrls.addAll(GitBlit.self().getOtherCloneUrls(repositoryName)); + + String primaryUrl = repositoryUrls.remove(0); + add(new RepositoryUrlPanel("repositoryCloneUrl", primaryUrl)); - add(new Label("repositoryCloneUrl", StringUtils.flattenStrings(repositoryUrls, "
")) - .setEscapeModelStrings(false)); + add(new Label("otherUrls", StringUtils.flattenStrings(repositoryUrls, "
")) + .setEscapeModelStrings(false)); add(new LogPanel("commitsPanel", repositoryName, null, r, numberCommits, 0)); add(new TagsPanel("tagsPanel", repositoryName, r, numberRefs).hideIfEmpty()); diff --git a/src/com/gitblit/wicket/panels/BasePanel.java b/src/com/gitblit/wicket/panels/BasePanel.java index 8ea2a697..73e13991 100644 --- a/src/com/gitblit/wicket/panels/BasePanel.java +++ b/src/com/gitblit/wicket/panels/BasePanel.java @@ -72,17 +72,16 @@ public abstract class BasePanel extends Panel { private static final long serialVersionUID = 1L; - public JavascriptTextPrompt(String event, String msg) { + private String initialValue = ""; + + public JavascriptTextPrompt(String event, String msg, String value) { super(event, true, new Model(msg)); + initialValue = value; } protected String newValue(final String currentValue, final String message) { String result = "var userText = prompt('" + message + "','" - + (currentValue == null ? "" : currentValue) + "'); " + "return userText; "; - // String result = prefix; - // if (currentValue != null) { - // result = prefix + currentValue; - // } + + (initialValue == null ? "" : initialValue) + "'); " + "return userText; "; return result; } } diff --git a/src/com/gitblit/wicket/panels/RepositoriesPanel.java b/src/com/gitblit/wicket/panels/RepositoriesPanel.java index fd5e34f7..fc90316f 100644 --- a/src/com/gitblit/wicket/panels/RepositoriesPanel.java +++ b/src/com/gitblit/wicket/panels/RepositoriesPanel.java @@ -51,7 +51,9 @@ import com.gitblit.utils.StringUtils; import com.gitblit.utils.TimeUtils; import com.gitblit.wicket.GitBlitWebSession; import com.gitblit.wicket.WicketUtils; +import com.gitblit.wicket.pages.BasePage; import com.gitblit.wicket.pages.EditRepositoryPage; +import com.gitblit.wicket.pages.EmptyRepositoryPage; import com.gitblit.wicket.pages.SummaryPage; public class RepositoriesPanel extends BasePanel { @@ -160,17 +162,25 @@ public class RepositoriesPanel extends BasePanel { row.add(swatch); swatch.setVisible(showSwatch); - if (entry.hasCommits && linksActive) { + if (linksActive) { + Class linkPage; + if (entry.hasCommits) { + // repository has content + linkPage = SummaryPage.class; + } else { + // new/empty repository OR proposed repository + linkPage = EmptyRepositoryPage.class; + } + PageParameters pp = WicketUtils.newRepositoryParameter(entry.name); - row.add(new LinkPanel("repositoryName", "list", repoName, SummaryPage.class, pp)); + row.add(new LinkPanel("repositoryName", "list", repoName, linkPage, pp)); row.add(new LinkPanel("repositoryDescription", "list", entry.description, - SummaryPage.class, pp)); + linkPage, pp)); } else { - // new/empty repository OR proposed repository + // no links like on a federation page row.add(new Label("repositoryName", repoName)); row.add(new Label("repositoryDescription", entry.description)); } - if (entry.hasCommits) { // Existing repository row.add(new Label("repositorySize", entry.size).setVisible(showSize)); diff --git a/src/com/gitblit/wicket/panels/RepositoryUrlPanel.html b/src/com/gitblit/wicket/panels/RepositoryUrlPanel.html new file mode 100644 index 00000000..25ba1559 --- /dev/null +++ b/src/com/gitblit/wicket/panels/RepositoryUrlPanel.html @@ -0,0 +1,13 @@ + + + + + + + + [repository url] + + \ No newline at end of file diff --git a/src/com/gitblit/wicket/panels/RepositoryUrlPanel.java b/src/com/gitblit/wicket/panels/RepositoryUrlPanel.java new file mode 100644 index 00000000..bfb02f13 --- /dev/null +++ b/src/com/gitblit/wicket/panels/RepositoryUrlPanel.java @@ -0,0 +1,35 @@ +/* + * Copyright 2011 gitblit.com. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.gitblit.wicket.panels; + +import org.apache.wicket.markup.html.basic.Label; +import org.apache.wicket.markup.html.image.ContextImage; + +import com.gitblit.wicket.WicketUtils; + +public class RepositoryUrlPanel extends BasePanel { + + private static final long serialVersionUID = 1L; + + public RepositoryUrlPanel(String wicketId, String url) { + super(wicketId); + add(new Label("repositoryUrl", url)); + ContextImage img = WicketUtils.newImage("copyIcon", "clipboard_13x13.png"); + WicketUtils.setHtmlTooltip(img, "Manual Copy to Clipboard"); + img.add(new JavascriptTextPrompt("onclick", "Copy to Clipboard (Ctrl+C, Enter)", url)); + add(img); + } +} -- 2.39.5