From fdd82f02dddd2d4211e9df4239f3be6c8595b2dd Mon Sep 17 00:00:00 2001 From: James Moger Date: Thu, 1 May 2014 19:53:53 -0400 Subject: Refactored common code out of My Tickets and Tickets --- src/main/java/com/gitblit/wicket/pages/RepositoryPage.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/main/java/com/gitblit/wicket/pages/RepositoryPage.java') diff --git a/src/main/java/com/gitblit/wicket/pages/RepositoryPage.java b/src/main/java/com/gitblit/wicket/pages/RepositoryPage.java index 2b97bc16..5ea99fd8 100644 --- a/src/main/java/com/gitblit/wicket/pages/RepositoryPage.java +++ b/src/main/java/com/gitblit/wicket/pages/RepositoryPage.java @@ -69,6 +69,7 @@ import com.gitblit.wicket.GitBlitWebSession; import com.gitblit.wicket.PageRegistration; import com.gitblit.wicket.PageRegistration.OtherPageLink; import com.gitblit.wicket.SessionlessForm; +import com.gitblit.wicket.TicketsUI; import com.gitblit.wicket.WicketUtils; import com.gitblit.wicket.panels.LinkPanel; import com.gitblit.wicket.panels.NavigationPanel; @@ -204,7 +205,7 @@ public abstract class RepositoryPage extends RootPage { pages.put("tree", new PageRegistration("gb.tree", TreePage.class, params)); if (app().tickets().isReady() && (app().tickets().isAcceptingNewTickets(getRepositoryModel()) || app().tickets().hasTickets(getRepositoryModel()))) { PageParameters tParams = new PageParameters(params); - for (String state : TicketsPage.openStatii) { + for (String state : TicketsUI.openStatii) { tParams.add(Lucene.status.name(), state); } pages.put("tickets", new PageRegistration("gb.tickets", TicketsPage.class, tParams)); -- cgit v1.2.3 From 7a401a3ff909bf82fb4068d6dba430497f74084a Mon Sep 17 00:00:00 2001 From: James Moger Date: Tue, 22 Apr 2014 22:53:06 -0400 Subject: Allow plugins to extend the top navbar and repository navbar This change also ties the plugin manager into the Wicket framework and allows plugins to contribute and mount new pages which are linked by the top navbar and repository navbar extensions. --- .../com/gitblit/extensions/AdminMenuExtension.java | 40 ------ .../gitblit/extensions/GitblitWicketPlugin.java | 49 ++++++++ .../com/gitblit/extensions/NavLinkExtension.java | 40 ++++++ .../extensions/RepositoryNavLinkExtension.java | 42 +++++++ src/main/java/com/gitblit/models/NavLink.java | 140 +++++++++++++++++++++ .../java/com/gitblit/wicket/GitBlitWebApp.java | 106 ++++++++++++++-- .../java/com/gitblit/wicket/GitblitWicketApp.java | 72 +++++++++++ .../java/com/gitblit/wicket/PageRegistration.java | 99 --------------- .../com/gitblit/wicket/PluginClassResolver.java | 122 ++++++++++++++++++ .../gitblit/wicket/UrlExternalFormComparator.java | 39 ++++++ .../com/gitblit/wicket/pages/ActivityPage.java | 10 +- .../com/gitblit/wicket/pages/DashboardPage.java | 10 +- .../java/com/gitblit/wicket/pages/ProjectPage.java | 14 +-- .../com/gitblit/wicket/pages/ProjectsPage.java | 10 +- .../com/gitblit/wicket/pages/RepositoriesPage.java | 10 +- .../com/gitblit/wicket/pages/RepositoryPage.java | 61 +++++---- .../java/com/gitblit/wicket/pages/RootPage.java | 53 ++++---- .../java/com/gitblit/wicket/pages/UserPage.java | 10 +- .../com/gitblit/wicket/panels/DropDownMenu.java | 45 ++++++- .../com/gitblit/wicket/panels/NavigationPanel.java | 49 +++++--- src/site/plugins_extensions.mkd | 58 ++++++++- 21 files changed, 817 insertions(+), 262 deletions(-) delete mode 100644 src/main/java/com/gitblit/extensions/AdminMenuExtension.java create mode 100644 src/main/java/com/gitblit/extensions/GitblitWicketPlugin.java create mode 100644 src/main/java/com/gitblit/extensions/NavLinkExtension.java create mode 100644 src/main/java/com/gitblit/extensions/RepositoryNavLinkExtension.java create mode 100644 src/main/java/com/gitblit/models/NavLink.java create mode 100644 src/main/java/com/gitblit/wicket/GitblitWicketApp.java delete mode 100644 src/main/java/com/gitblit/wicket/PageRegistration.java create mode 100644 src/main/java/com/gitblit/wicket/PluginClassResolver.java create mode 100644 src/main/java/com/gitblit/wicket/UrlExternalFormComparator.java (limited to 'src/main/java/com/gitblit/wicket/pages/RepositoryPage.java') diff --git a/src/main/java/com/gitblit/extensions/AdminMenuExtension.java b/src/main/java/com/gitblit/extensions/AdminMenuExtension.java deleted file mode 100644 index 8fe4288f..00000000 --- a/src/main/java/com/gitblit/extensions/AdminMenuExtension.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * Copyright 2014 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.extensions; - -import java.util.List; - -import ro.fortsoft.pf4j.ExtensionPoint; - -import com.gitblit.models.Menu.MenuItem; -import com.gitblit.models.UserModel; - -/** - * Extension point to contribute administration menu items. - * - * @author James Moger - * @since 1.6.0 - * - */ -public abstract class AdminMenuExtension implements ExtensionPoint { - - /** - * @param user - * @since 1.6.0 - * @return a list of menu items - */ - public abstract List getMenuItems(UserModel user); -} diff --git a/src/main/java/com/gitblit/extensions/GitblitWicketPlugin.java b/src/main/java/com/gitblit/extensions/GitblitWicketPlugin.java new file mode 100644 index 00000000..130f4993 --- /dev/null +++ b/src/main/java/com/gitblit/extensions/GitblitWicketPlugin.java @@ -0,0 +1,49 @@ +/* + * Copyright 2014 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.extensions; + +import org.apache.wicket.Application; +import org.apache.wicket.IInitializer; + +import ro.fortsoft.pf4j.PluginWrapper; + +import com.gitblit.wicket.GitblitWicketApp; + +/** + * A Gitblit plugin that is allowed to extend the Wicket webapp. + * + * @author James Moger + * @since 1.6.0 + */ +public abstract class GitblitWicketPlugin extends GitblitPlugin implements IInitializer { + + public GitblitWicketPlugin(PluginWrapper wrapper) { + super(wrapper); + } + + @Override + public final void init(Application application) { + init((GitblitWicketApp) application); + } + + /** + * Allows plugins to extend the web application. + * + * @param app + * @since 1.6.0 + */ + protected abstract void init(GitblitWicketApp app); +} \ No newline at end of file diff --git a/src/main/java/com/gitblit/extensions/NavLinkExtension.java b/src/main/java/com/gitblit/extensions/NavLinkExtension.java new file mode 100644 index 00000000..c8958603 --- /dev/null +++ b/src/main/java/com/gitblit/extensions/NavLinkExtension.java @@ -0,0 +1,40 @@ +/* + * Copyright 2014 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.extensions; + +import java.util.List; + +import ro.fortsoft.pf4j.ExtensionPoint; + +import com.gitblit.models.NavLink; +import com.gitblit.models.UserModel; + +/** + * Extension point to contribute top-level navigation links. + * + * @author James Moger + * @since 1.6.0 + * + */ +public abstract class NavLinkExtension implements ExtensionPoint { + + /** + * @param user + * @since 1.6.0 + * @return a list of nav links + */ + public abstract List getNavLinks(UserModel user); +} diff --git a/src/main/java/com/gitblit/extensions/RepositoryNavLinkExtension.java b/src/main/java/com/gitblit/extensions/RepositoryNavLinkExtension.java new file mode 100644 index 00000000..2b05c5a0 --- /dev/null +++ b/src/main/java/com/gitblit/extensions/RepositoryNavLinkExtension.java @@ -0,0 +1,42 @@ +/* + * Copyright 2014 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.extensions; + +import java.util.List; + +import ro.fortsoft.pf4j.ExtensionPoint; + +import com.gitblit.models.NavLink; +import com.gitblit.models.RepositoryModel; +import com.gitblit.models.UserModel; + +/** + * Extension point to contribute repository page navigation links. + * + * @author James Moger + * @since 1.6.0 + * + */ +public abstract class RepositoryNavLinkExtension implements ExtensionPoint { + + /** + * @param user + * @param repository + * @since 1.6.0 + * @return a list of nav links + */ + public abstract List getNavLinks(UserModel user, RepositoryModel repository); +} diff --git a/src/main/java/com/gitblit/models/NavLink.java b/src/main/java/com/gitblit/models/NavLink.java new file mode 100644 index 00000000..993d6954 --- /dev/null +++ b/src/main/java/com/gitblit/models/NavLink.java @@ -0,0 +1,140 @@ +/* + * 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.models; + +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; + +import org.apache.wicket.PageParameters; +import org.apache.wicket.markup.html.WebPage; + +import com.gitblit.models.Menu.MenuItem; + +/** + * Represents a navigation link for the navigation panel. + * + * @author James Moger + * + */ +public abstract class NavLink implements Serializable { + private static final long serialVersionUID = 1L; + + public final String translationKey; + public final boolean hiddenPhone; + + public NavLink(String translationKey, boolean hiddenPhone) { + this.translationKey = translationKey; + this.hiddenPhone = hiddenPhone; + } + + + /** + * Represents a Wicket page link. + * + * @author James Moger + * + */ + public static class PageNavLink extends NavLink implements Serializable { + private static final long serialVersionUID = 1L; + + public final Class pageClass; + public final PageParameters params; + + public PageNavLink(String translationKey, Class pageClass) { + this(translationKey, pageClass, null); + } + + public PageNavLink(String translationKey, Class pageClass, + PageParameters params) { + this(translationKey, pageClass, params, false); + } + + public PageNavLink(String translationKey, Class pageClass, + PageParameters params, boolean hiddenPhone) { + super(translationKey, hiddenPhone); + this.pageClass = pageClass; + this.params = params; + } + } + + /** + * Represents an explicitly href link. + * + * @author James Moger + * + */ + public static class ExternalNavLink extends NavLink implements Serializable { + + private static final long serialVersionUID = 1L; + + public final String url; + + public ExternalNavLink(String keyOrText, String url) { + super(keyOrText, false); + this.url = url; + } + + public ExternalNavLink(String keyOrText, String url, boolean hiddenPhone) { + super(keyOrText, hiddenPhone); + this.url = url; + } + } + + /** + * Represents a DropDownMenu for the current page. + * + * @author James Moger + * + */ + public static class DropDownPageMenuNavLink extends PageNavLink implements Serializable { + + private static final long serialVersionUID = 1L; + + public final List menuItems; + + public DropDownPageMenuNavLink(String keyOrText, Class pageClass) { + this(keyOrText, pageClass, false); + } + + public DropDownPageMenuNavLink(String keyOrText, Class pageClass, boolean hiddenPhone) { + super(keyOrText, pageClass, null, hiddenPhone); + menuItems = new ArrayList(); + } + } + + /** + * Represents a DropDownMenu. + * + * @author James Moger + * + */ + public static class DropDownMenuNavLink extends NavLink implements Serializable { + + private static final long serialVersionUID = 1L; + + public final List menuItems; + + public DropDownMenuNavLink(String keyOrText) { + this(keyOrText, false); + } + + public DropDownMenuNavLink(String keyOrText, boolean hiddenPhone) { + super(keyOrText, hiddenPhone); + menuItems = new ArrayList(); + } + } +} \ No newline at end of file diff --git a/src/main/java/com/gitblit/wicket/GitBlitWebApp.java b/src/main/java/com/gitblit/wicket/GitBlitWebApp.java index 3ca7d48f..d3aa62fd 100644 --- a/src/main/java/com/gitblit/wicket/GitBlitWebApp.java +++ b/src/main/java/com/gitblit/wicket/GitBlitWebApp.java @@ -28,8 +28,12 @@ import org.apache.wicket.Session; import org.apache.wicket.markup.html.WebPage; import org.apache.wicket.protocol.http.WebApplication; +import ro.fortsoft.pf4j.PluginState; +import ro.fortsoft.pf4j.PluginWrapper; + import com.gitblit.IStoredSettings; import com.gitblit.Keys; +import com.gitblit.extensions.GitblitWicketPlugin; import com.gitblit.manager.IAuthenticationManager; import com.gitblit.manager.IFederationManager; import com.gitblit.manager.IGitblit; @@ -83,7 +87,7 @@ import com.gitblit.wicket.pages.TreePage; import com.gitblit.wicket.pages.UserPage; import com.gitblit.wicket.pages.UsersPage; -public class GitBlitWebApp extends WebApplication { +public class GitBlitWebApp extends WebApplication implements GitblitWicketApp { private final Class homePageClass = MyDashboardPage.class; @@ -210,11 +214,29 @@ public class GitBlitWebApp extends WebApplication { mount("/forks", ForksPage.class, "r"); mount("/fork", ForkPage.class, "r"); + // allow started Wicket plugins to initialize + for (PluginWrapper pluginWrapper : pluginManager.getPlugins()) { + if (PluginState.STARTED != pluginWrapper.getPluginState()) { + continue; + } + if (pluginWrapper.getPlugin() instanceof GitblitWicketPlugin) { + GitblitWicketPlugin wicketPlugin = (GitblitWicketPlugin) pluginWrapper.getPlugin(); + wicketPlugin.init(this); + } + } + + // customize the Wicket class resolver to load from plugins + PluginClassResolver classResolver = new PluginClassResolver(pluginManager); + getApplicationSettings().setClassResolver(classResolver); + getMarkupSettings().setDefaultMarkupEncoding("UTF-8"); - super.init(); } - private void mount(String location, Class clazz, String... parameters) { + /* (non-Javadoc) + * @see com.gitblit.wicket.Webapp#mount(java.lang.String, java.lang.Class, java.lang.String) + */ + @Override + public void mount(String location, Class clazz, String... parameters) { if (parameters == null) { parameters = new String[] {}; } @@ -230,15 +252,26 @@ public class GitBlitWebApp extends WebApplication { } } + /* (non-Javadoc) + * @see com.gitblit.wicket.Webapp#getHomePage() + */ @Override public Class getHomePage() { return homePageClass; } + /* (non-Javadoc) + * @see com.gitblit.wicket.Webapp#isCacheablePage(java.lang.String) + */ + @Override public boolean isCacheablePage(String mountPoint) { return cacheablePages.containsKey(mountPoint); } + /* (non-Javadoc) + * @see com.gitblit.wicket.Webapp#getCacheControl(java.lang.String) + */ + @Override public CacheControl getCacheControl(String mountPoint) { return cacheablePages.get(mountPoint); } @@ -254,15 +287,18 @@ public class GitBlitWebApp extends WebApplication { return gitBlitWebSession; } + /* (non-Javadoc) + * @see com.gitblit.wicket.Webapp#settings() + */ + @Override public IStoredSettings settings() { return settings; } - /** - * Is Gitblit running in debug mode? - * - * @return true if Gitblit is running in debug mode + /* (non-Javadoc) + * @see com.gitblit.wicket.Webapp#isDebugMode() */ + @Override public boolean isDebugMode() { return runtimeManager.isDebugMode(); } @@ -271,58 +307,114 @@ public class GitBlitWebApp extends WebApplication { * These methods look strange... and they are... but they are the first * step towards modularization across multiple commits. */ + /* (non-Javadoc) + * @see com.gitblit.wicket.Webapp#getBootDate() + */ + @Override public Date getBootDate() { return runtimeManager.getBootDate(); } + /* (non-Javadoc) + * @see com.gitblit.wicket.Webapp#getLastActivityDate() + */ + @Override public Date getLastActivityDate() { return repositoryManager.getLastActivityDate(); } + /* (non-Javadoc) + * @see com.gitblit.wicket.Webapp#runtime() + */ + @Override public IRuntimeManager runtime() { return runtimeManager; } + /* (non-Javadoc) + * @see com.gitblit.wicket.Webapp#plugins() + */ + @Override public IPluginManager plugins() { return pluginManager; } + /* (non-Javadoc) + * @see com.gitblit.wicket.Webapp#notifier() + */ + @Override public INotificationManager notifier() { return notificationManager; } + /* (non-Javadoc) + * @see com.gitblit.wicket.Webapp#users() + */ + @Override public IUserManager users() { return userManager; } + /* (non-Javadoc) + * @see com.gitblit.wicket.Webapp#authentication() + */ + @Override public IAuthenticationManager authentication() { return authenticationManager; } + /* (non-Javadoc) + * @see com.gitblit.wicket.Webapp#keys() + */ + @Override public IPublicKeyManager keys() { return publicKeyManager; } + /* (non-Javadoc) + * @see com.gitblit.wicket.Webapp#repositories() + */ + @Override public IRepositoryManager repositories() { return repositoryManager; } + /* (non-Javadoc) + * @see com.gitblit.wicket.Webapp#projects() + */ + @Override public IProjectManager projects() { return projectManager; } + /* (non-Javadoc) + * @see com.gitblit.wicket.Webapp#federation() + */ + @Override public IFederationManager federation() { return federationManager; } + /* (non-Javadoc) + * @see com.gitblit.wicket.Webapp#gitblit() + */ + @Override public IGitblit gitblit() { return gitblit; } + /* (non-Javadoc) + * @see com.gitblit.wicket.Webapp#tickets() + */ + @Override public ITicketService tickets() { return gitblit.getTicketService(); } + /* (non-Javadoc) + * @see com.gitblit.wicket.Webapp#getTimezone() + */ + @Override public TimeZone getTimezone() { return runtimeManager.getTimezone(); } diff --git a/src/main/java/com/gitblit/wicket/GitblitWicketApp.java b/src/main/java/com/gitblit/wicket/GitblitWicketApp.java new file mode 100644 index 00000000..a56e6996 --- /dev/null +++ b/src/main/java/com/gitblit/wicket/GitblitWicketApp.java @@ -0,0 +1,72 @@ +package com.gitblit.wicket; + +import java.util.Date; +import java.util.TimeZone; + +import org.apache.wicket.markup.html.WebPage; + +import com.gitblit.IStoredSettings; +import com.gitblit.manager.IAuthenticationManager; +import com.gitblit.manager.IFederationManager; +import com.gitblit.manager.IGitblit; +import com.gitblit.manager.INotificationManager; +import com.gitblit.manager.IPluginManager; +import com.gitblit.manager.IProjectManager; +import com.gitblit.manager.IRepositoryManager; +import com.gitblit.manager.IRuntimeManager; +import com.gitblit.manager.IUserManager; +import com.gitblit.tickets.ITicketService; +import com.gitblit.transport.ssh.IPublicKeyManager; + +public interface GitblitWicketApp { + + public abstract void mount(String location, Class clazz, String... parameters); + + public abstract Class getHomePage(); + + public abstract boolean isCacheablePage(String mountPoint); + + public abstract CacheControl getCacheControl(String mountPoint); + + public abstract IStoredSettings settings(); + + /** + * Is Gitblit running in debug mode? + * + * @return true if Gitblit is running in debug mode + */ + public abstract boolean isDebugMode(); + + /* + * These methods look strange... and they are... but they are the first + * step towards modularization across multiple commits. + */ + public abstract Date getBootDate(); + + public abstract Date getLastActivityDate(); + + public abstract IRuntimeManager runtime(); + + public abstract IPluginManager plugins(); + + public abstract INotificationManager notifier(); + + public abstract IUserManager users(); + + public abstract IAuthenticationManager authentication(); + + public abstract IPublicKeyManager keys(); + + public abstract IRepositoryManager repositories(); + + public abstract IProjectManager projects(); + + public abstract IFederationManager federation(); + + public abstract IGitblit gitblit(); + + public abstract ITicketService tickets(); + + public abstract TimeZone getTimezone(); + +} \ No newline at end of file diff --git a/src/main/java/com/gitblit/wicket/PageRegistration.java b/src/main/java/com/gitblit/wicket/PageRegistration.java deleted file mode 100644 index 9fd8f870..00000000 --- a/src/main/java/com/gitblit/wicket/PageRegistration.java +++ /dev/null @@ -1,99 +0,0 @@ -/* - * 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; - -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - -import org.apache.wicket.PageParameters; -import org.apache.wicket.markup.html.WebPage; - -import com.gitblit.models.Menu.MenuItem; - -/** - * Represents a page link registration for the topbar. - * - * @author James Moger - * - */ -public class PageRegistration implements Serializable { - private static final long serialVersionUID = 1L; - - public final String translationKey; - public final Class pageClass; - public final PageParameters params; - public final boolean hiddenPhone; - - public PageRegistration(String translationKey, Class pageClass) { - this(translationKey, pageClass, null); - } - - public PageRegistration(String translationKey, Class pageClass, - PageParameters params) { - this(translationKey, pageClass, params, false); - } - - public PageRegistration(String translationKey, Class pageClass, - PageParameters params, boolean hiddenPhone) { - this.translationKey = translationKey; - this.pageClass = pageClass; - this.params = params; - this.hiddenPhone = hiddenPhone; - } - - /** - * Represents a page link to a non-Wicket page. Might be external. - * - * @author James Moger - * - */ - public static class OtherPageLink extends PageRegistration { - - private static final long serialVersionUID = 1L; - - public final String url; - - public OtherPageLink(String keyOrText, String url) { - super(keyOrText, null); - this.url = url; - } - - public OtherPageLink(String keyOrText, String url, boolean hiddenPhone) { - super(keyOrText, null, null, hiddenPhone); - this.url = url; - } - } - - /** - * Represents a DropDownMenu for the topbar - * - * @author James Moger - * - */ - public static class DropDownMenuRegistration extends PageRegistration { - - private static final long serialVersionUID = 1L; - - public final List menuItems; - - public DropDownMenuRegistration(String keyOrText, Class pageClass) { - super(keyOrText, pageClass); - menuItems = new ArrayList(); - } - } - -} \ No newline at end of file diff --git a/src/main/java/com/gitblit/wicket/PluginClassResolver.java b/src/main/java/com/gitblit/wicket/PluginClassResolver.java new file mode 100644 index 00000000..ba53b04b --- /dev/null +++ b/src/main/java/com/gitblit/wicket/PluginClassResolver.java @@ -0,0 +1,122 @@ +/* + * Copyright 2014 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; + +import java.io.IOException; +import java.net.URL; +import java.util.Enumeration; +import java.util.HashSet; +import java.util.Iterator; +import java.util.Set; +import java.util.TreeSet; + +import org.apache.wicket.Application; +import org.apache.wicket.WicketRuntimeException; +import org.apache.wicket.application.IClassResolver; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import ro.fortsoft.pf4j.PluginState; +import ro.fortsoft.pf4j.PluginWrapper; + +import com.gitblit.manager.IPluginManager; + +/** + * Resolves plugin classes and resources. + */ +public class PluginClassResolver implements IClassResolver { + private static final Logger logger = LoggerFactory.getLogger(PluginClassResolver.class); + + private final IPluginManager pluginManager; + + public PluginClassResolver(IPluginManager pluginManager) { + this.pluginManager = pluginManager; + } + + @Override + public Class resolveClass(final String className) throws ClassNotFoundException { + boolean debugEnabled = logger.isDebugEnabled(); + + for (PluginWrapper plugin : pluginManager.getPlugins()) { + if (PluginState.STARTED != plugin.getPluginState()) { + // ignore this plugin + continue; + } + + try { + return plugin.getPluginClassLoader().loadClass(className); + } catch (ClassNotFoundException cnfx) { + if (debugEnabled) { + logger.debug("ClassResolver '{}' cannot find class: '{}'", plugin.getPluginId(), className); + } + } + } + + throw new ClassNotFoundException(className); + } + + @Override + public Iterator getResources(final String name) { + Set urls = new TreeSet(new UrlExternalFormComparator()); + + for (PluginWrapper plugin : pluginManager.getPlugins()) { + if (PluginState.STARTED != plugin.getPluginState()) { + // ignore this plugin + continue; + } + + Iterator it = getResources(name, plugin); + while (it.hasNext()) { + URL url = it.next(); + urls.add(url); + } + } + + return urls.iterator(); + } + + protected Iterator getResources(String name, PluginWrapper plugin) { + HashSet loadedFiles = new HashSet(); + try { + // Try the classloader for the wicket jar/bundle + Enumeration resources = plugin.getPluginClassLoader().getResources(name); + loadResources(resources, loadedFiles); + + // Try the classloader for the user's application jar/bundle + resources = Application.get().getClass().getClassLoader().getResources(name); + loadResources(resources, loadedFiles); + + // Try the context class loader + resources = Thread.currentThread().getContextClassLoader().getResources(name); + loadResources(resources, loadedFiles); + } catch (IOException e) { + throw new WicketRuntimeException(e); + } + + return loadedFiles.iterator(); + } + + private void loadResources(Enumeration resources, Set loadedFiles) { + if (resources != null) { + while (resources.hasMoreElements()) { + final URL url = resources.nextElement(); + if (!loadedFiles.contains(url)) { + loadedFiles.add(url); + } + } + } + } +} \ No newline at end of file diff --git a/src/main/java/com/gitblit/wicket/UrlExternalFormComparator.java b/src/main/java/com/gitblit/wicket/UrlExternalFormComparator.java new file mode 100644 index 00000000..90f4b320 --- /dev/null +++ b/src/main/java/com/gitblit/wicket/UrlExternalFormComparator.java @@ -0,0 +1,39 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You 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; + +import java.net.URL; +import java.util.Comparator; + +/** + * A comparator of URL instances. + * + * Comparing URLs with their implementation of #equals() is + * bad because it may cause problems like DNS resolving, or other + * slow checks. This comparator uses the external form of an URL + * to make a simple comparison of two Strings. + * + * @since 1.5.6 + */ +public class UrlExternalFormComparator implements Comparator +{ + @Override + public int compare(URL url1, URL url2) + { + return url1.toExternalForm().compareTo(url2.toExternalForm()); + } +} \ No newline at end of file diff --git a/src/main/java/com/gitblit/wicket/pages/ActivityPage.java b/src/main/java/com/gitblit/wicket/pages/ActivityPage.java index 0870ff96..c505a666 100644 --- a/src/main/java/com/gitblit/wicket/pages/ActivityPage.java +++ b/src/main/java/com/gitblit/wicket/pages/ActivityPage.java @@ -32,14 +32,14 @@ import org.apache.wicket.markup.html.panel.Fragment; import com.gitblit.Keys; import com.gitblit.models.Activity; import com.gitblit.models.Menu.ParameterMenuItem; +import com.gitblit.models.NavLink.DropDownPageMenuNavLink; import com.gitblit.models.Metric; +import com.gitblit.models.NavLink; import com.gitblit.models.RepositoryModel; import com.gitblit.utils.ActivityUtils; import com.gitblit.utils.StringUtils; import com.gitblit.wicket.CacheControl; import com.gitblit.wicket.CacheControl.LastModified; -import com.gitblit.wicket.PageRegistration; -import com.gitblit.wicket.PageRegistration.DropDownMenuRegistration; import com.gitblit.wicket.WicketUtils; import com.gitblit.wicket.charting.Chart; import com.gitblit.wicket.charting.Charts; @@ -135,8 +135,8 @@ public class ActivityPage extends RootPage { } @Override - protected void addDropDownMenus(List pages) { - DropDownMenuRegistration filters = new DropDownMenuRegistration("gb.filters", + protected void addDropDownMenus(List navLinks) { + DropDownPageMenuNavLink filters = new DropDownPageMenuNavLink("gb.filters", ActivityPage.class); PageParameters currentParameters = getPageParameters(); @@ -155,7 +155,7 @@ public class ActivityPage extends RootPage { // Reset Filter filters.menuItems.add(new ParameterMenuItem(getString("gb.reset"))); } - pages.add(filters); + navLinks.add(filters); } /** diff --git a/src/main/java/com/gitblit/wicket/pages/DashboardPage.java b/src/main/java/com/gitblit/wicket/pages/DashboardPage.java index 16b0b734..9c10e01b 100644 --- a/src/main/java/com/gitblit/wicket/pages/DashboardPage.java +++ b/src/main/java/com/gitblit/wicket/pages/DashboardPage.java @@ -37,7 +37,9 @@ import org.eclipse.jgit.lib.Repository; import com.gitblit.Keys; import com.gitblit.models.DailyLogEntry; import com.gitblit.models.Menu.ParameterMenuItem; +import com.gitblit.models.NavLink.DropDownPageMenuNavLink; import com.gitblit.models.Metric; +import com.gitblit.models.NavLink; import com.gitblit.models.RefLogEntry; import com.gitblit.models.RepositoryCommit; import com.gitblit.models.RepositoryModel; @@ -46,8 +48,6 @@ import com.gitblit.utils.ArrayUtils; import com.gitblit.utils.RefLogUtils; import com.gitblit.utils.StringUtils; import com.gitblit.wicket.GitBlitWebApp; -import com.gitblit.wicket.PageRegistration; -import com.gitblit.wicket.PageRegistration.DropDownMenuRegistration; import com.gitblit.wicket.charting.Chart; import com.gitblit.wicket.charting.Charts; import com.gitblit.wicket.charting.Flotr2Charts; @@ -141,10 +141,10 @@ public abstract class DashboardPage extends RootPage { } @Override - protected void addDropDownMenus(List pages) { + protected void addDropDownMenus(List navLinks) { PageParameters params = getPageParameters(); - DropDownMenuRegistration menu = new DropDownMenuRegistration("gb.filters", + DropDownPageMenuNavLink menu = new DropDownPageMenuNavLink("gb.filters", GitBlitWebApp.get().getHomePage()); // preserve repository filter option on time choices @@ -155,7 +155,7 @@ public abstract class DashboardPage extends RootPage { menu.menuItems.add(new ParameterMenuItem(getString("gb.reset"))); } - pages.add(menu); + navLinks.add(menu); } diff --git a/src/main/java/com/gitblit/wicket/pages/ProjectPage.java b/src/main/java/com/gitblit/wicket/pages/ProjectPage.java index 6c8aa4f4..d358b775 100644 --- a/src/main/java/com/gitblit/wicket/pages/ProjectPage.java +++ b/src/main/java/com/gitblit/wicket/pages/ProjectPage.java @@ -29,6 +29,8 @@ import com.gitblit.Keys; import com.gitblit.models.Menu.MenuDivider; import com.gitblit.models.Menu.MenuItem; import com.gitblit.models.Menu.ParameterMenuItem; +import com.gitblit.models.NavLink.DropDownPageMenuNavLink; +import com.gitblit.models.NavLink; import com.gitblit.models.ProjectModel; import com.gitblit.models.RepositoryModel; import com.gitblit.models.UserModel; @@ -40,8 +42,6 @@ import com.gitblit.wicket.CacheControl.LastModified; import com.gitblit.wicket.GitBlitWebApp; import com.gitblit.wicket.GitBlitWebSession; import com.gitblit.wicket.GitblitRedirectException; -import com.gitblit.wicket.PageRegistration; -import com.gitblit.wicket.PageRegistration.DropDownMenuRegistration; import com.gitblit.wicket.WicketUtils; import com.gitblit.wicket.panels.FilterableRepositoryList; @@ -161,10 +161,10 @@ public class ProjectPage extends DashboardPage { } @Override - protected void addDropDownMenus(List pages) { + protected void addDropDownMenus(List navLinks) { PageParameters params = getPageParameters(); - DropDownMenuRegistration menu = new DropDownMenuRegistration("gb.filters", + DropDownPageMenuNavLink menu = new DropDownPageMenuNavLink("gb.filters", ProjectPage.class); // preserve time filter option on repository choices menu.menuItems.addAll(getRepositoryFilterItems(params)); @@ -177,12 +177,12 @@ public class ProjectPage extends DashboardPage { menu.menuItems.add(new ParameterMenuItem(getString("gb.reset"), "p", WicketUtils.getProjectName(params))); } - pages.add(menu); + navLinks.add(menu); - DropDownMenuRegistration projects = new DropDownMenuRegistration("gb.projects", + DropDownPageMenuNavLink projects = new DropDownPageMenuNavLink("gb.projects", ProjectPage.class); projects.menuItems.addAll(getProjectsMenu()); - pages.add(projects); + navLinks.add(projects); } @Override diff --git a/src/main/java/com/gitblit/wicket/pages/ProjectsPage.java b/src/main/java/com/gitblit/wicket/pages/ProjectsPage.java index c404ae61..f04fa78a 100644 --- a/src/main/java/com/gitblit/wicket/pages/ProjectsPage.java +++ b/src/main/java/com/gitblit/wicket/pages/ProjectsPage.java @@ -25,10 +25,10 @@ import org.apache.wicket.markup.repeater.data.ListDataProvider; import com.gitblit.Keys; import com.gitblit.models.Menu.ParameterMenuItem; +import com.gitblit.models.NavLink.DropDownPageMenuNavLink; +import com.gitblit.models.NavLink; import com.gitblit.models.ProjectModel; import com.gitblit.wicket.GitBlitWebSession; -import com.gitblit.wicket.PageRegistration; -import com.gitblit.wicket.PageRegistration.DropDownMenuRegistration; import com.gitblit.wicket.WicketUtils; import com.gitblit.wicket.panels.LinkPanel; @@ -115,10 +115,10 @@ public class ProjectsPage extends RootPage { } @Override - protected void addDropDownMenus(List pages) { + protected void addDropDownMenus(List navLinks) { PageParameters params = getPageParameters(); - DropDownMenuRegistration menu = new DropDownMenuRegistration("gb.filters", + DropDownPageMenuNavLink menu = new DropDownPageMenuNavLink("gb.filters", ProjectsPage.class); // preserve time filter option on repository choices menu.menuItems.addAll(getRepositoryFilterItems(params)); @@ -131,6 +131,6 @@ public class ProjectsPage extends RootPage { menu.menuItems.add(new ParameterMenuItem(getString("gb.reset"))); } - pages.add(menu); + navLinks.add(menu); } } diff --git a/src/main/java/com/gitblit/wicket/pages/RepositoriesPage.java b/src/main/java/com/gitblit/wicket/pages/RepositoriesPage.java index 41fe057c..a0b15a83 100644 --- a/src/main/java/com/gitblit/wicket/pages/RepositoriesPage.java +++ b/src/main/java/com/gitblit/wicket/pages/RepositoriesPage.java @@ -30,14 +30,14 @@ import org.eclipse.jgit.lib.Constants; import com.gitblit.Keys; import com.gitblit.models.Menu.ParameterMenuItem; +import com.gitblit.models.NavLink.DropDownPageMenuNavLink; +import com.gitblit.models.NavLink; import com.gitblit.models.RepositoryModel; import com.gitblit.utils.MarkdownUtils; import com.gitblit.utils.StringUtils; import com.gitblit.wicket.CacheControl; import com.gitblit.wicket.CacheControl.LastModified; import com.gitblit.wicket.GitBlitWebSession; -import com.gitblit.wicket.PageRegistration; -import com.gitblit.wicket.PageRegistration.DropDownMenuRegistration; import com.gitblit.wicket.WicketUtils; import com.gitblit.wicket.panels.RepositoriesPanel; @@ -92,10 +92,10 @@ public class RepositoriesPage extends RootPage { } @Override - protected void addDropDownMenus(List pages) { + protected void addDropDownMenus(List navLinks) { PageParameters params = getPageParameters(); - DropDownMenuRegistration menu = new DropDownMenuRegistration("gb.filters", + DropDownPageMenuNavLink menu = new DropDownPageMenuNavLink("gb.filters", RepositoriesPage.class); // preserve time filter option on repository choices menu.menuItems.addAll(getRepositoryFilterItems(params)); @@ -108,7 +108,7 @@ public class RepositoriesPage extends RootPage { menu.menuItems.add(new ParameterMenuItem(getString("gb.reset"))); } - pages.add(menu); + navLinks.add(menu); } private String readMarkdown(String messageSource, String resource) { diff --git a/src/main/java/com/gitblit/wicket/pages/RepositoryPage.java b/src/main/java/com/gitblit/wicket/pages/RepositoryPage.java index 5ea99fd8..165feedf 100644 --- a/src/main/java/com/gitblit/wicket/pages/RepositoryPage.java +++ b/src/main/java/com/gitblit/wicket/pages/RepositoryPage.java @@ -21,7 +21,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Date; import java.util.HashMap; -import java.util.LinkedHashMap; import java.util.LinkedHashSet; import java.util.List; import java.util.Map; @@ -49,6 +48,10 @@ import org.slf4j.LoggerFactory; import com.gitblit.Constants; import com.gitblit.GitBlitException; import com.gitblit.Keys; +import com.gitblit.extensions.RepositoryNavLinkExtension; +import com.gitblit.models.NavLink; +import com.gitblit.models.NavLink.ExternalNavLink; +import com.gitblit.models.NavLink.PageNavLink; import com.gitblit.models.ProjectModel; import com.gitblit.models.RefModel; import com.gitblit.models.RepositoryModel; @@ -66,8 +69,6 @@ import com.gitblit.utils.RefLogUtils; import com.gitblit.utils.StringUtils; import com.gitblit.wicket.CacheControl; import com.gitblit.wicket.GitBlitWebSession; -import com.gitblit.wicket.PageRegistration; -import com.gitblit.wicket.PageRegistration.OtherPageLink; import com.gitblit.wicket.SessionlessForm; import com.gitblit.wicket.TicketsUI; import com.gitblit.wicket.WicketUtils; @@ -91,7 +92,6 @@ public abstract class RepositoryPage extends RootPage { private Map submodules; - private final Map registeredPages; private boolean showAdmin; private boolean isOwner; @@ -150,12 +150,11 @@ public abstract class RepositoryPage extends RootPage { } } - // register the available page links for this page and user - registeredPages = registerPages(); + // register the available navigation links for this page and user + List navLinks = registerNavLinks(); - // standard page links - List pages = new ArrayList(registeredPages.values()); - NavigationPanel navigationPanel = new NavigationPanel("repositoryNavPanel", getRepoNavPageClass(), pages); + // standard navigation links + NavigationPanel navigationPanel = new NavigationPanel("repositoryNavPanel", getRepoNavPageClass(), navLinks); add(navigationPanel); add(new ExternalLink("syndication", SyndicationServlet.asLink(getRequest() @@ -183,45 +182,56 @@ public abstract class RepositoryPage extends RootPage { return new BugtraqProcessor(app().settings()); } - private Map registerPages() { + private List registerNavLinks() { PageParameters params = null; if (!StringUtils.isEmpty(repositoryName)) { params = WicketUtils.newRepositoryParameter(repositoryName); } - Map pages = new LinkedHashMap(); + List navLinks = new ArrayList(); Repository r = getRepository(); RepositoryModel model = getRepositoryModel(); // standard links if (RefLogUtils.getRefLogBranch(r) == null) { - pages.put("summary", new PageRegistration("gb.summary", SummaryPage.class, params)); + navLinks.add(new PageNavLink("gb.summary", SummaryPage.class, params)); } else { - pages.put("summary", new PageRegistration("gb.summary", SummaryPage.class, params)); + navLinks.add(new PageNavLink("gb.summary", SummaryPage.class, params)); // pages.put("overview", new PageRegistration("gb.overview", OverviewPage.class, params)); - pages.put("reflog", new PageRegistration("gb.reflog", ReflogPage.class, params)); + navLinks.add(new PageNavLink("gb.reflog", ReflogPage.class, params)); } - pages.put("commits", new PageRegistration("gb.commits", LogPage.class, params)); - pages.put("tree", new PageRegistration("gb.tree", TreePage.class, params)); + navLinks.add(new PageNavLink("gb.commits", LogPage.class, params)); + navLinks.add(new PageNavLink("gb.tree", TreePage.class, params)); if (app().tickets().isReady() && (app().tickets().isAcceptingNewTickets(getRepositoryModel()) || app().tickets().hasTickets(getRepositoryModel()))) { PageParameters tParams = new PageParameters(params); for (String state : TicketsUI.openStatii) { tParams.add(Lucene.status.name(), state); } - pages.put("tickets", new PageRegistration("gb.tickets", TicketsPage.class, tParams)); + navLinks.add(new PageNavLink("gb.tickets", TicketsPage.class, tParams)); } - pages.put("docs", new PageRegistration("gb.docs", DocsPage.class, params, true)); + navLinks.add(new PageNavLink("gb.docs", DocsPage.class, params, true)); if (app().settings().getBoolean(Keys.web.allowForking, true)) { - pages.put("forks", new PageRegistration("gb.forks", ForksPage.class, params, true)); + navLinks.add(new PageNavLink("gb.forks", ForksPage.class, params, true)); } - pages.put("compare", new PageRegistration("gb.compare", ComparePage.class, params, true)); + navLinks.add(new PageNavLink("gb.compare", ComparePage.class, params, true)); // conditional links - // per-repository extra page links + // per-repository extra navlinks if (JGitUtils.getPagesBranch(r) != null) { - OtherPageLink pagesLink = new OtherPageLink("gb.pages", PagesServlet.asLink( + ExternalNavLink pagesLink = new ExternalNavLink("gb.pages", PagesServlet.asLink( getRequest().getRelativePathPrefixToContextRoot(), repositoryName, null), true); - pages.put("pages", pagesLink); + navLinks.add(pagesLink); + } + + UserModel user = UserModel.ANONYMOUS; + if (GitBlitWebSession.get().isLoggedIn()) { + user = GitBlitWebSession.get().getUser(); + } + + // add repository nav link extensions + List extensions = app().plugins().getExtensions(RepositoryNavLinkExtension.class); + for (RepositoryNavLinkExtension ext : extensions) { + navLinks.addAll(ext.getNavLinks(user, model)); } // Conditionally add edit link @@ -233,9 +243,8 @@ public abstract class RepositoryPage extends RootPage { showAdmin = app().settings().getBoolean(Keys.web.allowAdministration, false); } isOwner = GitBlitWebSession.get().isLoggedIn() - && (model.isOwner(GitBlitWebSession.get() - .getUsername())); - return pages; + && (model.isOwner(GitBlitWebSession.get().getUsername())); + return navLinks; } protected boolean allowForkControls() { diff --git a/src/main/java/com/gitblit/wicket/pages/RootPage.java b/src/main/java/com/gitblit/wicket/pages/RootPage.java index 3003c70e..a2f3a497 100644 --- a/src/main/java/com/gitblit/wicket/pages/RootPage.java +++ b/src/main/java/com/gitblit/wicket/pages/RootPage.java @@ -50,6 +50,7 @@ import org.apache.wicket.protocol.http.WebResponse; import com.gitblit.Constants; import com.gitblit.Keys; +import com.gitblit.extensions.NavLinkExtension; import com.gitblit.extensions.UserMenuExtension; import com.gitblit.models.Menu.ExternalLinkMenuItem; import com.gitblit.models.Menu.MenuDivider; @@ -57,13 +58,14 @@ import com.gitblit.models.Menu.MenuItem; import com.gitblit.models.Menu.PageLinkMenuItem; import com.gitblit.models.Menu.ParameterMenuItem; import com.gitblit.models.Menu.ToggleMenuItem; +import com.gitblit.models.NavLink; +import com.gitblit.models.NavLink.PageNavLink; import com.gitblit.models.RepositoryModel; import com.gitblit.models.TeamModel; import com.gitblit.models.UserModel; import com.gitblit.utils.ModelUtils; import com.gitblit.utils.StringUtils; import com.gitblit.wicket.GitBlitWebSession; -import com.gitblit.wicket.PageRegistration; import com.gitblit.wicket.SessionlessForm; import com.gitblit.wicket.WicketUtils; import com.gitblit.wicket.panels.GravatarImage; @@ -174,50 +176,37 @@ public abstract class RootPage extends BasePage { } // navigation links - List pages = new ArrayList(); + List navLinks = new ArrayList(); if (!authenticateView || (authenticateView && isLoggedIn)) { - pages.add(new PageRegistration(isLoggedIn ? "gb.myDashboard" : "gb.dashboard", MyDashboardPage.class, + navLinks.add(new PageNavLink(isLoggedIn ? "gb.myDashboard" : "gb.dashboard", MyDashboardPage.class, getRootPageParameters())); if (isLoggedIn && app().tickets().isReady()) { - pages.add(new PageRegistration("gb.myTickets", MyTicketsPage.class)); + navLinks.add(new PageNavLink("gb.myTickets", MyTicketsPage.class)); } - pages.add(new PageRegistration("gb.repositories", RepositoriesPage.class, + navLinks.add(new PageNavLink("gb.repositories", RepositoriesPage.class, getRootPageParameters())); - pages.add(new PageRegistration("gb.activity", ActivityPage.class, getRootPageParameters())); + navLinks.add(new PageNavLink("gb.activity", ActivityPage.class, getRootPageParameters())); if (allowLucene) { - pages.add(new PageRegistration("gb.search", LuceneSearchPage.class)); + navLinks.add(new PageNavLink("gb.search", LuceneSearchPage.class)); } - UserModel user = GitBlitWebSession.get().getUser(); - - if (showAdmin) { - // admin dropdown menu - DropDownMenuRegistration adminMenu = new DropDownMenuRegistration("gb.adminMenuItem", MyDashboardPage.class); - - adminMenu.menuItems.add(new PageLinkMenuItem(getString("gb.users"), UsersPage.class)); - - boolean showRegistrations = app().federation().canFederate() - && app().settings().getBoolean(Keys.web.showFederationRegistrations, false); - if (showRegistrations) { - adminMenu.menuItems.add(new PageLinkMenuItem(getString("gb.federation"), FederationPage.class)); - } - - // allow plugins to contribute admin menu items - List extensions = app().plugins().getExtensions(AdminMenuExtension.class); - for (AdminMenuExtension ext : extensions) { - adminMenu.menuItems.add(new MenuDivider()); - adminMenu.menuItems.addAll(ext.getMenuItems(user)); - } + if (!authenticateView || (authenticateView && isLoggedIn)) { + addDropDownMenus(navLinks); + } - pages.add(adminMenu); + UserModel user = UserModel.ANONYMOUS; + if (isLoggedIn) { + user = GitBlitWebSession.get().getUser(); } - if (!authenticateView || (authenticateView && isLoggedIn)) { - addDropDownMenus(pages); + // add nav link extensions + List extensions = app().plugins().getExtensions(NavLinkExtension.class); + for (NavLinkExtension ext : extensions) { + navLinks.addAll(ext.getNavLinks(user)); } } - NavigationPanel navPanel = new NavigationPanel("navPanel", getRootNavPageClass(), pages); + NavigationPanel navPanel = new NavigationPanel("navPanel", getRootNavPageClass(), navLinks); add(navPanel); // display an error message cached from a redirect @@ -309,7 +298,7 @@ public abstract class RootPage extends BasePage { return repositoryModels; } - protected void addDropDownMenus(List pages) { + protected void addDropDownMenus(List navLinks) { } diff --git a/src/main/java/com/gitblit/wicket/pages/UserPage.java b/src/main/java/com/gitblit/wicket/pages/UserPage.java index 0767621c..6cb791eb 100644 --- a/src/main/java/com/gitblit/wicket/pages/UserPage.java +++ b/src/main/java/com/gitblit/wicket/pages/UserPage.java @@ -30,6 +30,8 @@ import org.eclipse.jgit.lib.PersonIdent; import com.gitblit.Keys; import com.gitblit.models.Menu.ParameterMenuItem; +import com.gitblit.models.NavLink.DropDownPageMenuNavLink; +import com.gitblit.models.NavLink; import com.gitblit.models.ProjectModel; import com.gitblit.models.RepositoryModel; import com.gitblit.models.UserModel; @@ -37,8 +39,6 @@ import com.gitblit.utils.StringUtils; import com.gitblit.wicket.GitBlitWebApp; import com.gitblit.wicket.GitBlitWebSession; import com.gitblit.wicket.GitblitRedirectException; -import com.gitblit.wicket.PageRegistration; -import com.gitblit.wicket.PageRegistration.DropDownMenuRegistration; import com.gitblit.wicket.WicketUtils; import com.gitblit.wicket.panels.GravatarImage; import com.gitblit.wicket.panels.LinkPanel; @@ -127,10 +127,10 @@ public class UserPage extends RootPage { } @Override - protected void addDropDownMenus(List pages) { + protected void addDropDownMenus(List navLinks) { PageParameters params = getPageParameters(); - DropDownMenuRegistration menu = new DropDownMenuRegistration("gb.filters", + DropDownPageMenuNavLink menu = new DropDownPageMenuNavLink("gb.filters", UserPage.class); // preserve time filter option on repository choices menu.menuItems.addAll(getRepositoryFilterItems(params)); @@ -143,6 +143,6 @@ public class UserPage extends RootPage { menu.menuItems.add(new ParameterMenuItem(getString("gb.reset"))); } - pages.add(menu); + navLinks.add(menu); } } diff --git a/src/main/java/com/gitblit/wicket/panels/DropDownMenu.java b/src/main/java/com/gitblit/wicket/panels/DropDownMenu.java index f561143d..4e7ae54c 100644 --- a/src/main/java/com/gitblit/wicket/panels/DropDownMenu.java +++ b/src/main/java/com/gitblit/wicket/panels/DropDownMenu.java @@ -21,24 +21,24 @@ import org.apache.wicket.markup.repeater.Item; import org.apache.wicket.markup.repeater.data.DataView; import org.apache.wicket.markup.repeater.data.ListDataProvider; -import com.gitblit.models.Menu.MenuDivider; import com.gitblit.models.Menu.ExternalLinkMenuItem; +import com.gitblit.models.Menu.MenuDivider; import com.gitblit.models.Menu.MenuItem; import com.gitblit.models.Menu.PageLinkMenuItem; import com.gitblit.models.Menu.ParameterMenuItem; -import com.gitblit.wicket.PageRegistration.DropDownMenuRegistration; +import com.gitblit.models.NavLink.DropDownMenuNavLink; +import com.gitblit.models.NavLink.DropDownPageMenuNavLink; import com.gitblit.wicket.WicketUtils; public class DropDownMenu extends Panel { private static final long serialVersionUID = 1L; - public DropDownMenu(String id, String label, final DropDownMenuRegistration menu) { + public DropDownMenu(String id, String label, final DropDownPageMenuNavLink menu) { super(id); add(new Label("label", label).setRenderBodyOnly(true)); - ListDataProvider items = new ListDataProvider( - menu.menuItems); + ListDataProvider items = new ListDataProvider(menu.menuItems); DataView view = new DataView("menuItems", items) { private static final long serialVersionUID = 1L; @@ -76,4 +76,39 @@ public class DropDownMenu extends Panel { add(view); setRenderBodyOnly(true); } + + public DropDownMenu(String id, String label, final DropDownMenuNavLink menu) { + super(id); + + add(new Label("label", label).setRenderBodyOnly(true)); + ListDataProvider items = new ListDataProvider(menu.menuItems); + DataView view = new DataView("menuItems", items) { + private static final long serialVersionUID = 1L; + + @Override + public void populateItem(final Item item) { + MenuItem entry = item.getModelObject(); + if (entry instanceof PageLinkMenuItem) { + // link to another Wicket page + PageLinkMenuItem pageLink = (PageLinkMenuItem) entry; + item.add(new LinkPanel("menuItem", null, null, pageLink.toString(), pageLink.getPageClass(), + pageLink.getPageParameters(), false).setRenderBodyOnly(true)); + } else if (entry instanceof ExternalLinkMenuItem) { + // link to a specified href + ExternalLinkMenuItem extLink = (ExternalLinkMenuItem) entry; + item.add(new LinkPanel("menuItem", null, extLink.toString(), extLink.getHref(), + extLink.openInNewWindow()).setRenderBodyOnly(true)); + } else if (entry instanceof MenuDivider) { + // divider + item.add(new Label("menuItem").setRenderBodyOnly(true)); + WicketUtils.setCssClass(item, "divider"); + } else { + throw new IllegalArgumentException(String.format("Unexpected menuitem type %s", + entry.getClass().getSimpleName())); + } + } + }; + add(view); + setRenderBodyOnly(true); + } } \ No newline at end of file diff --git a/src/main/java/com/gitblit/wicket/panels/NavigationPanel.java b/src/main/java/com/gitblit/wicket/panels/NavigationPanel.java index 7db29fa2..2bc92f4c 100644 --- a/src/main/java/com/gitblit/wicket/panels/NavigationPanel.java +++ b/src/main/java/com/gitblit/wicket/panels/NavigationPanel.java @@ -23,9 +23,11 @@ import org.apache.wicket.markup.repeater.Item; import org.apache.wicket.markup.repeater.data.DataView; import org.apache.wicket.markup.repeater.data.ListDataProvider; -import com.gitblit.wicket.PageRegistration; -import com.gitblit.wicket.PageRegistration.DropDownMenuRegistration; -import com.gitblit.wicket.PageRegistration.OtherPageLink; +import com.gitblit.models.NavLink; +import com.gitblit.models.NavLink.DropDownMenuNavLink; +import com.gitblit.models.NavLink.DropDownPageMenuNavLink; +import com.gitblit.models.NavLink.ExternalNavLink; +import com.gitblit.models.NavLink.PageNavLink; import com.gitblit.wicket.WicketUtils; import com.gitblit.wicket.pages.BasePage; @@ -34,52 +36,59 @@ public class NavigationPanel extends Panel { private static final long serialVersionUID = 1L; public NavigationPanel(String id, final Class pageClass, - List registeredPages) { + List navLinks) { super(id); - ListDataProvider refsDp = new ListDataProvider( - registeredPages); - DataView refsView = new DataView("navLink", refsDp) { + ListDataProvider refsDp = new ListDataProvider(navLinks); + DataView linksView = new DataView("navLink", refsDp) { private static final long serialVersionUID = 1L; @Override - public void populateItem(final Item item) { - PageRegistration entry = item.getModelObject(); - String linkText = entry.translationKey; + public void populateItem(final Item item) { + NavLink navLink = item.getModelObject(); + String linkText = navLink.translationKey; try { // try to lookup translation key - linkText = getString(entry.translationKey); + linkText = getString(navLink.translationKey); } catch (Exception e) { } - if (entry.hiddenPhone) { + if (navLink.hiddenPhone) { WicketUtils.setCssClass(item, "hidden-phone"); } - if (entry instanceof OtherPageLink) { + if (navLink instanceof ExternalNavLink) { // other link - OtherPageLink link = (OtherPageLink) entry; + ExternalNavLink link = (ExternalNavLink) navLink; Component c = new LinkPanel("link", null, linkText, link.url); c.setRenderBodyOnly(true); item.add(c); - } else if (entry instanceof DropDownMenuRegistration) { + } else if (navLink instanceof DropDownPageMenuNavLink) { // drop down menu - DropDownMenuRegistration reg = (DropDownMenuRegistration) entry; + DropDownPageMenuNavLink reg = (DropDownPageMenuNavLink) navLink; Component c = new DropDownMenu("link", linkText, reg); c.setRenderBodyOnly(true); item.add(c); WicketUtils.setCssClass(item, "dropdown"); - } else { + } else if (navLink instanceof DropDownMenuNavLink) { + // drop down menu + DropDownMenuNavLink reg = (DropDownMenuNavLink) navLink; + Component c = new DropDownMenu("link", linkText, reg); + c.setRenderBodyOnly(true); + item.add(c); + WicketUtils.setCssClass(item, "dropdown"); + } else if (navLink instanceof PageNavLink) { + PageNavLink reg = (PageNavLink) navLink; // standard page link Component c = new LinkPanel("link", null, linkText, - entry.pageClass, entry.params); + reg.pageClass, reg.params); c.setRenderBodyOnly(true); - if (entry.pageClass.equals(pageClass)) { + if (reg.pageClass.equals(pageClass)) { WicketUtils.setCssClass(item, "active"); } item.add(c); } } }; - add(refsView); + add(linksView); } } \ No newline at end of file diff --git a/src/site/plugins_extensions.mkd b/src/site/plugins_extensions.mkd index 18a7e325..7bf63c17 100644 --- a/src/site/plugins_extensions.mkd +++ b/src/site/plugins_extensions.mkd @@ -52,6 +52,37 @@ public class ExamplePlugin extends GitblitPlugin { public void onUninstall() { } } + +/** + * You can also create Webapp plugins that register mounted pages. + */ +public class ExampleWicketPlugin extends GitblitWicketPlugin { + @Override + public void start() { + } + + @Override + public void stop() { + } + + @Override + public void onInstall() { + } + + @Override + public void onUpgrade(Version oldVersion) { + } + + @Override + public void onUninstall() { + } + + @Override + protected void init(GitblitWicketApp app) { + app.mount("/logo", LogoPage.class); + app.mount("/hello", HelloWorldPage.class); + } +} ``` ### SSH Dispatch Command @@ -225,7 +256,32 @@ public class MyUserMenuContributor extends UserMenuExtension { @Override public List getMenuItems(UserModel user) { - return Arrays.asList((MenuItem) new ExternalLinkMenuItem("Github", String.format("https://github.com/%s", user.username)); + MenuItem item = new ExternalLinkMenuItem("Github", String.format("https://github.com/%s", user.username)); + return Arrays.asList(item); + } +} +``` + +### Navigation Links + +*SINCE 1.6.0* + +You can provide your own top-level navigation links by subclassing the *NavLinkExtension* class. + +```java +import java.util.Arrays; +import java.util.List; +import ro.fortsoft.pf4j.Extension; +import com.gitblit.extensions.NavLinkExtension; +import com.gitblit.models.UserModel; + +@Extension +public class MyNavLink extends NavLinkExtension { + + @Override + public List getNavLinks(UserModel user) { + NavLink link = new ExternalLinkMenuItem("Github", String.format("https://github.com/%s", user.username)); + return Arrays.asList(link); } } ``` -- cgit v1.2.3 From 3b23dcdde4ef55927e45e56596e7023ce2cf9424 Mon Sep 17 00:00:00 2001 From: James Moger Date: Wed, 7 May 2014 14:32:09 -0400 Subject: Consolidate open tickets page parameters --- src/main/java/com/gitblit/wicket/WicketUtils.java | 14 ++++++++++++++ .../java/com/gitblit/wicket/pages/EditMilestonePage.java | 14 +++++++------- .../java/com/gitblit/wicket/pages/NewMilestonePage.java | 8 ++++---- src/main/java/com/gitblit/wicket/pages/RepositoryPage.java | 9 ++------- .../java/com/gitblit/wicket/panels/TicketListPanel.java | 6 +----- 5 files changed, 28 insertions(+), 23 deletions(-) (limited to 'src/main/java/com/gitblit/wicket/pages/RepositoryPage.java') diff --git a/src/main/java/com/gitblit/wicket/WicketUtils.java b/src/main/java/com/gitblit/wicket/WicketUtils.java index 10b21468..687f0105 100644 --- a/src/main/java/com/gitblit/wicket/WicketUtils.java +++ b/src/main/java/com/gitblit/wicket/WicketUtils.java @@ -445,6 +445,20 @@ public class WicketUtils { return new PageParameters(parameterMap); } + public static PageParameters newTicketsParameters(String repositoryName, String... states) { + PageParameters tParams = newRepositoryParameter(repositoryName); + if (states != null) { + for (String state : states) { + tParams.add("status", state); + } + } + return tParams; + } + + public static PageParameters newOpenTicketsParameter(String repositoryName) { + return newTicketsParameters(repositoryName, TicketsUI.openStatii); + } + public static String getProjectName(PageParameters params) { return params.getString("p", ""); } diff --git a/src/main/java/com/gitblit/wicket/pages/EditMilestonePage.java b/src/main/java/com/gitblit/wicket/pages/EditMilestonePage.java index b844442a..d6f58e7b 100644 --- a/src/main/java/com/gitblit/wicket/pages/EditMilestonePage.java +++ b/src/main/java/com/gitblit/wicket/pages/EditMilestonePage.java @@ -66,7 +66,7 @@ public class EditMilestonePage extends RepositoryPage { RepositoryModel model = getRepositoryModel(); if (!app().tickets().isAcceptingTicketUpdates(model)) { // ticket service is read-only - throw new RestartResponseException(TicketsPage.class, WicketUtils.newRepositoryParameter(repositoryName)); + throw new RestartResponseException(TicketsPage.class, WicketUtils.newOpenTicketsParameter(repositoryName)); } UserModel currentUser = GitBlitWebSession.get().getUser(); @@ -76,19 +76,19 @@ public class EditMilestonePage extends RepositoryPage { if (!currentUser.isAuthenticated || !currentUser.canAdmin(model)) { // administration prohibited - throw new RestartResponseException(TicketsPage.class, WicketUtils.newRepositoryParameter(repositoryName)); + throw new RestartResponseException(TicketsPage.class, WicketUtils.newOpenTicketsParameter(repositoryName)); } oldName = WicketUtils.getObject(params); if (StringUtils.isEmpty(oldName)) { // milestone not specified - throw new RestartResponseException(TicketsPage.class, WicketUtils.newRepositoryParameter(repositoryName)); + throw new RestartResponseException(TicketsPage.class, WicketUtils.newOpenTicketsParameter(repositoryName)); } TicketMilestone tm = app().tickets().getMilestone(getRepositoryModel(), oldName); if (tm == null) { // milestone does not exist - throw new RestartResponseException(TicketsPage.class, WicketUtils.newRepositoryParameter(repositoryName)); + throw new RestartResponseException(TicketsPage.class, WicketUtils.newOpenTicketsParameter(repositoryName)); } setStatelessHint(false); @@ -140,7 +140,7 @@ public class EditMilestonePage extends RepositoryPage { } if (success && app().tickets().updateMilestone(getRepositoryModel(), tm, createdBy)) { - setResponsePage(TicketsPage.class, WicketUtils.newRepositoryParameter(getRepositoryModel().name)); + setResponsePage(TicketsPage.class, WicketUtils.newOpenTicketsParameter(repositoryName)); } else { // TODO error } @@ -151,7 +151,7 @@ public class EditMilestonePage extends RepositoryPage { @Override public void onSubmit() { - setResponsePage(TicketsPage.class, WicketUtils.newRepositoryParameter(repositoryName)); + setResponsePage(TicketsPage.class, WicketUtils.newOpenTicketsParameter(repositoryName)); } }; cancel.setDefaultFormProcessing(false); @@ -167,7 +167,7 @@ public class EditMilestonePage extends RepositoryPage { boolean notify = notificationModel.getObject(); if (app().tickets().deleteMilestone(getRepositoryModel(), oldName, createdBy, notify)) { - setResponsePage(TicketsPage.class, WicketUtils.newRepositoryParameter(repositoryName)); + setResponsePage(TicketsPage.class, WicketUtils.newOpenTicketsParameter(repositoryName)); } else { // TODO error processing } diff --git a/src/main/java/com/gitblit/wicket/pages/NewMilestonePage.java b/src/main/java/com/gitblit/wicket/pages/NewMilestonePage.java index a9f76d3a..cc331903 100644 --- a/src/main/java/com/gitblit/wicket/pages/NewMilestonePage.java +++ b/src/main/java/com/gitblit/wicket/pages/NewMilestonePage.java @@ -55,7 +55,7 @@ public class NewMilestonePage extends RepositoryPage { RepositoryModel model = getRepositoryModel(); if (!app().tickets().isAcceptingTicketUpdates(model)) { // ticket service is read-only - throw new RestartResponseException(TicketsPage.class, WicketUtils.newRepositoryParameter(repositoryName)); + throw new RestartResponseException(TicketsPage.class, WicketUtils.newOpenTicketsParameter(repositoryName)); } UserModel currentUser = GitBlitWebSession.get().getUser(); @@ -65,7 +65,7 @@ public class NewMilestonePage extends RepositoryPage { if (!currentUser.isAuthenticated || !currentUser.canAdmin(model)) { // administration prohibited - throw new RestartResponseException(TicketsPage.class, WicketUtils.newRepositoryParameter(repositoryName)); + throw new RestartResponseException(TicketsPage.class, WicketUtils.newOpenTicketsParameter(repositoryName)); } setStatelessHint(false); @@ -108,7 +108,7 @@ public class NewMilestonePage extends RepositoryPage { if (milestone != null) { milestone.due = due; app().tickets().updateMilestone(getRepositoryModel(), milestone, createdBy); - throw new RestartResponseException(TicketsPage.class, WicketUtils.newRepositoryParameter(getRepositoryModel().name)); + throw new RestartResponseException(TicketsPage.class, WicketUtils.newOpenTicketsParameter(repositoryName)); } else { // TODO error } @@ -120,7 +120,7 @@ public class NewMilestonePage extends RepositoryPage { @Override public void onSubmit() { - setResponsePage(TicketsPage.class, WicketUtils.newRepositoryParameter(repositoryName)); + setResponsePage(TicketsPage.class, WicketUtils.newOpenTicketsParameter(repositoryName)); } }; cancel.setDefaultFormProcessing(false); diff --git a/src/main/java/com/gitblit/wicket/pages/RepositoryPage.java b/src/main/java/com/gitblit/wicket/pages/RepositoryPage.java index 165feedf..a0c9ce01 100644 --- a/src/main/java/com/gitblit/wicket/pages/RepositoryPage.java +++ b/src/main/java/com/gitblit/wicket/pages/RepositoryPage.java @@ -60,7 +60,6 @@ import com.gitblit.models.UserModel; import com.gitblit.models.UserRepositoryPreferences; import com.gitblit.servlet.PagesServlet; import com.gitblit.servlet.SyndicationServlet; -import com.gitblit.tickets.TicketIndexer.Lucene; import com.gitblit.utils.ArrayUtils; import com.gitblit.utils.BugtraqProcessor; import com.gitblit.utils.DeepCopier; @@ -70,7 +69,6 @@ import com.gitblit.utils.StringUtils; import com.gitblit.wicket.CacheControl; import com.gitblit.wicket.GitBlitWebSession; import com.gitblit.wicket.SessionlessForm; -import com.gitblit.wicket.TicketsUI; import com.gitblit.wicket.WicketUtils; import com.gitblit.wicket.panels.LinkPanel; import com.gitblit.wicket.panels.NavigationPanel; @@ -202,11 +200,8 @@ public abstract class RepositoryPage extends RootPage { } navLinks.add(new PageNavLink("gb.commits", LogPage.class, params)); navLinks.add(new PageNavLink("gb.tree", TreePage.class, params)); - if (app().tickets().isReady() && (app().tickets().isAcceptingNewTickets(getRepositoryModel()) || app().tickets().hasTickets(getRepositoryModel()))) { - PageParameters tParams = new PageParameters(params); - for (String state : TicketsUI.openStatii) { - tParams.add(Lucene.status.name(), state); - } + if (app().tickets().isReady() && (app().tickets().isAcceptingNewTickets(model) || app().tickets().hasTickets(model))) { + PageParameters tParams = WicketUtils.newOpenTicketsParameter(repositoryName); navLinks.add(new PageNavLink("gb.tickets", TicketsPage.class, tParams)); } navLinks.add(new PageNavLink("gb.docs", DocsPage.class, params, true)); diff --git a/src/main/java/com/gitblit/wicket/panels/TicketListPanel.java b/src/main/java/com/gitblit/wicket/panels/TicketListPanel.java index 395200c1..ab763b8f 100644 --- a/src/main/java/com/gitblit/wicket/panels/TicketListPanel.java +++ b/src/main/java/com/gitblit/wicket/panels/TicketListPanel.java @@ -32,7 +32,6 @@ import com.gitblit.Constants; import com.gitblit.models.RepositoryModel; import com.gitblit.models.UserModel; import com.gitblit.tickets.QueryResult; -import com.gitblit.tickets.TicketIndexer.Lucene; import com.gitblit.tickets.TicketLabel; import com.gitblit.utils.ArrayUtils; import com.gitblit.utils.BugtraqProcessor; @@ -77,10 +76,7 @@ public class TicketListPanel extends BasePanel { if (showRepository) { String name = StringUtils.stripDotGit(ticket.repository); - PageParameters rp = new PageParameters(WicketUtils.newRepositoryParameter(ticket.repository)); - for (String state : TicketsUI.openStatii) { - rp.add(Lucene.status.name(), state); - } + PageParameters rp = WicketUtils.newOpenTicketsParameter(ticket.repository); LinkPanel link = new LinkPanel("ticketsLink", null, name, TicketsPage.class, rp); WicketUtils.setCssBackground(link, name); item.add(link); -- cgit v1.2.3 From 9e7b14b651cf3812718d33665529de919c05795d Mon Sep 17 00:00:00 2001 From: James Moger Date: Thu, 15 May 2014 08:10:20 -0400 Subject: Redesign the EmptyRepositoryPage --- releases.moxie | 1 + .../gitblit/wicket/pages/EmptyRepositoryPage.html | 87 +++++++++++---------- .../gitblit/wicket/pages/EmptyRepositoryPage.java | 17 ++-- .../wicket/pages/EmptyRepositoryPage_es.html | 88 +++++++++++---------- .../wicket/pages/EmptyRepositoryPage_ko.html | 91 +++++++++++----------- .../wicket/pages/EmptyRepositoryPage_nl.html | 87 +++++++++++---------- .../wicket/pages/EmptyRepositoryPage_pl.html | 86 ++++++++++---------- .../wicket/pages/EmptyRepositoryPage_pt_BR.html | 86 ++++++++++---------- .../wicket/pages/EmptyRepositoryPage_zh_CN.html | 89 ++++++++++----------- .../com/gitblit/wicket/pages/RepositoryPage.java | 33 ++++---- .../java/com/gitblit/wicket/pages/create_git.md | 6 ++ .../java/com/gitblit/wicket/pages/existing_git.md | 2 + 12 files changed, 347 insertions(+), 326 deletions(-) create mode 100644 src/main/java/com/gitblit/wicket/pages/create_git.md create mode 100644 src/main/java/com/gitblit/wicket/pages/existing_git.md (limited to 'src/main/java/com/gitblit/wicket/pages/RepositoryPage.java') diff --git a/releases.moxie b/releases.moxie index 86896d35..c0c243a8 100644 --- a/releases.moxie +++ b/releases.moxie @@ -20,6 +20,7 @@ r24: { - BARNUM: Create ticket/N instead of topic/N for pt start N (ticket-61) - Move repository deletion functions to the edit repository page AND allow deletion to be disabled (pr-180, ticket-67) - Update the Korean translation (pr-184, ticket-69) + - Overhaul the EmptyRepositoryPage (ticket-73) additions: - Add My Tickets page (issue-215, ticket-15) - Added CRUD functionality for Ticket Milestones (ticket-17) diff --git a/src/main/java/com/gitblit/wicket/pages/EmptyRepositoryPage.html b/src/main/java/com/gitblit/wicket/pages/EmptyRepositoryPage.html index c5f9bc95..ebd513ad 100644 --- a/src/main/java/com/gitblit/wicket/pages/EmptyRepositoryPage.html +++ b/src/main/java/com/gitblit/wicket/pages/EmptyRepositoryPage.html @@ -7,52 +7,53 @@
-

Empty Repository

-

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

- Please push some commits to -

-
- After you have pushed commits you may refresh this page to view your repository. -
-
-
+
+
+
+

Empty Repository

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

+ Please push some commits to +
+ After you have pushed commits you may refresh this page to view your repository. +
-

Git Command-Line Syntax

- If you do not have a local Git repository, then you should clone this repository, commit some files, and then push your commits back to Gitblit. -

-

-		

- If you already have a local Git repository with commits, then you may add this repository as a remote and push to it. -

-

-		

- If your repository is meant to be kept in sync with an upstream repository, then you may add it. -

-

-		

-

Learn Git

- If you are unsure how to use this information, consider reviewing the Git Community Book or Pro Git for a better understanding on how to use Git. -

+

Create a new repository on the command-line

+ +

+
+	

Push an existing repository from the command-line

+ +

+	
+	
+

Learn Git

+

If you are unsure how to use this information, consider reviewing the Git Community 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)
  • -
  • Git Extensions - C# frontend for Git that features Windows Explorer and Visual Studio integration
  • -
  • GitX-dev - a Mac OS X Git client
  • -
-

+ + + + + + + + +
Gitthe official, command-line Git
TortoiseGitWindows file explorer integration (requires official, command-line Git)
Eclipse/EGitGit for the Eclipse IDE (based on JGit, like Gitblit)
Git ExtensionsC# frontend for Git that features Windows Explorer and Visual Studio integration
GitX-deva Mac OS X Git client
+

Commercial/Closed-Source Git Clients

-
    -
  • SmartGit/Hg - A Java Git and Mercurial client for Windows, Mac, and Linux
  • -
  • SourceTree - A free Git and Mercurial client for Windows & Mac
  • -
  • Tower - a Mac OS X Git client
  • -
+ + + + + + +
SmartGit/HgA Java Git and Mercurial client for Windows, Mac, and Linux
SourceTreeA free Git and Mercurial client for Windows & Mac
Towera Mac OS X Git client
+
+
+
+
diff --git a/src/main/java/com/gitblit/wicket/pages/EmptyRepositoryPage.java b/src/main/java/com/gitblit/wicket/pages/EmptyRepositoryPage.java index 00bac634..b3c52436 100644 --- a/src/main/java/com/gitblit/wicket/pages/EmptyRepositoryPage.java +++ b/src/main/java/com/gitblit/wicket/pages/EmptyRepositoryPage.java @@ -15,7 +15,6 @@ */ package com.gitblit.wicket.pages; -import java.text.MessageFormat; import java.util.List; import javax.servlet.http.HttpServletRequest; @@ -32,7 +31,7 @@ import com.gitblit.wicket.GitblitRedirectException; import com.gitblit.wicket.WicketUtils; import com.gitblit.wicket.panels.RepositoryUrlPanel; -public class EmptyRepositoryPage extends RootPage { +public class EmptyRepositoryPage extends RepositoryPage { public EmptyRepositoryPage(PageParameters params) { super(params); @@ -50,8 +49,6 @@ public class EmptyRepositoryPage extends RootPage { throw new GitblitRedirectException(SummaryPage.class, params); } - setupPage(repositoryName, getString("gb.emptyRepository")); - UserModel user = GitBlitWebSession.get().getUser(); if (user == null) { user = UserModel.ANONYMOUS; @@ -62,15 +59,17 @@ public class EmptyRepositoryPage extends RootPage { RepositoryUrl primaryUrl = repositoryUrls.size() == 0 ? null : repositoryUrls.get(0); String url = primaryUrl != null ? primaryUrl.url : ""; + String createSyntax = readResource("create_git.md").replace("${primaryUrl}", url); + String existingSyntax = readResource("existing_git.md").replace("${primaryUrl}", url); + add(new Label("repository", repositoryName)); add(new RepositoryUrlPanel("pushurl", false, user, repository)); - add(new Label("cloneSyntax", MessageFormat.format("git clone {0}", url))); - add(new Label("remoteSyntax", MessageFormat.format("git remote add origin {0}\ngit push -u origin --all\ngit push -u origin --tags", url))); - add(new Label("upstreamSyntax", "git remote add upstream ")); + add(new Label("createSyntax", createSyntax)); + add(new Label("existingSyntax", existingSyntax)); } @Override - protected Class getRootNavPageClass() { - return RepositoriesPage.class; + protected String getPageName() { + return getString("gb.summary"); } } diff --git a/src/main/java/com/gitblit/wicket/pages/EmptyRepositoryPage_es.html b/src/main/java/com/gitblit/wicket/pages/EmptyRepositoryPage_es.html index f98cb050..0f168bff 100644 --- a/src/main/java/com/gitblit/wicket/pages/EmptyRepositoryPage_es.html +++ b/src/main/java/com/gitblit/wicket/pages/EmptyRepositoryPage_es.html @@ -9,52 +9,54 @@
-

Repositorio Vacío

-

-
-
-
- [repository] es un repositorio vacío y no puede ser visto en Gitblit. -

- Por favor, empuja algunas consignas a -

-
- Después de empujar tus consignas puedes refrescar ésta página para ver tu repositorio. -
-
-
+
+
+
+

Repositorio Vacío

+
+ [repository] es un repositorio vacío y no puede ser visto en Gitblit. +

+ Por favor, empuja algunas consignas a +
+ Después de empujar tus consignas puedes refrescar ésta página para ver tu repositorio. +
-

Sintaxis de la Línea de Comandos de Git

- Si no tienes un repositiorio local Git, puedes clonar éste, consignar algunos archivos, y después empujar las consignas de vuelta a Gitblit. -

-

-		

- Si ya tienes un repositorio local Git con algunas consignas, puedes añadir éste como remoto y empujar desde allí. -

-

-		Si el repositorio está pensado para mantenerse sincronizado con otro repositorio corriente-arriba, entonces puedes añadirlo.
-		

-

-		

-

Aprender sobre Git

- Si no estás seguro de como usar esta información, échale un vistazo al Libro de la cominidad Git o Pro Git para una mejor compresión de como usar Git. -

+

Create a new repository on the command-line

+ +

+
+	

Push an existing repository from the command-line

+ +

+
+	
+

Aprender sobre Git

+

Si no estás seguro de como usar esta información, échale un vistazo al Libro de la cominidad Git para una mejor compresión de como usar Git.

+

Clientes Git de Código abierto.

-
    -
  • Git - El Git oficial en línea de comandos
  • -
  • TortoiseGit - Explorador de archivos integrado en Windows (necesita Git oficial en línea de comandos)
  • -
  • Eclipse/EGit - Git para el IDE de Eclipse (basado en JGit, como Gitblit)
  • -
  • Git Extensions - Interfaz de usuario gráfico Git en C# con integración en IE y en Visual Studio
  • -
  • GitX-dev - Cliente Git para Mac OS X
  • -
-

+ + + + + + + + +
GitEl Git oficial en línea de comandos
TortoiseGitExplorador de archivos integrado en Windows (necesita Git oficial en línea de comandos)
Eclipse/EGitGit para el IDE de Eclipse (basado en JGit, como Gitblit)
Git ExtensionsInterfaz de usuario gráfico Git en C# con integración en IE y en Visual Studio
GitX-devCliente Git para Mac OS X
+

Clientes Git comerciales

-
    -
  • SmartGit/Hg - aplicación Java (necesita Git oficial en línea de comandos)
  • -
  • SourceTree - Un cliente Git gratuito para Mac, Mercurial, y SVN
  • -
  • Tower - Cliente Git para Mac OS X
  • -
-
+ + + + + + +
SmartGit/Hgaplicación Java (necesita Git oficial en línea de comandos)
SourceTreeUn cliente Git gratuito para Mac, Mercurial, y SVN
TowerCliente Git para Mac OS X
+
+
+
+
+
diff --git a/src/main/java/com/gitblit/wicket/pages/EmptyRepositoryPage_ko.html b/src/main/java/com/gitblit/wicket/pages/EmptyRepositoryPage_ko.html index 4027f0e3..bd1f4f5f 100644 --- a/src/main/java/com/gitblit/wicket/pages/EmptyRepositoryPage_ko.html +++ b/src/main/java/com/gitblit/wicket/pages/EmptyRepositoryPage_ko.html @@ -7,55 +7,54 @@
-

비어있는 저장소

-

-
-
-
- [repository] 저장소는 비어 있어서 Gitblit 에서 볼 수 없습니다. -

- 이 Git url 에 커밋해 주세요. -

-
- After you have pushed commits you may refresh this page to view your repository. -
-
-
+
+
+
+

비어있는 저장소

+
+ [repository] 저장소는 비어 있어서 Gitblit 에서 볼 수 없습니다. +

+ 이 Git url 에 커밋해 주세요. +
+ After you have pushed commits you may refresh this page to view your repository. +
+ +

Create a new repository on the command-line

+ +

+
+	

Push an existing repository from the command-line

+ +

+
+	
+

Git 배우기

+

만약 사용법에 자신이 없다면, Git 사용법을 더 잘 이해하기 위해 + Git Community Book 또는 을 볼 것을 고려해 보세요.

-

-

Git 명령어

- 로컬 Git 저장소가 없다면, 이 저장소를 클론(clone) 한 후, 몇 파일을 커밋하고, 그 커밋을 Gitblit 에 푸시(push) 하세요. -

-

-		

- 만약 커밋된 로컬 Git 저장소가 있다면, 다음과 같이 저장소에 리모트를 추가하고 푸시(push)할 수 있습니다. -

-

-		If your repository is meant to be kept in sync with an upstream repository, then you may add it.
-		

-

-		

-

Git 배우기

- 만약 사용법에 자신이 없다면, Git 사용법을 더 잘 이해하기 위해 - Git Community Book 또는 - Pro Git, - Pro Git 한글 을 볼 것을 고려해 보세요. -

오픈소스 Git 클라이언트

-
    -
  • Git - 명령어 기반 공식 Git
  • -
  • TortoiseGit - 윈도의 파일 탐색기에 통합된 UI 클라이언트 (명령어 기반 공식 Git 필요)
  • -
  • Eclipse/EGit - 이클립스 IDE 플러그인 (Gitblit 과 같은 JGit 기반)
  • -
  • Git Extensions - C# frontend for Git that features Windows Explorer and Visual Studio integration
  • -
  • GitX-dev - a Mac OS X Git client
  • -
-

+ + + + + + + + +
Git명령어 기반 공식 Git
TortoiseGit윈도의 파일 탐색기에 통합된 UI 클라이언트 (명령어 기반 공식 Git 필요)
Eclipse/EGit이클립스 IDE 플러그인 (Gitblit 과 같은 JGit 기반)
Git ExtensionsC# frontend for Git that features Windows Explorer and Visual Studio integration
GitX-deva Mac OS X Git client
+

유료 Git 클라이언트

-
    -
  • SmartGit/Hg - 자바 어플리케이션 (명령어 기반 공식 Git 필요)
  • -
  • SourceTree - A free Mac Client for Git, Mercurial, and SVN
  • -
  • Tower - a Mac OS X Git client
  • -
+ + + + + + +
SmartGit/Hg자바 어플리케이션 (명령어 기반 공식 Git 필요)
SourceTreeA free Git and Mercurial client for Windows & Mac
Towera Mac OS X Git client
+
+
+
+
diff --git a/src/main/java/com/gitblit/wicket/pages/EmptyRepositoryPage_nl.html b/src/main/java/com/gitblit/wicket/pages/EmptyRepositoryPage_nl.html index 1fc3fe8d..dd58ed46 100644 --- a/src/main/java/com/gitblit/wicket/pages/EmptyRepositoryPage_nl.html +++ b/src/main/java/com/gitblit/wicket/pages/EmptyRepositoryPage_nl.html @@ -7,52 +7,53 @@
-

Lege Repository

-

-
-
-
- [repository] is een lege repository en kan niet bekeken worden door Gitblit. -

- Push alstublieft een paar commits naar -

-
- Nadat u een commits gepushed heeft, kunt u deze pagina verversen om uw repository te bekijken. -
-
-
+
+
+
+

Lege Repository

+
+ [repository] is een lege repository en kan niet bekeken worden door Gitblit. +

+ Push alstublieft een paar commits naar +
+ Nadat u een commits gepushed heeft, kunt u deze pagina verversen om uw repository te bekijken. +
-

Git Command-Line Syntax

- Als u geen lokale Git repository heeft, kunt u deze repository clonen, er bestanden naar committen en dan uw commits terug pushen naar Gitblit. -

-

-		

- Als u al een lokale Git repository met commits heeft, kunt u deze repository als een remote toevoegen en er naar pushen. -

-

-		

- Indien uw repository bedoeld is om synchroon gehouden te worden met een upstream repository, dan kunt u deze toevoegen. -

-

-		

-

Leer Git

- Als u niet goed weet wat u met deze informatie aan moet, raden we u aan om het Git Community Book of Pro Git te bestuderen voor een beter begrip over hoe u Git kunt gebruiken. -

+

Create a new repository on the command-line

+ +

+
+	

Push an existing repository from the command-line

+ +

+
+	
+

Leer Git

+

Als u niet goed weet wat u met deze informatie aan moet, raden we u aan om het Git Community Book te bestuderen voor een beter begrip over hoe u Git kunt gebruiken.

+

Open Source Git Clients

-
    -
  • Git - de officiele, command-line Git
  • -
  • TortoiseGit - Windows bestandsverkenner ingetratie (officiele command-line Git is wel nodig)
  • -
  • Eclipse/EGit - Git voor de Eclipse IDE (gebaseerd op JGit, zoals Gitblit)
  • -
  • Git Extensions - C# frontend voor Git met Windows Explorer en Visual Studio integratie
  • -
  • GitX-dev - een Mac OS X Git client
  • -
-

+ + + + + + + + +
Gitde officiele, command-line Git
TortoiseGitWindows bestandsverkenner ingetratie (officiele command-line Git is wel nodig)
Eclipse/EGitGit voor de Eclipse IDE (gebaseerd op JGit, zoals Gitblit)
Git ExtensionsC# frontend voor Git met Windows Explorer en Visual Studio integratie
GitX-deveen Mac OS X Git client
+

Commercial/Closed-Source Git Clients

-
    -
  • SmartGit/Hg - Een Java Git, Mercurial, en SVN client applicatie (officiele command-line Git is wel nodig)
  • -
  • SourceTree - Een gratis Mac Client voor Git, Mercurial, en SVN
  • -
  • Tower - een Mac OS X Git client
  • -
+ + + + + + +
SmartGit/HgEen Java Git, Mercurial, en SVN client applicatie (officiele command-line Git is wel nodig)
SourceTreeEen gratis Mac Client voor Git en Mercurial
Towereen Mac OS X Git client
+
+
+
+
diff --git a/src/main/java/com/gitblit/wicket/pages/EmptyRepositoryPage_pl.html b/src/main/java/com/gitblit/wicket/pages/EmptyRepositoryPage_pl.html index 3f9db908..dd0f4a5d 100644 --- a/src/main/java/com/gitblit/wicket/pages/EmptyRepositoryPage_pl.html +++ b/src/main/java/com/gitblit/wicket/pages/EmptyRepositoryPage_pl.html @@ -9,51 +9,53 @@
-

Puste repozytorium

-

-
-
-
- [repository] jest pustym repozytorium i nie może być zaprezentowane przez Gitblit. -

- Wgraj, poprzez push, dowolne zmiany do lokalizacji -

-
- Po wgraniu zmian odśwież stronę, aby podejrzeć repozytorium. -
-
-
+
+
+
+

Puste repozytorium

+
+ [repository] jest pustym repozytorium i nie może być zaprezentowane przez Gitblit. +

+ Wgraj, poprzez push, dowolne zmiany do lokalizacji +
+ Po wgraniu zmian odśwież stronę, aby podejrzeć repozytorium. +
-

Składnia linii poleceń GITa

- Jeśli nie posiadasz lokalnego repozytorium GITa to sklonuj to repozytorium, wgraj dowolne pliki, a następnie wyślij poprzez push zmiany na Gitblit. -

-

-		

- Gdy posiadasz lokalne repozytorium GITa z dowolnymi zmianami, to możesz dodać to repozytorium jako remote i wysłać do niego zmiany poprzez push. -

-

-		If your repository is meant to be kept in sync with an upstream repository, then you may add it.
-		

-

-		

-

Nauka GITa

- Jeżeli powyższe informacje są dla Ciebie niezrozumiałe, zapoznaj się z książką Pro Git - Wersja PL dla lepszego zrozumienia, jak poprawnie używać GITa. -

+

Create a new repository on the command-line

+ +

+
+	

Push an existing repository from the command-line

+ +

+
+	
+

Nauka GITa

+

Jeżeli powyższe informacje są dla Ciebie niezrozumiałe, zapoznaj się z książką Pro Git - Wersja PL dla lepszego zrozumienia, jak poprawnie używać GITa.

+

Darmowi klienci GITa

-
    -
  • Git - Oficjalny klient, dostępny przez linię poleceń
  • -
  • TortoiseGit - Rozszerzenie eksploratora Windows (wymaga oficjalnego, dostępnego przez linię poleceń klienta)
  • -
  • Eclipse/EGit - GIT dla edytora Eclipse (oparty o JGit, podobnie jak Gitblit)
  • -
  • Git Extensions - napisana w C# fasada na GIT, udostępniająca integrację dla Windows Explorer oraz Visual Studio
  • -
  • GitX-dev - klient GIT na Mac OS X
  • -
-

+ + + + + + + + +
GitOficjalny klient, dostępny przez linię poleceń
TortoiseGitRozszerzenie eksploratora Windows (wymaga oficjalnego, dostępnego przez linię poleceń klienta)
Eclipse/EGitGIT dla edytora Eclipse (oparty o JGit, podobnie jak Gitblit)
Git Extensionsnapisana w C# fasada na GIT, udostępniająca integrację dla Windows Explorer oraz Visual Studio
GitX-devklient GIT na Mac OS X
+

Komercyjni klienci GITa

-
    -
  • SmartGit/Hg - aplikacja napisana w Javie (wymaga oficjalnego, dostępnego przez linię poleceń klienta)
  • -
  • SourceTree - darmowy klient GIT, Mercurial i SVN na Mac OS X
  • -
  • Tower - klient GIT na Mac OS X
  • -
+ + + + + + +
SmartGit/Hgaplikacja napisana w Javie (wymaga oficjalnego, dostępnego przez linię poleceń klienta)
SourceTreedarmowy klient GIT, Mercurial i SVN na Mac OS X
Towerklient GIT na Mac OS X
+
+
+
+
diff --git a/src/main/java/com/gitblit/wicket/pages/EmptyRepositoryPage_pt_BR.html b/src/main/java/com/gitblit/wicket/pages/EmptyRepositoryPage_pt_BR.html index 351fe872..0182d87e 100644 --- a/src/main/java/com/gitblit/wicket/pages/EmptyRepositoryPage_pt_BR.html +++ b/src/main/java/com/gitblit/wicket/pages/EmptyRepositoryPage_pt_BR.html @@ -7,51 +7,53 @@
-

Repositório Vazio

-

-
-
-
- [repository] é um repositório vazio e não pode ser visualizado pelo Gitblit. -

- Por favor faça o push de alguns commits para -

-
- Depois de ter feito push você poderá atualizar esta página para visualizar seu repositório. -
-
-
+
+
+
+

Repositório Vazio

+
+ [repository] é um repositório vazio e não pode ser visualizado pelo Gitblit. +

+ Por favor faça o push de alguns commits para +
+ Depois de ter feito push você poderá atualizar esta página para visualizar seu repositório. +
-

Sintaxe dos comandos do Git

- Se você ainda não tem um repositório local do Git, então você deve primeiro clonar este repositório, fazer commit de alguns arquivos e então fazer push desses commits para o Gitblit. -

-

-		

- Se você já tem um repositório Git local com alguns commits, então você deve adicionar este repositório como uma referência remota e então fazer push. -

-

-		If your repository is meant to be kept in sync with an upstream repository, then you may add it.
-		

-

-		

-

Aprenda Git

- Se você estiver com dúvidas sobre como ultilizar essas informações, uma sugestão seria dar uma olhada no livro Git Community Book ou Pro Git para entender melhor como usar o Git. -

+

Create a new repository on the command-line

+ +

+
+	

Push an existing repository from the command-line

+ +

+
+	
+

Aprenda Git

+

Se você estiver com dúvidas sobre como ultilizar essas informações, uma sugestão seria dar uma olhada no livro Git Community Book para entender melhor como usar o Git.

+

Alguns clients do Git que são Open Source

-
    -
  • Git - o Git oficial através de linhas de comando
  • -
  • TortoiseGit - Faz integração do Explorer do Windows com o Git (por isso requer o Git Oficial)
  • -
  • Eclipse/EGit - Git para a IDE Eclipse (baseada no JGit, como o Gitblit)
  • -
  • Git Extensions - Interface (em C#) para o Git cuja a característica é a integração com o Windows Explorer e o Visual Studio
  • -
  • GitX-dev - um Cliente do Git para Mac OS X
  • -
-

+ + + + + + + + +
Gito Git oficial através de linhas de comando
TortoiseGitFaz integração do Explorer do Windows com o Git (por isso requer o Git Oficial)
Eclipse/EGitGit para a IDE Eclipse (baseada no JGit, como o Gitblit)
Git ExtensionsInterface (em C#) para o Git cuja a característica é a integração com o Windows Explorer e o Visual Studio
GitX-devum Cliente do Git para Mac OS X
+

Clients do Git proprietários ou com Código Proprietário

-
    -
  • SmartGit/Hg - Aplicação Client (em Java) para Git, Mercurial, e SVN (por isso requer o Git Oficial)
  • -
  • SourceTree - Client gratuito para o Mac que suporta Git, Mercurial e SVN
  • -
  • Tower - um Cliente do Git para Mac OS X
  • -
+ + + + + + +
SmartGit/HgAplicação Client (em Java) para Git e Mercurial (por isso requer o Git Oficial)
SourceTreeClient gratuito para o Mac que suporta Git e Mercurial
Towerum Cliente do Git para Mac OS X
+
+
+
+
diff --git a/src/main/java/com/gitblit/wicket/pages/EmptyRepositoryPage_zh_CN.html b/src/main/java/com/gitblit/wicket/pages/EmptyRepositoryPage_zh_CN.html index 955b4312..151abc42 100644 --- a/src/main/java/com/gitblit/wicket/pages/EmptyRepositoryPage_zh_CN.html +++ b/src/main/java/com/gitblit/wicket/pages/EmptyRepositoryPage_zh_CN.html @@ -7,53 +7,54 @@
-

空版本库

-

-
-
-
- [repository] 版本库目前为空。 - Gitblit 无法查看。 -

- 请往此网址进行推送 -

-
- 当你推送完毕后你可以 刷新 此页面重新查看您的版本库。 -
-
-
+
+
+
+

空版本库

+
+ [repository] 版本库目前为空。 + Gitblit 无法查看。 +

+ 请往此网址进行推送 +
+ 当你推送完毕后你可以 刷新 此页面重新查看您的版本库。 +
-

Git 命令行格式

- 如果您没有本地 Git 版本库, 您可以克隆此版本库, 提交一些文件, 然后将您的提交推送回Gitblit。 -

-

-		

- 如果您已经有一个本地的提交过的版本库, 那么您可以将此版本库加为远程 - 版本库,并进行推送。 -

-

-		If your repository is meant to be kept in sync with an upstream repository, then you may add it.
-		

-

-		

-

学习 Git

- 如果您不明白这些信息什么意思, 您可以参考 Git Community Book 或者 Pro Git 去更加深入的学习 Git 的用法。 -

+

Create a new repository on the command-line

+ +

+
+	

Push an existing repository from the command-line

+ +

+
+	
+

学习 Git

+

如果您不明白这些信息什么意思, 您可以参考 Git Community Book 去更加深入的学习 Git 的用法。

+

开源 Git 客户端

-
    -
  • Git - 官方, 命令行版本 Git
  • -
  • TortoiseGit - 与 Windows 资源管理器集成 (需要官方, 命令行 Git 的支持)
  • -
  • Eclipse/EGit - Git for the Eclipse IDE (基于 JGit, 类似 Gitblit)
  • -
  • Git Extensions - C# 版本的 Git 前端,与 Windows 资源管理器和 Visual Studio 集成
  • -
  • GitX-dev - Mac OS X Git 客户端
  • -
-

+ + + + + + + + +
Git官方, 命令行版本 Git
TortoiseGit与 Windows 资源管理器集成 (需要官方, 命令行 Git 的支持)
Eclipse/EGitGit for the Eclipse IDE (基于 JGit, 类似 Gitblit)
Git ExtensionsC# 版本的 Git 前端,与 Windows 资源管理器和 Visual Studio 集成
GitX-devMac OS X Git 客户端
+

商业/闭源 Git 客户端

-
    -
  • SmartGit/Hg - Java 版本的支持 Git, Mercurial 和 SVN 客户端应用 (需要官方, 命令行 Git 的支持)
  • -
  • SourceTree - 免费的 Mac Git Mercurial 以及 SVN 客户端, Mercurial, and SVN
  • -
  • Tower - Mac OS X Git 客户端
  • -
+ + + + + + +
SmartGit/HgJava 版本的支持 Git, Mercurial 和 SVN 客户端应用 (需要官方, 命令行 Git 的支持)
SourceTree免费的 Mac Git Mercurial 以及 SVN 客户端 and Mercurial
TowerMac OS X Git 客户端
+
+
+
+
diff --git a/src/main/java/com/gitblit/wicket/pages/RepositoryPage.java b/src/main/java/com/gitblit/wicket/pages/RepositoryPage.java index a0c9ce01..fcf659af 100644 --- a/src/main/java/com/gitblit/wicket/pages/RepositoryPage.java +++ b/src/main/java/com/gitblit/wicket/pages/RepositoryPage.java @@ -108,7 +108,7 @@ public abstract class RepositoryPage extends RootPage { error(MessageFormat.format(getString("gb.repositoryNotSpecifiedFor"), getPageName()), true); } - if (!getRepositoryModel().hasCommits) { + if (!getRepositoryModel().hasCommits && getClass() != EmptyRepositoryPage.class) { throw new RestartResponseException(EmptyRepositoryPage.class, params); } @@ -148,6 +148,16 @@ public abstract class RepositoryPage extends RootPage { } } + showAdmin = false; + if (app().settings().getBoolean(Keys.web.authenticateAdminPages, true)) { + boolean allowAdmin = app().settings().getBoolean(Keys.web.allowAdministration, false); + showAdmin = allowAdmin && GitBlitWebSession.get().canAdmin(); + } else { + showAdmin = app().settings().getBoolean(Keys.web.allowAdministration, false); + } + isOwner = GitBlitWebSession.get().isLoggedIn() + && (getRepositoryModel().isOwner(GitBlitWebSession.get().getUsername())); + // register the available navigation links for this page and user List navLinks = registerNavLinks(); @@ -195,9 +205,14 @@ public abstract class RepositoryPage extends RootPage { navLinks.add(new PageNavLink("gb.summary", SummaryPage.class, params)); } else { navLinks.add(new PageNavLink("gb.summary", SummaryPage.class, params)); -// pages.put("overview", new PageRegistration("gb.overview", OverviewPage.class, params)); + // pages.put("overview", new PageRegistration("gb.overview", OverviewPage.class, params)); navLinks.add(new PageNavLink("gb.reflog", ReflogPage.class, params)); } + + if (!model.hasCommits) { + return navLinks; + } + navLinks.add(new PageNavLink("gb.commits", LogPage.class, params)); navLinks.add(new PageNavLink("gb.tree", TreePage.class, params)); if (app().tickets().isReady() && (app().tickets().isAcceptingNewTickets(model) || app().tickets().hasTickets(model))) { @@ -229,16 +244,6 @@ public abstract class RepositoryPage extends RootPage { navLinks.addAll(ext.getNavLinks(user, model)); } - // Conditionally add edit link - showAdmin = false; - if (app().settings().getBoolean(Keys.web.authenticateAdminPages, true)) { - boolean allowAdmin = app().settings().getBoolean(Keys.web.allowAdministration, false); - showAdmin = allowAdmin && GitBlitWebSession.get().canAdmin(); - } else { - showAdmin = app().settings().getBoolean(Keys.web.allowAdministration, false); - } - isOwner = GitBlitWebSession.get().isLoggedIn() - && (model.isOwner(GitBlitWebSession.get().getUsername())); return navLinks; } @@ -311,7 +316,7 @@ public abstract class RepositoryPage extends RootPage { } // (un)star link allows a user to star a repository - if (user.isAuthenticated) { + if (user.isAuthenticated && model.hasCommits) { PageParameters starParams = DeepCopier.copy(getPageParameters()); starParams.put(PARAM_STAR, !user.getPreferences().isStarredRepository(model.name)); String toggleStarUrl = getRequestCycle().urlFor(getClass(), starParams).toString(); @@ -338,7 +343,7 @@ public abstract class RepositoryPage extends RootPage { } else { String fork = app().repositories().getFork(user.username, model.name); boolean hasFork = fork != null; - boolean canFork = user.canFork(model); + boolean canFork = user.canFork(model) && model.hasCommits; if (hasFork || !canFork) { // user not allowed to fork or fork already exists or repo forbids forking diff --git a/src/main/java/com/gitblit/wicket/pages/create_git.md b/src/main/java/com/gitblit/wicket/pages/create_git.md new file mode 100644 index 00000000..309ac675 --- /dev/null +++ b/src/main/java/com/gitblit/wicket/pages/create_git.md @@ -0,0 +1,6 @@ + touch README.md + git init + git add README.md + git commit -m "first commit" + git remote add origin ${primaryUrl} + git push -u origin master diff --git a/src/main/java/com/gitblit/wicket/pages/existing_git.md b/src/main/java/com/gitblit/wicket/pages/existing_git.md new file mode 100644 index 00000000..0a6fad9a --- /dev/null +++ b/src/main/java/com/gitblit/wicket/pages/existing_git.md @@ -0,0 +1,2 @@ + git remote add origin ${primaryUrl} + git push -u origin master -- cgit v1.2.3