Generate Keys class from gitblit.properties as part of build process.
1 files added
44 files modified
| | |
| | | <mkdir dir="${project.build.dir}" />
|
| | | <javac srcdir="${basedir}/src" destdir="${project.build.dir}">
|
| | | <include name="com/gitblit/Build.java" />
|
| | | <include name="com/gitblit/Constants.java" />
|
| | | </javac>
|
| | | <java classpath="${project.build.dir}" classname="com.gitblit.Build" />
|
| | |
|
| | |
| | | </path>
|
| | | <javac destdir="${project.build.dir}">
|
| | | <src path="${basedir}/src" />
|
| | | <src path="${basedir}/contrib" />
|
| | | <classpath refid="master-classpath" />
|
| | | </javac>
|
| | | <copy todir="${project.build.dir}">
|
| | |
| | | #
|
| | |
|
| | | # Allow push/pull over http/https with JGit servlet
|
| | | allowPushPull = true
|
| | | git.allowPushPull = true
|
| | |
|
| | | # Base folder for repositories
|
| | | # Use forward slashes on Windows!!
|
| | | repositoriesFolder = c:/projects/git
|
| | | git.repositoriesFolder = c:/projects/git
|
| | |
|
| | | # Export all repositories
|
| | | # if false, each exported repository must have a .git/git-daemon-export-ok file
|
| | | exportAll = true
|
| | | git.exportAll = true
|
| | |
|
| | | # Search repositories folder for nested repositories
|
| | | nestedRepositories = true
|
| | | git.nestedRepositories = true
|
| | |
|
| | | # The root clone url
|
| | | cloneUrl = https://localhost/git/
|
| | | git.cloneUrl = https://localhost/git/
|
| | |
|
| | | #
|
| | | # Authentication Settings
|
| | | #
|
| | |
|
| | | # Require authentication for http/https push/pull access of git repositories
|
| | | authenticatePushPull = true
|
| | | git.authenticate = true
|
| | |
|
| | | # Require authentication to see the web ui
|
| | | authenticateWebUI = true
|
| | | web.authenticate = true
|
| | |
|
| | | # Simple user realm file to authenticate users for push/pull
|
| | | realmFile = users.properties
|
| | | # Simple user realm file to authenticate users
|
| | | server.realmFile = users.properties
|
| | |
|
| | | #
|
| | | # Server Settings
|
| | | #
|
| | | debugMode = true
|
| | | tempFolder = temp
|
| | | log4jPattern = %-5p %d{MM-dd HH:mm:ss.SSS} %-20.20c{1} %m%n
|
| | | server.debugMode = true
|
| | | server.tempFolder = temp
|
| | | server.log4jPattern = %-5p %d{MM-dd HH:mm:ss.SSS} %-20.20c{1} %m%n
|
| | |
|
| | | # Aggressive heap management will run the garbage collector on every generated
|
| | | # page. This slows down page generation but improves heap consumption.
|
| | | aggressiveHeapManagement = true
|
| | | server.aggressiveHeapManagement = true
|
| | |
|
| | | #
|
| | | # Git:Blit UI Settings
|
| | | #
|
| | | siteName =
|
| | | web.siteName =
|
| | |
|
| | | # If authenticateWebUI=true, users with "admin" role can create repositories,
|
| | | # create users, and edit repository metadata (owner, description, etc)
|
| | | #
|
| | | # If authenticateWebUI=false, any user can execute the aforementioned functions.
|
| | | allowAdministration = true
|
| | | web.allowAdministration = true
|
| | |
|
| | | repositoriesMessage = Welcome to Git:Blit!<br>A quick and easy way to host your own Git repositories.<br>Built with <a href="http://eclipse.org/jgit">JGit</a>, <a href="http://wicket.apache.org">Wicket</a>, <a href="http://code.google.com/p/google-code-prettify/">google-code-prettify</a>, <a href="http://eclipse.org/jetty">Jetty</a>, <a href="http://www.slf4j.org">SLF4J</a>, <a href="http://logging.apache.org/log4j">Log4j</a>, and <a href="http://jcommander.org">JCommander</a>.
|
| | | # This is the message display above the repositories table.
|
| | | # This can point to a file with HTML content.
|
| | | web.repositoriesMessage = Welcome to Git:Blit!<br>A quick and easy way to host your own Git repositories.<br>Built with <a href="http://eclipse.org/jgit">JGit</a>, <a href="http://wicket.apache.org">Wicket</a>, <a href="http://code.google.com/p/google-code-prettify/">google-code-prettify</a>, <a href="http://eclipse.org/jetty">Jetty</a>, <a href="http://www.slf4j.org">SLF4J</a>, <a href="http://logging.apache.org/log4j">Log4j</a>, and <a href="http://jcommander.org">JCommander</a>.
|
| | |
|
| | | # Use the client timezone when formatting dates.
|
| | | # This uses AJAX to determine the browser's timezone and enables Wicket
|
| | | # session management for the connection.
|
| | | useClientTimezone = false
|
| | | web.useClientTimezone = false
|
| | |
|
| | | # Date and Time formats
|
| | | timestampFormat = h:mm a
|
| | |
|
| | | datestampShortFormat = yyyy-MM-dd
|
| | | datestampLongFormat = EEEE, MMMM d, yyyy
|
| | |
|
| | | datetimestampShortFormat = yyyy-MM-dd h:mm a z
|
| | | datetimestampLongFormat = EEEE, MMMM d, yyyy h:mm a z
|
| | | web.datestampShortFormat = yyyy-MM-dd
|
| | | web.datetimestampLongFormat = EEEE, MMMM d, yyyy h:mm a z
|
| | |
|
| | | # Generates a line graph of repository activity over time on the Summary page.
|
| | | # This is a real-time graph so generation may be expensive.
|
| | | generateActivityGraph = true
|
| | | web.generateActivityGraph = true
|
| | |
|
| | | # The number of commits to display on the summary page
|
| | | # Value must exceed 0 else default of 20 is used
|
| | | summaryCommitCount = 20
|
| | | web.summaryCommitCount = 20
|
| | |
|
| | | # The number of tags/heads to display on the summary page
|
| | | # Value must exceed 0 else default of 5 is used
|
| | | summaryRefsCount = 5
|
| | | web.summaryRefsCount = 5
|
| | |
|
| | | # The number of commits to show on each page of a Log
|
| | | # Value must exceed 0 else default of 50 is used
|
| | | logPageCommitCount = 50
|
| | | web.logPageCommitCount = 50
|
| | |
|
| | | # Registered extensions for google-code-prettify
|
| | | prettyPrintExtensions = c cpp cs css htm html java js php pl prefs properties py rb sh sql xml vb
|
| | | web.prettyPrintExtensions = c cpp cs css htm html java js php pl prefs properties py rb sh sql xml vb
|
| | |
|
| | | # Image extensions
|
| | | imageExtensions = bmp jpg gif png |
| | | web.imageExtensions = bmp jpg gif png |
| | |
|
| | | # Registered extensions for binary blobs
|
| | | binaryExtensions = jar pdf tar.gz zip
|
| | | web.binaryExtensions = jar pdf tar.gz zip
|
| | |
|
| | | # Example global regex substitutions
|
| | | regex.global.bug = \\b(Bug:)(\\s*[#]?|-){0,1}(\\d+)\\b!!!<a href="http://somehost/bug/$3">Bug-Id: $3</a>
|
| | | regex.global.changeid = \\b(Change-Id:\\s*)([A-Za-z0-9]*)\\b!!!<a href="http://somehost/changeid/$2">Change-Id: $2</a>
|
| | |
|
| | | # Example per-repository regex substitutions overrides global
|
| | | regex.myrepository.bug = \\b(Bug:)(\\s*[#]?|-){0,1}(\\d+)\\b!!!<a href="http://elsewhere/bug/$3">Bug-Id: $3</a>
|
| | | #regex.myrepository.bug = \\b(Bug:)(\\s*[#]?|-){0,1}(\\d+)\\b!!!<a href="http://elsewhere/bug/$3">Bug-Id: $3</a>
|
| | |
|
| | | # Enable ticgit viewer for all repositories (checks for ticgit branch)
|
| | | ticgit.global = false
|
| | |
|
| | | # Enable ticgit viewer for specified repository (checks for ticgit branch)
|
| | | ticgit.myrepository = true
|
| | | ticgit.ticgit = true
|
| | | #ticgit.myrepository = true
|
| | |
|
| | | #
|
| | | # Jetty Settings
|
| | | #
|
| | |
|
| | | # use NIO connectors. If false, socket connectors will be used.
|
| | | useNio = true
|
| | | server.useNio = true
|
| | |
|
| | | # Standard http port to serve. <= 0 disables this connector.
|
| | | httpPort = 0
|
| | | server.httpPort = 0
|
| | |
|
| | | # Secure/SSL https port to serve. <= 0 disables this connector.
|
| | | httpsPort = 443
|
| | | server.httpsPort = 443
|
| | |
|
| | | # Password for SSL keystore (keystore password and certificate password must match)
|
| | | storePassword = dosomegit
|
| | | server.storePassword = dosomegit
|
| | |
|
| | | # Port for shutdown monitor to listen on.
|
| | | shutdownPort = 8081
|
| | | server.shutdownPort = 8081
|
New file |
| | |
| | | /SettingKeys.java |
| | | /Keys.java |
| | |
| | | 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() {
|
| | |
| | |
|
| | | public static void compiletime() {
|
| | | 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();
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | |
| | | 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;
|
| | |
| | | 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";
|
| | | }
|
| | |
| | | }
|
| | |
|
| | | 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;
|
| | | }
|
| | |
| | | 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) {
|
| | |
| | | }
|
| | | 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);
|
| | | }
|
| | |
| | | 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));
|
| | |
|
| | |
| | | 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");
|
| | | }
|
| | |
|
| | |
| | | // 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;
|
| | |
| | | GitBlit.self().setLoginService(jettyLoginService);
|
| | | loginService = jettyLoginService;
|
| | | }
|
| | | |
| | |
|
| | | // Determine what handler to use
|
| | | Handler handler;
|
| | | if (gitServlet != null) {
|
| | |
| | | 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);
|
| | |
|
| | | }
|
| | | } |
| | |
| | |
|
| | | public interface ILoginService {
|
| | |
|
| | | User authenticate(String username, char [] password);
|
| | | |
| | | User authenticate(char [] cookie);
|
| | | User authenticate(String username, char[] password);
|
| | |
|
| | | User authenticate(char[] cookie);
|
| | | }
|
| | |
| | | public JettyLoginService(String realmFile) {
|
| | | super(Constants.NAME, realmFile);
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | public User authenticate(String username, char[] password) {
|
| | | UserIdentity identity = login(username, new String(password));
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public User authenticate(char [] cookie) {
|
| | | public User authenticate(char[] cookie) {
|
| | | // TODO cookie login
|
| | | return null;
|
| | | }
|
| | |
| | | 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);
|
| | | }
|
| | |
| | | }
|
| | |
|
| | | 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) {
|
| | |
| | | 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);
|
| | |
| | | import org.eclipse.jgit.diff.RawText;
|
| | |
|
| | | public class HtmlDiffFormatter extends DiffFormatter {
|
| | | |
| | |
|
| | | private final OutputStream os;
|
| | |
|
| | | public HtmlDiffFormatter(OutputStream os) {
|
| | |
| | | }
|
| | | 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);
|
| | |
| | | }
|
| | | return ago;
|
| | | }
|
| | | |
| | |
|
| | | public static String leftPad(String input, int length, char pad) {
|
| | | if (input.length() < length) {
|
| | | StringBuilder sb = new StringBuilder();
|
| | |
| | | }
|
| | | 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;
|
| | |
| | |
|
| | | @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
|
| | |
| | | return false;
|
| | | User user = session.getUser();
|
| | | if (pageClass.isAnnotationPresent(AdminPage.class)) {
|
| | | |
| | |
|
| | | }
|
| | | return true;
|
| | | }
|
| | |
| | | import org.slf4j.LoggerFactory;
|
| | |
|
| | | import com.gitblit.Constants;
|
| | | import com.gitblit.Keys;
|
| | | import com.gitblit.StoredSettings;
|
| | | import com.gitblit.wicket.pages.SummaryPage;
|
| | |
|
| | |
| | | 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));
|
| | |
| | | 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);
|
| | |
| | | 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;
|
| | |
| | | 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);
|
| | | }
|
| | |
|
| | |
| | | }
|
| | |
|
| | | 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() {
|
| | |
| | | private static final long serialVersionUID = 1L;
|
| | |
|
| | | protected TimeZone timezone = null;
|
| | | |
| | |
|
| | | private User user = null;
|
| | |
|
| | | public GitBlitWebSession(Request request) {
|
| | |
| | | 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;
|
| | | }
|
| | |
| | | }
|
| | | if (linkCssClass != null) {
|
| | | link.add(new SimpleAttributeModifier("class", linkCssClass));
|
| | | } |
| | | }
|
| | | link.add(new Label("label", labelModel));
|
| | | add(link);
|
| | | }
|
| | |
| | | loginForm.add(new FeedbackPanel("feedback"));
|
| | | add(loginForm);
|
| | | }
|
| | | |
| | |
|
| | | protected String getServerName() {
|
| | | ServletWebRequest servletWebRequest = (ServletWebRequest) getRequest();
|
| | | HttpServletRequest req = servletWebRequest.getHttpServletRequest();
|
| | |
| | | @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)
|
| | |
| | | // 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);
|
| | |
| | | }
|
| | |
|
| | | 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) {
|
| | |
| | | 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;
|
| | | }
|
| | |
| | | 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;
|
| | | }
|
| | |
| | | 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;
|
| | |
|
| | |
| | | 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")) {
|
| | |
| | | setCssClass(container, css);
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | public static String flattenStrings(List<String> values) {
|
| | | StringBuilder sb = new StringBuilder();
|
| | | for (String value : values) {
|
| | |
| | | }
|
| | | 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);
|
| | |
| | | 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);
|
| | | }
|
| | |
| | | }
|
| | | 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", "");
|
| | | }
|
| | |
| | | }
|
| | |
|
| | | 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);
|
| | | }
|
| | |
| | | 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);
|
| | | }
|
| | |
| | |
|
| | | 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;
|
| | |
| | | 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) {
|
| | |
| | |
|
| | | import com.gitblit.utils.JGitUtils;
|
| | |
|
| | |
|
| | | public class RefModel implements Serializable, Comparable<RefModel> {
|
| | |
|
| | | private static final long serialVersionUID = 1L;
|
| | |
| | | public String getName() {
|
| | | return ref.getName();
|
| | | }
|
| | | |
| | |
|
| | | public RevCommit getCommit() {
|
| | | return commit;
|
| | | }
|
| | |
| | | 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());
|
| | |
| | | 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;
|
| | |
| | | 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");
|
| | |
| | | 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.RepositoryPage;
|
| | | import com.gitblit.wicket.WicketUtils;
|
| | | import com.gitblit.wicket.panels.PathBreadcrumbsPanel;
|
| | |
|
| | |
|
| | | 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);
|
| | | }
|
| | |
|
| | |
| | | add(blobLabel);
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | protected String getPageName() {
|
| | | return getString("gb.view");
|
| | |
| | | import com.gitblit.wicket.RepositoryPage;
|
| | | import com.gitblit.wicket.panels.BranchesPanel;
|
| | |
|
| | |
|
| | | public class BranchesPage extends RepositoryPage {
|
| | |
|
| | | public BranchesPage(PageParameters params) {
|
| | |
| | |
|
| | | add(new BranchesPanel("branchesPanel", repositoryName, getRepository(), -1));
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | protected String getPageName() {
|
| | | return getString("gb.branches");
|
| | |
| | |
|
| | | 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"));
|
| | |
| | | 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;
|
| | |
| | | } 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));
|
| | |
| | | add(pathsView);
|
| | | add(new Label("diffText", diff).setEscapeModelStrings(false));
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | protected String getPageName() {
|
| | | return getString("gb.commitdiff");
|
| | |
| | | import com.gitblit.wicket.WicketUtils;
|
| | | import com.gitblit.wicket.models.PathModel;
|
| | |
|
| | |
|
| | | public class CommitPage extends RepositoryPage {
|
| | |
|
| | | public CommitPage(PageParameters params) {
|
| | |
| | |
|
| | | 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"));
|
| | |
| | | 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())));
|
| | |
| | | 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;
|
| | |
| | | } 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));
|
| | |
| | | };
|
| | | add(pathsView);
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | protected String getPageName() {
|
| | | return getString("gb.commit");
|
| | |
| | | import com.gitblit.utils.JGitUtils;
|
| | | import com.gitblit.wicket.WicketUtils;
|
| | |
|
| | |
|
| | | public class PatchPage extends WebPage {
|
| | |
|
| | | public PatchPage(PageParameters params) {
|
| | |
| | | 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();
|
| | |
| | | String patch = JGitUtils.getCommitPatch(r, commit, blobPath);
|
| | | add(new Label("patchText", patch));
|
| | | r.close();
|
| | | } |
| | | }
|
| | | }
|
| | |
| | | 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 {
|
| | |
|
| | |
| | | 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();
|
| | |
| | |
|
| | | // 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);
|
| | | }
|
| | |
|
| | |
| | | add(blobLabel);
|
| | | }
|
| | | r.close();
|
| | | } |
| | | }
|
| | | }
|
| | |
| | | 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;
|
| | |
| | | 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);
|
| | |
| | | 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;
|
| | |
| | |
|
| | | 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;
|
| | |
| | | // 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);
|
| | |
| | |
|
| | | add(new Chart("commitsChart", provider));
|
| | | } else {
|
| | | add(new ContextImage("commitsChart", "blank.png")); |
| | | add(new ContextImage("commitsChart", "blank.png"));
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | 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;
|
| | |
| | | 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");
|
| | |
| | | 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");
|
| | |
| | | };
|
| | | add(ticketsView);
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | protected String getPageName() {
|
| | | return getString("gb.ticgit");
|
| | |
| | | };
|
| | | add(commentsView);
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | protected String getPageName() {
|
| | | return getString("gb.ticket");
|
| | |
| | |
|
| | | 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>");
|
| | | }
|
| | | }
|
| | |
| | | import com.gitblit.wicket.models.PathModel;
|
| | | import com.gitblit.wicket.panels.PathBreadcrumbsPanel;
|
| | |
|
| | |
|
| | | public class TreePage extends RepositoryPage {
|
| | |
|
| | | public TreePage(PageParameters params) {
|
| | |
| | | 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;
|
| | |
| | | // 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)));
|
| | |
| | | // 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)));
|
| | |
| | | };
|
| | | add(pathsView);
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | protected String getPageName() {
|
| | | return getString("gb.tree");
|
| | |
| | |
|
| | | import org.apache.wicket.markup.html.panel.Panel;
|
| | |
|
| | | import com.gitblit.Keys;
|
| | | import com.gitblit.StoredSettings;
|
| | | import com.gitblit.wicket.GitBlitWebSession;
|
| | |
|
| | |
| | | }
|
| | |
|
| | | 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();
|
| | | }
|
| | | }
|
| | |
| | | // 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;
|
| | |
| | | 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())));
|
| | |
|
| | |
| | | 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;
|
| | |
| | | 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;
|
| | | }
|
| | |
| | | // 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) {
|
| | |
| | | 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);
|
| | | }
|
| | |
| | | import com.gitblit.wicket.pages.LogPage;
|
| | | import com.gitblit.wicket.pages.TagPage;
|
| | |
|
| | |
|
| | | public class RefsPanel extends Panel {
|
| | |
|
| | | private static final long serialVersionUID = 1L;
|
| | |
| | | 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;
|