- fixed: several a bugs in FileUserService related to cleaning up old repository permissions on a rename or delete\r
- added: optional flash-based 1-step *copy to clipboard* of the primary repository url\r
- added: javascript-based 3-step (click, ctrl+c, enter) *copy to clipboard* of the primary repository url \r
- **New:** *web.allowFlashCopyToClipboard = true* \r
+ **New:** *web.allowFlashCopyToClipboard = true*\r
+- added: Name, regex, set, and team filtering of the repositories list and the activity page via url parameters (issue 27) \r
+ Here are some url examples: \r
+ localhost/gb?r=myrepo.git *(specific repository)* \r
+ localhost/gb?x=my *(regex matching. encoding may be an issue. YMMV)* \r
+ localhost/gb?set=animal,mineral *(animal and mineral federation sets)* \r
+ localhost/qb/activity?team=qa,qa2 *(qa and qa2 teams)*\r
- improved: empty repositories now link to a new *empty repository* page which gives some direction to the user for the next step in using Gitblit. This page displays the primary push/clone url of the repository and gives sample syntax for the git command-line client. (issue 31)\r
- improved: unit testing framework has been migrated to JUnit4 syntax and the test suite has been redesigned to run all unit tests, including rpc, federation, and git push/clone tests\r
\r
return params.getInt("pg", 1);\r
}\r
\r
+ public static String getRegEx(PageParameters params) {\r
+ return params.getString("x", "");\r
+ }\r
+\r
public static String getSet(PageParameters params) {\r
return params.getString("set", "");\r
}\r
\r
+ public static String getTeam(PageParameters params) {\r
+ return params.getString("team", "");\r
+ }\r
+\r
public static int getDaysBack(PageParameters params) {\r
return params.getInt("db", 14);\r
}\r
\r
import java.text.MessageFormat;\r
import java.text.SimpleDateFormat;\r
-import java.util.ArrayList;\r
import java.util.Collections;\r
import java.util.HashMap;\r
import java.util.HashSet;\r
import org.apache.wicket.behavior.HeaderContributor;\r
import org.apache.wicket.markup.html.basic.Label;\r
\r
-import com.gitblit.GitBlit;\r
import com.gitblit.models.Activity;\r
import com.gitblit.models.Metric;\r
import com.gitblit.models.RepositoryModel;\r
-import com.gitblit.models.UserModel;\r
import com.gitblit.utils.ActivityUtils;\r
-import com.gitblit.utils.StringUtils;\r
-import com.gitblit.wicket.GitBlitWebSession;\r
import com.gitblit.wicket.WicketUtils;\r
import com.gitblit.wicket.charting.GoogleChart;\r
import com.gitblit.wicket.charting.GoogleCharts;\r
public class ActivityPage extends RootPage {\r
\r
public ActivityPage(PageParameters params) {\r
- super();\r
+ super(params);\r
setupPage("", "");\r
\r
// parameters\r
}\r
}\r
\r
- private List<RepositoryModel> getRepositories(PageParameters params) {\r
- final UserModel user = GitBlitWebSession.get().getUser();\r
- String set = WicketUtils.getSet(params);\r
- String repositoryName = WicketUtils.getRepositoryName(params);\r
-\r
- List<RepositoryModel> models = null;\r
- if (!StringUtils.isEmpty(repositoryName)) {\r
- // named repository\r
- models = new ArrayList<RepositoryModel>();\r
- RepositoryModel model = GitBlit.self().getRepositoryModel(repositoryName);\r
- if (user.canAccessRepository(model)) {\r
- models.add(model);\r
- }\r
- }\r
-\r
- // get all user accessible repositories\r
- if (models == null) {\r
- models = GitBlit.self().getRepositoryModels(user);\r
- }\r
-\r
- // filter the repositories by the specified set\r
- if (!StringUtils.isEmpty(set)) {\r
- List<String> sets = StringUtils.getStringsFromValue(set, ",");\r
- List<RepositoryModel> setModels = new ArrayList<RepositoryModel>();\r
- for (RepositoryModel model : models) {\r
- for (String curr : sets) {\r
- if (model.federationSets.contains(curr)) {\r
- setModels.add(model);\r
- }\r
- }\r
- }\r
- models = setModels;\r
- }\r
- return models;\r
- }\r
-\r
/**\r
* Creates the daily activity line chart, the active repositories pie chart,\r
* and the active authors pie chart\r
import java.io.InputStream;\r
import java.io.InputStreamReader;\r
import java.text.MessageFormat;\r
+import java.util.List;\r
\r
import org.apache.wicket.Component;\r
+import org.apache.wicket.PageParameters;\r
import org.apache.wicket.markup.html.basic.Label;\r
import org.apache.wicket.resource.ContextRelativeResource;\r
\r
import com.gitblit.GitBlit;\r
import com.gitblit.Keys;\r
+import com.gitblit.models.RepositoryModel;\r
import com.gitblit.utils.MarkdownUtils;\r
import com.gitblit.utils.StringUtils;\r
import com.gitblit.wicket.GitBlitWebSession;\r
\r
public RepositoriesPage() {\r
super();\r
- setupPage("", "");\r
+ setup(null);\r
+ }\r
+\r
+ public RepositoriesPage(PageParameters params) {\r
+ super(params);\r
+ setup(params);\r
+ }\r
\r
+ private void setup(PageParameters params) {\r
+ setupPage("", "");\r
// check to see if we should display a login message\r
boolean authenticateView = GitBlit.getBoolean(Keys.web.authenticateViewPages, true);\r
if (authenticateView && !GitBlitWebSession.get().isLoggedIn()) {\r
Component repositoriesMessage = new Label("repositoriesMessage", message)\r
.setEscapeModelStrings(false).setVisible(message.length() > 0);\r
add(repositoriesMessage);\r
- RepositoriesPanel repositories = new RepositoriesPanel("repositoriesPanel", showAdmin,\r
- null, getAccessRestrictions());\r
+\r
+ List<RepositoryModel> repositories = getRepositories(params);\r
+\r
+ RepositoriesPanel repositoriesPanel = new RepositoriesPanel("repositoriesPanel", showAdmin,\r
+ repositories, true, getAccessRestrictions());\r
// push the panel down if we are hiding the admin controls and the\r
// welcome message\r
if (!showAdmin && !repositoriesMessage.isVisible()) {\r
- WicketUtils.setCssStyle(repositories, "padding-top:5px;");\r
+ WicketUtils.setCssStyle(repositoriesPanel, "padding-top:5px;");\r
}\r
- add(repositories);\r
+ add(repositoriesPanel);\r
}\r
\r
private String readMarkdown(String messageSource, String resource) {\r
List<RepositoryModel> repositories = new ArrayList<RepositoryModel>(\r
proposal.repositories.values());\r
RepositoriesPanel repositoriesPanel = new RepositoriesPanel("repositoriesPanel", false,\r
- repositories, getAccessRestrictions());\r
+ repositories, false, getAccessRestrictions());\r
add(repositoriesPanel);\r
}\r
\r
import java.text.MessageFormat;\r
import java.util.ArrayList;\r
import java.util.List;\r
+import java.util.regex.Pattern;\r
\r
import org.apache.wicket.PageParameters;\r
import org.apache.wicket.markup.html.form.PasswordTextField;\r
import com.gitblit.Constants;\r
import com.gitblit.GitBlit;\r
import com.gitblit.Keys;\r
+import com.gitblit.models.RepositoryModel;\r
+import com.gitblit.models.TeamModel;\r
import com.gitblit.models.UserModel;\r
import com.gitblit.utils.StringUtils;\r
import com.gitblit.wicket.GitBlitWebSession;\r
}\r
if (showAdmin || showRegistrations) {\r
pages.add(new PageRegistration("gb.federation", FederationPage.class));\r
- } \r
+ }\r
NavigationPanel navPanel = new NavigationPanel("navPanel", getClass(), pages);\r
add(navPanel);\r
\r
}\r
}\r
}\r
+\r
+ protected List<RepositoryModel> getRepositories(PageParameters params) {\r
+ final UserModel user = GitBlitWebSession.get().getUser();\r
+ if (params == null) {\r
+ return GitBlit.self().getRepositoryModels(user);\r
+ }\r
+\r
+ String repositoryName = WicketUtils.getRepositoryName(params);\r
+ String set = WicketUtils.getSet(params);\r
+ String regex = WicketUtils.getRegEx(params);\r
+ String team = WicketUtils.getTeam(params);\r
+\r
+ List<RepositoryModel> models = null;\r
+\r
+ if (!StringUtils.isEmpty(repositoryName)) {\r
+ // try named repository\r
+ models = new ArrayList<RepositoryModel>();\r
+ RepositoryModel model = GitBlit.self().getRepositoryModel(repositoryName);\r
+ if (user.canAccessRepository(model)) {\r
+ models.add(model);\r
+ }\r
+ }\r
+\r
+ // get all user accessible repositories\r
+ if (models == null) {\r
+ models = GitBlit.self().getRepositoryModels(user);\r
+ }\r
+\r
+ if (!StringUtils.isEmpty(regex)) {\r
+ // filter the repositories by the regex\r
+ List<RepositoryModel> accessible = GitBlit.self().getRepositoryModels(user);\r
+ List<RepositoryModel> matchingModels = new ArrayList<RepositoryModel>();\r
+ Pattern pattern = Pattern.compile(regex);\r
+ for (RepositoryModel aModel : accessible) {\r
+ if (pattern.matcher(aModel.name).find()) {\r
+ matchingModels.add(aModel);\r
+ }\r
+ }\r
+ models = matchingModels;\r
+ } else if (!StringUtils.isEmpty(set)) {\r
+ // filter the repositories by the specified sets\r
+ List<String> sets = StringUtils.getStringsFromValue(set, ",");\r
+ List<RepositoryModel> matchingModels = new ArrayList<RepositoryModel>();\r
+ for (RepositoryModel model : models) {\r
+ for (String curr : sets) {\r
+ if (model.federationSets.contains(curr)) {\r
+ matchingModels.add(model);\r
+ }\r
+ }\r
+ }\r
+ models = matchingModels;\r
+ } else if (!StringUtils.isEmpty(team)) {\r
+ // filter the repositories by the specified teams\r
+ List<String> teams = StringUtils.getStringsFromValue(team, ",");\r
+ \r
+ // need TeamModels first\r
+ List<TeamModel> teamModels = new ArrayList<TeamModel>();\r
+ for (String name : teams) {\r
+ TeamModel model = GitBlit.self().getTeamModel(name);\r
+ if (model != null) {\r
+ teamModels.add(model);\r
+ }\r
+ }\r
+ \r
+ // brute-force our way through finding the matching models\r
+ List<RepositoryModel> matchingModels = new ArrayList<RepositoryModel>();\r
+ for (RepositoryModel repositoryModel : models) {\r
+ for (TeamModel teamModel : teamModels) {\r
+ if (teamModel.hasRepository(repositoryModel.name)) {\r
+ matchingModels.add(repositoryModel);\r
+ }\r
+ }\r
+ }\r
+ models = matchingModels;\r
+ }\r
+ return models;\r
+ }\r
}\r
List<RepositoryModel> repositories = new ArrayList<RepositoryModel>(\r
proposal.repositories.values());\r
RepositoriesPanel repositoriesPanel = new RepositoriesPanel("repositoriesPanel", false,\r
- repositories, getAccessRestrictions());\r
+ repositories, false, getAccessRestrictions());\r
add(repositoriesPanel);\r
}\r
}\r
private static final long serialVersionUID = 1L;\r
\r
public RepositoriesPanel(String wicketId, final boolean showAdmin,\r
- List<RepositoryModel> models,\r
+ List<RepositoryModel> models, boolean enableLinks,\r
final Map<AccessRestrictionType, String> accessRestrictionTranslations) {\r
super(wicketId);\r
\r
- final boolean linksActive;\r
+ final boolean linksActive = enableLinks;\r
final boolean showSize = GitBlit.getBoolean(Keys.web.showRepositorySizes, true);\r
\r
final UserModel user = GitBlitWebSession.get().getUser();\r
- if (models == null) {\r
- linksActive = true;\r
- models = GitBlit.self().getRepositoryModels(user);\r
- } else {\r
- // disable links if the repositories are already provided\r
- // the repositories are most likely from a proposal\r
- linksActive = false;\r
- }\r
\r
final IDataProvider<RepositoryModel> dp;\r
\r