<javac srcdir="${basedir}/src" destdir="${project.build.dir}">\r
<include name="com/gitblit/Build.java" />\r
<include name="com/gitblit/Constants.java" />\r
+ <include name="com/gitblit/utils/StringUtils.java" />\r
</javac>\r
<java classpath="${project.build.dir}" classname="com.gitblit.Build" />\r
\r
server.realmFile = users.properties\r
\r
#\r
-# Server Settings\r
-#\r
-server.debugMode = true\r
-server.tempFolder = temp\r
-server.log4jPattern = %-5p %d{MM-dd HH:mm:ss.SSS} %-20.20c{1} %m%n\r
-\r
-# Aggressive heap management will run the garbage collector on every generated\r
-# page. This slows down page generation but improves heap consumption. \r
-server.aggressiveHeapManagement = true\r
-\r
-#\r
-# Git:Blit UI Settings\r
+# Git:Blit Web Settings\r
#\r
web.siteName =\r
\r
-# If authenticateWebUI=true, users with "admin" role can create repositories,\r
+# If web.authenticate=true, users with "admin" role can create repositories,\r
# create users, and edit repository metadata (owner, description, etc)\r
#\r
-# If authenticateWebUI=false, any user can execute the aforementioned functions. \r
+# If web.authenticate=false, any user can execute the aforementioned functions. \r
web.allowAdministration = true\r
\r
# This is the message display above the repositories table.\r
# Registered extensions for binary blobs\r
web.binaryExtensions = jar pdf tar.gz zip\r
\r
+# Aggressive heap management will run the garbage collector on every generated\r
+# page. This slows down page generation but improves heap consumption. \r
+web.aggressiveHeapManagement = true\r
+\r
+# Run the webapp in debug mode\r
+web.debugMode = true\r
+\r
+# Enable/disable global regex substitutions (i.e. shared across repositories)\r
+regex.global = true\r
+\r
# Example global regex substitutions\r
+# Use !!! to separate the search pattern and the replace pattern\r
+# searchpattern!!!replacepattern\r
regex.global.bug = \\b(Bug:)(\\s*[#]?|-){0,1}(\\d+)\\b!!!<a href="http://somehost/bug/$3">Bug-Id: $3</a>\r
regex.global.changeid = \\b(Change-Id:\\s*)([A-Za-z0-9]*)\\b!!!<a href="http://somehost/changeid/$2">Change-Id: $2</a>\r
\r
# Example per-repository regex substitutions overrides global\r
#regex.myrepository.bug = \\b(Bug:)(\\s*[#]?|-){0,1}(\\d+)\\b!!!<a href="http://elsewhere/bug/$3">Bug-Id: $3</a>\r
\r
-# Enable ticgit viewer for all repositories (checks for ticgit branch)\r
+# Enable ticgit pages for all repositories (if ticgit branch is present)\r
ticgit.global = false\r
\r
-# Enable ticgit viewer for specified repository (checks for ticgit branch)\r
+# Enable ticgit pages for specified repository (if ticgit branch is present)\r
#ticgit.myrepository = true\r
\r
+#\r
+# Server Settings\r
+#\r
+server.tempFolder = temp\r
+server.log4jPattern = %-5p %d{MM-dd HH:mm:ss.SSS} %-20.20c{1} %m%n\r
+\r
#\r
# Jetty Settings\r
#\r
# Secure/SSL https port to serve. <= 0 disables this connector.\r
server.httpsPort = 443\r
\r
+# Specify the interface for Jetty to bind the standard connector.\r
+# You may specify an ip or an empty value to bind to all interfaces. \r
+server.httpBindInterface = localhost\r
+\r
+# Specify the interface for Jetty to bind the secure connector.\r
+# You may specify an ip or an empty value to bind to all interfaces.\r
+server.httpsBindInterface = localhost\r
+\r
# Password for SSL keystore (keystore password and certificate password must match)\r
server.storePassword = dosomegit\r
\r
import java.io.InputStream;\r
import java.io.RandomAccessFile;\r
import java.net.URL;\r
-import java.security.MessageDigest;\r
-import java.security.NoSuchAlgorithmException;\r
import java.text.MessageFormat;\r
import java.util.ArrayList;\r
import java.util.Collections;\r
+import java.util.HashMap;\r
import java.util.List;\r
+import java.util.Map;\r
import java.util.Properties;\r
\r
+import com.gitblit.utils.StringUtils;\r
+\r
public class Build {\r
\r
public static void main(String... args) {\r
}\r
\r
public static void buildSettingKeys() {\r
+ // Load all keys\r
Properties properties = new Properties();\r
try {\r
properties.load(new FileInputStream(Constants.PROPERTIES_FILE));\r
List<String> keys = new ArrayList<String>(properties.stringPropertyNames());\r
Collections.sort(keys);\r
\r
+ // Determine static key group classes\r
+ Map<String, List<String>> staticClasses = new HashMap<String, List<String>>();\r
+ staticClasses.put("", new ArrayList<String>());\r
+ for (String key : keys) {\r
+ String clazz = "";\r
+ String field = key;\r
+ if (key.indexOf('.') > -1) {\r
+ clazz = key.substring(0, key.indexOf('.'));\r
+ field = key.substring(key.indexOf('.') + 1);\r
+ }\r
+ if (!staticClasses.containsKey(clazz)) {\r
+ staticClasses.put(clazz, new ArrayList<String>());\r
+ }\r
+ staticClasses.get(clazz).add(field);\r
+ }\r
+\r
+ // Assemble Keys source file\r
StringBuilder sb = new StringBuilder();\r
sb.append("package com.gitblit;\n");\r
sb.append("\n");\r
sb.append(" */\n");\r
sb.append("public final class Keys {\n");\r
sb.append("\n");\r
- for (String key : keys) {\r
- sb.append(MessageFormat.format("\tpublic static final String {0} = \"{1}\";\n\n", key.replace('.', '_'), key));\r
+ List<String> classSet = new ArrayList<String>(staticClasses.keySet());\r
+ Collections.sort(classSet);\r
+ for (String clazz : classSet) {\r
+ List<String> keySet = staticClasses.get(clazz);\r
+ if (clazz.equals("")) {\r
+ // root keys\r
+ for (String key : keySet) {\r
+ sb.append(MessageFormat.format("\tpublic static final String {0} = \"{1}\";\n\n", key.replace('.', '_'), key));\r
+ }\r
+ } else {\r
+ // class keys\r
+ sb.append(MessageFormat.format("\tpublic static final class {0} '{'\n\n", clazz));\r
+ sb.append(MessageFormat.format("\t\tpublic static final String _ROOT = \"{0}\";\n\n", clazz));\r
+ for (String key : keySet) {\r
+ sb.append(MessageFormat.format("\t\tpublic static final String {0} = \"{1}\";\n\n", key.replace('.', '_'), clazz + "." + key));\r
+ }\r
+ sb.append("\t}\n\n");\r
+ }\r
}\r
sb.append("}");\r
+\r
+ // Save Keys class definition\r
try {\r
File file = new File("src/com/gitblit/Keys.java");\r
file.delete();\r
throw new RuntimeException("Error downloading " + mavenURL + " to " + targetFile, e);\r
}\r
byte[] data = buff.toByteArray();\r
- String got = getSHA1(data);\r
+ String got = StringUtils.getSHA1(data);\r
if (mo.sha1 != null && !got.equals(mo.sha1)) {\r
throw new RuntimeException("SHA1 checksum mismatch; got: " + got);\r
}\r
return targetFile;\r
}\r
\r
- /**\r
- * Generate the SHA1 checksum of a byte array.\r
- * \r
- * @param data\r
- * the byte array\r
- * @return the SHA1 checksum\r
- */\r
- public static String getSHA1(byte[] data) {\r
- MessageDigest md;\r
- try {\r
- md = MessageDigest.getInstance("SHA-1");\r
- byte[] value = md.digest(data);\r
- StringBuilder buff = new StringBuilder(value.length * 2);\r
- for (byte c : value) {\r
- int x = c & 0xff;\r
- buff.append(Integer.toString(x >> 4, 16)).append(Integer.toString(x & 0xf, 16));\r
- }\r
- return buff.toString();\r
- } catch (NoSuchAlgorithmException e) {\r
- throw new RuntimeException(e);\r
- }\r
- }\r
-\r
private static class MavenObject {\r
\r
public static final MavenObject JCOMMANDER = new MavenObject("jCommander", "com/beust", "jcommander", "1.17", "219a3540f3b27d7cc3b1d91d6ea046cd8723290e");\r
--- /dev/null
+package com.gitblit;\r
+\r
+import java.io.File;\r
+import java.io.FileInputStream;\r
+import java.io.FileNotFoundException;\r
+import java.util.ArrayList;\r
+import java.util.List;\r
+import java.util.Properties;\r
+\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
+\r
+/**\r
+ * Reads GitBlit settings file.\r
+ * \r
+ */\r
+public class FileSettings implements IStoredSettings {\r
+\r
+ private Properties properties = new Properties();\r
+\r
+ private long lastread = 0;\r
+\r
+ private final Logger logger = LoggerFactory.getLogger(FileSettings.class);\r
+\r
+ @Override\r
+ public List<String> getAllKeys(String startingWith) {\r
+ startingWith = startingWith.toLowerCase();\r
+ List<String> keys = new ArrayList<String>();\r
+ Properties props = read();\r
+ for (Object o : props.keySet()) {\r
+ String key = o.toString().toLowerCase();\r
+ if (key.startsWith(startingWith)) {\r
+ keys.add(key);\r
+ }\r
+ }\r
+ return keys;\r
+ }\r
+\r
+ @Override\r
+ public boolean getBoolean(String name, boolean defaultValue) {\r
+ Properties props = read();\r
+ if (props.containsKey(name)) {\r
+ try {\r
+ String value = props.getProperty(name);\r
+ if (value != null && value.trim().length() > 0) {\r
+ return Boolean.parseBoolean(value);\r
+ }\r
+ } catch (Exception e) {\r
+ logger.warn("No override setting for " + name + " using default of " + defaultValue);\r
+ }\r
+ }\r
+ return defaultValue;\r
+ }\r
+\r
+ @Override\r
+ public int getInteger(String name, int defaultValue) {\r
+ Properties props = read();\r
+ if (props.containsKey(name)) {\r
+ try {\r
+ String value = props.getProperty(name);\r
+ if (value != null && value.trim().length() > 0) {\r
+ return Integer.parseInt(value);\r
+ }\r
+ } catch (Exception e) {\r
+ logger.warn("No override setting for " + name + " using default of " + defaultValue);\r
+ }\r
+ }\r
+ return defaultValue;\r
+ }\r
+\r
+ @Override\r
+ public String getString(String name, String defaultValue) {\r
+ Properties props = read();\r
+ if (props.containsKey(name)) {\r
+ try {\r
+ String value = props.getProperty(name);\r
+ if (value != null) {\r
+ return value;\r
+ }\r
+ } catch (Exception e) {\r
+ logger.warn("No override setting for " + name + " using default of " + defaultValue);\r
+ }\r
+ }\r
+ return defaultValue;\r
+ }\r
+\r
+ @Override\r
+ public List<String> getStrings(String name) {\r
+ return getStrings(name, " ");\r
+ }\r
+\r
+ @Override\r
+ public List<String> getStringsFromValue(String value) {\r
+ return getStringsFromValue(value, " ");\r
+ }\r
+\r
+ @Override\r
+ public List<String> getStrings(String name, String separator) {\r
+ List<String> strings = new ArrayList<String>();\r
+ Properties props = read();\r
+ if (props.containsKey(name)) {\r
+ String value = props.getProperty(name);\r
+ strings = getStringsFromValue(value, separator);\r
+ }\r
+ return strings;\r
+ }\r
+\r
+ @Override\r
+ public List<String> getStringsFromValue(String value, String separator) {\r
+ List<String> strings = new ArrayList<String>();\r
+ try {\r
+ String[] chunks = value.split(separator);\r
+ for (String chunk : chunks) {\r
+ chunk = chunk.trim();\r
+ if (chunk.length() > 0) {\r
+ strings.add(chunk);\r
+ }\r
+ }\r
+ } catch (Exception e) {\r
+ }\r
+ return strings;\r
+ }\r
+\r
+ private synchronized Properties read() {\r
+ File file = new File(Constants.PROPERTIES_FILE);\r
+ if (file.exists() && (file.lastModified() > lastread)) {\r
+ try {\r
+ properties = new Properties();\r
+ properties.load(new FileInputStream(Constants.PROPERTIES_FILE));\r
+ lastread = file.lastModified();\r
+ } catch (FileNotFoundException f) {\r
+ } catch (Throwable t) {\r
+ t.printStackTrace();\r
+ }\r
+ }\r
+ return properties;\r
+ }\r
+ \r
+ @Override\r
+ public String toString() {\r
+ return getClass().getSimpleName() + ": " + new File(Constants.PROPERTIES_FILE).getAbsolutePath();\r
+ }\r
+}\r
import java.util.Date;\r
import java.util.List;\r
\r
+import javax.servlet.ServletContextEvent;\r
+import javax.servlet.ServletContextListener;\r
import javax.servlet.http.Cookie;\r
import javax.servlet.http.HttpServletRequest;\r
\r
import com.gitblit.wicket.User;\r
import com.gitblit.wicket.models.RepositoryModel;\r
\r
-public class GitBlit {\r
+public class GitBlit implements ServletContextListener {\r
\r
- private static GitBlit gitblit;\r
+ private final static GitBlit gitblit;\r
\r
private final Logger logger = LoggerFactory.getLogger(GitBlit.class);\r
\r
- private final boolean debugMode;\r
+ private FileResolver repositoryResolver;\r
\r
- private final FileResolver repositoryResolver;\r
+ private File repositories;\r
\r
- private final File repositories;\r
-\r
- private final boolean exportAll;\r
+ private boolean exportAll;\r
\r
private ILoginService loginService;\r
\r
+ private IStoredSettings storedSettings;\r
+\r
+ static {\r
+ gitblit = new GitBlit();\r
+ }\r
+\r
public static GitBlit self() {\r
- if (gitblit == null) {\r
- gitblit = new GitBlit();\r
- }\r
return gitblit;\r
}\r
\r
private GitBlit() {\r
- repositories = new File(StoredSettings.getString(Keys.git_repositoriesFolder, "repos"));\r
- exportAll = StoredSettings.getBoolean(Keys.git_exportAll, true);\r
- repositoryResolver = new FileResolver(repositories, exportAll);\r
- debugMode = StoredSettings.getBoolean(Keys.server_debugMode, false);\r
+ }\r
+\r
+ public IStoredSettings settings() {\r
+ return storedSettings;\r
}\r
\r
public boolean isDebugMode() {\r
- return debugMode;\r
+ return storedSettings.getBoolean(Keys.web.debugMode, false);\r
+ }\r
+\r
+ public String getCloneUrl(String repositoryName) {\r
+ return storedSettings.getString(Keys.git.cloneUrl, "https://localhost/git/") + repositoryName;\r
}\r
\r
public void setLoginService(ILoginService loginService) {\r
}\r
\r
public List<String> getRepositoryList() {\r
- return JGitUtils.getRepositoryList(repositories, exportAll, StoredSettings.getBoolean(Keys.git_nestedRepositories, true));\r
+ return JGitUtils.getRepositoryList(repositories, exportAll, storedSettings.getBoolean(Keys.git.nestedRepositories, true));\r
}\r
\r
public List<RepositoryModel> getRepositories(Request request) {\r
}\r
return r;\r
}\r
+\r
+ public void setupContext(IStoredSettings settings) {\r
+ logger.info("Setting up GitBlit context from " + settings.toString());\r
+ this.storedSettings = settings;\r
+ repositories = new File(settings.getString(Keys.git.repositoriesFolder, "repos"));\r
+ exportAll = settings.getBoolean(Keys.git.exportAll, true);\r
+ repositoryResolver = new FileResolver(repositories, exportAll);\r
+ }\r
+\r
+ @Override\r
+ public void contextInitialized(ServletContextEvent contextEvent) {\r
+ logger.info("GitBlit context initialization by servlet container...");\r
+ if (storedSettings == null) {\r
+ WebXmlSettings webxmlSettings = new WebXmlSettings(contextEvent.getServletContext());\r
+ setupContext(webxmlSettings);\r
+ } else {\r
+ logger.info("GitBlit context already setup by " + storedSettings.toString()); \r
+ }\r
+ }\r
+\r
+ @Override\r
+ public void contextDestroyed(ServletContextEvent contextEvent) {\r
+ logger.info("GitBlit context destroyed by servlet container.");\r
+ }\r
}\r
import java.net.URL;\r
import java.net.UnknownHostException;\r
import java.security.ProtectionDomain;\r
+import java.text.MessageFormat;\r
import java.util.ArrayList;\r
import java.util.List;\r
\r
import com.beust.jcommander.Parameter;\r
import com.beust.jcommander.ParameterException;\r
import com.beust.jcommander.Parameters;\r
+import com.gitblit.utils.StringUtils;\r
import com.gitblit.wicket.GitBlitWebApp;\r
\r
public class GitBlitServer {\r
private final static Logger logger = Log.getLogger(GitBlitServer.class.getSimpleName());\r
private final static String border_star = "***********************************************************";\r
\r
+ private final static FileSettings fileSettings = new FileSettings();\r
+\r
public static void main(String[] args) {\r
Params params = new Params();\r
JCommander jc = new JCommander(params);\r
* Start Server.\r
*/\r
private static void start(Params params) {\r
- // instantiate GitBlit\r
- GitBlit.self();\r
-\r
- PatternLayout layout = new PatternLayout(StoredSettings.getString(Keys.server_log4jPattern, "%-5p %d{MM-dd HH:mm:ss.SSS} %-20.20c{1} %m%n"));\r
+ PatternLayout layout = new PatternLayout(fileSettings.getString(Keys.server.log4jPattern, "%-5p %d{MM-dd HH:mm:ss.SSS} %-20.20c{1} %m%n"));\r
org.apache.log4j.Logger rootLogger = org.apache.log4j.Logger.getRootLogger();\r
rootLogger.addAppender(new ConsoleAppender(layout));\r
\r
String osversion = System.getProperty("os.version");\r
logger.info("Running on " + osname + " (" + osversion + ")");\r
\r
- if (StoredSettings.getBoolean(Keys.server_debugMode, false)) {\r
- logger.warn("DEBUG Mode");\r
- }\r
-\r
// Determine port connectors\r
List<Connector> connectors = new ArrayList<Connector>();\r
if (params.port > 0) {\r
Connector httpConnector = createConnector(params.useNIO, params.port);\r
+ String bindInterface = fileSettings.getString(Keys.server.httpBindInterface, null);\r
+ if (!StringUtils.isEmpty(bindInterface)) {\r
+ logger.warn(MessageFormat.format("Binding port {0} to {1}", params.port, bindInterface));\r
+ httpConnector.setHost(bindInterface);\r
+ }\r
connectors.add(httpConnector);\r
}\r
\r
if (params.securePort > 0) {\r
if (new File("keystore").exists()) {\r
Connector secureConnector = createSSLConnector(params.useNIO, params.securePort, params.storePassword);\r
+ String bindInterface = fileSettings.getString(Keys.server.httpsBindInterface, null);\r
+ if (!StringUtils.isEmpty(bindInterface)) {\r
+ logger.warn(MessageFormat.format("Binding port {0} to {1}", params.port, bindInterface));\r
+ secureConnector.setHost(bindInterface);\r
+ }\r
connectors.add(secureConnector);\r
} else {\r
logger.warn("Failed to find Keystore? Did you run \"makekeystore\"?");\r
// Git Servlet\r
ServletHolder gitServlet = null;\r
String gitServletPathSpec = "/git/*";\r
- if (StoredSettings.getBoolean(Keys.git_allowPushPull, true)) {\r
+ if (fileSettings.getBoolean(Keys.git.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
// Set the server's contexts\r
server.setHandler(handler);\r
\r
+ // Setup the GitBlit context\r
+ GitBlit gitblit = GitBlit.self();\r
+ gitblit.setupContext(fileSettings);\r
+ rootContext.addEventListener(gitblit);\r
+\r
// Start the Server\r
try {\r
if (params.shutdownPort > 0) {\r
public Boolean stop = false;\r
\r
@Parameter(names = { "--temp" }, description = "Server temp folder")\r
- public String temp = StoredSettings.getString(Keys.server_tempFolder, "temp");\r
+ public String temp = fileSettings.getString(Keys.server.tempFolder, "temp");\r
\r
/*\r
* GIT Servlet Parameters\r
*/\r
@Parameter(names = { "--repos" }, description = "Git Repositories Folder")\r
- public String repositoriesFolder = StoredSettings.getString(Keys.git_repositoriesFolder, "repos");\r
+ public String repositoriesFolder = fileSettings.getString(Keys.git.repositoriesFolder, "repos");\r
\r
@Parameter(names = { "--exportAll" }, description = "Export All Found Repositories")\r
- public Boolean exportAll = StoredSettings.getBoolean(Keys.git_exportAll, true);\r
+ public Boolean exportAll = fileSettings.getBoolean(Keys.git.exportAll, true);\r
\r
/*\r
* Authentication Parameters\r
*/\r
@Parameter(names = { "--authenticatePushPull" }, description = "Authenticate Git Push/Pull access")\r
- public Boolean authenticatePushPull = StoredSettings.getBoolean(Keys.git_authenticate, true);\r
+ public Boolean authenticatePushPull = fileSettings.getBoolean(Keys.git.authenticate, true);\r
\r
@Parameter(names = { "--realm" }, description = "Users Realm Hash File")\r
- public String realmFile = StoredSettings.getString(Keys.server_realmFile, "users.properties");\r
+ public String realmFile = fileSettings.getString(Keys.server.realmFile, "users.properties");\r
\r
/*\r
* JETTY Parameters\r
*/\r
@Parameter(names = { "--nio" }, description = "Use NIO Connector else use Socket Connector.")\r
- public Boolean useNIO = StoredSettings.getBoolean(Keys.server_useNio, true);\r
+ public Boolean useNIO = fileSettings.getBoolean(Keys.server.useNio, true);\r
\r
@Parameter(names = "--port", description = "HTTP port for to serve. (port <= 0 will disable this connector)")\r
- public Integer port = StoredSettings.getInteger(Keys.server_httpPort, 80);\r
+ public Integer port = fileSettings.getInteger(Keys.server.httpPort, 80);\r
\r
@Parameter(names = "--securePort", description = "HTTPS port to serve. (port <= 0 will disable this connector)")\r
- public Integer securePort = StoredSettings.getInteger(Keys.server_httpsPort, 443);\r
+ public Integer securePort = fileSettings.getInteger(Keys.server.httpsPort, 443);\r
\r
@Parameter(names = "--storePassword", description = "Password for SSL (https) keystore.")\r
- public String storePassword = StoredSettings.getString(Keys.server_storePassword, "");\r
+ public String storePassword = fileSettings.getString(Keys.server.storePassword, "");\r
\r
@Parameter(names = "--shutdownPort", description = "Port for Shutdown Monitor to listen on. (port <= 0 will disable this monitor)")\r
- public Integer shutdownPort = StoredSettings.getInteger(Keys.server_shutdownPort, 8081);\r
+ public Integer shutdownPort = fileSettings.getInteger(Keys.server.shutdownPort, 8081);\r
\r
}\r
}
\ No newline at end of file
--- /dev/null
+package com.gitblit;\r
+\r
+import java.util.List;\r
+\r
+public interface IStoredSettings {\r
+\r
+ public abstract List<String> getAllKeys(String startingWith);\r
+\r
+ public abstract boolean getBoolean(String name, boolean defaultValue);\r
+\r
+ public abstract int getInteger(String name, int defaultValue);\r
+\r
+ public abstract String getString(String name, String defaultValue);\r
+\r
+ public abstract List<String> getStrings(String name);\r
+\r
+ public abstract List<String> getStringsFromValue(String value);\r
+\r
+ public abstract List<String> getStrings(String name, String separator);\r
+\r
+ public abstract List<String> getStringsFromValue(String value, String separator);\r
+\r
+}
\ No newline at end of file
+++ /dev/null
-package com.gitblit;\r
-\r
-import java.io.File;\r
-import java.io.FileInputStream;\r
-import java.io.FileNotFoundException;\r
-import java.util.ArrayList;\r
-import java.util.List;\r
-import java.util.Properties;\r
-\r
-import org.slf4j.Logger;\r
-import org.slf4j.LoggerFactory;\r
-\r
-/**\r
- * Reads settings file.\r
- * \r
- */\r
-public class StoredSettings {\r
-\r
- private static Properties properties = new Properties();\r
-\r
- private static long lastread = 0;\r
-\r
- private static final Logger logger = LoggerFactory.getLogger(StoredSettings.class);\r
-\r
- public static List<String> getAllKeys(String startingWith) {\r
- startingWith = startingWith.toLowerCase();\r
- List<String> keys = new ArrayList<String>();\r
- Properties props = read();\r
- for (Object o : props.keySet()) {\r
- String key = o.toString().toLowerCase();\r
- if (key.startsWith(startingWith)) {\r
- keys.add(key);\r
- }\r
- }\r
- return keys;\r
- }\r
-\r
- public static boolean getBoolean(String name, boolean defaultValue) {\r
- Properties props = read();\r
- if (props.containsKey(name)) {\r
- try {\r
- String value = props.getProperty(name);\r
- if (value != null && value.trim().length() > 0) {\r
- return Boolean.parseBoolean(value);\r
- }\r
- } catch (Exception e) {\r
- logger.warn("No override setting for " + name + " using default of " + defaultValue);\r
- }\r
- }\r
- return defaultValue;\r
- }\r
-\r
- public static int getInteger(String name, int defaultValue) {\r
- Properties props = read();\r
- if (props.containsKey(name)) {\r
- try {\r
- String value = props.getProperty(name);\r
- if (value != null && value.trim().length() > 0) {\r
- return Integer.parseInt(value);\r
- }\r
- } catch (Exception e) {\r
- logger.warn("No override setting for " + name + " using default of " + defaultValue);\r
- }\r
- }\r
- return defaultValue;\r
- }\r
-\r
- public static String getString(String name, String defaultValue) {\r
- Properties props = read();\r
- if (props.containsKey(name)) {\r
- try {\r
- String value = props.getProperty(name);\r
- if (value != null) {\r
- return value;\r
- }\r
- } catch (Exception e) {\r
- logger.warn("No override setting for " + name + " using default of " + defaultValue);\r
- }\r
- }\r
- return defaultValue;\r
- }\r
-\r
- public static List<String> getStrings(String name) {\r
- return getStrings(name, " ");\r
- }\r
-\r
- public static List<String> getStringsFromValue(String value) {\r
- return getStringsFromValue(value, " ");\r
- }\r
-\r
- public static List<String> getStrings(String name, String separator) {\r
- List<String> strings = new ArrayList<String>();\r
- Properties props = read();\r
- if (props.containsKey(name)) {\r
- String value = props.getProperty(name);\r
- strings = getStringsFromValue(value, separator);\r
- }\r
- return strings;\r
- }\r
-\r
- public static List<String> getStringsFromValue(String value, String separator) {\r
- List<String> strings = new ArrayList<String>();\r
- try {\r
- String[] chunks = value.split(separator);\r
- for (String chunk : chunks) {\r
- chunk = chunk.trim();\r
- if (chunk.length() > 0) {\r
- strings.add(chunk);\r
- }\r
- }\r
- } catch (Exception e) {\r
- }\r
- return strings;\r
- }\r
-\r
- private static synchronized Properties read() {\r
- File file = new File(Constants.PROPERTIES_FILE);\r
- if (file.exists() && (file.lastModified() > lastread)) {\r
- try {\r
- properties = new Properties();\r
- properties.load(new FileInputStream(Constants.PROPERTIES_FILE));\r
- lastread = file.lastModified();\r
- } catch (FileNotFoundException f) {\r
- } catch (Throwable t) {\r
- t.printStackTrace();\r
- }\r
- }\r
- return properties;\r
- }\r
-}\r
--- /dev/null
+package com.gitblit;\r
+\r
+import java.util.List;\r
+\r
+import javax.servlet.ServletContext;\r
+\r
+public class WebXmlSettings implements IStoredSettings {\r
+\r
+ public WebXmlSettings(ServletContext context) {\r
+ \r
+ }\r
+ \r
+ @Override\r
+ public List<String> getAllKeys(String startingWith) {\r
+ // TODO Auto-generated method stub\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public boolean getBoolean(String name, boolean defaultValue) {\r
+ // TODO Auto-generated method stub\r
+ return false;\r
+ }\r
+\r
+ @Override\r
+ public int getInteger(String name, int defaultValue) {\r
+ // TODO Auto-generated method stub\r
+ return 0;\r
+ }\r
+\r
+ @Override\r
+ public String getString(String name, String defaultValue) {\r
+ // TODO Auto-generated method stub\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public List<String> getStrings(String name) {\r
+ // TODO Auto-generated method stub\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public List<String> getStringsFromValue(String value) {\r
+ // TODO Auto-generated method stub\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public List<String> getStrings(String name, String separator) {\r
+ // TODO Auto-generated method stub\r
+ return null;\r
+ }\r
+\r
+ @Override\r
+ public List<String> getStringsFromValue(String value, String separator) {\r
+ // TODO Auto-generated method stub\r
+ return null;\r
+ }\r
+ \r
+ @Override\r
+ public String toString() {\r
+ return getClass().getSimpleName() + ": web.xml";\r
+ }\r
+}\r
-/*
- * Copyright 2011 Squeal Group. Licensed under the Eclipse Public License,
- * Version 1.0 (http://www.eclipse.org/legal/epl-v10.html).
- * Initial Developer: Squeal Group
- */
package com.gitblit.utils;
import java.text.DecimalFormat;
ByteArrayOutputStream bos = new ByteArrayOutputStream();\r
text.writeLine(bos, cur);\r
String line = bos.toString();\r
- line = Utils.escapeForHtml(line, false);\r
+ line = StringUtils.escapeForHtml(line, false);\r
os.write(line.getBytes());\r
switch (prefix) {\r
case '+':\r
}\r
for (String path : changes.keySet()) {\r
PatchTouple touple = changes.get(path);\r
- patch.append("\n " + Utils.rightPad(path, maxPathLen, ' ') + " | " + Utils.leftPad("" + touple.total(), 4, ' ') + " " + touple.relativeScale(unit));\r
+ patch.append("\n " + StringUtils.rightPad(path, maxPathLen, ' ') + " | " + StringUtils.leftPad("" + touple.total(), 4, ' ') + " " + touple.relativeScale(unit));\r
}\r
patch.append(MessageFormat.format("\n {0} files changed, {1} insertions(+), {2} deletions(-)\n\n", files, insertions, deletions));\r
patch.append(os.toString());\r
--- /dev/null
+package com.gitblit.utils;\r
+\r
+import java.io.UnsupportedEncodingException;\r
+import java.security.MessageDigest;\r
+import java.security.NoSuchAlgorithmException;\r
+import java.util.List;\r
+\r
+public class StringUtils {\r
+ \r
+ public static boolean isEmpty(String value) {\r
+ return value == null || value.trim().length() == 0;\r
+ }\r
+\r
+ public static String breakLinesForHtml(String string) {\r
+ return string.replace("\r\n", "<br/>").replace("\r", "<br/>").replace("\n", "<br/>");\r
+ }\r
+\r
+ public static String escapeForHtml(String inStr, boolean changeSpace) {\r
+ StringBuffer retStr = new StringBuffer();\r
+ int i = 0;\r
+ while (i < inStr.length()) {\r
+ if (inStr.charAt(i) == '&') {\r
+ retStr.append("&");\r
+ } else if (inStr.charAt(i) == '<') {\r
+ retStr.append("<");\r
+ } else if (inStr.charAt(i) == '>') {\r
+ retStr.append(">");\r
+ } else if (inStr.charAt(i) == '\"') {\r
+ retStr.append(""");\r
+ } else if (changeSpace && inStr.charAt(i) == ' ') {\r
+ retStr.append(" ");\r
+ } else if (changeSpace && inStr.charAt(i) == '\t') {\r
+ retStr.append(" ");\r
+ } else\r
+ retStr.append(inStr.charAt(i));\r
+ i++;\r
+ }\r
+ return retStr.toString();\r
+ }\r
+\r
+ public static String flattenStrings(List<String> values) {\r
+ StringBuilder sb = new StringBuilder();\r
+ for (String value : values) {\r
+ sb.append(value).append(" ");\r
+ }\r
+ return sb.toString().trim();\r
+ }\r
+\r
+ public static String trimString(String value, int max) {\r
+ if (value.length() <= max) {\r
+ return value;\r
+ }\r
+ return value.substring(0, max - 3) + "...";\r
+ }\r
+\r
+ public static String trimShortLog(String string) {\r
+ return trimString(string, 60);\r
+ }\r
+\r
+ public static String leftPad(String input, int length, char pad) {\r
+ if (input.length() < length) {\r
+ StringBuilder sb = new StringBuilder();\r
+ for (int i = 0, len = length - input.length(); i < len; i++) {\r
+ sb.append(pad);\r
+ }\r
+ sb.append(input);\r
+ return sb.toString();\r
+ }\r
+ return input;\r
+ }\r
+\r
+ public static String rightPad(String input, int length, char pad) {\r
+ if (input.length() < length) {\r
+ StringBuilder sb = new StringBuilder();\r
+ sb.append(input);\r
+ for (int i = 0, len = length - input.length(); i < len; i++) {\r
+ sb.append(pad);\r
+ }\r
+ return sb.toString();\r
+ }\r
+ return input;\r
+ }\r
+\r
+ public static String getSHA1(String text) {\r
+ try {\r
+ byte[] bytes = text.getBytes("iso-8859-1");\r
+ return getSHA1(bytes);\r
+ } catch (UnsupportedEncodingException u) {\r
+ throw new RuntimeException(u);\r
+ }\r
+ }\r
+\r
+ public static String getSHA1(byte[] bytes) {\r
+ try {\r
+ MessageDigest md = MessageDigest.getInstance("SHA-1");\r
+ md.update(bytes, 0, bytes.length);\r
+ byte[] sha1hash = md.digest();\r
+ StringBuilder sb = new StringBuilder(sha1hash.length * 2);\r
+ for (int i = 0; i < sha1hash.length; i++) {\r
+ if (((int) sha1hash[i] & 0xff) < 0x10)\r
+ sb.append("0");\r
+ sb.append(Long.toString((int) sha1hash[i] & 0xff, 16));\r
+ }\r
+ return sb.toString();\r
+ } catch (NoSuchAlgorithmException t) {\r
+ throw new RuntimeException(t);\r
+ }\r
+ }\r
+\r
+}\r
--- /dev/null
+package com.gitblit.utils;\r
+\r
+import java.util.Date;\r
+\r
+public class TimeUtils {\r
+ private final static long min = 1000 * 60l;\r
+\r
+ private final static long halfhour = min * 30l;\r
+\r
+ private final static long onehour = halfhour * 2;\r
+\r
+ private final static long oneday = onehour * 24l;\r
+\r
+ @SuppressWarnings("deprecation")\r
+ public static boolean isToday(Date date) {\r
+ Date now = new Date();\r
+ return now.getDate() == date.getDate() && now.getMonth() == date.getMonth() && now.getYear() == date.getYear();\r
+ }\r
+\r
+ @SuppressWarnings("deprecation")\r
+ public static boolean isYesterday(Date date) {\r
+ Date now = new Date();\r
+ return now.getDate() == (date.getDate() + 1) && now.getMonth() == date.getMonth() && now.getYear() == date.getYear();\r
+ }\r
+\r
+ public static int minutesAgo(Date date, long endTime, boolean roundup) {\r
+ long diff = endTime - date.getTime();\r
+ int mins = (int) (diff / min);\r
+ if (roundup && (diff % min) >= 30)\r
+ mins++;\r
+ return mins;\r
+ }\r
+\r
+ public static int minutesAgo(Date date, boolean roundup) {\r
+ return minutesAgo(date, System.currentTimeMillis(), roundup);\r
+ }\r
+\r
+ public static int hoursAgo(Date date, boolean roundup) {\r
+ long diff = System.currentTimeMillis() - date.getTime();\r
+ int hours = (int) (diff / onehour);\r
+ if (roundup && (diff % onehour) >= halfhour)\r
+ hours++;\r
+ return hours;\r
+ }\r
+\r
+ public static int daysAgo(Date date, boolean roundup) {\r
+ long diff = System.currentTimeMillis() - date.getTime();\r
+ int days = (int) (diff / oneday);\r
+ if (roundup && (diff % oneday) > 0)\r
+ days++;\r
+ return days;\r
+ }\r
+\r
+ public static String timeAgo(Date date) {\r
+ return timeAgo(date, false);\r
+ }\r
+\r
+ public static String timeAgoCss(Date date) {\r
+ return timeAgo(date, true);\r
+ }\r
+\r
+ private static String timeAgo(Date date, boolean css) {\r
+ String ago = null;\r
+ if (isToday(date) || isYesterday(date)) {\r
+ int mins = minutesAgo(date, true);\r
+ if (mins > 120) {\r
+ if (css) {\r
+ return "age1";\r
+ }\r
+ int hours = hoursAgo(date, true);\r
+ if (hours > 23) {\r
+ ago = "yesterday";\r
+ } else {\r
+ ago = hours + " hour" + (hours > 1 ? "s" : "") + " ago";\r
+ }\r
+ } else {\r
+ if (css) {\r
+ return "age0";\r
+ }\r
+ ago = mins + " min" + (mins > 1 ? "s" : "") + " ago";\r
+ }\r
+ } else {\r
+ if (css) {\r
+ return "age2";\r
+ }\r
+ int days = daysAgo(date, true);\r
+ if (days < 365) {\r
+ if (days <= 30) {\r
+ ago = days + " day" + (days > 1 ? "s" : "") + " ago";\r
+ } else if (days <= 90) {\r
+ int weeks = days / 7;\r
+ if (weeks == 12)\r
+ ago = "3 months ago";\r
+ else\r
+ ago = weeks + " weeks ago";\r
+ } else if (days > 90) {\r
+ int months = days / 30;\r
+ int weeks = (days % 30) / 7;\r
+ if (weeks >= 2)\r
+ months++;\r
+ ago = months + " month" + (months > 1 ? "s" : "") + " ago";\r
+ } else\r
+ ago = days + " day" + (days > 1 ? "s" : "") + " ago";\r
+ } else if (days == 365) {\r
+ ago = "1 year ago";\r
+ } else {\r
+ int yr = days / 365;\r
+ days = days % 365;\r
+ int months = (yr * 12) + (days / 30);\r
+ if (months > 23) {\r
+ ago = yr + " years ago";\r
+ } else {\r
+ ago = months + " months ago";\r
+ }\r
+ }\r
+ }\r
+ return ago;\r
+ }\r
+}\r
+++ /dev/null
-package com.gitblit.utils;\r
-\r
-import java.util.Date;\r
-\r
-public class Utils {\r
- private final static long min = 1000 * 60l;\r
-\r
- private final static long halfhour = min * 30l;\r
-\r
- private final static long onehour = halfhour * 2;\r
-\r
- private final static long oneday = onehour * 24l;\r
-\r
- @SuppressWarnings("deprecation")\r
- public static boolean isToday(Date date) {\r
- Date now = new Date();\r
- return now.getDate() == date.getDate() && now.getMonth() == date.getMonth() && now.getYear() == date.getYear();\r
- }\r
-\r
- @SuppressWarnings("deprecation")\r
- public static boolean isYesterday(Date date) {\r
- Date now = new Date();\r
- return now.getDate() == (date.getDate() + 1) && now.getMonth() == date.getMonth() && now.getYear() == date.getYear();\r
- }\r
-\r
- public static int minutesAgo(Date date, long endTime, boolean roundup) {\r
- long diff = endTime - date.getTime();\r
- int mins = (int) (diff / min);\r
- if (roundup && (diff % min) >= 30)\r
- mins++;\r
- return mins;\r
- }\r
-\r
- public static int minutesAgo(Date date, boolean roundup) {\r
- return minutesAgo(date, System.currentTimeMillis(), roundup);\r
- }\r
-\r
- public static int hoursAgo(Date date, boolean roundup) {\r
- long diff = System.currentTimeMillis() - date.getTime();\r
- int hours = (int) (diff / onehour);\r
- if (roundup && (diff % onehour) >= halfhour)\r
- hours++;\r
- return hours;\r
- }\r
-\r
- public static int daysAgo(Date date, boolean roundup) {\r
- long diff = System.currentTimeMillis() - date.getTime();\r
- int days = (int) (diff / oneday);\r
- if (roundup && (diff % oneday) > 0)\r
- days++;\r
- return days;\r
- }\r
-\r
- public static String timeAgo(Date date) {\r
- return timeAgo(date, false);\r
- }\r
-\r
- public static String timeAgoCss(Date date) {\r
- return timeAgo(date, true);\r
- }\r
-\r
- private static String timeAgo(Date date, boolean css) {\r
- String ago = null;\r
- if (isToday(date) || isYesterday(date)) {\r
- int mins = minutesAgo(date, true);\r
- if (mins > 120) {\r
- if (css) {\r
- return "age1";\r
- }\r
- int hours = hoursAgo(date, true);\r
- if (hours > 23) {\r
- ago = "yesterday";\r
- } else {\r
- ago = hours + " hour" + (hours > 1 ? "s" : "") + " ago";\r
- }\r
- } else {\r
- if (css) {\r
- return "age0";\r
- }\r
- ago = mins + " min" + (mins > 1 ? "s" : "") + " ago";\r
- }\r
- } else {\r
- if (css) {\r
- return "age2";\r
- }\r
- int days = daysAgo(date, true);\r
- if (days < 365) {\r
- if (days <= 30) {\r
- ago = days + " day" + (days > 1 ? "s" : "") + " ago";\r
- } else if (days <= 90) {\r
- int weeks = days / 7;\r
- if (weeks == 12)\r
- ago = "3 months ago";\r
- else\r
- ago = weeks + " weeks ago";\r
- } else if (days > 90) {\r
- int months = days / 30;\r
- int weeks = (days % 30) / 7;\r
- if (weeks >= 2)\r
- months++;\r
- ago = months + " month" + (months > 1 ? "s" : "") + " ago";\r
- } else\r
- ago = days + " day" + (days > 1 ? "s" : "") + " ago";\r
- } else if (days == 365) {\r
- ago = "1 year ago";\r
- } else {\r
- int yr = days / 365;\r
- days = days % 365;\r
- int months = (yr * 12) + (days / 30);\r
- if (months > 23) {\r
- ago = yr + " years ago";\r
- } else {\r
- ago = months + " months ago";\r
- }\r
- }\r
- }\r
- return ago;\r
- }\r
-\r
- public static String leftPad(String input, int length, char pad) {\r
- if (input.length() < length) {\r
- StringBuilder sb = new StringBuilder();\r
- for (int i = 0, len = length - input.length(); i < len; i++) {\r
- sb.append(pad);\r
- }\r
- sb.append(input);\r
- return sb.toString();\r
- }\r
- return input;\r
- }\r
-\r
- public static String rightPad(String input, int length, char pad) {\r
- if (input.length() < length) {\r
- StringBuilder sb = new StringBuilder();\r
- sb.append(input);\r
- for (int i = 0, len = length - input.length(); i < len; i++) {\r
- sb.append(pad);\r
- }\r
- return sb.toString();\r
- }\r
- return input;\r
- }\r
-\r
- public static String escapeForHtml(String inStr, boolean changeSpace) {\r
- StringBuffer retStr = new StringBuffer();\r
- int i = 0;\r
- while (i < inStr.length()) {\r
- if (inStr.charAt(i) == '&') {\r
- retStr.append("&");\r
- } else if (inStr.charAt(i) == '<') {\r
- retStr.append("<");\r
- } else if (inStr.charAt(i) == '>') {\r
- retStr.append(">");\r
- } else if (inStr.charAt(i) == '\"') {\r
- retStr.append(""");\r
- } else if (changeSpace && inStr.charAt(i) == ' ') {\r
- retStr.append(" ");\r
- } else if (changeSpace && inStr.charAt(i) == '\t') {\r
- retStr.append(" ");\r
- } else\r
- retStr.append(inStr.charAt(i));\r
- i++;\r
- }\r
- return retStr.toString();\r
- }\r
-}\r
@SuppressWarnings({ "unchecked", "rawtypes" })\r
@Override\r
protected boolean isPageAuthorized(Class pageClass) {\r
- if (BasePage.class.isAssignableFrom(pageClass))\r
- return isAuthorized(pageClass);\r
- // Return contruction by default\r
+ if (BasePage.class.isAssignableFrom(pageClass)) {\r
+ GitBlitWebSession session = GitBlitWebSession.get();\r
+ if (!session.isLoggedIn())\r
+ return false;\r
+ User user = session.getUser();\r
+ if (pageClass.isAnnotationPresent(AdminPage.class)) {\r
+ return user.canAdmin();\r
+ }\r
+ }\r
return true;\r
}\r
\r
throw new RestartResponseAtInterceptPageException(RepositoriesPage.class);\r
}\r
}\r
-\r
- protected boolean isAuthorized(Class<? extends BasePage> pageClass) {\r
- GitBlitWebSession session = GitBlitWebSession.get();\r
- if (!session.isLoggedIn())\r
- return false;\r
- User user = session.getUser();\r
- if (pageClass.isAnnotationPresent(AdminPage.class)) {\r
-\r
- }\r
- return true;\r
- }\r
}\r
<div style="float:right">\r
<a href="http://gitblit.com"><span wicket:id="gbVersion"></span></a> \r
</div>\r
- <div wicket:id="userText">[user text]</div>\r
+ <div wicket:id="userPanel">[user panel]</div>\r
</div>\r
</body>\r
</html>
\ No newline at end of file
import org.slf4j.LoggerFactory;\r
\r
import com.gitblit.Constants;\r
+import com.gitblit.GitBlit;\r
import com.gitblit.Keys;\r
-import com.gitblit.StoredSettings;\r
import com.gitblit.wicket.pages.SummaryPage;\r
\r
public abstract class BasePage extends WebPage {\r
\r
- Logger logger = LoggerFactory.getLogger(BasePage.class);\r
+ private final Logger logger;\r
\r
public BasePage() {\r
super();\r
+ logger = LoggerFactory.getLogger(getClass());\r
}\r
\r
public BasePage(PageParameters params) {\r
super(params);\r
+ logger = LoggerFactory.getLogger(getClass());\r
}\r
\r
protected void setupPage(String repositoryName, String pageName) {\r
add(new Label("title", getServerName()));\r
}\r
// header\r
- String siteName = StoredSettings.getString(Keys.web_siteName, Constants.NAME);\r
+ String siteName = GitBlit.self().settings().getString(Keys.web.siteName, Constants.NAME);\r
if (siteName == null || siteName.trim().length() == 0) {\r
siteName = Constants.NAME;\r
}\r
\r
// footer\r
User user = null;\r
- if (StoredSettings.getBoolean(Keys.web_authenticate, true)) {\r
+ if (GitBlit.self().settings().getBoolean(Keys.web.authenticate, true)) {\r
user = GitBlitWebSession.get().getUser();\r
- add(new Label("userText", "Logout " + user.toString()));\r
+ add(new LinkPanel("userPanel", null, getString("gb.logout") + " " + user.toString(), LogoutPage.class));\r
} else {\r
- add(new Label("userText", ""));\r
+ add(new Label("userPanel", ""));\r
}\r
add(new Label("gbVersion", "v" + Constants.VERSION));\r
- if (StoredSettings.getBoolean(Keys.server_aggressiveHeapManagement, false)) {\r
+ if (GitBlit.self().settings().getBoolean(Keys.web.aggressiveHeapManagement, false)) {\r
System.gc();\r
}\r
}\r
\r
protected TimeZone getTimeZone() {\r
- return StoredSettings.getBoolean(Keys.web_useClientTimezone, false) ? GitBlitWebSession.get().getTimezone() : TimeZone.getDefault();\r
+ return GitBlit.self().settings().getBoolean(Keys.web.useClientTimezone, false) ? GitBlitWebSession.get().getTimezone() : TimeZone.getDefault();\r
}\r
\r
protected String getServerName() {\r
\r
import com.gitblit.GitBlit;\r
import com.gitblit.Keys;\r
-import com.gitblit.StoredSettings;\r
import com.gitblit.wicket.pages.BlobDiffPage;\r
import com.gitblit.wicket.pages.BlobPage;\r
import com.gitblit.wicket.pages.BranchesPage;\r
super.init();\r
\r
// Setup page authorization mechanism\r
- if (StoredSettings.getBoolean(Keys.web_authenticate, false)) {\r
+ if (GitBlit.self().settings().getBoolean(Keys.web.authenticate, false)) {\r
AuthorizationStrategy authStrategy = new AuthorizationStrategy();\r
getSecuritySettings().setAuthorizationStrategy(authStrategy);\r
getSecuritySettings().setUnauthorizedComponentInstantiationListener(authStrategy);\r
}\r
\r
// Grab Browser info (like timezone, etc)\r
- if (StoredSettings.getBoolean(Keys.web_useClientTimezone, false)) {\r
+ if (GitBlit.self().settings().getBoolean(Keys.web.useClientTimezone, false)) {\r
getRequestCycleSettings().setGatherExtendedBrowserInfo(true);\r
}\r
\r
mount(new MixedParamUrlCodingStrategy("/commitdiff", CommitDiffPage.class, new String[] { "r", "h" }));\r
mount(new MixedParamUrlCodingStrategy("/patch", PatchPage.class, new String[] { "r", "h", "f" }));\r
\r
- // setup extended urls\r
+ // setup ticgit urls\r
mount(new MixedParamUrlCodingStrategy("/ticgit", TicGitPage.class, new String[] { "r" }));\r
mount(new MixedParamUrlCodingStrategy("/ticgittkt", TicGitTicketPage.class, new String[] { "r", "h", "f" }));\r
\r
- mount(new MixedParamUrlCodingStrategy("/login", LoginPage.class, new String[] {}));\r
+ // setup login/logout urls, if we are using authentication\r
+ if (GitBlit.self().settings().getBoolean(Keys.web.authenticate, true)) {\r
+ mount(new MixedParamUrlCodingStrategy("/login", LoginPage.class, new String[] {}));\r
+ mount(new MixedParamUrlCodingStrategy("/logout", LogoutPage.class, new String[] {}));\r
+ }\r
}\r
\r
@Override\r
return Application.DEPLOYMENT;\r
}\r
\r
- public String getCloneUrl(String repositoryName) {\r
- return StoredSettings.getString(Keys.git_cloneUrl, "https://localhost/git/") + repositoryName;\r
- }\r
-\r
public static GitBlitWebApp get() {\r
return (GitBlitWebApp) WebApplication.get();\r
}\r
gb.pageNext = next\r
gb.parent = parent\r
gb.head = HEAD\r
-gb.blame = blame
\ No newline at end of file
+gb.blame = blame\r
+gb.login = Login\r
+gb.logout = Logout\r
+gb.username = Username\r
+gb.password = Password
\ No newline at end of file
\r
private final IModel<String> labelModel;\r
\r
+ public LinkPanel(String wicketId, String linkCssClass, String label, Class<? extends WebPage> clazz) {\r
+ this(wicketId, linkCssClass, new Model<String>(label), clazz, null);\r
+ }\r
+ \r
public LinkPanel(String wicketId, String linkCssClass, String label, Class<? extends WebPage> clazz, PageParameters parameters) {\r
this(wicketId, linkCssClass, new Model<String>(label), clazz, parameters);\r
}\r
<body onload="document.getElementById('username').focus();">\r
<div>\r
<center>\r
- <img wicket:id="logo" /><br/>\r
+ <wicket:link>\r
+ <img src="resources/gitblt2.png" alt="Git:Blit"/><br/>\r
+ </wicket:link>\r
<span style="font-weight:bold;" wicket:id="name">[name]</span><br/>\r
\r
<div>\r
<form style="text-align:center;" wicket:id="loginForm">\r
<p/>\r
- Username <input type="text" id="username" wicket:id="username" value=""/>\r
+ <wicket:message key="gb.username"></wicket:message>\r
+ <input type="text" id="username" wicket:id="username" value=""/>\r
<p/>\r
- Password <input type="password" wicket:id="password" value=""/>\r
+ <wicket:message key="gb.password"></wicket:message>\r
+ <input type="password" wicket:id="password" value=""/>\r
<p/>\r
- <input type="submit" value="Login" />\r
+ <input type="submit" value="Login" wicket:message="value:gb.login" />\r
<div style="background-color:#c7c7c7" wicket:id="feedback"></div>\r
</form>\r
</div>\r
package com.gitblit.wicket;\r
\r
import javax.servlet.http.Cookie;\r
-import javax.servlet.http.HttpServletRequest;\r
\r
import org.apache.wicket.PageParameters;\r
import org.apache.wicket.markup.html.WebPage;\r
import org.apache.wicket.markup.html.basic.Label;\r
import org.apache.wicket.markup.html.form.Form;\r
import org.apache.wicket.markup.html.form.PasswordTextField;\r
+import org.apache.wicket.markup.html.form.StatelessForm;\r
import org.apache.wicket.markup.html.form.TextField;\r
-import org.apache.wicket.markup.html.image.ContextImage;\r
import org.apache.wicket.markup.html.panel.FeedbackPanel;\r
import org.apache.wicket.model.IModel;\r
import org.apache.wicket.model.Model;\r
import org.apache.wicket.protocol.http.WebRequest;\r
import org.apache.wicket.protocol.http.WebResponse;\r
-import org.apache.wicket.protocol.http.servlet.ServletWebRequest;\r
\r
import com.gitblit.Constants;\r
import com.gitblit.GitBlit;\r
+import com.gitblit.Keys;\r
\r
public class LoginPage extends WebPage {\r
\r
\r
tryAutomaticLogin();\r
\r
- add(new Label("title", getServerName()));\r
- add(new ContextImage("logo", "gitblt2.png"));\r
+ add(new Label("title", GitBlit.self().settings().getString(Keys.web.siteName, Constants.NAME)));\r
add(new Label("name", Constants.NAME));\r
\r
Form<Void> loginForm = new LoginForm("loginForm");\r
add(loginForm);\r
}\r
\r
- protected String getServerName() {\r
- ServletWebRequest servletWebRequest = (ServletWebRequest) getRequest();\r
- HttpServletRequest req = servletWebRequest.getHttpServletRequest();\r
- return req.getServerName();\r
- }\r
-\r
- class LoginForm extends Form<Void> {\r
+ class LoginForm extends StatelessForm<Void> {\r
private static final long serialVersionUID = 1L;\r
\r
public LoginForm(String id) {\r
super(id);\r
+\r
+ // If we are already logged in because user directly accessed\r
+ // the login url, redirect to the home page\r
+ if (GitBlitWebSession.get().isLoggedIn()) {\r
+ setRedirect(true);\r
+ setResponsePage(getApplication().getHomePage());\r
+ }\r
+ \r
+ tryAutomaticLogin();\r
}\r
\r
@Override\r
\r
private void loginUser(User user) {\r
if (user != null) {\r
- GitBlitWebSession session = GitBlitWebSession.get();\r
+ // Set the user into the session\r
+ GitBlitWebSession.get().setUser(user);\r
\r
// Set Cookie\r
WebResponse response = (WebResponse) getRequestCycle().getResponse();\r
GitBlit.self().setCookie(response, user);\r
\r
- // track user object so that we do not have to continue\r
- // re-authenticating on each request.\r
- session.setUser(user);\r
-\r
- // Redirect to original page OR to first available tab\r
if (!continueToOriginalDestination()) {\r
// Redirect to home page\r
- setResponsePage(session.getApplication().getHomePage());\r
+ setResponsePage(getApplication().getHomePage());\r
}\r
}\r
}\r
--- /dev/null
+package com.gitblit.wicket;\r
+\r
+import org.apache.wicket.markup.html.WebPage;\r
+\r
+public class LogoutPage extends WebPage {\r
+\r
+ public LogoutPage() {\r
+ getSession().invalidate();\r
+ setRedirect(true);\r
+ setResponsePage(getApplication().getHomePage());\r
+ }\r
+}
\ No newline at end of file
import org.apache.wicket.protocol.http.servlet.ServletWebRequest;\r
import org.eclipse.jgit.lib.Repository;\r
import org.eclipse.jgit.revwalk.RevCommit;\r
+import org.slf4j.Logger;\r
+import org.slf4j.LoggerFactory;\r
\r
import com.gitblit.GitBlit;\r
-import com.gitblit.StoredSettings;\r
+import com.gitblit.Keys;\r
import com.gitblit.utils.JGitUtils;\r
+import com.gitblit.utils.StringUtils;\r
import com.gitblit.wicket.pages.RepositoriesPage;\r
import com.gitblit.wicket.panels.PageLinksPanel;\r
import com.gitblit.wicket.panels.RefsPanel;\r
\r
private transient Repository r = null;\r
\r
+ private final Logger logger = LoggerFactory.getLogger(RepositoryPage.class);\r
+ \r
public RepositoryPage(PageParameters params) {\r
super(params);\r
if (!params.containsKey("r")) {\r
}\r
\r
protected void addFullText(String wicketId, String text, boolean substituteRegex) {\r
- String html = WicketUtils.breakLines(text);\r
+ String html = StringUtils.breakLinesForHtml(text);\r
if (substituteRegex) {\r
Map<String, String> map = new HashMap<String, String>();\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
+ if (GitBlit.self().settings().getBoolean(Keys.regex.global, false)) {\r
+ for (String key : GitBlit.self().settings().getAllKeys(Keys.regex.global)) {\r
+ if (!key.equals(Keys.regex.global)) {\r
+ String subKey = key.substring(key.lastIndexOf('.') + 1);\r
+ map.put(subKey, GitBlit.self().settings().getString(key, ""));\r
+ }\r
+ }\r
}\r
\r
// repository-specific regex keys\r
- List<String> keys = StoredSettings.getAllKeys("regex." + repositoryName.toLowerCase());\r
+ List<String> keys = GitBlit.self().settings().getAllKeys(Keys.regex._ROOT + "." + repositoryName.toLowerCase());\r
for (String key : keys) {\r
String subKey = key.substring(key.lastIndexOf('.') + 1);\r
- map.put(subKey, StoredSettings.getString(key, ""));\r
+ map.put(subKey, GitBlit.self().settings().getString(key, ""));\r
}\r
\r
for (String key : map.keySet()) {\r
package com.gitblit.wicket;\r
\r
-import com.gitblit.Build;\r
+import java.io.Serializable;\r
+\r
import com.gitblit.Constants;\r
+import com.gitblit.utils.StringUtils;\r
\r
-public class User {\r
+public class User implements Serializable {\r
\r
+ private static final long serialVersionUID = 1L;\r
+ \r
private String username;\r
private String cookie;\r
private boolean canAdmin = false;\r
\r
public User(String username, char[] password) {\r
this.username = username;\r
- this.cookie = Build.getSHA1((Constants.NAME + username + new String(password)).getBytes());\r
+ this.cookie = StringUtils.getSHA1((Constants.NAME + username + new String(password)));\r
}\r
\r
public void canAdmin(boolean value) {\r
import java.text.DateFormat;\r
import java.text.SimpleDateFormat;\r
import java.util.Date;\r
-import java.util.List;\r
import java.util.TimeZone;\r
\r
import org.apache.wicket.Component;\r
import org.apache.wicket.markup.html.basic.Label;\r
import org.eclipse.jgit.lib.Constants;\r
\r
+import com.gitblit.GitBlit;\r
import com.gitblit.Keys;\r
-import com.gitblit.StoredSettings;\r
-import com.gitblit.utils.Utils;\r
+import com.gitblit.utils.TimeUtils;\r
\r
public class WicketUtils {\r
\r
container.add(new SimpleAttributeModifier("title", value));\r
}\r
\r
- public static String breakLines(String string) {\r
- return string.replace("\r", "<br/>").replace("\n", "<br/>");\r
- }\r
-\r
public static void setTicketCssClass(Component container, String state) {\r
String css = null;\r
if (state.equals("open")) {\r
}\r
}\r
\r
- public static String flattenStrings(List<String> values) {\r
- StringBuilder sb = new StringBuilder();\r
- for (String value : values) {\r
- sb.append(value).append(" ");\r
- }\r
- return sb.toString().trim();\r
- }\r
-\r
public static void setAlternatingBackground(Component c, int i) {\r
String clazz = i % 2 == 0 ? "dark" : "light";\r
setCssClass(c, clazz);\r
return label;\r
}\r
\r
- public static String trimShortLog(String string) {\r
- return trimString(string, 60);\r
- }\r
-\r
- public static String trimString(String value, int max) {\r
- if (value.length() <= max) {\r
- return value;\r
- }\r
- return value.substring(0, max - 3) + "...";\r
- }\r
-\r
public static PageParameters newRepositoryParameter(String repositoryName) {\r
return new PageParameters("r=" + repositoryName);\r
}\r
}\r
\r
public static Label createDateLabel(String wicketId, Date date, TimeZone timeZone) {\r
- DateFormat df = new SimpleDateFormat(StoredSettings.getString(Keys.web_datestampShortFormat, "MM/dd/yy"));\r
+ DateFormat df = new SimpleDateFormat(GitBlit.self().settings().getString(Keys.web.datestampShortFormat, "MM/dd/yy"));\r
if (timeZone != null) {\r
df.setTimeZone(timeZone);\r
}\r
String dateString = df.format(date);\r
- String title = Utils.timeAgo(date);\r
+ String title = TimeUtils.timeAgo(date);\r
if ((System.currentTimeMillis() - date.getTime()) < 10 * 24 * 60 * 60 * 1000l) {\r
String tmp = dateString;\r
dateString = title;\r
title = tmp;\r
}\r
Label label = new Label(wicketId, dateString);\r
- WicketUtils.setCssClass(label, Utils.timeAgoCss(date));\r
+ WicketUtils.setCssClass(label, TimeUtils.timeAgoCss(date));\r
WicketUtils.setHtmlTitle(label, title);\r
return label;\r
}\r
\r
public static Label createTimestampLabel(String wicketId, Date date, TimeZone timeZone) {\r
- DateFormat df = new SimpleDateFormat(StoredSettings.getString(Keys.web_datetimestampLongFormat, "EEEE, MMMM d, yyyy h:mm a z"));\r
+ DateFormat df = new SimpleDateFormat(GitBlit.self().settings().getString(Keys.web.datetimestampLongFormat, "EEEE, MMMM d, yyyy h:mm a z"));\r
if (timeZone != null) {\r
df.setTimeZone(timeZone);\r
}\r
String dateString = df.format(date);\r
- String title = Utils.timeAgo(date);\r
+ String title = TimeUtils.timeAgo(date);\r
Label label = new Label(wicketId, dateString);\r
WicketUtils.setHtmlTitle(label, title);\r
return label;\r
import org.eclipse.jgit.lib.Repository;\r
import org.eclipse.jgit.revwalk.RevCommit;\r
\r
+import com.gitblit.GitBlit;\r
import com.gitblit.Keys;\r
-import com.gitblit.StoredSettings;\r
import com.gitblit.utils.JGitUtils;\r
import com.gitblit.wicket.LinkPanel;\r
import com.gitblit.wicket.RepositoryPage;\r
\r
// Map the extensions to types\r
Map<String, Integer> map = new HashMap<String, Integer>();\r
- for (String ext : StoredSettings.getStrings(Keys.web_prettyPrintExtensions)) {\r
+ for (String ext : GitBlit.self().settings().getStrings(Keys.web.prettyPrintExtensions)) {\r
map.put(ext.toLowerCase(), 1);\r
}\r
- for (String ext : StoredSettings.getStrings(Keys.web_imageExtensions)) {\r
+ for (String ext : GitBlit.self().settings().getStrings(Keys.web.imageExtensions)) {\r
map.put(ext.toLowerCase(), 2);\r
}\r
- for (String ext : StoredSettings.getStrings(Keys.web_binaryExtensions)) {\r
+ for (String ext : GitBlit.self().settings().getStrings(Keys.web.binaryExtensions)) {\r
map.put(ext.toLowerCase(), 3);\r
}\r
\r
\r
import com.gitblit.GitBlit;\r
import com.gitblit.Keys;\r
-import com.gitblit.StoredSettings;\r
import com.gitblit.utils.JGitUtils;\r
import com.gitblit.wicket.WicketUtils;\r
\r
\r
// Map the extensions to types\r
Map<String, Integer> map = new HashMap<String, Integer>();\r
- for (String ext : StoredSettings.getStrings(Keys.web_imageExtensions)) {\r
+ for (String ext : GitBlit.self().settings().getStrings(Keys.web.imageExtensions)) {\r
map.put(ext.toLowerCase(), 2);\r
}\r
- for (String ext : StoredSettings.getStrings(Keys.web_binaryExtensions)) {\r
+ for (String ext : GitBlit.self().settings().getStrings(Keys.web.binaryExtensions)) {\r
map.put(ext.toLowerCase(), 3);\r
}\r
\r
\r
import com.gitblit.GitBlit;\r
import com.gitblit.Keys;\r
-import com.gitblit.StoredSettings;\r
-import com.gitblit.utils.Utils;\r
+import com.gitblit.utils.TimeUtils;\r
import com.gitblit.wicket.BasePage;\r
import com.gitblit.wicket.GitBlitWebSession;\r
import com.gitblit.wicket.LinkPanel;\r
setupPage("", "");\r
\r
boolean showAdmin = false;\r
- if (StoredSettings.getBoolean(Keys.web_authenticate, true)) {\r
- boolean allowAdmin = StoredSettings.getBoolean(Keys.web_allowAdministration, false);\r
+ if (GitBlit.self().settings().getBoolean(Keys.web.authenticate, true)) {\r
+ boolean allowAdmin = GitBlit.self().settings().getBoolean(Keys.web.allowAdministration, false);\r
showAdmin = allowAdmin && GitBlitWebSession.get().canAdmin();\r
} else {\r
- showAdmin = StoredSettings.getBoolean(Keys.web_allowAdministration, false);\r
+ showAdmin = GitBlit.self().settings().getBoolean(Keys.web.allowAdministration, false);\r
}\r
\r
Fragment adminLinks = new Fragment("adminPanel", "adminLinks", this);\r
adminLinks.add(new BookmarkablePageLink<Void>("newUser", RepositoriesPage.class));\r
add(adminLinks.setVisible(showAdmin));\r
\r
- add(new Label("repositoriesMessage", StoredSettings.getString(Keys.web_repositoriesMessage, "")).setEscapeModelStrings(false));\r
+ add(new Label("repositoriesMessage", GitBlit.self().settings().getString(Keys.web.repositoriesMessage, "")).setEscapeModelStrings(false));\r
\r
List<RepositoryModel> rows = GitBlit.self().getRepositories(getRequest());\r
DataProvider dp = new DataProvider(rows);\r
item.add(new LinkPanel("repositoryDescription", "list", entry.description, SummaryPage.class, pp));\r
item.add(new Label("repositoryOwner", entry.owner));\r
\r
- String lastChange = Utils.timeAgo(entry.lastChange);\r
+ String lastChange = TimeUtils.timeAgo(entry.lastChange);\r
Label lastChangeLabel = new Label("repositoryLastChange", lastChange);\r
item.add(lastChangeLabel);\r
- WicketUtils.setCssClass(lastChangeLabel, Utils.timeAgoCss(entry.lastChange));\r
+ WicketUtils.setCssClass(lastChangeLabel, TimeUtils.timeAgoCss(entry.lastChange));\r
\r
WicketUtils.setAlternatingBackground(item, counter);\r
counter++;\r
import com.codecommit.wicket.ChartProvider;\r
import com.codecommit.wicket.ChartType;\r
import com.codecommit.wicket.IChartData;\r
+import com.gitblit.GitBlit;\r
import com.gitblit.Keys;\r
-import com.gitblit.StoredSettings;\r
import com.gitblit.utils.JGitUtils;\r
-import com.gitblit.wicket.GitBlitWebApp;\r
import com.gitblit.wicket.RepositoryPage;\r
import com.gitblit.wicket.WicketUtils;\r
import com.gitblit.wicket.models.Metric;\r
int numCommitsDef = 20;\r
int numRefsDef = 5;\r
\r
- int numberCommits = StoredSettings.getInteger(Keys.web_summaryCommitCount, numCommitsDef);\r
+ int numberCommits = GitBlit.self().settings().getInteger(Keys.web.summaryCommitCount, numCommitsDef);\r
if (numberCommits <= 0) {\r
numberCommits = numCommitsDef;\r
}\r
\r
- int numberRefs = StoredSettings.getInteger(Keys.web_summaryRefsCount, numRefsDef);\r
+ int numberRefs = GitBlit.self().settings().getInteger(Keys.web.summaryRefsCount, numRefsDef);\r
if (numberRefs <= 0) {\r
numberRefs = numRefsDef;\r
}\r
add(new Label("repositoryOwner", JGitUtils.getRepositoryOwner(r)));\r
\r
add(WicketUtils.createTimestampLabel("repositoryLastChange", JGitUtils.getLastChange(r), getTimeZone()));\r
- add(new Label("repositoryCloneUrl", GitBlitWebApp.get().getCloneUrl(repositoryName)));\r
+ add(new Label("repositoryCloneUrl", GitBlit.self().getCloneUrl(repositoryName)));\r
\r
add(new LogPanel("commitsPanel", repositoryName, null, r, numberCommits, 0));\r
add(new TagsPanel("tagsPanel", repositoryName, r, numberRefs));\r
}\r
\r
private void insertActivityGraph(List<Metric> metrics) {\r
- if (StoredSettings.getBoolean(Keys.web_generateActivityGraph, true)) {\r
+ if (GitBlit.self().settings().getBoolean(Keys.web.generateActivityGraph, true)) {\r
IChartData data = getChartData(metrics);\r
\r
ChartProvider provider = new ChartProvider(new Dimension(400, 80), ChartType.LINE, data);\r
import org.apache.wicket.markup.repeater.data.ListDataProvider;\r
\r
import com.gitblit.utils.JGitUtils;\r
+import com.gitblit.utils.StringUtils;\r
import com.gitblit.wicket.GitBlitWebSession;\r
import com.gitblit.wicket.LinkPanel;\r
import com.gitblit.wicket.RepositoryPage;\r
WicketUtils.setTicketCssClass(stateLabel, entry.state);\r
item.add(stateLabel);\r
item.add(WicketUtils.createDateLabel("ticketDate", entry.date, GitBlitWebSession.get().getTimezone()));\r
- item.add(new Label("ticketHandler", WicketUtils.trimString(entry.handler.toLowerCase(), 30)));\r
- item.add(new LinkPanel("ticketTitle", "list subject", WicketUtils.trimString(entry.title, 80), TicGitTicketPage.class, newPathParameter(entry.name)));\r
+ item.add(new Label("ticketHandler", StringUtils.trimString(entry.handler.toLowerCase(), 30)));\r
+ item.add(new LinkPanel("ticketTitle", "list subject", StringUtils.trimString(entry.title, 80), TicGitTicketPage.class, newPathParameter(entry.name)));\r
\r
WicketUtils.setAlternatingBackground(item, counter);\r
counter++;\r
<table style="width:100%;" class="comments">\r
<tbody>\r
<tr valign="top" wicket:id="comment">\r
- <td><span class="date" wicket:id="commentDate">[comment date]</span><br/>\r
- <span class="author" wicket:id="commentAuthor">[comment author]</span></td>\r
+ <td><span class="author" wicket:id="commentAuthor">[comment author]</span><br/>\r
+ <span class="date" wicket:id="commentDate">[comment date]</span>\r
+ </td>\r
<td><span wicket:id="commentText">[comment text]</span></td>\r
</tr>\r
</tbody>\r
import org.eclipse.jgit.lib.Repository;\r
\r
import com.gitblit.utils.JGitUtils;\r
-import com.gitblit.utils.Utils;\r
+import com.gitblit.utils.StringUtils;\r
import com.gitblit.wicket.GitBlitWebSession;\r
import com.gitblit.wicket.RepositoryPage;\r
import com.gitblit.wicket.WicketUtils;\r
Label stateLabel = new Label("ticketState", t.state);\r
WicketUtils.setTicketCssClass(stateLabel, t.state);\r
add(stateLabel);\r
- add(new Label("ticketTags", WicketUtils.flattenStrings(t.tags)));\r
+ add(new Label("ticketTags", StringUtils.flattenStrings(t.tags)));\r
\r
ListDataProvider<Comment> commentsDp = new ListDataProvider<Comment>(t.comments);\r
DataView<Comment> commentsView = new DataView<Comment>("comment", commentsDp) {\r
}\r
\r
private String prepareComment(String comment) {\r
- String html = Utils.escapeForHtml(comment, false);\r
- html = WicketUtils.breakLines(comment).trim();\r
+ String html = StringUtils.escapeForHtml(comment, false);\r
+ html = StringUtils.breakLinesForHtml(comment).trim();\r
return html.replaceAll("\\bcommit\\s*([A-Za-z0-9]*)\\b", "<a href=\"/commit/" + repositoryName + "/$1\">commit $1</a>");\r
}\r
}\r
\r
import org.apache.wicket.markup.html.panel.Panel;\r
\r
+import com.gitblit.GitBlit;\r
import com.gitblit.Keys;\r
-import com.gitblit.StoredSettings;\r
import com.gitblit.wicket.GitBlitWebSession;\r
\r
public abstract class BasePanel extends Panel {\r
}\r
\r
protected TimeZone getTimeZone() {\r
- return StoredSettings.getBoolean(Keys.web_useClientTimezone, false) ? GitBlitWebSession.get().getTimezone() : TimeZone.getDefault();\r
+ return GitBlit.self().settings().getBoolean(Keys.web.useClientTimezone, false) ? GitBlitWebSession.get().getTimezone() : TimeZone.getDefault();\r
}\r
}\r
import org.eclipse.jgit.lib.Repository;\r
\r
import com.gitblit.utils.JGitUtils;\r
+import com.gitblit.utils.StringUtils;\r
import com.gitblit.wicket.LinkPanel;\r
import com.gitblit.wicket.WicketUtils;\r
import com.gitblit.wicket.models.RefModel;\r
\r
item.add(WicketUtils.createDateLabel("branchDate", entry.getDate(), getTimeZone()));\r
\r
- item.add(new LinkPanel("branchName", "list name", WicketUtils.trimString(entry.getDisplayName(), 28), LogPage.class, WicketUtils.newObjectParameter(repositoryName, entry.getName())));\r
+ item.add(new LinkPanel("branchName", "list name", StringUtils.trimString(entry.getDisplayName(), 28), LogPage.class, WicketUtils.newObjectParameter(repositoryName, entry.getName())));\r
\r
// only show branch type on the branches page\r
boolean remote = entry.getName().startsWith(Constants.R_REMOTES);\r
import org.eclipse.jgit.lib.Repository;\r
import org.eclipse.jgit.revwalk.RevCommit;\r
\r
+import com.gitblit.GitBlit;\r
import com.gitblit.Keys;\r
-import com.gitblit.StoredSettings;\r
import com.gitblit.utils.JGitUtils;\r
+import com.gitblit.utils.StringUtils;\r
import com.gitblit.wicket.LinkPanel;\r
import com.gitblit.wicket.WicketUtils;\r
import com.gitblit.wicket.pages.CommitDiffPage;\r
public LogPanel(String wicketId, final String repositoryName, String objectId, Repository r, int limit, int pageOffset) {\r
super(wicketId);\r
boolean pageResults = limit <= 0;\r
- int itemsPerPage = StoredSettings.getInteger(Keys.web_logPageCommitCount, 50);\r
+ int itemsPerPage = GitBlit.self().settings().getInteger(Keys.web.logPageCommitCount, 50);\r
if (itemsPerPage <= 1) {\r
itemsPerPage = 50;\r
}\r
item.add(WicketUtils.createAuthorLabel("commitAuthor", author));\r
\r
String shortMessage = entry.getShortMessage();\r
- String trimmedMessage = WicketUtils.trimShortLog(shortMessage);\r
+ String trimmedMessage = StringUtils.trimShortLog(shortMessage);\r
LinkPanel shortlog = new LinkPanel("commitShortMessage", "list subject", trimmedMessage, CommitPage.class, WicketUtils.newObjectParameter(repositoryName, entry.getName()));\r
if (!shortMessage.equals(trimmedMessage)) {\r
WicketUtils.setHtmlTitle(shortlog, shortMessage);\r
import org.apache.wicket.markup.repeater.data.ListDataProvider;\r
import org.eclipse.jgit.lib.Repository;\r
\r
-import com.gitblit.StoredSettings;\r
+import com.gitblit.GitBlit;\r
+import com.gitblit.Keys;\r
import com.gitblit.utils.JGitUtils;\r
import com.gitblit.wicket.LinkPanel;\r
import com.gitblit.wicket.WicketUtils;\r
add(new BookmarkablePageLink<Void>("tree", TreePage.class, WicketUtils.newRepositoryParameter(repositoryName)));\r
\r
// Get the repository ticgit setting\r
- boolean checkTicgit = StoredSettings.getBoolean("ticgit.global", false);\r
- checkTicgit |= StoredSettings.getBoolean(MessageFormat.format("ticgit.{0}", repositoryName), false);\r
+ boolean checkTicgit = GitBlit.self().settings().getBoolean(Keys.ticgit.global, false);\r
+ checkTicgit |= GitBlit.self().settings().getBoolean(MessageFormat.format(Keys.ticgit._ROOT + ".{0}", repositoryName), false);\r
\r
// Add dynamic repository extras\r
List<String> extras = new ArrayList<String>();\r
import org.eclipse.jgit.lib.Repository;\r
\r
import com.gitblit.utils.JGitUtils;\r
+import com.gitblit.utils.StringUtils;\r
import com.gitblit.wicket.LinkPanel;\r
import com.gitblit.wicket.WicketUtils;\r
import com.gitblit.wicket.models.RefModel;\r
item.add(new LinkPanel("tagName", "list name", entry.getDisplayName(), CommitPage.class, WicketUtils.newObjectParameter(repositoryName, entry.getCommitId().getName())));\r
String message;\r
if (maxCount > 0) {\r
- message = WicketUtils.trimString(entry.getShortLog(), 40);\r
+ message = StringUtils.trimString(entry.getShortLog(), 40);\r
} else {\r
message = entry.getShortLog();\r
}\r