summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJames Moger <james.moger@gitblit.com>2011-04-06 17:25:23 -0400
committerJames Moger <james.moger@gitblit.com>2011-04-06 17:25:23 -0400
commit7ba0ec1e871a1f7b5a40b3272e860ade13038e95 (patch)
tree3ba89d94a01f6454235cd2636ecaa3c1c7c6a306 /src
parent87c3d714693b216cee9c31cdc5170715c56f541d (diff)
downloadgitblit-7ba0ec1e871a1f7b5a40b3272e860ade13038e95.tar.gz
gitblit-7ba0ec1e871a1f7b5a40b3272e860ade13038e95.zip
Added placeholder for Admin links on main page.
Added placeholder for Admin links on main page. Dynamically add ticgit link to nav links, if ticgit branch is discovered. Settings refinements.
Diffstat (limited to 'src')
-rw-r--r--src/com/gitblit/GitBlitServer.java98
-rw-r--r--src/com/gitblit/wicket/RepositoryPage.java49
-rw-r--r--src/com/gitblit/wicket/pages/DiffPage.html2
-rw-r--r--src/com/gitblit/wicket/pages/RepositoriesPage.html6
-rw-r--r--src/com/gitblit/wicket/pages/RepositoriesPage.java5
-rw-r--r--src/com/gitblit/wicket/pages/TicGitPage.html2
-rw-r--r--src/com/gitblit/wicket/pages/TicGitTicketPage.java18
-rw-r--r--src/com/gitblit/wicket/panels/AdminLinksPanel.html9
-rw-r--r--src/com/gitblit/wicket/panels/AdminLinksPanel.java16
-rw-r--r--src/com/gitblit/wicket/panels/PageFooter.java2
-rw-r--r--src/com/gitblit/wicket/panels/PageLinksPanel.html2
-rw-r--r--src/com/gitblit/wicket/panels/PageLinksPanel.java42
12 files changed, 169 insertions, 82 deletions
diff --git a/src/com/gitblit/GitBlitServer.java b/src/com/gitblit/GitBlitServer.java
index ae542e8d..9991a75d 100644
--- a/src/com/gitblit/GitBlitServer.java
+++ b/src/com/gitblit/GitBlitServer.java
@@ -40,7 +40,6 @@ import org.eclipse.jetty.util.thread.QueuedThreadPool;
import org.eclipse.jetty.webapp.WebAppContext;
import org.eclipse.jgit.http.server.GitServlet;
-
import com.beust.jcommander.JCommander;
import com.beust.jcommander.Parameter;
import com.beust.jcommander.ParameterException;
@@ -134,7 +133,7 @@ public class GitBlitServer {
Connector httpConnector = createConnector(params.useNIO, params.port);
connectors.add(httpConnector);
}
-
+
if (params.securePort > 0) {
if (new File("keystore").exists()) {
Connector secureConnector = createSSLConnector(params.useNIO, params.securePort, params.storePassword);
@@ -176,51 +175,58 @@ public class GitBlitServer {
wicketFilter.setInitParameter(WicketFilter.FILTER_MAPPING_PARAM, wicketPathSpec);
rootContext.addFilter(wicketFilter, wicketPathSpec, FilterMapping.DEFAULT);
- // GIT Servlet
- String gitServletPathSpec = "/git/*";
- ServletHolder gitServlet = rootContext.addServlet(GitServlet.class, gitServletPathSpec);
- gitServlet.setInitParameter("base-path", params.repositoriesFolder);
- gitServlet.setInitParameter("export-all", params.exportAll ? "1" : "0");
-
- String realmUsers = params.realmFile;
-
- // Authentication Realm
Handler handler;
- if (realmUsers != null && new File(realmUsers).exists() && params.authenticateAccess) {
- List<String> list = StoredSettings.getStrings("gitRoles");
- String[] roles;
- if (list.size() == 0) {
- roles = new String[] { "*" };
+
+ // Git Servlet
+ ServletHolder gitServlet = null;
+ String gitServletPathSpec = "/git/*";
+ if (StoredSettings.getBoolean("allowPushPull", true)) {
+ gitServlet = rootContext.addServlet(GitServlet.class, gitServletPathSpec);
+ gitServlet.setInitParameter("base-path", params.repositoriesFolder);
+ gitServlet.setInitParameter("export-all", params.exportAll ? "1" : "0");
+ String realmUsers = params.realmFile;
+
+ if (realmUsers != null && new File(realmUsers).exists() && params.authenticatePushPull) {
+ // Authenticate Pull/Push
+ List<String> list = StoredSettings.getStrings("gitRoles");
+ String[] roles;
+ if (list.size() == 0) {
+ roles = new String[] { "*" };
+ } else {
+ roles = list.toArray(new String[list.size()]);
+ }
+ logger.info("Authentication required for git servlet pull/push access");
+ logger.info("Setting up realm from " + realmUsers);
+ HashLoginService loginService = new HashLoginService(Constants.NAME, realmUsers);
+
+ Constraint constraint = new Constraint();
+ constraint.setName("auth");
+ constraint.setAuthenticate(true);
+ constraint.setRoles(roles);
+
+ ConstraintMapping mapping = new ConstraintMapping();
+ mapping.setPathSpec(gitServletPathSpec);
+ mapping.setConstraint(constraint);
+
+ ConstraintSecurityHandler security = new ConstraintSecurityHandler();
+ security.addConstraintMapping(mapping);
+ for (String role : roles) {
+ security.addRole(role);
+ }
+ security.setAuthenticator(new BasicAuthenticator());
+ security.setLoginService(loginService);
+ security.setStrict(false);
+
+ security.setHandler(rootContext);
+
+ handler = security;
} else {
- roles = list.toArray(new String[list.size()]);
- }
- logger.info("Authentication required for GIT access");
- logger.info("Setting up realm from " + realmUsers);
- HashLoginService loginService = new HashLoginService(Constants.NAME, realmUsers);
-
- Constraint constraint = new Constraint();
- constraint.setName("auth");
- constraint.setAuthenticate(true);
- constraint.setRoles(roles);
-
- ConstraintMapping mapping = new ConstraintMapping();
- mapping.setPathSpec(gitServletPathSpec);
- mapping.setConstraint(constraint);
-
- ConstraintSecurityHandler security = new ConstraintSecurityHandler();
- security.addConstraintMapping(mapping);
- for (String role : roles) {
- security.addRole(role);
+ // Anonymous Pull/Push
+ logger.info("Setting up anonymous git servlet pull/push access");
+ handler = rootContext;
}
- security.setAuthenticator(new BasicAuthenticator());
- security.setLoginService(loginService);
- security.setStrict(false);
-
- security.setHandler(rootContext);
-
- handler = security;
} else {
- logger.info("Setting up anonymous access");
+ logger.info("Git servlet pull/push disabled");
handler = rootContext;
}
@@ -356,7 +362,7 @@ public class GitBlitServer {
/*
* GIT Servlet Parameters
*/
- @Parameter(names = { "--repos" }, description = "GIT Repositories Folder")
+ @Parameter(names = { "--repos" }, description = "Git Repositories Folder")
public String repositoriesFolder = StoredSettings.getString("repositoriesFolder", "repos");
@Parameter(names = { "--exportAll" }, description = "Export All Found Repositories")
@@ -365,8 +371,8 @@ public class GitBlitServer {
/*
* Authentication Parameters
*/
- @Parameter(names = { "--authenticateAccess" }, description = "Authenticate GIT access")
- public Boolean authenticateAccess = StoredSettings.getBoolean("authenticateAccess", true);
+ @Parameter(names = { "--authenticatePushPull" }, description = "Authenticate Git Push/Pull access")
+ public Boolean authenticatePushPull = StoredSettings.getBoolean("authenticatePushPull", true);
@Parameter(names = { "--realm" }, description = "Users Realm Hash File")
public String realmFile = StoredSettings.getString("realmFile", "users.properties");
diff --git a/src/com/gitblit/wicket/RepositoryPage.java b/src/com/gitblit/wicket/RepositoryPage.java
index b4f6fdc3..2f2b9676 100644
--- a/src/com/gitblit/wicket/RepositoryPage.java
+++ b/src/com/gitblit/wicket/RepositoryPage.java
@@ -20,13 +20,14 @@ import com.gitblit.wicket.panels.PageHeader;
import com.gitblit.wicket.panels.PageLinksPanel;
import com.gitblit.wicket.panels.RefsPanel;
-
public abstract class RepositoryPage extends BasePage {
protected final String repositoryName;
protected final String commitId;
protected String description;
+ private transient Repository r = null;
+
public RepositoryPage(PageParameters params, String pageName) {
super(params);
if (!params.containsKey("p")) {
@@ -36,23 +37,28 @@ public abstract class RepositoryPage extends BasePage {
repositoryName = params.getString("p", "");
commitId = params.getString("h", "");
+ Repository r = getRepository();
+
add(new PageHeader("pageHeader", repositoryName, "/ " + pageName));
- add(new PageLinksPanel("pageLinks", repositoryName, pageName));
+ add(new PageLinksPanel("pageLinks", r, repositoryName, pageName));
setStatelessHint(true);
}
protected Repository getRepository() {
- ServletWebRequest servletWebRequest = (ServletWebRequest) getRequest();
- HttpServletRequest req = servletWebRequest.getHttpServletRequest();
- req.getServerName();
-
- Repository r = GitBlitWebApp.get().getRepository(req, repositoryName);
if (r == null) {
- error("Can not load repository " + repositoryName);
- redirectToInterceptPage(new RepositoriesPage());
- return null;
+ ServletWebRequest servletWebRequest = (ServletWebRequest) getRequest();
+ HttpServletRequest req = servletWebRequest.getHttpServletRequest();
+ req.getServerName();
+
+ Repository r = GitBlitWebApp.get().getRepository(req, repositoryName);
+ if (r == null) {
+ error("Can not load repository " + repositoryName);
+ redirectToInterceptPage(new RepositoriesPage());
+ return null;
+ }
+ description = JGitUtils.getRepositoryDescription(r);
+ this.r = r;
}
- description = JGitUtils.getRepositoryDescription(r);
return r;
}
@@ -64,22 +70,22 @@ public abstract class RepositoryPage extends BasePage {
String html = WicketUtils.breakLines(text);
if (substituteRegex) {
Map<String, String> map = new HashMap<String, String>();
- // global regex keys
+ // global regex keys
for (String key : StoredSettings.getAllKeys("regex.global")) {
String subKey = key.substring(key.lastIndexOf('.') + 1);
map.put(subKey, StoredSettings.getString(key, ""));
}
-
+
// repository-specific regex keys
List<String> keys = StoredSettings.getAllKeys("regex." + repositoryName.toLowerCase());
for (String key : keys) {
String subKey = key.substring(key.lastIndexOf('.') + 1);
map.put(subKey, StoredSettings.getString(key, ""));
}
-
+
for (String key : map.keySet()) {
String definition = map.get(key).trim();
- String [] chunks = definition.split("!!!");
+ String[] chunks = definition.split("!!!");
if (chunks.length == 2) {
html = html.replaceAll(chunks[0], chunks[1]);
} else {
@@ -91,28 +97,29 @@ public abstract class RepositoryPage extends BasePage {
}
protected void addFooter() {
+ r.close();
add(new PageFooter("pageFooter", description));
}
protected PageParameters newRepositoryParameter() {
- return new PageParameters("p=" + repositoryName);
+ return new PageParameters("p=" + repositoryName);
}
-
+
protected PageParameters newCommitParameter() {
return newCommitParameter(commitId);
}
-
+
protected PageParameters newCommitParameter(String commitId) {
if (commitId == null || commitId.trim().length() == 0) {
- return newRepositoryParameter();
+ return newRepositoryParameter();
}
return new PageParameters("p=" + repositoryName + ",h=" + commitId);
}
- protected PageParameters newPathParameter(String path) {
+ protected PageParameters newPathParameter(String path) {
if (path == null || path.trim().length() == 0) {
return newCommitParameter();
}
return new PageParameters("p=" + repositoryName + ",h=" + commitId + ",f=" + path);
- }
+ }
}
diff --git a/src/com/gitblit/wicket/pages/DiffPage.html b/src/com/gitblit/wicket/pages/DiffPage.html
index b7aa03b2..b001dead 100644
--- a/src/com/gitblit/wicket/pages/DiffPage.html
+++ b/src/com/gitblit/wicket/pages/DiffPage.html
@@ -4,7 +4,7 @@
<link href="prettify/prettify.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="prettify/prettify.js"></script>
</head>
-<body onload="prettyPrint()">
+<body>
<!-- page header -->
<div wicket:id="pageHeader"></div>
diff --git a/src/com/gitblit/wicket/pages/RepositoriesPage.html b/src/com/gitblit/wicket/pages/RepositoriesPage.html
index 0a7b2706..43168bba 100644
--- a/src/com/gitblit/wicket/pages/RepositoriesPage.html
+++ b/src/com/gitblit/wicket/pages/RepositoriesPage.html
@@ -2,7 +2,11 @@
<html xmlns="http://www.w3.org/1999/xhtml" >
<body>
<div wicket:id="pageHeader"></div>
- <div class="repositories_message" wicket:id="indexInclude"></div>
+
+ <div wicket:id="adminPanel"></div>
+
+ <div class="repositories_message" wicket:id="repositoriesMessage"></div>
+
<table class="repositories">
<tr>
<th wicket:id="orderByRepository">Repository</th>
diff --git a/src/com/gitblit/wicket/pages/RepositoriesPage.java b/src/com/gitblit/wicket/pages/RepositoriesPage.java
index 50bcba28..4755e415 100644
--- a/src/com/gitblit/wicket/pages/RepositoriesPage.java
+++ b/src/com/gitblit/wicket/pages/RepositoriesPage.java
@@ -22,6 +22,7 @@ import com.gitblit.wicket.GitBlitWebApp;
import com.gitblit.wicket.LinkPanel;
import com.gitblit.wicket.WicketUtils;
import com.gitblit.wicket.models.RepositoryModel;
+import com.gitblit.wicket.panels.AdminLinksPanel;
import com.gitblit.wicket.panels.PageFooter;
import com.gitblit.wicket.panels.PageHeader;
@@ -31,7 +32,9 @@ public class RepositoriesPage extends BasePage {
public RepositoriesPage() {
add(new PageHeader("pageHeader"));
- add(new Label("indexInclude", StoredSettings.getString("indexMessage", "")).setEscapeModelStrings(false));
+ add(new AdminLinksPanel("adminPanel").setVisible(StoredSettings.getBoolean("allowAdministration", false)));
+
+ add(new Label("repositoriesMessage", StoredSettings.getString("repositoriesMessage", "")).setEscapeModelStrings(false));
List<RepositoryModel> rows = GitBlitWebApp.get().getRepositories(getRequest());
DataProvider dp = new DataProvider(rows);
diff --git a/src/com/gitblit/wicket/pages/TicGitPage.html b/src/com/gitblit/wicket/pages/TicGitPage.html
index e3b9ed8e..451058d0 100644
--- a/src/com/gitblit/wicket/pages/TicGitPage.html
+++ b/src/com/gitblit/wicket/pages/TicGitPage.html
@@ -12,7 +12,7 @@
<table style="width:100%" class="pretty">
<tbody>
<tr wicket:id="ticket">
- <td style="padding:0; margin:0;" ><div wicket:id="ticketState"></div></td>
+ <td style="padding:0; margin:0;"><div wicket:id="ticketState"></div></td>
<td class="date"><span wicket:id="ticketDate"></span></td>
<td><div wicket:id="ticketHandler"></div></td>
<td><div wicket:id="ticketTitle"></div></td>
diff --git a/src/com/gitblit/wicket/pages/TicGitTicketPage.java b/src/com/gitblit/wicket/pages/TicGitTicketPage.java
index 63905001..c73a3ce5 100644
--- a/src/com/gitblit/wicket/pages/TicGitTicketPage.java
+++ b/src/com/gitblit/wicket/pages/TicGitTicketPage.java
@@ -19,7 +19,7 @@ import com.gitblit.wicket.WicketUtils;
public class TicGitTicketPage extends RepositoryPage {
public TicGitTicketPage(PageParameters params) {
- super(params, "ticgit ticket");
+ super(params, "ticket");
final String ticketFolder = params.getString("f", "");
@@ -32,7 +32,21 @@ public class TicGitTicketPage extends RepositoryPage {
add(new Label("ticketHandler", t.handler));
String openDate = GitBlitWebSession.get().formatDateTimeLong(t.date);
add(new Label("ticketOpenDate", openDate));
- add(new Label("ticketState", t.state));
+ Label stateLabel = new Label("ticketState", t.state);
+ String css = null;
+ if (t.state.equals("open")) {
+ css = "bug_open";
+ } else if (t.state.equals("hold")) {
+ css = "bug_hold";
+ } else if (t.state.equals("resolved")) {
+ css = "bug_resolved";
+ } else if (t.state.equals("invalid")) {
+ css = "bug_invalid";
+ }
+ if (css != null) {
+ WicketUtils.setCssClass(stateLabel, css);
+ }
+ add(stateLabel);
add(new Label("ticketTags", flattenStrings(t.tags)));
ListDataProvider<Comment> commentsDp = new ListDataProvider<Comment>(t.comments);
diff --git a/src/com/gitblit/wicket/panels/AdminLinksPanel.html b/src/com/gitblit/wicket/panels/AdminLinksPanel.html
new file mode 100644
index 00000000..5643c84d
--- /dev/null
+++ b/src/com/gitblit/wicket/panels/AdminLinksPanel.html
@@ -0,0 +1,9 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">
+<wicket:panel>
+ <!-- page nav links -->
+ <div class="page_nav">
+ <span wicket:id="newRepository"></span> | <span wicket:id="newUser"></span>
+ </div>
+</wicket:panel>
+</html> \ No newline at end of file
diff --git a/src/com/gitblit/wicket/panels/AdminLinksPanel.java b/src/com/gitblit/wicket/panels/AdminLinksPanel.java
new file mode 100644
index 00000000..2089f489
--- /dev/null
+++ b/src/com/gitblit/wicket/panels/AdminLinksPanel.java
@@ -0,0 +1,16 @@
+package com.gitblit.wicket.panels;
+
+import org.apache.wicket.markup.html.basic.Label;
+import org.apache.wicket.markup.html.panel.Panel;
+
+public class AdminLinksPanel extends Panel {
+
+ private static final long serialVersionUID = 1L;
+
+ public AdminLinksPanel(String id) {
+ super(id);
+
+ add(new Label("newRepository", "new repository"));
+ add(new Label("newUser", "new user"));
+ }
+} \ No newline at end of file
diff --git a/src/com/gitblit/wicket/panels/PageFooter.java b/src/com/gitblit/wicket/panels/PageFooter.java
index b7440e8c..a6a691ff 100644
--- a/src/com/gitblit/wicket/panels/PageFooter.java
+++ b/src/com/gitblit/wicket/panels/PageFooter.java
@@ -19,7 +19,7 @@ public class PageFooter extends Panel {
super(id);
add(new Label("footerText", description));
add(new Label("gbVersion", "v" + Constants.VERSION));
- if (StoredSettings.getBoolean("aggressiveGC", false)) {
+ if (StoredSettings.getBoolean("aggressiveHeapManagement", false)) {
System.gc();
}
}
diff --git a/src/com/gitblit/wicket/panels/PageLinksPanel.html b/src/com/gitblit/wicket/panels/PageLinksPanel.html
index 072221fe..0aabffc6 100644
--- a/src/com/gitblit/wicket/panels/PageLinksPanel.html
+++ b/src/com/gitblit/wicket/panels/PageLinksPanel.html
@@ -3,7 +3,7 @@
<wicket:panel>
<!-- page nav links -->
<div class="page_nav">
- <span wicket:id="summary"></span> | <span wicket:id="shortlog"></span> | <span wicket:id="branches"></span> | <span wicket:id="tags"></span> | <span wicket:id="tree"></span>
+ <span wicket:id="summary"></span> | <span wicket:id="shortlog"></span> | <span wicket:id="branches"></span> | <span wicket:id="tags"></span> | <span wicket:id="tree"></span> <span wicket:id="extra"><span wicket:id="extraSeparator"></span><span wicket:id="extraLink"></span></span>
</div>
</wicket:panel>
</html> \ No newline at end of file
diff --git a/src/com/gitblit/wicket/panels/PageLinksPanel.java b/src/com/gitblit/wicket/panels/PageLinksPanel.java
index 23f33835..d2034267 100644
--- a/src/com/gitblit/wicket/panels/PageLinksPanel.java
+++ b/src/com/gitblit/wicket/panels/PageLinksPanel.java
@@ -1,24 +1,32 @@
package com.gitblit.wicket.panels;
+import java.util.ArrayList;
+import java.util.List;
+
import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.panel.Panel;
+import org.apache.wicket.markup.repeater.Item;
+import org.apache.wicket.markup.repeater.data.DataView;
+import org.apache.wicket.markup.repeater.data.ListDataProvider;
+import org.eclipse.jgit.lib.Repository;
+import com.gitblit.utils.JGitUtils;
import com.gitblit.wicket.LinkPanel;
import com.gitblit.wicket.pages.BranchesPage;
-import com.gitblit.wicket.pages.CommitPage;
import com.gitblit.wicket.pages.ShortLogPage;
import com.gitblit.wicket.pages.SummaryPage;
import com.gitblit.wicket.pages.TagsPage;
+import com.gitblit.wicket.pages.TicGitPage;
import com.gitblit.wicket.pages.TreePage;
-
public class PageLinksPanel extends Panel {
private static final long serialVersionUID = 1L;
- public PageLinksPanel(String id, String repositoryName, String pageName) {
+ public PageLinksPanel(String id, Repository r, final String repositoryName, String pageName) {
super(id);
+
// summary
if (pageName.equals("summary")) {
add(new Label("summary", pageName));
@@ -32,26 +40,46 @@ public class PageLinksPanel extends Panel {
} else {
add(new LinkPanel("shortlog", null, "shortlog", ShortLogPage.class, new PageParameters("p=" + repositoryName)));
}
-
+
// branches
if (pageName.equals("branches")) {
add(new Label("branches", pageName));
} else {
add(new LinkPanel("branches", null, "branches", BranchesPage.class, new PageParameters("p=" + repositoryName)));
}
-
+
// tags
if (pageName.equals("tags")) {
add(new Label("tags", pageName));
} else {
add(new LinkPanel("tags", null, "tags", TagsPage.class, new PageParameters("p=" + repositoryName)));
}
-
+
// tree
if (pageName.equals("tree")) {
add(new Label("tree", pageName));
} else {
add(new LinkPanel("tree", null, "tree", TreePage.class, new PageParameters("p=" + repositoryName + ",h=HEAD")));
- }
+ }
+
+ // Add dynamic repository extras
+ List<String> extras = new ArrayList<String>();
+ if (JGitUtils.getTicGitBranch(r) != null) {
+ extras.add("ticgit");
+ }
+
+ ListDataProvider<String> extrasDp = new ListDataProvider<String>(extras);
+ DataView<String> extrasView = new DataView<String>("extra", extrasDp) {
+ private static final long serialVersionUID = 1L;
+
+ public void populateItem(final Item<String> item) {
+ String extra = item.getModelObject();
+ if (extra.equals("ticgit")) {
+ item.add(new Label("extraSeparator", " | "));
+ item.add(new LinkPanel("extraLink", null, "ticgit", TicGitPage.class, new PageParameters("p=" + repositoryName)));
+ }
+ }
+ };
+ add(extrasView);
}
} \ No newline at end of file