diff options
author | James Moger <james.moger@gitblit.com> | 2011-04-14 19:44:47 -0400 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2011-04-14 19:44:47 -0400 |
commit | 155bf78e3377910d29b2c912f58c0f496cb428e8 (patch) | |
tree | be65a3b6276499c914f3a3f0994dfde9956f4dc9 /src | |
parent | fc948cacef9c9b8c0a1e84cbc082ca67cd5f68d9 (diff) | |
download | gitblit-155bf78e3377910d29b2c912f58c0f496cb428e8.tar.gz gitblit-155bf78e3377910d29b2c912f58c0f496cb428e8.zip |
Generate Keys class from gitblit.properties as part of build process.
Diffstat (limited to 'src')
43 files changed, 236 insertions, 194 deletions
diff --git a/src/com/gitblit/.gitignore b/src/com/gitblit/.gitignore new file mode 100644 index 00000000..c6298604 --- /dev/null +++ b/src/com/gitblit/.gitignore @@ -0,0 +1,2 @@ +/SettingKeys.java +/Keys.java diff --git a/src/com/gitblit/Build.java b/src/com/gitblit/Build.java index 0af7390c..ec392e1f 100644 --- a/src/com/gitblit/Build.java +++ b/src/com/gitblit/Build.java @@ -3,18 +3,25 @@ package com.gitblit; import java.io.BufferedInputStream;
import java.io.ByteArrayOutputStream;
import java.io.File;
+import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.RandomAccessFile;
import java.net.URL;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Properties;
public class Build {
public static void main(String... args) {
runtime();
compiletime();
+ buildSettingKeys();
}
public static void runtime() {
@@ -33,6 +40,40 @@ public class Build { downloadFromMaven(MavenObject.JUNIT);
}
+ public static void buildSettingKeys() {
+ Properties properties = new Properties();
+ try {
+ properties.load(new FileInputStream(Constants.PROPERTIES_FILE));
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+ List<String> keys = new ArrayList<String>(properties.stringPropertyNames());
+ Collections.sort(keys);
+
+ StringBuilder sb = new StringBuilder();
+ sb.append("package com.gitblit;\n");
+ sb.append("\n");
+ sb.append("/*\n");
+ sb.append(" * This class is auto-generated from the properties file.\n");
+ sb.append(" * Do not version control!\n");
+ sb.append(" */\n");
+ sb.append("public final class Keys {\n");
+ sb.append("\n");
+ for (String key : keys) {
+ sb.append(MessageFormat.format("\tpublic static final String {0} = \"{1}\";\n\n", key.replace('.', '_'), key));
+ }
+ sb.append("}");
+ try {
+ File file = new File("src/com/gitblit/Keys.java");
+ file.delete();
+ RandomAccessFile raf = new RandomAccessFile(file, "rw");
+ raf.writeBytes(sb.toString());
+ raf.close();
+ } catch (Throwable t) {
+ t.printStackTrace();
+ }
+ }
+
/**
* Download a file from a Maven repository.
*
@@ -135,7 +176,7 @@ public class Build { public static final MavenObject WICKET_EXT = new MavenObject("Apache Wicket Extensions", "org/apache/wicket", "wicket-extensions", "1.4.17", "01111d0dbffdc425581b006a43864c22797ce72a");
public static final MavenObject WICKET_AUTH_ROLES = new MavenObject("Apache Wicket Auth Roles", "org/apache/wicket", "wicket-auth-roles", "1.4.17", "86d20ff32f62d3026213ff11a78555da643bc676");
-
+
public static final MavenObject JUNIT = new MavenObject("JUnit", "junit", "junit", "3.8.2", "07e4cde26b53a9a0e3fe5b00d1dbbc7cc1d46060");
public final String name;
diff --git a/src/com/gitblit/Constants.java b/src/com/gitblit/Constants.java index 186193eb..75f1badb 100644 --- a/src/com/gitblit/Constants.java +++ b/src/com/gitblit/Constants.java @@ -5,17 +5,19 @@ public class Constants { public final static String NAME = "Git:Blit";
public final static String VERSION = "0.0.1";
-
+
public final static String ADMIN_ROLE = "admin";
-
+
public final static String PULL_ROLE = "pull";
-
+
public final static String PUSH_ROLE = "push";
+ public final static String PROPERTIES_FILE = "gitblit.properties";
+
public static String getGitBlitVersion() {
return NAME + " v" + VERSION;
}
-
+
public static String getJGitVersion() {
return "JGit 0.11.3";
}
diff --git a/src/com/gitblit/GitBlit.java b/src/com/gitblit/GitBlit.java index 27641432..f437e5f0 100644 --- a/src/com/gitblit/GitBlit.java +++ b/src/com/gitblit/GitBlit.java @@ -46,12 +46,12 @@ public class GitBlit { }
private GitBlit() {
- repositories = new File(StoredSettings.getString("repositoriesFolder", "repos"));
- exportAll = StoredSettings.getBoolean("exportAll", true);
+ repositories = new File(StoredSettings.getString(Keys.git_repositoriesFolder, "repos"));
+ exportAll = StoredSettings.getBoolean(Keys.git_exportAll, true);
repositoryResolver = new FileResolver(repositories, exportAll);
- debugMode = StoredSettings.getBoolean("debugMode", false);
+ debugMode = StoredSettings.getBoolean(Keys.server_debugMode, false);
}
-
+
public boolean isDebugMode() {
return debugMode;
}
@@ -88,9 +88,9 @@ public class GitBlit { userCookie.setPath("/");
response.addCookie(userCookie);
}
-
+
public List<String> getRepositoryList() {
- return JGitUtils.getRepositoryList(repositories, exportAll, StoredSettings.getBoolean("nestedRepositories", true));
+ return JGitUtils.getRepositoryList(repositories, exportAll, StoredSettings.getBoolean(Keys.git_nestedRepositories, true));
}
public List<RepositoryModel> getRepositories(Request request) {
diff --git a/src/com/gitblit/GitBlitServer.java b/src/com/gitblit/GitBlitServer.java index 4f1aeccc..b167e6c1 100644 --- a/src/com/gitblit/GitBlitServer.java +++ b/src/com/gitblit/GitBlitServer.java @@ -79,7 +79,7 @@ public class GitBlitServer { }
if (jc != null) {
jc.usage();
- System.out.println("\nExample:\n java -server -Xmx1024M -jar go-git-go.jar --repos c:\\git --port 80 --securePort 443");
+ System.out.println("\nExample:\n java -server -Xmx1024M -jar gitblit.jar --repos c:\\git --port 80 --securePort 443");
}
System.exit(0);
}
@@ -108,8 +108,8 @@ public class GitBlitServer { private static void start(Params params) {
// instantiate GitBlit
GitBlit.self();
-
- PatternLayout layout = new PatternLayout(StoredSettings.getString("log4jPattern", "%-5p %d{MM-dd HH:mm:ss.SSS} %-20.20c{1} %m%n"));
+
+ PatternLayout layout = new PatternLayout(StoredSettings.getString(Keys.server_log4jPattern, "%-5p %d{MM-dd HH:mm:ss.SSS} %-20.20c{1} %m%n"));
org.apache.log4j.Logger rootLogger = org.apache.log4j.Logger.getRootLogger();
rootLogger.addAppender(new ConsoleAppender(layout));
@@ -121,7 +121,7 @@ public class GitBlitServer { String osversion = System.getProperty("os.version");
logger.info("Running on " + osname + " (" + osversion + ")");
- if (StoredSettings.getBoolean("debugMode", false)) {
+ if (StoredSettings.getBoolean(Keys.server_debugMode, false)) {
logger.warn("DEBUG Mode");
}
@@ -177,12 +177,12 @@ public class GitBlitServer { // Git Servlet
ServletHolder gitServlet = null;
String gitServletPathSpec = "/git/*";
- if (StoredSettings.getBoolean("allowPushPull", true)) {
+ if (StoredSettings.getBoolean(Keys.git_allowPushPull, true)) {
gitServlet = rootContext.addServlet(GitServlet.class, gitServletPathSpec);
gitServlet.setInitParameter("base-path", params.repositoriesFolder);
gitServlet.setInitParameter("export-all", params.exportAll ? "1" : "0");
}
-
+
// Login Service
LoginService loginService = null;
String realmUsers = params.realmFile;
@@ -192,7 +192,7 @@ public class GitBlitServer { GitBlit.self().setLoginService(jettyLoginService);
loginService = jettyLoginService;
}
-
+
// Determine what handler to use
Handler handler;
if (gitServlet != null) {
@@ -356,43 +356,43 @@ public class GitBlitServer { public Boolean stop = false;
@Parameter(names = { "--temp" }, description = "Server temp folder")
- public String temp = StoredSettings.getString("tempFolder", "temp");
+ public String temp = StoredSettings.getString(Keys.server_tempFolder, "temp");
/*
* GIT Servlet Parameters
*/
@Parameter(names = { "--repos" }, description = "Git Repositories Folder")
- public String repositoriesFolder = StoredSettings.getString("repositoriesFolder", "repos");
+ public String repositoriesFolder = StoredSettings.getString(Keys.git_repositoriesFolder, "repos");
@Parameter(names = { "--exportAll" }, description = "Export All Found Repositories")
- public Boolean exportAll = StoredSettings.getBoolean("exportAll", true);
+ public Boolean exportAll = StoredSettings.getBoolean(Keys.git_exportAll, true);
/*
* Authentication Parameters
*/
@Parameter(names = { "--authenticatePushPull" }, description = "Authenticate Git Push/Pull access")
- public Boolean authenticatePushPull = StoredSettings.getBoolean("authenticatePushPull", true);
+ public Boolean authenticatePushPull = StoredSettings.getBoolean(Keys.git_authenticate, true);
@Parameter(names = { "--realm" }, description = "Users Realm Hash File")
- public String realmFile = StoredSettings.getString("realmFile", "users.properties");
+ public String realmFile = StoredSettings.getString(Keys.server_realmFile, "users.properties");
/*
* JETTY Parameters
*/
@Parameter(names = { "--nio" }, description = "Use NIO Connector else use Socket Connector.")
- public Boolean useNIO = StoredSettings.getBoolean("useNio", true);
+ public Boolean useNIO = StoredSettings.getBoolean(Keys.server_useNio, true);
@Parameter(names = "--port", description = "HTTP port for to serve. (port <= 0 will disable this connector)")
- public Integer port = StoredSettings.getInteger("httpPort", 80);
+ public Integer port = StoredSettings.getInteger(Keys.server_httpPort, 80);
@Parameter(names = "--securePort", description = "HTTPS port to serve. (port <= 0 will disable this connector)")
- public Integer securePort = StoredSettings.getInteger("httpsPort", 443);
+ public Integer securePort = StoredSettings.getInteger(Keys.server_httpsPort, 443);
@Parameter(names = "--storePassword", description = "Password for SSL (https) keystore.")
- public String storePassword = StoredSettings.getString("storePassword", "");
+ public String storePassword = StoredSettings.getString(Keys.server_storePassword, "");
@Parameter(names = "--shutdownPort", description = "Port for Shutdown Monitor to listen on. (port <= 0 will disable this monitor)")
- public Integer shutdownPort = StoredSettings.getInteger("shutdownPort", 8081);
+ public Integer shutdownPort = StoredSettings.getInteger(Keys.server_shutdownPort, 8081);
}
}
\ No newline at end of file diff --git a/src/com/gitblit/ILoginService.java b/src/com/gitblit/ILoginService.java index ee98d8ef..b58f4f1f 100644 --- a/src/com/gitblit/ILoginService.java +++ b/src/com/gitblit/ILoginService.java @@ -4,7 +4,7 @@ import com.gitblit.wicket.User; public interface ILoginService {
- User authenticate(String username, char [] password);
-
- User authenticate(char [] cookie);
+ User authenticate(String username, char[] password);
+
+ User authenticate(char[] cookie);
}
diff --git a/src/com/gitblit/JettyLoginService.java b/src/com/gitblit/JettyLoginService.java index 93e9a192..5173d213 100644 --- a/src/com/gitblit/JettyLoginService.java +++ b/src/com/gitblit/JettyLoginService.java @@ -10,7 +10,7 @@ public class JettyLoginService extends HashLoginService implements ILoginService public JettyLoginService(String realmFile) {
super(Constants.NAME, realmFile);
}
-
+
@Override
public User authenticate(String username, char[] password) {
UserIdentity identity = login(username, new String(password));
@@ -25,7 +25,7 @@ public class JettyLoginService extends HashLoginService implements ILoginService }
@Override
- public User authenticate(char [] cookie) {
+ public User authenticate(char[] cookie) {
// TODO cookie login
return null;
}
diff --git a/src/com/gitblit/StoredSettings.java b/src/com/gitblit/StoredSettings.java index d495ad87..1db87c04 100644 --- a/src/com/gitblit/StoredSettings.java +++ b/src/com/gitblit/StoredSettings.java @@ -27,7 +27,7 @@ public class StoredSettings { List<String> keys = new ArrayList<String>();
Properties props = read();
for (Object o : props.keySet()) {
- String key = o.toString().toLowerCase();
+ String key = o.toString().toLowerCase();
if (key.startsWith(startingWith)) {
keys.add(key);
}
@@ -114,11 +114,11 @@ public class StoredSettings { }
private static synchronized Properties read() {
- File file = new File("gitblit.properties");
+ File file = new File(Constants.PROPERTIES_FILE);
if (file.exists() && (file.lastModified() > lastread)) {
try {
properties = new Properties();
- properties.load(new FileInputStream("gitblit.properties"));
+ properties.load(new FileInputStream(Constants.PROPERTIES_FILE));
lastread = file.lastModified();
} catch (FileNotFoundException f) {
} catch (Throwable t) {
diff --git a/src/com/gitblit/tests/JGitUtilsTest.java b/src/com/gitblit/tests/JGitUtilsTest.java index abc733c9..c77aaaf1 100644 --- a/src/com/gitblit/tests/JGitUtilsTest.java +++ b/src/com/gitblit/tests/JGitUtilsTest.java @@ -86,7 +86,7 @@ public class JGitUtilsTest extends TestCase { r.close();
assertTrue("No changed paths found!", paths.size() > 0);
}
-
+
public void testCommitDiff() throws Exception {
Repository r = getRepository();
RevCommit commit = JGitUtils.getCommit(r, Constants.HEAD);
diff --git a/src/com/gitblit/utils/HtmlDiffFormatter.java b/src/com/gitblit/utils/HtmlDiffFormatter.java index 08c0c219..a3e58c38 100644 --- a/src/com/gitblit/utils/HtmlDiffFormatter.java +++ b/src/com/gitblit/utils/HtmlDiffFormatter.java @@ -10,7 +10,7 @@ import org.eclipse.jgit.diff.DiffFormatter; import org.eclipse.jgit.diff.RawText;
public class HtmlDiffFormatter extends DiffFormatter {
-
+
private final OutputStream os;
public HtmlDiffFormatter(OutputStream os) {
diff --git a/src/com/gitblit/utils/JGitUtils.java b/src/com/gitblit/utils/JGitUtils.java index 69c46da4..fa313911 100644 --- a/src/com/gitblit/utils/JGitUtils.java +++ b/src/com/gitblit/utils/JGitUtils.java @@ -340,11 +340,11 @@ public class JGitUtils { }
return null;
}
-
+
public static String getCommitPatch(Repository r, RevCommit commit) {
return getCommitPatch(r, commit);
}
-
+
public static String getCommitPatch(Repository r, RevCommit commit, String path) {
try {
final RevWalk rw = new RevWalk(r);
diff --git a/src/com/gitblit/utils/Utils.java b/src/com/gitblit/utils/Utils.java index c742fb62..6d0c6b3c 100644 --- a/src/com/gitblit/utils/Utils.java +++ b/src/com/gitblit/utils/Utils.java @@ -116,7 +116,7 @@ public class Utils { }
return ago;
}
-
+
public static String leftPad(String input, int length, char pad) {
if (input.length() < length) {
StringBuilder sb = new StringBuilder();
@@ -128,19 +128,19 @@ public class Utils { }
return input;
}
-
+
public static String rightPad(String input, int length, char pad) {
if (input.length() < length) {
StringBuilder sb = new StringBuilder();
sb.append(input);
for (int i = 0, len = length - input.length(); i < len; i++) {
sb.append(pad);
- }
+ }
return sb.toString();
}
return input;
}
-
+
public static String escapeForHtml(String inStr, boolean changeSpace) {
StringBuffer retStr = new StringBuffer();
int i = 0;
diff --git a/src/com/gitblit/wicket/AuthorizationStrategy.java b/src/com/gitblit/wicket/AuthorizationStrategy.java index b99ad6de..b73e849c 100644 --- a/src/com/gitblit/wicket/AuthorizationStrategy.java +++ b/src/com/gitblit/wicket/AuthorizationStrategy.java @@ -23,8 +23,8 @@ public class AuthorizationStrategy extends AbstractPageAuthorizationStrategy imp @Override
public void onUnauthorizedInstantiation(Component component) {
- if (component instanceof BasePage) {
- GitBlitWebSession session = GitBlitWebSession.get();
+ if (component instanceof BasePage) {
+ GitBlitWebSession session = GitBlitWebSession.get();
if (!session.isLoggedIn())
throw new RestartResponseAtInterceptPageException(LoginPage.class);
else
@@ -38,7 +38,7 @@ public class AuthorizationStrategy extends AbstractPageAuthorizationStrategy imp return false;
User user = session.getUser();
if (pageClass.isAnnotationPresent(AdminPage.class)) {
-
+
}
return true;
}
diff --git a/src/com/gitblit/wicket/BasePage.java b/src/com/gitblit/wicket/BasePage.java index 8084b335..9aa7baa0 100644 --- a/src/com/gitblit/wicket/BasePage.java +++ b/src/com/gitblit/wicket/BasePage.java @@ -12,6 +12,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory;
import com.gitblit.Constants;
+import com.gitblit.Keys;
import com.gitblit.StoredSettings;
import com.gitblit.wicket.pages.SummaryPage;
@@ -26,7 +27,7 @@ public abstract class BasePage extends WebPage { public BasePage(PageParameters params) {
super(params);
}
-
+
protected void setupPage(String repositoryName, String pageName) {
if (repositoryName != null && repositoryName.trim().length() > 0) {
add(new Label("title", getServerName() + " - " + repositoryName));
@@ -34,38 +35,38 @@ public abstract class BasePage extends WebPage { add(new Label("title", getServerName()));
}
// header
- String siteName = StoredSettings.getString("siteName", Constants.NAME);
+ String siteName = StoredSettings.getString(Keys.web_siteName, Constants.NAME);
if (siteName == null || siteName.trim().length() == 0) {
siteName = Constants.NAME;
}
add(new Label("siteName", siteName));
add(new LinkPanel("repositoryName", null, repositoryName, SummaryPage.class, WicketUtils.newRepositoryParameter(repositoryName)));
add(new Label("pageName", pageName));
-
+
// footer
User user = null;
- if (StoredSettings.getBoolean("authenticateWebUI", true)) {
+ if (StoredSettings.getBoolean(Keys.web_authenticate, true)) {
user = GitBlitWebSession.get().getUser();
add(new Label("userText", "Logout " + user.toString()));
} else {
add(new Label("userText", ""));
}
add(new Label("gbVersion", "v" + Constants.VERSION));
- if (StoredSettings.getBoolean("aggressiveHeapManagement", false)) {
+ if (StoredSettings.getBoolean(Keys.server_aggressiveHeapManagement, false)) {
System.gc();
}
}
-
+
protected TimeZone getTimeZone() {
- return StoredSettings.getBoolean("useClientTimezone", false) ? GitBlitWebSession.get().getTimezone() : TimeZone.getDefault();
+ return StoredSettings.getBoolean(Keys.web_useClientTimezone, false) ? GitBlitWebSession.get().getTimezone() : TimeZone.getDefault();
}
-
+
protected String getServerName() {
ServletWebRequest servletWebRequest = (ServletWebRequest) getRequest();
HttpServletRequest req = servletWebRequest.getHttpServletRequest();
return req.getServerName();
}
-
+
public void error(String message, Throwable t) {
super.error(message);
logger.error(message, t);
diff --git a/src/com/gitblit/wicket/GitBlitWebApp.java b/src/com/gitblit/wicket/GitBlitWebApp.java index 658ae67a..8589b75c 100644 --- a/src/com/gitblit/wicket/GitBlitWebApp.java +++ b/src/com/gitblit/wicket/GitBlitWebApp.java @@ -11,6 +11,7 @@ import org.apache.wicket.request.IRequestCycleProcessor; import org.apache.wicket.request.target.coding.MixedParamUrlCodingStrategy;
import com.gitblit.GitBlit;
+import com.gitblit.Keys;
import com.gitblit.StoredSettings;
import com.gitblit.wicket.pages.BlobDiffPage;
import com.gitblit.wicket.pages.BlobPage;
@@ -35,14 +36,14 @@ public class GitBlitWebApp extends WebApplication { super.init();
// Setup page authorization mechanism
- if (StoredSettings.getBoolean("authenticateWebUI", false)) {
+ if (StoredSettings.getBoolean(Keys.web_authenticate, false)) {
AuthorizationStrategy authStrategy = new AuthorizationStrategy();
getSecuritySettings().setAuthorizationStrategy(authStrategy);
getSecuritySettings().setUnauthorizedComponentInstantiationListener(authStrategy);
}
// Grab Browser info (like timezone, etc)
- if (StoredSettings.getBoolean("useClientTimezone", false)) {
+ if (StoredSettings.getBoolean(Keys.web_useClientTimezone, false)) {
getRequestCycleSettings().setGatherExtendedBrowserInfo(true);
}
@@ -90,7 +91,7 @@ public class GitBlitWebApp extends WebApplication { }
public String getCloneUrl(String repositoryName) {
- return StoredSettings.getString("cloneUrl", "https://localhost/git/") + repositoryName;
+ return StoredSettings.getString(Keys.git_cloneUrl, "https://localhost/git/") + repositoryName;
}
public static GitBlitWebApp get() {
diff --git a/src/com/gitblit/wicket/GitBlitWebSession.java b/src/com/gitblit/wicket/GitBlitWebSession.java index 34e597f0..92eaff66 100644 --- a/src/com/gitblit/wicket/GitBlitWebSession.java +++ b/src/com/gitblit/wicket/GitBlitWebSession.java @@ -12,7 +12,7 @@ public final class GitBlitWebSession extends WebSession { private static final long serialVersionUID = 1L;
protected TimeZone timezone = null;
-
+
private User user = null;
public GitBlitWebSession(Request request) {
@@ -23,22 +23,22 @@ public final class GitBlitWebSession extends WebSession { super.invalidate();
user = null;
}
-
+
public boolean isLoggedIn() {
return user != null;
}
-
+
public boolean canAdmin() {
if (user == null) {
- return false;
+ return false;
}
return user.canAdmin();
}
-
+
public User getUser() {
return user;
}
-
+
public void setUser(User user) {
this.user = user;
}
diff --git a/src/com/gitblit/wicket/LinkPanel.java b/src/com/gitblit/wicket/LinkPanel.java index 716ed491..ab55cfdd 100644 --- a/src/com/gitblit/wicket/LinkPanel.java +++ b/src/com/gitblit/wicket/LinkPanel.java @@ -31,7 +31,7 @@ public class LinkPanel extends Panel { }
if (linkCssClass != null) {
link.add(new SimpleAttributeModifier("class", linkCssClass));
- }
+ }
link.add(new Label("label", labelModel));
add(link);
}
diff --git a/src/com/gitblit/wicket/LoginPage.java b/src/com/gitblit/wicket/LoginPage.java index e27adc31..e3a345ce 100644 --- a/src/com/gitblit/wicket/LoginPage.java +++ b/src/com/gitblit/wicket/LoginPage.java @@ -40,7 +40,7 @@ public class LoginPage extends WebPage { loginForm.add(new FeedbackPanel("feedback"));
add(loginForm);
}
-
+
protected String getServerName() {
ServletWebRequest servletWebRequest = (ServletWebRequest) getRequest();
HttpServletRequest req = servletWebRequest.getHttpServletRequest();
@@ -57,7 +57,7 @@ public class LoginPage extends WebPage { @Override
public void onSubmit() {
String username = LoginPage.this.username.getObject();
- char [] password = LoginPage.this.password.getObject().toCharArray();
+ char[] password = LoginPage.this.password.getObject().toCharArray();
User user = GitBlit.self().authenticate(username, password);
if (user == null)
@@ -87,7 +87,7 @@ public class LoginPage extends WebPage { // Set Cookie
WebResponse response = (WebResponse) getRequestCycle().getResponse();
GitBlit.self().setCookie(response, user);
-
+
// track user object so that we do not have to continue
// re-authenticating on each request.
session.setUser(user);
diff --git a/src/com/gitblit/wicket/RepositoryPage.java b/src/com/gitblit/wicket/RepositoryPage.java index 8dc485a5..e7196690 100644 --- a/src/com/gitblit/wicket/RepositoryPage.java +++ b/src/com/gitblit/wicket/RepositoryPage.java @@ -65,7 +65,7 @@ public abstract class RepositoryPage extends BasePage { }
protected void addRefs(Repository r, RevCommit c) {
- add(new RefsPanel("refsPanel", repositoryName, c, JGitUtils.getAllRefs(r)));
+ add(new RefsPanel("refsPanel", repositoryName, c, JGitUtils.getAllRefs(r)));
}
protected void addFullText(String wicketId, String text, boolean substituteRegex) {
diff --git a/src/com/gitblit/wicket/User.java b/src/com/gitblit/wicket/User.java index c23b849c..e506c8cb 100644 --- a/src/com/gitblit/wicket/User.java +++ b/src/com/gitblit/wicket/User.java @@ -4,22 +4,22 @@ import com.gitblit.Build; import com.gitblit.Constants;
public class User {
-
+
private String username;
- private char [] password;
+ private String cookie;
private boolean canAdmin = false;
private boolean canClone = false;
private boolean canPush = false;
-
- public User(String username, char [] password) {
+
+ public User(String username, char[] password) {
this.username = username;
- this.password = password;
+ this.cookie = Build.getSHA1((Constants.NAME + username + new String(password)).getBytes());
}
-
+
public void canAdmin(boolean value) {
canAdmin = value;
}
-
+
public boolean canAdmin() {
return canAdmin;
}
@@ -27,23 +27,23 @@ public class User { public void canClone(boolean value) {
canClone = value;
}
-
+
public boolean canClone() {
return canClone;
}
-
+
public void canPush(boolean value) {
canPush = value;
}
-
+
public boolean canPush() {
return canPush;
}
public String getCookie() {
- return Build.getSHA1((Constants.NAME + username + new String(password)).getBytes());
+ return cookie;
}
-
+
public String toString() {
return username;
}
diff --git a/src/com/gitblit/wicket/WicketUtils.java b/src/com/gitblit/wicket/WicketUtils.java index 65270a2c..27992f13 100644 --- a/src/com/gitblit/wicket/WicketUtils.java +++ b/src/com/gitblit/wicket/WicketUtils.java @@ -12,6 +12,7 @@ import org.apache.wicket.behavior.SimpleAttributeModifier; import org.apache.wicket.markup.html.basic.Label;
import org.eclipse.jgit.lib.Constants;
+import com.gitblit.Keys;
import com.gitblit.StoredSettings;
import com.gitblit.utils.Utils;
@@ -32,7 +33,7 @@ public class WicketUtils { public static String breakLines(String string) {
return string.replace("\r", "<br/>").replace("\n", "<br/>");
}
-
+
public static void setTicketCssClass(Component container, String state) {
String css = null;
if (state.equals("open")) {
@@ -48,7 +49,7 @@ public class WicketUtils { setCssClass(container, css);
}
}
-
+
public static String flattenStrings(List<String> values) {
StringBuilder sb = new StringBuilder();
for (String value : values) {
@@ -56,12 +57,12 @@ public class WicketUtils { }
return sb.toString().trim();
}
-
+
public static void setAlternatingBackground(Component c, int i) {
String clazz = i % 2 == 0 ? "dark" : "light";
setCssClass(c, clazz);
}
-
+
public static Label createAuthorLabel(String wicketId, String author) {
Label label = new Label(wicketId, author);
WicketUtils.setHtmlTitle(label, author);
@@ -71,14 +72,14 @@ public class WicketUtils { public static String trimShortLog(String string) {
return trimString(string, 60);
}
-
+
public static String trimString(String value, int max) {
if (value.length() <= max) {
return value;
}
return value.substring(0, max - 3) + "...";
}
-
+
public static PageParameters newRepositoryParameter(String repositoryName) {
return new PageParameters("r=" + repositoryName);
}
@@ -96,14 +97,14 @@ public class WicketUtils { }
return new PageParameters("r=" + repositoryName + ",h=" + objectId + ",f=" + path);
}
-
+
public static PageParameters newLogPageParameter(String repositoryName, String objectId, int pageNumber) {
if (pageNumber <= 1) {
return newObjectParameter(repositoryName, objectId);
}
return new PageParameters("r=" + repositoryName + ",h=" + objectId + ",page=" + pageNumber);
}
-
+
public static String getRepositoryName(PageParameters params) {
return params.getString("r", "");
}
@@ -121,7 +122,7 @@ public class WicketUtils { }
public static Label createDateLabel(String wicketId, Date date, TimeZone timeZone) {
- DateFormat df = new SimpleDateFormat(StoredSettings.getString("datestampShortFormat", "MM/dd/yy"));
+ DateFormat df = new SimpleDateFormat(StoredSettings.getString(Keys.web_datestampShortFormat, "MM/dd/yy"));
if (timeZone != null) {
df.setTimeZone(timeZone);
}
@@ -137,9 +138,9 @@ public class WicketUtils { WicketUtils.setHtmlTitle(label, title);
return label;
}
-
+
public static Label createTimestampLabel(String wicketId, Date date, TimeZone timeZone) {
- DateFormat df = new SimpleDateFormat(StoredSettings.getString("datetimestampLongFormat", "EEEE, MMMM d, yyyy h:mm a z"));
+ DateFormat df = new SimpleDateFormat(StoredSettings.getString(Keys.web_datetimestampLongFormat, "EEEE, MMMM d, yyyy h:mm a z"));
if (timeZone != null) {
df.setTimeZone(timeZone);
}
diff --git a/src/com/gitblit/wicket/models/PathModel.java b/src/com/gitblit/wicket/models/PathModel.java index cd44730a..e2e463f9 100644 --- a/src/com/gitblit/wicket/models/PathModel.java +++ b/src/com/gitblit/wicket/models/PathModel.java @@ -4,18 +4,17 @@ import java.io.Serializable; import com.gitblit.utils.JGitUtils;
-
public class PathModel implements Serializable, Comparable<PathModel> {
private static final long serialVersionUID = 1L;
-
+
public final String name;
public final String path;
public final long size;
- public final int mode;
+ public final int mode;
public final String commitId;
public boolean isParentPath;
-
+
public PathModel(String name, String path, long size, int mode, String commitId) {
this.name = name;
this.path = path;
@@ -23,11 +22,11 @@ public class PathModel implements Serializable, Comparable<PathModel> { this.mode = mode;
this.commitId = commitId;
}
-
+
public boolean isTree() {
return JGitUtils.isTreeFromMode(mode);
}
-
+
public static PathModel getParentPath(String basePath, String commitId) {
String parentPath = null;
if (basePath.lastIndexOf('/') > -1) {
diff --git a/src/com/gitblit/wicket/models/RefModel.java b/src/com/gitblit/wicket/models/RefModel.java index 0c784340..bb563d52 100644 --- a/src/com/gitblit/wicket/models/RefModel.java +++ b/src/com/gitblit/wicket/models/RefModel.java @@ -9,7 +9,6 @@ import org.eclipse.jgit.revwalk.RevCommit; import com.gitblit.utils.JGitUtils;
-
public class RefModel implements Serializable, Comparable<RefModel> {
private static final long serialVersionUID = 1L;
@@ -34,7 +33,7 @@ public class RefModel implements Serializable, Comparable<RefModel> { public String getName() {
return ref.getName();
}
-
+
public RevCommit getCommit() {
return commit;
}
@@ -50,12 +49,12 @@ public class RefModel implements Serializable, Comparable<RefModel> { public ObjectId getObjectId() {
return ref.getObjectId();
}
-
+
public boolean isAnnotatedTag() {
// ref.isPeeled() ??
return !getCommitId().equals(getObjectId());
}
-
+
@Override
public int compareTo(RefModel o) {
return getDate().compareTo(o.getDate());
diff --git a/src/com/gitblit/wicket/models/TicGitTicket.java b/src/com/gitblit/wicket/models/TicGitTicket.java index 50f1e08f..6bbb7be0 100644 --- a/src/com/gitblit/wicket/models/TicGitTicket.java +++ b/src/com/gitblit/wicket/models/TicGitTicket.java @@ -38,13 +38,13 @@ public class TicGitTicket implements Serializable, Comparable<TicGitTicket> { if (chunks.length == 3) {
date = new Date(Long.parseLong(chunks[0]) * 1000l);
title = chunks[1].replace('-', ' ');
- }
+ }
}
public static class Comment implements Serializable, Comparable<Comment> {
-
+
private static final long serialVersionUID = 1L;
-
+
public String text;
public String author;
public Date date;
diff --git a/src/com/gitblit/wicket/pages/BlobDiffPage.java b/src/com/gitblit/wicket/pages/BlobDiffPage.java index 17d78968..21127bc4 100644 --- a/src/com/gitblit/wicket/pages/BlobDiffPage.java +++ b/src/com/gitblit/wicket/pages/BlobDiffPage.java @@ -33,10 +33,10 @@ public class BlobDiffPage extends RepositoryPage { add(new LinkPanel("shortlog", "title", commit.getShortMessage(), CommitPage.class, newCommitParameter()));
add(new PathBreadcrumbsPanel("breadcrumbs", repositoryName, blobPath, objectId));
-
+
add(new Label("diffText", diff).setEscapeModelStrings(false));
}
-
+
@Override
protected String getPageName() {
return getString("gb.diff");
diff --git a/src/com/gitblit/wicket/pages/BlobPage.java b/src/com/gitblit/wicket/pages/BlobPage.java index 0c112d08..51749a36 100644 --- a/src/com/gitblit/wicket/pages/BlobPage.java +++ b/src/com/gitblit/wicket/pages/BlobPage.java @@ -11,6 +11,7 @@ import org.eclipse.jgit.lib.Constants; import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
+import com.gitblit.Keys;
import com.gitblit.StoredSettings;
import com.gitblit.utils.JGitUtils;
import com.gitblit.wicket.LinkPanel;
@@ -18,7 +19,6 @@ import com.gitblit.wicket.RepositoryPage; import com.gitblit.wicket.WicketUtils;
import com.gitblit.wicket.panels.PathBreadcrumbsPanel;
-
public class BlobPage extends RepositoryPage {
public BlobPage(PageParameters params) {
@@ -45,13 +45,13 @@ public class BlobPage extends RepositoryPage { // Map the extensions to types
Map<String, Integer> map = new HashMap<String, Integer>();
- for (String ext : StoredSettings.getStrings("prettyPrintExtensions")) {
+ for (String ext : StoredSettings.getStrings(Keys.web_prettyPrintExtensions)) {
map.put(ext.toLowerCase(), 1);
}
- for (String ext : StoredSettings.getStrings("imageExtensions")) {
+ for (String ext : StoredSettings.getStrings(Keys.web_imageExtensions)) {
map.put(ext.toLowerCase(), 2);
}
- for (String ext : StoredSettings.getStrings("binaryExtensions")) {
+ for (String ext : StoredSettings.getStrings(Keys.web_binaryExtensions)) {
map.put(ext.toLowerCase(), 3);
}
@@ -88,7 +88,7 @@ public class BlobPage extends RepositoryPage { add(blobLabel);
}
}
-
+
@Override
protected String getPageName() {
return getString("gb.view");
diff --git a/src/com/gitblit/wicket/pages/BranchesPage.java b/src/com/gitblit/wicket/pages/BranchesPage.java index f4359d81..49088f0d 100644 --- a/src/com/gitblit/wicket/pages/BranchesPage.java +++ b/src/com/gitblit/wicket/pages/BranchesPage.java @@ -5,7 +5,6 @@ import org.apache.wicket.PageParameters; import com.gitblit.wicket.RepositoryPage;
import com.gitblit.wicket.panels.BranchesPanel;
-
public class BranchesPage extends RepositoryPage {
public BranchesPage(PageParameters params) {
@@ -13,7 +12,7 @@ public class BranchesPage extends RepositoryPage { add(new BranchesPanel("branchesPanel", repositoryName, getRepository(), -1));
}
-
+
@Override
protected String getPageName() {
return getString("gb.branches");
diff --git a/src/com/gitblit/wicket/pages/CommitDiffPage.java b/src/com/gitblit/wicket/pages/CommitDiffPage.java index 7f6d347e..7218cf81 100644 --- a/src/com/gitblit/wicket/pages/CommitDiffPage.java +++ b/src/com/gitblit/wicket/pages/CommitDiffPage.java @@ -25,15 +25,15 @@ public class CommitDiffPage extends RepositoryPage { Repository r = getRepository();
RevCommit commit = JGitUtils.getCommit(r, objectId);
- String diff = JGitUtils.getCommitDiff(r, commit, true);
-
+ String diff = JGitUtils.getCommitDiff(r, commit, true);
+
List<String> parents = new ArrayList<String>();
if (commit.getParentCount() > 0) {
for (RevCommit parent : commit.getParents()) {
parents.add(parent.name());
}
}
-
+
// commit page links
if (parents.size() == 0) {
add(new Label("parentLink", "none"));
@@ -46,7 +46,7 @@ public class CommitDiffPage extends RepositoryPage { add(new LinkPanel("shortlog", "title", commit.getShortMessage(), CommitPage.class, newCommitParameter()));
// changed paths list
- List<PathModel> paths = JGitUtils.getFilesInCommit(r, commit);
+ List<PathModel> paths = JGitUtils.getFilesInCommit(r, commit);
ListDataProvider<PathModel> pathsDp = new ListDataProvider<PathModel>(paths);
DataView<PathModel> pathsView = new DataView<PathModel>("changedPath", pathsDp) {
private static final long serialVersionUID = 1L;
@@ -59,7 +59,7 @@ public class CommitDiffPage extends RepositoryPage { } else {
item.add(new LinkPanel("pathName", "list", entry.path, BlobPage.class, newPathParameter(entry.path)));
}
-
+
item.add(new BookmarkablePageLink<Void>("patch", PatchPage.class, newPathParameter(entry.path)));
item.add(new BookmarkablePageLink<Void>("view", BlobPage.class, newPathParameter(entry.path)));
item.add(new BookmarkablePageLink<Void>("blame", BlobPage.class).setEnabled(false));
@@ -72,7 +72,7 @@ public class CommitDiffPage extends RepositoryPage { add(pathsView);
add(new Label("diffText", diff).setEscapeModelStrings(false));
}
-
+
@Override
protected String getPageName() {
return getString("gb.commitdiff");
diff --git a/src/com/gitblit/wicket/pages/CommitPage.java b/src/com/gitblit/wicket/pages/CommitPage.java index 7e3403de..9cc6df85 100644 --- a/src/com/gitblit/wicket/pages/CommitPage.java +++ b/src/com/gitblit/wicket/pages/CommitPage.java @@ -19,7 +19,6 @@ import com.gitblit.wicket.RepositoryPage; import com.gitblit.wicket.WicketUtils;
import com.gitblit.wicket.models.PathModel;
-
public class CommitPage extends RepositoryPage {
public CommitPage(PageParameters params) {
@@ -27,14 +26,14 @@ public class CommitPage extends RepositoryPage { Repository r = getRepository();
RevCommit c = JGitUtils.getCommit(r, objectId);
-
+
List<String> parents = new ArrayList<String>();
if (c.getParentCount() > 0) {
for (RevCommit parent : c.getParents()) {
parents.add(parent.name());
}
}
-
+
// commit page links
if (parents.size() == 0) {
add(new Label("parentLink", "none"));
@@ -44,9 +43,9 @@ public class CommitPage extends RepositoryPage { add(new LinkPanel("commitdiffLink", null, new StringResourceModel("gb.commitdiff", this, null), CommitDiffPage.class, WicketUtils.newObjectParameter(repositoryName, objectId)));
}
add(new BookmarkablePageLink<Void>("patchLink", PatchPage.class, WicketUtils.newObjectParameter(repositoryName, objectId)));
-
+
add(new LinkPanel("shortlog", "title", c.getShortMessage(), CommitDiffPage.class, WicketUtils.newObjectParameter(repositoryName, objectId)));
-
+
addRefs(r, c);
add(new Label("commitAuthor", JGitUtils.getDisplayName(c.getAuthorIdent())));
@@ -76,7 +75,7 @@ public class CommitPage extends RepositoryPage { addFullText("fullMessage", c.getFullMessage(), true);
// changed paths list
- List<PathModel> paths = JGitUtils.getFilesInCommit(r, c);
+ List<PathModel> paths = JGitUtils.getFilesInCommit(r, c);
ListDataProvider<PathModel> pathsDp = new ListDataProvider<PathModel>(paths);
DataView<PathModel> pathsView = new DataView<PathModel>("changedPath", pathsDp) {
private static final long serialVersionUID = 1L;
@@ -89,7 +88,7 @@ public class CommitPage extends RepositoryPage { } else {
item.add(new LinkPanel("pathName", "list", entry.path, BlobPage.class, newPathParameter(entry.path)));
}
-
+
item.add(new BookmarkablePageLink<Void>("diff", BlobDiffPage.class, newPathParameter(entry.path)));
item.add(new BookmarkablePageLink<Void>("view", BlobPage.class, newPathParameter(entry.path)));
item.add(new BookmarkablePageLink<Void>("blame", BlobPage.class).setEnabled(false));
@@ -101,7 +100,7 @@ public class CommitPage extends RepositoryPage { };
add(pathsView);
}
-
+
@Override
protected String getPageName() {
return getString("gb.commit");
diff --git a/src/com/gitblit/wicket/pages/PatchPage.java b/src/com/gitblit/wicket/pages/PatchPage.java index c877bb6d..12e89a6c 100644 --- a/src/com/gitblit/wicket/pages/PatchPage.java +++ b/src/com/gitblit/wicket/pages/PatchPage.java @@ -13,7 +13,6 @@ import com.gitblit.GitBlit; import com.gitblit.utils.JGitUtils;
import com.gitblit.wicket.WicketUtils;
-
public class PatchPage extends WebPage {
public PatchPage(PageParameters params) {
@@ -24,7 +23,7 @@ public class PatchPage extends WebPage { redirectToInterceptPage(new RepositoriesPage());
}
final String repositoryName = WicketUtils.getRepositoryName(params);
- final String objectId = WicketUtils.getObject(params);
+ final String objectId = WicketUtils.getObject(params);
final String blobPath = WicketUtils.getPath(params);
ServletWebRequest servletWebRequest = (ServletWebRequest) getRequest();
@@ -42,5 +41,5 @@ public class PatchPage extends WebPage { String patch = JGitUtils.getCommitPatch(r, commit, blobPath);
add(new Label("patchText", patch));
r.close();
- }
+ }
}
diff --git a/src/com/gitblit/wicket/pages/RawPage.java b/src/com/gitblit/wicket/pages/RawPage.java index dc58b208..961e4c94 100644 --- a/src/com/gitblit/wicket/pages/RawPage.java +++ b/src/com/gitblit/wicket/pages/RawPage.java @@ -14,11 +14,11 @@ import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.revwalk.RevCommit;
import com.gitblit.GitBlit;
+import com.gitblit.Keys;
import com.gitblit.StoredSettings;
import com.gitblit.utils.JGitUtils;
import com.gitblit.wicket.WicketUtils;
-
public class RawPage extends WebPage {
public RawPage(PageParameters params) {
@@ -29,7 +29,7 @@ public class RawPage extends WebPage { redirectToInterceptPage(new RepositoriesPage());
}
final String repositoryName = WicketUtils.getRepositoryName(params);
- final String objectId = WicketUtils.getObject(params);
+ final String objectId = WicketUtils.getObject(params);
final String blobPath = WicketUtils.getPath(params);
ServletWebRequest servletWebRequest = (ServletWebRequest) getRequest();
@@ -52,10 +52,10 @@ public class RawPage extends WebPage { // Map the extensions to types
Map<String, Integer> map = new HashMap<String, Integer>();
- for (String ext : StoredSettings.getStrings("imageExtensions")) {
+ for (String ext : StoredSettings.getStrings(Keys.web_imageExtensions)) {
map.put(ext.toLowerCase(), 2);
}
- for (String ext : StoredSettings.getStrings("binaryExtensions")) {
+ for (String ext : StoredSettings.getStrings(Keys.web_binaryExtensions)) {
map.put(ext.toLowerCase(), 3);
}
@@ -87,5 +87,5 @@ public class RawPage extends WebPage { add(blobLabel);
}
r.close();
- }
+ }
}
diff --git a/src/com/gitblit/wicket/pages/RepositoriesPage.java b/src/com/gitblit/wicket/pages/RepositoriesPage.java index 3a43b0d9..eca216c9 100644 --- a/src/com/gitblit/wicket/pages/RepositoriesPage.java +++ b/src/com/gitblit/wicket/pages/RepositoriesPage.java @@ -18,6 +18,7 @@ import org.apache.wicket.model.IModel; import org.apache.wicket.model.Model;
import com.gitblit.GitBlit;
+import com.gitblit.Keys;
import com.gitblit.StoredSettings;
import com.gitblit.utils.Utils;
import com.gitblit.wicket.BasePage;
@@ -26,27 +27,26 @@ import com.gitblit.wicket.LinkPanel; import com.gitblit.wicket.WicketUtils;
import com.gitblit.wicket.models.RepositoryModel;
-
public class RepositoriesPage extends BasePage {
public RepositoriesPage() {
super();
setupPage("", "");
-
+
boolean showAdmin = false;
- if (StoredSettings.getBoolean("authenticateWebUI", true)) {
- boolean allowAdmin = StoredSettings.getBoolean("allowAdministration", false);
- showAdmin = allowAdmin && GitBlitWebSession.get().canAdmin();
+ if (StoredSettings.getBoolean(Keys.web_authenticate, true)) {
+ boolean allowAdmin = StoredSettings.getBoolean(Keys.web_allowAdministration, false);
+ showAdmin = allowAdmin && GitBlitWebSession.get().canAdmin();
} else {
- showAdmin = StoredSettings.getBoolean("allowAdministration", false);
+ showAdmin = StoredSettings.getBoolean(Keys.web_allowAdministration, false);
}
-
+
Fragment adminLinks = new Fragment("adminPanel", "adminLinks", this);
adminLinks.add(new BookmarkablePageLink<Void>("newRepository", RepositoriesPage.class));
- adminLinks.add(new BookmarkablePageLink<Void>("newUser", RepositoriesPage.class));
+ adminLinks.add(new BookmarkablePageLink<Void>("newUser", RepositoriesPage.class));
add(adminLinks.setVisible(showAdmin));
-
- add(new Label("repositoriesMessage", StoredSettings.getString("repositoriesMessage", "")).setEscapeModelStrings(false));
+
+ add(new Label("repositoriesMessage", StoredSettings.getString(Keys.web_repositoriesMessage, "")).setEscapeModelStrings(false));
List<RepositoryModel> rows = GitBlit.self().getRepositories(getRequest());
DataProvider dp = new DataProvider(rows);
diff --git a/src/com/gitblit/wicket/pages/SummaryPage.java b/src/com/gitblit/wicket/pages/SummaryPage.java index 1dafb52b..50de96ec 100644 --- a/src/com/gitblit/wicket/pages/SummaryPage.java +++ b/src/com/gitblit/wicket/pages/SummaryPage.java @@ -15,6 +15,7 @@ import com.codecommit.wicket.ChartAxisType; import com.codecommit.wicket.ChartProvider;
import com.codecommit.wicket.ChartType;
import com.codecommit.wicket.IChartData;
+import com.gitblit.Keys;
import com.gitblit.StoredSettings;
import com.gitblit.utils.JGitUtils;
import com.gitblit.wicket.GitBlitWebApp;
@@ -29,23 +30,23 @@ public class SummaryPage extends RepositoryPage { public SummaryPage(PageParameters params) {
super(params);
-
+
int numCommitsDef = 20;
int numRefsDef = 5;
-
- int numberCommits = StoredSettings.getInteger("summaryCommitCount", numCommitsDef);
+
+ int numberCommits = StoredSettings.getInteger(Keys.web_summaryCommitCount, numCommitsDef);
if (numberCommits <= 0) {
numberCommits = numCommitsDef;
}
- int numberRefs = StoredSettings.getInteger("summaryRefsCount", numRefsDef);
+ int numberRefs = StoredSettings.getInteger(Keys.web_summaryRefsCount, numRefsDef);
if (numberRefs <= 0) {
numberRefs = numRefsDef;
}
-
- Repository r = getRepository();
+
+ Repository r = getRepository();
List<Metric> metrics = JGitUtils.getDateMetrics(r);
-
+
long numberOfCommits = 0;
for (Metric m : metrics) {
numberOfCommits += m.count;
@@ -54,25 +55,25 @@ public class SummaryPage extends RepositoryPage { // repository description
add(new Label("repositoryDescription", description));
add(new Label("repositoryOwner", JGitUtils.getRepositoryOwner(r)));
-
+
add(WicketUtils.createTimestampLabel("repositoryLastChange", JGitUtils.getLastChange(r), getTimeZone()));
add(new Label("repositoryCloneUrl", GitBlitWebApp.get().getCloneUrl(repositoryName)));
add(new LogPanel("commitsPanel", repositoryName, null, r, numberCommits, 0));
add(new TagsPanel("tagsPanel", repositoryName, r, numberRefs));
add(new BranchesPanel("branchesPanel", repositoryName, r, numberRefs));
-
+
// Display an activity line graph
insertActivityGraph(metrics);
}
-
+
@Override
protected String getPageName() {
return getString("gb.summary");
}
private void insertActivityGraph(List<Metric> metrics) {
- if (StoredSettings.getBoolean("generateActivityGraph", true)) {
+ if (StoredSettings.getBoolean(Keys.web_generateActivityGraph, true)) {
IChartData data = getChartData(metrics);
ChartProvider provider = new ChartProvider(new Dimension(400, 80), ChartType.LINE, data);
@@ -86,7 +87,7 @@ public class SummaryPage extends RepositoryPage { add(new Chart("commitsChart", provider));
} else {
- add(new ContextImage("commitsChart", "blank.png"));
+ add(new ContextImage("commitsChart", "blank.png"));
}
}
diff --git a/src/com/gitblit/wicket/pages/TagPage.java b/src/com/gitblit/wicket/pages/TagPage.java index e6f2fd6b..d36c887a 100644 --- a/src/com/gitblit/wicket/pages/TagPage.java +++ b/src/com/gitblit/wicket/pages/TagPage.java @@ -13,19 +13,18 @@ import com.gitblit.wicket.RepositoryPage; import com.gitblit.wicket.WicketUtils;
import com.gitblit.wicket.models.RefModel;
-
public class TagPage extends RepositoryPage {
public TagPage(PageParameters params) {
super(params);
- Repository r = getRepository();
+ Repository r = getRepository();
List<RefModel> tags = JGitUtils.getTags(r, -1);
RevCommit c = JGitUtils.getCommit(r, objectId);
-
+
RefModel tagRef = null;
// determine tag
- for (RefModel tag:tags) {
+ for (RefModel tag : tags) {
if (tag.getName().equals(objectId) || tag.getObjectId().getName().equals(objectId)) {
tagRef = tag;
break;
@@ -35,19 +34,19 @@ public class TagPage extends RepositoryPage { if (tagRef == null) {
// point to commit
add(new LinkPanel("commit", "title", c.getShortMessage(), CommitPage.class, newCommitParameter()));
- add(new LinkPanel("tagId", "list", c.getName(), CommitPage.class, newCommitParameter(c.getName())));
+ add(new LinkPanel("tagId", "list", c.getName(), CommitPage.class, newCommitParameter(c.getName())));
} else {
// TODO commit or tree or blob?
add(new LinkPanel("commit", "title", tagRef.getDisplayName(), CommitPage.class, newCommitParameter()));
add(new LinkPanel("tagId", "list", c.getName(), CommitPage.class, newCommitParameter(c.getName())));
- }
-
+ }
+
add(new Label("tagAuthor", JGitUtils.getDisplayName(c.getAuthorIdent())));
add(WicketUtils.createTimestampLabel("tagDate", c.getAuthorIdent().getWhen(), getTimeZone()));
addFullText("fullMessage", c.getFullMessage(), true);
}
-
+
@Override
protected String getPageName() {
return getString("gb.tag");
diff --git a/src/com/gitblit/wicket/pages/TagsPage.java b/src/com/gitblit/wicket/pages/TagsPage.java index eb1742d1..d759d5d1 100644 --- a/src/com/gitblit/wicket/pages/TagsPage.java +++ b/src/com/gitblit/wicket/pages/TagsPage.java @@ -5,16 +5,15 @@ import org.apache.wicket.PageParameters; import com.gitblit.wicket.RepositoryPage;
import com.gitblit.wicket.panels.TagsPanel;
-
public class TagsPage extends RepositoryPage {
public TagsPage(PageParameters params) {
super(params);
-
+
add(new TagsPanel("tagsPanel", repositoryName, getRepository(), -1));
-
+
}
-
+
@Override
protected String getPageName() {
return getString("gb.tags");
diff --git a/src/com/gitblit/wicket/pages/TicGitPage.java b/src/com/gitblit/wicket/pages/TicGitPage.java index 7a8b301e..204565c6 100644 --- a/src/com/gitblit/wicket/pages/TicGitPage.java +++ b/src/com/gitblit/wicket/pages/TicGitPage.java @@ -45,7 +45,7 @@ public class TicGitPage extends RepositoryPage { };
add(ticketsView);
}
-
+
@Override
protected String getPageName() {
return getString("gb.ticgit");
diff --git a/src/com/gitblit/wicket/pages/TicGitTicketPage.java b/src/com/gitblit/wicket/pages/TicGitTicketPage.java index 73b70850..30bd6ccf 100644 --- a/src/com/gitblit/wicket/pages/TicGitTicketPage.java +++ b/src/com/gitblit/wicket/pages/TicGitTicketPage.java @@ -50,7 +50,7 @@ public class TicGitTicketPage extends RepositoryPage { };
add(commentsView);
}
-
+
@Override
protected String getPageName() {
return getString("gb.ticket");
@@ -58,7 +58,7 @@ public class TicGitTicketPage extends RepositoryPage { private String prepareComment(String comment) {
String html = Utils.escapeForHtml(comment, false);
- html = WicketUtils.breakLines(comment).trim();
+ html = WicketUtils.breakLines(comment).trim();
return html.replaceAll("\\bcommit\\s*([A-Za-z0-9]*)\\b", "<a href=\"/commit/" + repositoryName + "/$1\">commit $1</a>");
}
}
diff --git a/src/com/gitblit/wicket/pages/TreePage.java b/src/com/gitblit/wicket/pages/TreePage.java index d83939ea..5ebb1b65 100644 --- a/src/com/gitblit/wicket/pages/TreePage.java +++ b/src/com/gitblit/wicket/pages/TreePage.java @@ -21,7 +21,6 @@ import com.gitblit.wicket.WicketUtils; import com.gitblit.wicket.models.PathModel;
import com.gitblit.wicket.panels.PathBreadcrumbsPanel;
-
public class TreePage extends RepositoryPage {
public TreePage(PageParameters params) {
@@ -37,18 +36,17 @@ public class TreePage extends RepositoryPage { add(new Label("historyLink", getString("gb.history")));
add(new BookmarkablePageLink<Void>("headLink", TreePage.class, WicketUtils.newPathParameter(repositoryName, Constants.HEAD, basePath)));
-
add(new LinkPanel("shortlog", "title", commit.getShortMessage(), CommitPage.class, newCommitParameter()));
// breadcrumbs
- add(new PathBreadcrumbsPanel("breadcrumbs", repositoryName, basePath, objectId));
+ add(new PathBreadcrumbsPanel("breadcrumbs", repositoryName, basePath, objectId));
if (basePath != null && basePath.trim().length() > 0) {
paths.add(0, PathModel.getParentPath(basePath, objectId));
}
final ByteFormat byteFormat = new ByteFormat();
-
- // changed paths list
+
+ // changed paths list
ListDataProvider<PathModel> pathsDp = new ListDataProvider<PathModel>(paths);
DataView<PathModel> pathsView = new DataView<PathModel>("changedPath", pathsDp) {
private static final long serialVersionUID = 1L;
@@ -67,7 +65,7 @@ public class TreePage extends RepositoryPage { // folder/tree link
item.add(new Label("pathSize", ""));
item.add(new LinkPanel("pathName", null, entry.name, TreePage.class, newPathParameter(entry.path)));
-
+
// links
Fragment links = new Fragment("pathLinks", "treeLinks", this);
links.add(new BookmarkablePageLink<Void>("tree", TreePage.class, WicketUtils.newPathParameter(repositoryName, entry.commitId, entry.path)));
@@ -77,7 +75,7 @@ public class TreePage extends RepositoryPage { // blob link
item.add(new Label("pathSize", byteFormat.format(entry.size)));
item.add(new LinkPanel("pathName", "list", entry.name, BlobPage.class, newPathParameter(entry.path)));
-
+
// links
Fragment links = new Fragment("pathLinks", "blobLinks", this);
links.add(new BookmarkablePageLink<Void>("view", BlobPage.class, WicketUtils.newPathParameter(repositoryName, entry.commitId, entry.path)));
@@ -93,7 +91,7 @@ public class TreePage extends RepositoryPage { };
add(pathsView);
}
-
+
@Override
protected String getPageName() {
return getString("gb.tree");
diff --git a/src/com/gitblit/wicket/panels/BasePanel.java b/src/com/gitblit/wicket/panels/BasePanel.java index f81dfa9f..cdfc050c 100644 --- a/src/com/gitblit/wicket/panels/BasePanel.java +++ b/src/com/gitblit/wicket/panels/BasePanel.java @@ -4,6 +4,7 @@ import java.util.TimeZone; import org.apache.wicket.markup.html.panel.Panel;
+import com.gitblit.Keys;
import com.gitblit.StoredSettings;
import com.gitblit.wicket.GitBlitWebSession;
@@ -16,6 +17,6 @@ public abstract class BasePanel extends Panel { }
protected TimeZone getTimeZone() {
- return StoredSettings.getBoolean("useClientTimezone", false) ? GitBlitWebSession.get().getTimezone() : TimeZone.getDefault();
+ return StoredSettings.getBoolean(Keys.web_useClientTimezone, false) ? GitBlitWebSession.get().getTimezone() : TimeZone.getDefault();
}
}
diff --git a/src/com/gitblit/wicket/panels/BranchesPanel.java b/src/com/gitblit/wicket/panels/BranchesPanel.java index 1c68b6f9..8ac78e4c 100644 --- a/src/com/gitblit/wicket/panels/BranchesPanel.java +++ b/src/com/gitblit/wicket/panels/BranchesPanel.java @@ -48,7 +48,7 @@ public class BranchesPanel extends BasePanel { // show repository summary page link
add(new LinkPanel("branches", "title", repositoryName, SummaryPage.class, WicketUtils.newRepositoryParameter(repositoryName)));
}
-
+
ListDataProvider<RefModel> branchesDp = new ListDataProvider<RefModel>(branches);
DataView<RefModel> branchesView = new DataView<RefModel>("branch", branchesDp) {
private static final long serialVersionUID = 1L;
@@ -60,11 +60,11 @@ public class BranchesPanel extends BasePanel { item.add(WicketUtils.createDateLabel("branchDate", entry.getDate(), getTimeZone()));
item.add(new LinkPanel("branchName", "list name", WicketUtils.trimString(entry.getDisplayName(), 28), LogPage.class, WicketUtils.newObjectParameter(repositoryName, entry.getName())));
-
+
// only show branch type on the branches page
boolean remote = entry.getName().startsWith(Constants.R_REMOTES);
- item.add(new Label("branchType", remote ? getString("gb.remote"):getString("gb.local")).setVisible(maxCount <= 0));
-
+ item.add(new Label("branchType", remote ? getString("gb.remote") : getString("gb.local")).setVisible(maxCount <= 0));
+
item.add(new BookmarkablePageLink<Void>("log", LogPage.class, WicketUtils.newObjectParameter(repositoryName, entry.getName())));
item.add(new BookmarkablePageLink<Void>("tree", TreePage.class, WicketUtils.newObjectParameter(repositoryName, entry.getName())));
diff --git a/src/com/gitblit/wicket/panels/LogPanel.java b/src/com/gitblit/wicket/panels/LogPanel.java index 8ef1e3e7..504bdd3a 100644 --- a/src/com/gitblit/wicket/panels/LogPanel.java +++ b/src/com/gitblit/wicket/panels/LogPanel.java @@ -14,12 +14,13 @@ import org.eclipse.jgit.lib.ObjectId; import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
+import com.gitblit.Keys;
import com.gitblit.StoredSettings;
import com.gitblit.utils.JGitUtils;
import com.gitblit.wicket.LinkPanel;
import com.gitblit.wicket.WicketUtils;
-import com.gitblit.wicket.pages.CommitPage;
import com.gitblit.wicket.pages.CommitDiffPage;
+import com.gitblit.wicket.pages.CommitPage;
import com.gitblit.wicket.pages.LogPage;
import com.gitblit.wicket.pages.SummaryPage;
import com.gitblit.wicket.pages.TreePage;
@@ -31,7 +32,7 @@ public class LogPanel extends BasePanel { public LogPanel(String wicketId, final String repositoryName, String objectId, Repository r, int limit, int pageOffset) {
super(wicketId);
boolean pageResults = limit <= 0;
- int itemsPerPage = StoredSettings.getInteger("logPageCommitCount", 50);
+ int itemsPerPage = StoredSettings.getInteger(Keys.web_logPageCommitCount, 50);
if (itemsPerPage <= 1) {
itemsPerPage = 50;
}
diff --git a/src/com/gitblit/wicket/panels/PageLinksPanel.java b/src/com/gitblit/wicket/panels/PageLinksPanel.java index e2f9401d..252b49a4 100644 --- a/src/com/gitblit/wicket/panels/PageLinksPanel.java +++ b/src/com/gitblit/wicket/panels/PageLinksPanel.java @@ -57,7 +57,7 @@ public class PageLinksPanel extends Panel { // Get the repository ticgit setting
boolean checkTicgit = StoredSettings.getBoolean("ticgit.global", false);
checkTicgit |= StoredSettings.getBoolean(MessageFormat.format("ticgit.{0}", repositoryName), false);
-
+
// Add dynamic repository extras
List<String> extras = new ArrayList<String>();
if (checkTicgit && JGitUtils.getTicGitBranch(r) != null) {
@@ -84,7 +84,7 @@ public class PageLinksPanel extends Panel { String key = knownPages.get(wicketId);
String linkName = getString(key);
if (linkName.equals(pageName)) {
- Component c = get(wicketId);
+ Component c = get(wicketId);
if (c != null) {
c.setEnabled(false);
}
diff --git a/src/com/gitblit/wicket/panels/RefsPanel.java b/src/com/gitblit/wicket/panels/RefsPanel.java index 9f928912..b84d9df8 100644 --- a/src/com/gitblit/wicket/panels/RefsPanel.java +++ b/src/com/gitblit/wicket/panels/RefsPanel.java @@ -20,7 +20,6 @@ import com.gitblit.wicket.pages.CommitPage; import com.gitblit.wicket.pages.LogPage;
import com.gitblit.wicket.pages.TagPage;
-
public class RefsPanel extends Panel {
private static final long serialVersionUID = 1L;
@@ -32,11 +31,12 @@ public class RefsPanel extends Panel { refNames = new ArrayList<String>();
}
Collections.sort(refNames);
-// refNames.remove(Constants.HEAD);
-
+ // refNames.remove(Constants.HEAD);
+
ListDataProvider<String> refsDp = new ListDataProvider<String>(refNames);
DataView<String> refsView = new DataView<String>("ref", refsDp) {
private static final long serialVersionUID = 1L;
+
public void populateItem(final Item<String> item) {
String entry = item.getModelObject();
Component c = null;
|