Added placeholder for Admin links on main page.
Dynamically add ticgit link to nav links, if ticgit branch is
discovered.
Settings refinements.
#\r
-# GIT Servlet Settings\r
+# Git Servlet Settings\r
#\r
\r
+# Allow push/pull over http/https with JGit servlet\r
+allowPushPull = true\r
+\r
# Base folder for repositories\r
# Use forward slashes on Windows!!\r
repositoriesFolder = c:/projects/git\r
# Authentication Settings\r
#\r
\r
-# Require authentication for http push/pull of git repositories\r
-authenticateAccess = true\r
+# Require authentication for http/https push/pull access of git repositories\r
+authenticatePushPull = true\r
\r
# Simple user realm file to authenticate users for push/pull\r
realmFile = users.properties\r
debug = true\r
tempFolder = temp\r
log4jPattern = %-5p %d{MM-dd HH:mm:ss.SSS} %-20.20c{1} %m%n\r
-# Aggressive garbage collection will run the collector on every generated page\r
-# this slows down page generation but improves heap consumption \r
-aggressiveGC = true\r
+# Aggressive heap management will run the garbage collector on every generated\r
+# page. This slows down page generation but improves heap consumption. \r
+aggressiveHeapManagement = true\r
\r
#\r
# Git:Blit UI Settings\r
#\r
siteName = Repositories\r
allowAdministration = true\r
-indexMessage = Welcome to Git:Blit!<br>A quick and easy way to host your own GIT repositories.<br>Built with <a href="http://eclipse.org/jgit">JGit</a>, <a href="http://wicket.apache.org">Wicket</a>, <a href="http://code.google.com/p/google-code-prettify/">google-code-prettify</a>, <a href="http://eclipse.org/jetty">Jetty</a>, <a href="http://www.slf4j.org">SLF4J</a>, <a href="http://logging.apache.org/log4j">Log4j</a>, and <a href="http://jcommander.org">JCommander</a>.\r
+repositoriesMessage = Welcome to Git:Blit!<br>A quick and easy way to host your own Git repositories.<br>Built with <a href="http://eclipse.org/jgit">JGit</a>, <a href="http://wicket.apache.org">Wicket</a>, <a href="http://code.google.com/p/google-code-prettify/">google-code-prettify</a>, <a href="http://eclipse.org/jetty">Jetty</a>, <a href="http://www.slf4j.org">SLF4J</a>, <a href="http://logging.apache.org/log4j">Log4j</a>, and <a href="http://jcommander.org">JCommander</a>.\r
\r
# Date and Time formats\r
timestampFormat = h:mm a\r
padding: 8px;\r
}\r
\r
+div.repositories_message {\r
+ line-height: inherit;\r
+}\r
+\r
div.header {\r
background-color: #D2C3AF;\r
padding: 3px;\r
border-width: 1px 0px 1px;\r
}\r
\r
-div.bug_open {\r
+div.bug_open, span.bug_open {\r
padding: 2px;\r
background-color: #800000;\r
color: white; \r
text-align: center;\r
}\r
\r
-div.bug_resolved {\r
+div.bug_resolved, span.bug_resolved {\r
padding: 2px;\r
background-color: #008000;\r
color: white;\r
text-align: center;\r
}\r
\r
-div.bug_invalid {\r
+div.bug_invalid, span.bug_invalid {\r
padding: 2px;\r
background-color: gray;\r
text-align: center;\r
}\r
\r
-div.bug_hold {\r
+div.bug_hold, span.bug_hold {\r
padding: 2px;\r
background-color: orange;\r
text-align: center;\r
}\r
\r
table.repositories th {\r
- background-color:#000070;\r
+ background-color:#D2C3AF;\r
padding: 4px;\r
- border-bottom: 1px solid #bbb;\r
+ border-bottom: 1px solid #808080;\r
}\r
\r
table.repositories td {\r
}\r
\r
table.repositories th a {\r
- color:#ddd;\r
+ color:black;/*#ddd;*/\r
text-decoration: none;\r
font-weight: normal;\r
}\r
}\r
\r
table.repositories th.wicket_orderDown a, table.repositories th.wicket_orderUp a {\r
- color: yellow;\r
+ color: black;\r
+ font-weight: bold;\r
}\r
\r
tr th a { padding-right: 15px; background-position: right; background-repeat:no-repeat; }\r
import org.eclipse.jetty.webapp.WebAppContext;\r
import org.eclipse.jgit.http.server.GitServlet;\r
\r
-\r
import com.beust.jcommander.JCommander;\r
import com.beust.jcommander.Parameter;\r
import com.beust.jcommander.ParameterException;\r
Connector httpConnector = createConnector(params.useNIO, params.port);\r
connectors.add(httpConnector);\r
}\r
- \r
+\r
if (params.securePort > 0) {\r
if (new File("keystore").exists()) {\r
Connector secureConnector = createSSLConnector(params.useNIO, params.securePort, params.storePassword);\r
wicketFilter.setInitParameter(WicketFilter.FILTER_MAPPING_PARAM, wicketPathSpec);\r
rootContext.addFilter(wicketFilter, wicketPathSpec, FilterMapping.DEFAULT);\r
\r
- // GIT Servlet\r
- String gitServletPathSpec = "/git/*";\r
- ServletHolder gitServlet = rootContext.addServlet(GitServlet.class, gitServletPathSpec);\r
- gitServlet.setInitParameter("base-path", params.repositoriesFolder);\r
- gitServlet.setInitParameter("export-all", params.exportAll ? "1" : "0");\r
-\r
- String realmUsers = params.realmFile;\r
-\r
- // Authentication Realm\r
Handler handler;\r
- if (realmUsers != null && new File(realmUsers).exists() && params.authenticateAccess) {\r
- List<String> list = StoredSettings.getStrings("gitRoles");\r
- String[] roles;\r
- if (list.size() == 0) {\r
- roles = new String[] { "*" };\r
+\r
+ // Git Servlet\r
+ ServletHolder gitServlet = null;\r
+ String gitServletPathSpec = "/git/*";\r
+ if (StoredSettings.getBoolean("allowPushPull", true)) {\r
+ gitServlet = rootContext.addServlet(GitServlet.class, gitServletPathSpec);\r
+ gitServlet.setInitParameter("base-path", params.repositoriesFolder);\r
+ gitServlet.setInitParameter("export-all", params.exportAll ? "1" : "0");\r
+ String realmUsers = params.realmFile;\r
+\r
+ if (realmUsers != null && new File(realmUsers).exists() && params.authenticatePushPull) {\r
+ // Authenticate Pull/Push\r
+ List<String> list = StoredSettings.getStrings("gitRoles");\r
+ String[] roles;\r
+ if (list.size() == 0) {\r
+ roles = new String[] { "*" };\r
+ } else {\r
+ roles = list.toArray(new String[list.size()]);\r
+ }\r
+ logger.info("Authentication required for git servlet pull/push access");\r
+ logger.info("Setting up realm from " + realmUsers);\r
+ HashLoginService loginService = new HashLoginService(Constants.NAME, realmUsers);\r
+\r
+ Constraint constraint = new Constraint();\r
+ constraint.setName("auth");\r
+ constraint.setAuthenticate(true);\r
+ constraint.setRoles(roles);\r
+\r
+ ConstraintMapping mapping = new ConstraintMapping();\r
+ mapping.setPathSpec(gitServletPathSpec);\r
+ mapping.setConstraint(constraint);\r
+\r
+ ConstraintSecurityHandler security = new ConstraintSecurityHandler();\r
+ security.addConstraintMapping(mapping);\r
+ for (String role : roles) {\r
+ security.addRole(role);\r
+ }\r
+ security.setAuthenticator(new BasicAuthenticator());\r
+ security.setLoginService(loginService);\r
+ security.setStrict(false);\r
+\r
+ security.setHandler(rootContext);\r
+\r
+ handler = security;\r
} else {\r
- roles = list.toArray(new String[list.size()]);\r
- }\r
- logger.info("Authentication required for GIT access");\r
- logger.info("Setting up realm from " + realmUsers);\r
- HashLoginService loginService = new HashLoginService(Constants.NAME, realmUsers);\r
-\r
- Constraint constraint = new Constraint();\r
- constraint.setName("auth");\r
- constraint.setAuthenticate(true);\r
- constraint.setRoles(roles);\r
-\r
- ConstraintMapping mapping = new ConstraintMapping();\r
- mapping.setPathSpec(gitServletPathSpec);\r
- mapping.setConstraint(constraint);\r
-\r
- ConstraintSecurityHandler security = new ConstraintSecurityHandler();\r
- security.addConstraintMapping(mapping);\r
- for (String role : roles) {\r
- security.addRole(role);\r
+ // Anonymous Pull/Push\r
+ logger.info("Setting up anonymous git servlet pull/push access");\r
+ handler = rootContext;\r
}\r
- security.setAuthenticator(new BasicAuthenticator());\r
- security.setLoginService(loginService);\r
- security.setStrict(false);\r
-\r
- security.setHandler(rootContext);\r
-\r
- handler = security;\r
} else {\r
- logger.info("Setting up anonymous access");\r
+ logger.info("Git servlet pull/push disabled");\r
handler = rootContext;\r
}\r
\r
/*\r
* GIT Servlet Parameters\r
*/\r
- @Parameter(names = { "--repos" }, description = "GIT Repositories Folder")\r
+ @Parameter(names = { "--repos" }, description = "Git Repositories Folder")\r
public String repositoriesFolder = StoredSettings.getString("repositoriesFolder", "repos");\r
\r
@Parameter(names = { "--exportAll" }, description = "Export All Found Repositories")\r
/*\r
* Authentication Parameters\r
*/\r
- @Parameter(names = { "--authenticateAccess" }, description = "Authenticate GIT access")\r
- public Boolean authenticateAccess = StoredSettings.getBoolean("authenticateAccess", true);\r
+ @Parameter(names = { "--authenticatePushPull" }, description = "Authenticate Git Push/Pull access")\r
+ public Boolean authenticatePushPull = StoredSettings.getBoolean("authenticatePushPull", true);\r
\r
@Parameter(names = { "--realm" }, description = "Users Realm Hash File")\r
public String realmFile = StoredSettings.getString("realmFile", "users.properties");\r
import com.gitblit.wicket.panels.PageLinksPanel;\r
import com.gitblit.wicket.panels.RefsPanel;\r
\r
-\r
public abstract class RepositoryPage extends BasePage {\r
\r
protected final String repositoryName;\r
protected final String commitId;\r
protected String description;\r
\r
+ private transient Repository r = null;\r
+\r
public RepositoryPage(PageParameters params, String pageName) {\r
super(params);\r
if (!params.containsKey("p")) {\r
repositoryName = params.getString("p", "");\r
commitId = params.getString("h", "");\r
\r
+ Repository r = getRepository();\r
+\r
add(new PageHeader("pageHeader", repositoryName, "/ " + pageName));\r
- add(new PageLinksPanel("pageLinks", repositoryName, pageName));\r
+ add(new PageLinksPanel("pageLinks", r, repositoryName, pageName));\r
setStatelessHint(true);\r
}\r
\r
protected Repository getRepository() {\r
- ServletWebRequest servletWebRequest = (ServletWebRequest) getRequest();\r
- HttpServletRequest req = servletWebRequest.getHttpServletRequest();\r
- req.getServerName();\r
-\r
- Repository r = GitBlitWebApp.get().getRepository(req, repositoryName);\r
if (r == null) {\r
- error("Can not load repository " + repositoryName);\r
- redirectToInterceptPage(new RepositoriesPage());\r
- return null;\r
+ ServletWebRequest servletWebRequest = (ServletWebRequest) getRequest();\r
+ HttpServletRequest req = servletWebRequest.getHttpServletRequest();\r
+ req.getServerName();\r
+\r
+ Repository r = GitBlitWebApp.get().getRepository(req, repositoryName);\r
+ if (r == null) {\r
+ error("Can not load repository " + repositoryName);\r
+ redirectToInterceptPage(new RepositoriesPage());\r
+ return null;\r
+ }\r
+ description = JGitUtils.getRepositoryDescription(r);\r
+ this.r = r;\r
}\r
- description = JGitUtils.getRepositoryDescription(r);\r
return r;\r
}\r
\r
String html = WicketUtils.breakLines(text);\r
if (substituteRegex) {\r
Map<String, String> map = new HashMap<String, String>();\r
- // global regex keys \r
+ // global regex keys\r
for (String key : StoredSettings.getAllKeys("regex.global")) {\r
String subKey = key.substring(key.lastIndexOf('.') + 1);\r
map.put(subKey, StoredSettings.getString(key, ""));\r
}\r
- \r
+\r
// repository-specific regex keys\r
List<String> keys = StoredSettings.getAllKeys("regex." + repositoryName.toLowerCase());\r
for (String key : keys) {\r
String subKey = key.substring(key.lastIndexOf('.') + 1);\r
map.put(subKey, StoredSettings.getString(key, ""));\r
}\r
- \r
+\r
for (String key : map.keySet()) {\r
String definition = map.get(key).trim();\r
- String [] chunks = definition.split("!!!");\r
+ String[] chunks = definition.split("!!!");\r
if (chunks.length == 2) {\r
html = html.replaceAll(chunks[0], chunks[1]);\r
} else {\r
}\r
\r
protected void addFooter() {\r
+ r.close();\r
add(new PageFooter("pageFooter", description));\r
}\r
\r
protected PageParameters newRepositoryParameter() {\r
- return new PageParameters("p=" + repositoryName); \r
+ return new PageParameters("p=" + repositoryName);\r
}\r
- \r
+\r
protected PageParameters newCommitParameter() {\r
return newCommitParameter(commitId);\r
}\r
- \r
+\r
protected PageParameters newCommitParameter(String commitId) {\r
if (commitId == null || commitId.trim().length() == 0) {\r
- return newRepositoryParameter(); \r
+ return newRepositoryParameter();\r
}\r
return new PageParameters("p=" + repositoryName + ",h=" + commitId);\r
}\r
\r
- protected PageParameters newPathParameter(String path) { \r
+ protected PageParameters newPathParameter(String path) {\r
if (path == null || path.trim().length() == 0) {\r
return newCommitParameter();\r
}\r
return new PageParameters("p=" + repositoryName + ",h=" + commitId + ",f=" + path);\r
- } \r
+ }\r
}\r
<link href="prettify/prettify.css" type="text/css" rel="stylesheet" />\r
<script type="text/javascript" src="prettify/prettify.js"></script>\r
</head>\r
-<body onload="prettyPrint()">\r
+<body>\r
<!-- page header -->\r
<div wicket:id="pageHeader"></div>\r
\r
<html xmlns="http://www.w3.org/1999/xhtml" >\r
<body>\r
<div wicket:id="pageHeader"></div>\r
- <div class="repositories_message" wicket:id="indexInclude"></div> \r
+ \r
+ <div wicket:id="adminPanel"></div>\r
+ \r
+ <div class="repositories_message" wicket:id="repositoriesMessage"></div>\r
+ \r
<table class="repositories">\r
<tr>\r
<th wicket:id="orderByRepository">Repository</th>\r
import com.gitblit.wicket.LinkPanel;\r
import com.gitblit.wicket.WicketUtils;\r
import com.gitblit.wicket.models.RepositoryModel;\r
+import com.gitblit.wicket.panels.AdminLinksPanel;\r
import com.gitblit.wicket.panels.PageFooter;\r
import com.gitblit.wicket.panels.PageHeader;\r
\r
public RepositoriesPage() {\r
add(new PageHeader("pageHeader"));\r
\r
- add(new Label("indexInclude", StoredSettings.getString("indexMessage", "")).setEscapeModelStrings(false));\r
+ add(new AdminLinksPanel("adminPanel").setVisible(StoredSettings.getBoolean("allowAdministration", false)));\r
+ \r
+ add(new Label("repositoriesMessage", StoredSettings.getString("repositoriesMessage", "")).setEscapeModelStrings(false));\r
\r
List<RepositoryModel> rows = GitBlitWebApp.get().getRepositories(getRequest());\r
DataProvider dp = new DataProvider(rows);\r
<table style="width:100%" class="pretty">\r
<tbody>\r
<tr wicket:id="ticket">\r
- <td style="padding:0; margin:0;" ><div wicket:id="ticketState"></div></td>\r
+ <td style="padding:0; margin:0;"><div wicket:id="ticketState"></div></td>\r
<td class="date"><span wicket:id="ticketDate"></span></td>\r
<td><div wicket:id="ticketHandler"></div></td>\r
<td><div wicket:id="ticketTitle"></div></td>\r
public class TicGitTicketPage extends RepositoryPage {\r
\r
public TicGitTicketPage(PageParameters params) {\r
- super(params, "ticgit ticket");\r
+ super(params, "ticket");\r
\r
final String ticketFolder = params.getString("f", "");\r
\r
add(new Label("ticketHandler", t.handler));\r
String openDate = GitBlitWebSession.get().formatDateTimeLong(t.date);\r
add(new Label("ticketOpenDate", openDate));\r
- add(new Label("ticketState", t.state));\r
+ Label stateLabel = new Label("ticketState", t.state);\r
+ String css = null;\r
+ if (t.state.equals("open")) {\r
+ css = "bug_open";\r
+ } else if (t.state.equals("hold")) {\r
+ css = "bug_hold";\r
+ } else if (t.state.equals("resolved")) {\r
+ css = "bug_resolved";\r
+ } else if (t.state.equals("invalid")) {\r
+ css = "bug_invalid";\r
+ }\r
+ if (css != null) {\r
+ WicketUtils.setCssClass(stateLabel, css);\r
+ }\r
+ add(stateLabel);\r
add(new Label("ticketTags", flattenStrings(t.tags)));\r
\r
ListDataProvider<Comment> commentsDp = new ListDataProvider<Comment>(t.comments);\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>\r
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org/dtds.data/wicket-xhtml1.4-strict.dtd">\r
+<wicket:panel>\r
+ <!-- page nav links --> \r
+ <div class="page_nav">\r
+ <span wicket:id="newRepository"></span> | <span wicket:id="newUser"></span>\r
+ </div> \r
+</wicket:panel>\r
+</html>
\ No newline at end of file
--- /dev/null
+package com.gitblit.wicket.panels;\r
+\r
+import org.apache.wicket.markup.html.basic.Label;\r
+import org.apache.wicket.markup.html.panel.Panel;\r
+\r
+public class AdminLinksPanel extends Panel {\r
+\r
+ private static final long serialVersionUID = 1L;\r
+\r
+ public AdminLinksPanel(String id) {\r
+ super(id);\r
+\r
+ add(new Label("newRepository", "new repository"));\r
+ add(new Label("newUser", "new user"));\r
+ }\r
+}
\ No newline at end of file
super(id); \r
add(new Label("footerText", description));\r
add(new Label("gbVersion", "v" + Constants.VERSION));\r
- if (StoredSettings.getBoolean("aggressiveGC", false)) {\r
+ if (StoredSettings.getBoolean("aggressiveHeapManagement", false)) {\r
System.gc();\r
}\r
}\r
<wicket:panel>\r
<!-- page nav links --> \r
<div class="page_nav">\r
- <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>\r
+ <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>\r
</div> \r
</wicket:panel>\r
</html>
\ No newline at end of file
package com.gitblit.wicket.panels;\r
\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+\r
import org.apache.wicket.PageParameters;\r
import org.apache.wicket.markup.html.basic.Label;\r
import org.apache.wicket.markup.html.panel.Panel;\r
+import org.apache.wicket.markup.repeater.Item;\r
+import org.apache.wicket.markup.repeater.data.DataView;\r
+import org.apache.wicket.markup.repeater.data.ListDataProvider;\r
+import org.eclipse.jgit.lib.Repository;\r
\r
+import com.gitblit.utils.JGitUtils;\r
import com.gitblit.wicket.LinkPanel;\r
import com.gitblit.wicket.pages.BranchesPage;\r
-import com.gitblit.wicket.pages.CommitPage;\r
import com.gitblit.wicket.pages.ShortLogPage;\r
import com.gitblit.wicket.pages.SummaryPage;\r
import com.gitblit.wicket.pages.TagsPage;\r
+import com.gitblit.wicket.pages.TicGitPage;\r
import com.gitblit.wicket.pages.TreePage;\r
\r
-\r
public class PageLinksPanel extends Panel {\r
\r
private static final long serialVersionUID = 1L;\r
\r
- public PageLinksPanel(String id, String repositoryName, String pageName) {\r
+ public PageLinksPanel(String id, Repository r, final String repositoryName, String pageName) {\r
super(id);\r
+\r
// summary\r
if (pageName.equals("summary")) {\r
add(new Label("summary", pageName));\r
} else {\r
add(new LinkPanel("shortlog", null, "shortlog", ShortLogPage.class, new PageParameters("p=" + repositoryName)));\r
}\r
- \r
+\r
// branches\r
if (pageName.equals("branches")) {\r
add(new Label("branches", pageName));\r
} else {\r
add(new LinkPanel("branches", null, "branches", BranchesPage.class, new PageParameters("p=" + repositoryName)));\r
}\r
- \r
+\r
// tags\r
if (pageName.equals("tags")) {\r
add(new Label("tags", pageName));\r
} else {\r
add(new LinkPanel("tags", null, "tags", TagsPage.class, new PageParameters("p=" + repositoryName)));\r
}\r
- \r
+\r
// tree\r
if (pageName.equals("tree")) {\r
add(new Label("tree", pageName));\r
} else {\r
add(new LinkPanel("tree", null, "tree", TreePage.class, new PageParameters("p=" + repositoryName + ",h=HEAD")));\r
- } \r
+ }\r
+\r
+ // Add dynamic repository extras\r
+ List<String> extras = new ArrayList<String>();\r
+ if (JGitUtils.getTicGitBranch(r) != null) {\r
+ extras.add("ticgit");\r
+ }\r
+\r
+ ListDataProvider<String> extrasDp = new ListDataProvider<String>(extras);\r
+ DataView<String> extrasView = new DataView<String>("extra", extrasDp) {\r
+ private static final long serialVersionUID = 1L;\r
+\r
+ public void populateItem(final Item<String> item) {\r
+ String extra = item.getModelObject();\r
+ if (extra.equals("ticgit")) {\r
+ item.add(new Label("extraSeparator", " | "));\r
+ item.add(new LinkPanel("extraLink", null, "ticgit", TicGitPage.class, new PageParameters("p=" + repositoryName)));\r
+ }\r
+ }\r
+ };\r
+ add(extrasView);\r
}\r
}
\ No newline at end of file