From 5450d08e4cd11176bcc50a5b3d001d291bd8982c Mon Sep 17 00:00:00 2001 From: James Moger Date: Sat, 18 Jun 2011 08:28:47 -0400 Subject: [PATCH] Mostly stable war build. Reorganization of resources. Dropped most hard-coded webapp configuration in favor of common web.xml file. Still contemplating configuring git servlet from web.xml too. --- .gitignore | 2 + build.xml | 100 +++++++++++--- distrib/gitblit.properties | 31 +---- docs/00_index.mkd | 19 ++- docs/00_setup.mkd | 4 +- docs/01_faq.mkd | 19 +-- .../resources => resources}/add_16x16.png | Bin .../resources => resources}/arrow_down.png | Bin .../resources => resources}/arrow_off.png | Bin .../resources => resources}/arrow_up.png | Bin .../resources => resources}/background.png | Bin .../wicket/resources => resources}/blank.png | Bin .../resources => resources}/book_16x16.png | Bin .../resources => resources}/bug_16x16.png | Bin .../resources => resources}/bullet_error.png | Bin .../resources => resources}/cold_16x16.png | Bin .../commit_branch_16x16.png | Bin .../commit_divide_16x16.png | Bin .../commit_join_16x16.png | Bin .../commit_merge_16x16.png | Bin .../commit_up_16x16.png | Bin .../resources => resources}/feed_16x16.png | Bin .../resources => resources}/file_16x16.png | Bin .../file_acrobat_16x16.png | Bin .../resources => resources}/file_c_16x16.png | Bin .../file_code_16x16.png | Bin .../file_cpp_16x16.png | Bin .../resources => resources}/file_cs_16x16.png | Bin .../file_doc_16x16.png | Bin .../file_excel_16x16.png | Bin .../resources => resources}/file_h_16x16.png | Bin .../file_java_16x16.png | Bin .../file_php_16x16.png | Bin .../file_ppt_16x16.png | Bin .../file_ruby_16x16.png | Bin .../file_settings_16x16.png | Bin .../resources => resources}/file_vs_16x16.png | Bin .../file_world_16x16.png | Bin .../file_zip_16x16.png | Bin .../resources => resources}/folder_16x16.png | Bin .../resources => resources}/gitblit.css | 2 +- resources/gitblt-favicon.png | Bin 0 -> 534 bytes .../resources => resources}/gitblt-logo.png | Bin .../resources => resources}/gitblt2.png | Bin .../resources => resources}/gitblt_25.png | Bin .../gitweb-favicon.png | Bin .../resources => resources}/lock_16x16.png | Bin .../resources => resources}/lock_go_16x16.png | Bin .../lock_pull_16x16.png | Bin .../resources => resources}/markdown.css | 0 .../wicket/resources => resources}/pixel.png | Bin .../resources => resources}/search-icon.png | Bin .../resources => resources}/shield_16x16.png | Bin .../resources => resources}/tag_16x16.png | Bin .../resources => resources}/user_16x16.png | Bin .../resources => resources}/welcome.mkd | 0 src/WEB-INF/web.xml | 125 ++++++++++++++++++ src/com/gitblit/AccessRestrictionFilter.java | 17 ++- src/com/gitblit/Build.java | 12 +- src/com/gitblit/BuildWebXml.java | 80 +++++++++++ src/com/gitblit/Constants.java | 8 +- src/com/gitblit/DownloadZipServlet.java | 2 +- src/com/gitblit/FileLoginService.java | 3 +- src/com/gitblit/GitBlit.java | 59 ++++++--- src/com/gitblit/GitBlitServer.java | 78 ++--------- src/com/gitblit/GitFilter.java | 4 + src/com/gitblit/ILoginService.java | 2 + src/com/gitblit/IStoredSettings.java | 18 ++- src/com/gitblit/SyndicationServlet.java | 2 +- src/com/gitblit/utils/JGitUtils.java | 27 ++-- src/com/gitblit/utils/StringUtils.java | 17 +-- src/com/gitblit/utils/SyndicationUtils.java | 2 +- .../gitblit/wicket/GitBlitWebApp.properties | 4 +- src/com/gitblit/wicket/WicketUtils.java | 4 +- src/com/gitblit/wicket/pages/BasePage.html | 14 +- src/com/gitblit/wicket/pages/BasePage.java | 6 +- src/com/gitblit/wicket/pages/DocsPage.java | 3 +- src/com/gitblit/wicket/pages/LoginPage.html | 10 +- .../gitblit/wicket/pages/MarkdownPage.html | 6 +- .../gitblit/wicket/pages/MarkdownPage.java | 3 +- .../wicket/pages/RepositoriesPage.html | 4 +- .../wicket/pages/RepositoriesPage.java | 2 +- .../gitblit/wicket/pages/RepositoryPage.html | 2 +- .../gitblit/wicket/pages/RepositoryPage.java | 102 +++++++------- src/com/gitblit/wicket/pages/SummaryPage.html | 4 +- src/com/gitblit/wicket/pages/SummaryPage.java | 2 +- .../wicket/panels/RepositoriesPanel.html | 14 +- .../gitblit/wicket/panels/SearchPanel.html | 4 +- .../gitblit/wicket/panels/SearchPanel.java | 8 +- src/com/gitblit/wicket/panels/UsersPanel.html | 8 +- .../wicket/resources/gitblt-favicon.png | Bin 380 -> 0 bytes src/log4j.properties | 66 ++++++++- 92 files changed, 578 insertions(+), 321 deletions(-) rename {src/com/gitblit/wicket/resources => resources}/add_16x16.png (100%) rename {src/com/gitblit/wicket/resources => resources}/arrow_down.png (100%) rename {src/com/gitblit/wicket/resources => resources}/arrow_off.png (100%) rename {src/com/gitblit/wicket/resources => resources}/arrow_up.png (100%) rename {src/com/gitblit/wicket/resources => resources}/background.png (100%) rename {src/com/gitblit/wicket/resources => resources}/blank.png (100%) rename {src/com/gitblit/wicket/resources => resources}/book_16x16.png (100%) rename {src/com/gitblit/wicket/resources => resources}/bug_16x16.png (100%) rename {src/com/gitblit/wicket/resources => resources}/bullet_error.png (100%) rename {src/com/gitblit/wicket/resources => resources}/cold_16x16.png (100%) rename {src/com/gitblit/wicket/resources => resources}/commit_branch_16x16.png (100%) rename {src/com/gitblit/wicket/resources => resources}/commit_divide_16x16.png (100%) rename {src/com/gitblit/wicket/resources => resources}/commit_join_16x16.png (100%) rename {src/com/gitblit/wicket/resources => resources}/commit_merge_16x16.png (100%) rename {src/com/gitblit/wicket/resources => resources}/commit_up_16x16.png (100%) rename {src/com/gitblit/wicket/resources => resources}/feed_16x16.png (100%) rename {src/com/gitblit/wicket/resources => resources}/file_16x16.png (100%) rename {src/com/gitblit/wicket/resources => resources}/file_acrobat_16x16.png (100%) rename {src/com/gitblit/wicket/resources => resources}/file_c_16x16.png (100%) rename {src/com/gitblit/wicket/resources => resources}/file_code_16x16.png (100%) rename {src/com/gitblit/wicket/resources => resources}/file_cpp_16x16.png (100%) rename {src/com/gitblit/wicket/resources => resources}/file_cs_16x16.png (100%) rename {src/com/gitblit/wicket/resources => resources}/file_doc_16x16.png (100%) rename {src/com/gitblit/wicket/resources => resources}/file_excel_16x16.png (100%) rename {src/com/gitblit/wicket/resources => resources}/file_h_16x16.png (100%) rename {src/com/gitblit/wicket/resources => resources}/file_java_16x16.png (100%) rename {src/com/gitblit/wicket/resources => resources}/file_php_16x16.png (100%) rename {src/com/gitblit/wicket/resources => resources}/file_ppt_16x16.png (100%) rename {src/com/gitblit/wicket/resources => resources}/file_ruby_16x16.png (100%) rename {src/com/gitblit/wicket/resources => resources}/file_settings_16x16.png (100%) rename {src/com/gitblit/wicket/resources => resources}/file_vs_16x16.png (100%) rename {src/com/gitblit/wicket/resources => resources}/file_world_16x16.png (100%) rename {src/com/gitblit/wicket/resources => resources}/file_zip_16x16.png (100%) rename {src/com/gitblit/wicket/resources => resources}/folder_16x16.png (100%) rename {src/com/gitblit/wicket/resources => resources}/gitblit.css (93%) create mode 100644 resources/gitblt-favicon.png rename {src/com/gitblit/wicket/resources => resources}/gitblt-logo.png (100%) rename {src/com/gitblit/wicket/resources => resources}/gitblt2.png (100%) rename {src/com/gitblit/wicket/resources => resources}/gitblt_25.png (100%) rename {src/com/gitblit/wicket/resources => resources}/gitweb-favicon.png (100%) rename {src/com/gitblit/wicket/resources => resources}/lock_16x16.png (100%) rename {src/com/gitblit/wicket/resources => resources}/lock_go_16x16.png (100%) rename {src/com/gitblit/wicket/resources => resources}/lock_pull_16x16.png (100%) rename {src/com/gitblit/wicket/resources => resources}/markdown.css (100%) rename {src/com/gitblit/wicket/resources => resources}/pixel.png (100%) rename {src/com/gitblit/wicket/resources => resources}/search-icon.png (100%) rename {src/com/gitblit/wicket/resources => resources}/shield_16x16.png (100%) rename {src/com/gitblit/wicket/resources => resources}/tag_16x16.png (100%) rename {src/com/gitblit/wicket/resources => resources}/user_16x16.png (100%) rename {src/com/gitblit/wicket/resources => resources}/welcome.mkd (100%) create mode 100644 src/WEB-INF/web.xml create mode 100644 src/com/gitblit/BuildWebXml.java delete mode 100644 src/com/gitblit/wicket/resources/gitblt-favicon.png diff --git a/.gitignore b/.gitignore index 1819e8ea..7cc5c3bc 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,5 @@ /git /target /build.properties +/war +/*.war diff --git a/build.xml b/build.xml index ddb0dfbf..ee01de7d 100644 --- a/build.xml +++ b/build.xml @@ -5,17 +5,16 @@ + - - - - + + - + @@ -30,7 +29,7 @@ - + @@ -46,6 +45,13 @@ Building Gitblit ${gb.version} + + + + + + + @@ -62,8 +68,9 @@ + - + @@ -87,6 +94,9 @@ + + + @@ -97,7 +107,7 @@ - + @@ -211,7 +221,7 @@ - + @@ -284,8 +294,7 @@ - - + @@ -306,6 +315,67 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -318,11 +388,5 @@ - - - - - - - + \ No newline at end of file diff --git a/distrib/gitblit.properties b/distrib/gitblit.properties index 2d55a584..6adf11e5 100644 --- a/distrib/gitblit.properties +++ b/distrib/gitblit.properties @@ -2,8 +2,7 @@ # Git Servlet Settings # -# Allow push/pull over http/https with JGit servlet -# Changing this value requires a server restart. +# Allow push/pull over http/https with JGit servlet. git.enableGitServlet = true # Base folder for repositories @@ -12,11 +11,6 @@ git.enableGitServlet = true # e.g. c:/gitrepos git.repositoriesFolder = git -# Export all repositories -# Changing this value requires a server restart. -# if false, each exported repository must have a .git/git-daemon-export-ok file -git.exportAll = true - # Search the repositories folder subfolders for other repositories. # Repositories MAY NOT be nested (i.e. one repository within another) # but they may be grouped together in subfolders. @@ -36,7 +30,9 @@ web.authenticateViewPages = false # Changing this value requires a server restart. web.authenticateAdminPages = true -# Simple user realm file to authenticate users +# Either a simple user realm file to authenticate users +# OR a fully qualified class name that implements the ILoginService interface. +# Any custom implementation must have a public default constructor. # Changing this value requires a server restart. realm.realmFile = users.properties @@ -154,11 +150,11 @@ regex.global = true # Example global regex substitutions # Use !!! to separate the search pattern and the replace pattern # searchpattern!!!replacepattern -#regex.global.bug = \\b(Bug:)(\\s*[#]?|-){0,1}(\\d+)\\b!!!Bug-Id: $3 -#regex.global.changeid = \\b(Change-Id:\\s*)([A-Za-z0-9]*)\\b!!!Change-Id: $2 +regex.global.bug = \\b(Bug:)(\\s*[#]?|-){0,1}(\\d+)\\b!!!Bug-Id: $3 +regex.global.changeid = \\b(Change-Id:\\s*)([A-Za-z0-9]*)\\b!!!Change-Id: $2 # Example per-repository regex substitutions overrides global -#regex.myrepository.bug = \\b(Bug:)(\\s*[#]?|-){0,1}(\\d+)\\b!!!Bug-Id: $3 +regex.myrepository.bug = \\b(Bug:)(\\s*[#]?|-){0,1}(\\d+)\\b!!!Bug-Id: $3 # # Server Settings @@ -168,19 +164,6 @@ regex.global = true # The temporary folder to decompress the gitblit webapp. server.tempFolder = temp -# The common log4j logging pattern -# http://logging.apache.org/log4j/1.2/apidocs/org/apache/log4j/PatternLayout.html -server.log4jPattern = %-5p %d{MM-dd HH:mm:ss.SSS} %-20.20c{1} %m%n - -# Alternatively, you may specify a logging pattern for your OS. -# If the os pattern is blank, the common pattern is used. - -# This windows pattern fits (mostly) within the fixed bounds of a command prompt. -server.log4jPattern.windows = %-5p %m%n - -server.log4jPattern.linux = - - # # Jetty Settings # diff --git a/docs/00_index.mkd b/docs/00_index.mkd index bcf41e11..7a2bc569 100644 --- a/docs/00_index.mkd +++ b/docs/00_index.mkd @@ -4,7 +4,7 @@ Its designed primarily as a tool for small workgroups who want to host [Git][git ### Current Release -[%VERSION%](http://gitblit.com/%DISTRIBUTION%) based on [%JGIT%][jgit]   (*%BUILDDATE%*) +%VERSION% ([go](http://gitblit.com/%GO%)|[war](http://gitblit.com/%WAR%)) based on [%JGIT%][jgit]   (*%BUILDDATE%*) sources @ [Github][gitbltsrc] @@ -13,8 +13,7 @@ sources @ [Github][gitbltsrc] 2. Offer useful features for serving Git repositories. If feature is complex, refer to #1. 3. All dependencies must be retrievable from a publicly accessible [Maven](http://maven.apache.org) repository.
This is to ensure authenticity of dependencies and to keep the Gitblit distribution svelte. -### Features -- Out-of-the-box integrated stack requiring minimal configuration +### Gitblit Features - JGit SmartHTTP servlet - Browser and git client authentication - Four repository access control configurations and a Read-Only flag @@ -29,7 +28,6 @@ sources @ [Github][gitbltsrc] - Administrators may create, edit, rename, or delete repositories through the web UI - Administrators may create, edit, rename, or delete users through the web UI - Repository Owners may edit repositories through the web UI -- Automatically generates a self-signed certificate for https communications - Git-notes support - Branch metrics (uses Google Charts) - HEAD and branch RSS feeds @@ -41,7 +39,6 @@ sources @ [Github][gitbltsrc] - Markdown file view support - Syntax highlighting for popular source code types - Customizable regular expression substitution for commit messages (i.e. bug or code review link integration) -- Single text file for server configuration - Single text file for users configuration - Optional utility pages
    @@ -49,12 +46,15 @@ sources @ [Github][gitbltsrc]
  • ![tickets](bug_16x16.png) Ticgit ticket pages *(based on last MIT release bf57b032 2009-01-27)*
+### Gitblit-Go Features +- Out-of-the-box integrated stack requiring minimal configuration +- Automatically generates a self-signed certificate for https communications +- Single text file for server configuration + ### Limitations -- [%JGIT%][jgit] does not currently [garbage collect or repack](http://www.kernel.org/pub/software/scm/git/docs/git-gc.html) - HTTP/HTTPS are the only supported protocols - Access controls are not path-based, they are repository-based - Only Administrators can create, rename or delete repositories -- Gitblit is an integrated, full-stack solution. There is no WAR build at this time. ### Caveats - Gitblit may eat your data. Use at your own risk. @@ -64,7 +64,6 @@ sources @ [Github][gitbltsrc] - Code documentation - Unit testing - Update Build.java to JGit 1.0.0, when its released -- WAR solution ### Idea List - Consider clone remote repository feature @@ -90,7 +89,7 @@ Gitblit is distributed under the terms of the [Apache Software Foundation licens ![block diagram](architecture.png "Gitblit Architecture") ### Bundled Dependencies -The following dependencies are bundled with the Gitblit zip distribution file. +The following dependencies are bundled with Gitblit. - [google-code-prettify](http://code.google.com/p/google-code-prettify) (Apache 2.0) - [JavaService](http://forge.ow2.org/projects/javaservice) (BSD and LGPL) @@ -99,7 +98,7 @@ The following dependencies are bundled with the Gitblit zip distribution file. - other icons courtesy of [FatCow Hosting](http://www.fatcow.com/free-icons) (Creative Commons CC-BY) ### Downloaded Dependencies -The following dependencies are automatically downloaded from the Apache Maven repository and from the Eclipse Maven repository when Gitblit is launched for the first time. +The following dependencies are automatically downloaded by Gitblit-Go (or already bundled with the WAR) from the Apache Maven repository and from the Eclipse Maven repository when Gitblit is launched for the first time. - [JGit][jgit] (EDL 1.0) - [Wicket](http://wicket.apache.org) (Apache 2.0) diff --git a/docs/00_setup.mkd b/docs/00_setup.mkd index ccf38b83..02816e7f 100644 --- a/docs/00_setup.mkd +++ b/docs/00_setup.mkd @@ -1,6 +1,6 @@ -## Server Setup and Configuration +## Gitblit-Go Setup and Configuration -1. Download and unzip [Gitblit %VERSION%](http://gitblit.com/%DISTRIBUTION%).
+1. Download and unzip [Gitblit-Go %VERSION%](http://gitblit.com/%GO%).
*Its best to eliminate spaces in the path name as that can cause troubleshooting headaches.* 2. The server itself is configured through a simple text file.
Open `gitblit.properties` in your favorite text editor and make sure to review and set: diff --git a/docs/01_faq.mkd b/docs/01_faq.mkd index 3605387a..552c89d2 100644 --- a/docs/01_faq.mkd +++ b/docs/01_faq.mkd @@ -12,10 +12,10 @@ There are a few ways this can occur: 3. The repository is clone-restricted and your password changed. 4. A regression in Gitblit. :( -### Why can't I access Gitblit from another machine? +### Why can't I access Gitblit-Go from another machine? Please check *server.httpBindInterface* and *server.httpsBindInterface* in `gitblit.properties`. -### How do I run Gitblit on port 80 or 443 in Linux? +### How do I run Gitblit-Go on port 80 or 443 in Linux? Linux requires root permissions to serve on ports < 1024.
Run the server as *root* (security concern) or change the ports you are serving to 8080 (http) and/or 8443 (https). @@ -47,22 +47,12 @@ Gitblit eliminates all that complication with its 100% Java stack and simple sin No. Gitblit is based on [JGit][jgit] which is a pure Java implementation of the [Git version control system][git].
Everything you need for Gitblit is either in the zip distribution file or automatically downloaded on execution. -### What about periodic Git garbage collection (git-gc)? -Good question. I'm not sure. - -Git repositories grow and grow and periodically need to be repacked every once in a while. Git calls this process [garbage collection](http://www.kernel.org/pub/software/scm/git/docs/git-gc.html) (which is not to be confused with [garbage collection](http://en.wikipedia.org/wiki/Garbage_collection_(computer_science)).) - -[JGit's][jgit] documentation is sparse and its unclear whether or not JGit performs this function. - ### Can I run Gitblit in conjunction with my existing Git tooling? -Yes. You can configure Gitblit to only be a repository viewer. +Yes. ### Do I need a JDK or can I use a JRE? Gitblit will run just fine with a JRE. Gitblit can optionally use `keytool` from the JDK to generate self-signed certificates, but normally Gitblit uses [BouncyCastle][bouncycastle] for that need. -### I want to deploy Gitblit into my own servlet container. Where is the WAR? -At this time there is no WAR build available. - ### Does Gitblit use a database to store its data? No. Gitblit stores its repository configuration information within the `.git/config` file and its user information in `users.properties` or whatever filename is configured in `gitblit.properties`. @@ -76,6 +66,9 @@ No. Access restrictions apply to the repository as a whole. Gitblit's simple authentication and authorization mechanism can be used to facilitate one or more of the [workflows outlined here](http://progit.org/book/ch5-1.html). Should you require more fine-grained access controls you might consider using [gitolite](https://github.com/sitaramc/gitolite). +### Can I authenticate users against XYZ? +Yes. The login service is pluggable. You may write your own authentication module by implementing the *ILoginService* interface. Set the fully qualified classname as the *realm.realmFile* property. + ### Why doesn't Gitblit support SSH? Gitblit could integrate [Apache Mina][mina] to provide SSH access. However, doing so violates Gitblit's first design principle: [KISS](http://en.wikipedia.org/wiki/KISS_principle).
SSH support requires creating, exchanging, and managing SSH keys (arguably not more complicated than managing users). While this is possible, JGit's SmartHTTP implementation is a simpler and universal transport mechanism. diff --git a/src/com/gitblit/wicket/resources/add_16x16.png b/resources/add_16x16.png similarity index 100% rename from src/com/gitblit/wicket/resources/add_16x16.png rename to resources/add_16x16.png diff --git a/src/com/gitblit/wicket/resources/arrow_down.png b/resources/arrow_down.png similarity index 100% rename from src/com/gitblit/wicket/resources/arrow_down.png rename to resources/arrow_down.png diff --git a/src/com/gitblit/wicket/resources/arrow_off.png b/resources/arrow_off.png similarity index 100% rename from src/com/gitblit/wicket/resources/arrow_off.png rename to resources/arrow_off.png diff --git a/src/com/gitblit/wicket/resources/arrow_up.png b/resources/arrow_up.png similarity index 100% rename from src/com/gitblit/wicket/resources/arrow_up.png rename to resources/arrow_up.png diff --git a/src/com/gitblit/wicket/resources/background.png b/resources/background.png similarity index 100% rename from src/com/gitblit/wicket/resources/background.png rename to resources/background.png diff --git a/src/com/gitblit/wicket/resources/blank.png b/resources/blank.png similarity index 100% rename from src/com/gitblit/wicket/resources/blank.png rename to resources/blank.png diff --git a/src/com/gitblit/wicket/resources/book_16x16.png b/resources/book_16x16.png similarity index 100% rename from src/com/gitblit/wicket/resources/book_16x16.png rename to resources/book_16x16.png diff --git a/src/com/gitblit/wicket/resources/bug_16x16.png b/resources/bug_16x16.png similarity index 100% rename from src/com/gitblit/wicket/resources/bug_16x16.png rename to resources/bug_16x16.png diff --git a/src/com/gitblit/wicket/resources/bullet_error.png b/resources/bullet_error.png similarity index 100% rename from src/com/gitblit/wicket/resources/bullet_error.png rename to resources/bullet_error.png diff --git a/src/com/gitblit/wicket/resources/cold_16x16.png b/resources/cold_16x16.png similarity index 100% rename from src/com/gitblit/wicket/resources/cold_16x16.png rename to resources/cold_16x16.png diff --git a/src/com/gitblit/wicket/resources/commit_branch_16x16.png b/resources/commit_branch_16x16.png similarity index 100% rename from src/com/gitblit/wicket/resources/commit_branch_16x16.png rename to resources/commit_branch_16x16.png diff --git a/src/com/gitblit/wicket/resources/commit_divide_16x16.png b/resources/commit_divide_16x16.png similarity index 100% rename from src/com/gitblit/wicket/resources/commit_divide_16x16.png rename to resources/commit_divide_16x16.png diff --git a/src/com/gitblit/wicket/resources/commit_join_16x16.png b/resources/commit_join_16x16.png similarity index 100% rename from src/com/gitblit/wicket/resources/commit_join_16x16.png rename to resources/commit_join_16x16.png diff --git a/src/com/gitblit/wicket/resources/commit_merge_16x16.png b/resources/commit_merge_16x16.png similarity index 100% rename from src/com/gitblit/wicket/resources/commit_merge_16x16.png rename to resources/commit_merge_16x16.png diff --git a/src/com/gitblit/wicket/resources/commit_up_16x16.png b/resources/commit_up_16x16.png similarity index 100% rename from src/com/gitblit/wicket/resources/commit_up_16x16.png rename to resources/commit_up_16x16.png diff --git a/src/com/gitblit/wicket/resources/feed_16x16.png b/resources/feed_16x16.png similarity index 100% rename from src/com/gitblit/wicket/resources/feed_16x16.png rename to resources/feed_16x16.png diff --git a/src/com/gitblit/wicket/resources/file_16x16.png b/resources/file_16x16.png similarity index 100% rename from src/com/gitblit/wicket/resources/file_16x16.png rename to resources/file_16x16.png diff --git a/src/com/gitblit/wicket/resources/file_acrobat_16x16.png b/resources/file_acrobat_16x16.png similarity index 100% rename from src/com/gitblit/wicket/resources/file_acrobat_16x16.png rename to resources/file_acrobat_16x16.png diff --git a/src/com/gitblit/wicket/resources/file_c_16x16.png b/resources/file_c_16x16.png similarity index 100% rename from src/com/gitblit/wicket/resources/file_c_16x16.png rename to resources/file_c_16x16.png diff --git a/src/com/gitblit/wicket/resources/file_code_16x16.png b/resources/file_code_16x16.png similarity index 100% rename from src/com/gitblit/wicket/resources/file_code_16x16.png rename to resources/file_code_16x16.png diff --git a/src/com/gitblit/wicket/resources/file_cpp_16x16.png b/resources/file_cpp_16x16.png similarity index 100% rename from src/com/gitblit/wicket/resources/file_cpp_16x16.png rename to resources/file_cpp_16x16.png diff --git a/src/com/gitblit/wicket/resources/file_cs_16x16.png b/resources/file_cs_16x16.png similarity index 100% rename from src/com/gitblit/wicket/resources/file_cs_16x16.png rename to resources/file_cs_16x16.png diff --git a/src/com/gitblit/wicket/resources/file_doc_16x16.png b/resources/file_doc_16x16.png similarity index 100% rename from src/com/gitblit/wicket/resources/file_doc_16x16.png rename to resources/file_doc_16x16.png diff --git a/src/com/gitblit/wicket/resources/file_excel_16x16.png b/resources/file_excel_16x16.png similarity index 100% rename from src/com/gitblit/wicket/resources/file_excel_16x16.png rename to resources/file_excel_16x16.png diff --git a/src/com/gitblit/wicket/resources/file_h_16x16.png b/resources/file_h_16x16.png similarity index 100% rename from src/com/gitblit/wicket/resources/file_h_16x16.png rename to resources/file_h_16x16.png diff --git a/src/com/gitblit/wicket/resources/file_java_16x16.png b/resources/file_java_16x16.png similarity index 100% rename from src/com/gitblit/wicket/resources/file_java_16x16.png rename to resources/file_java_16x16.png diff --git a/src/com/gitblit/wicket/resources/file_php_16x16.png b/resources/file_php_16x16.png similarity index 100% rename from src/com/gitblit/wicket/resources/file_php_16x16.png rename to resources/file_php_16x16.png diff --git a/src/com/gitblit/wicket/resources/file_ppt_16x16.png b/resources/file_ppt_16x16.png similarity index 100% rename from src/com/gitblit/wicket/resources/file_ppt_16x16.png rename to resources/file_ppt_16x16.png diff --git a/src/com/gitblit/wicket/resources/file_ruby_16x16.png b/resources/file_ruby_16x16.png similarity index 100% rename from src/com/gitblit/wicket/resources/file_ruby_16x16.png rename to resources/file_ruby_16x16.png diff --git a/src/com/gitblit/wicket/resources/file_settings_16x16.png b/resources/file_settings_16x16.png similarity index 100% rename from src/com/gitblit/wicket/resources/file_settings_16x16.png rename to resources/file_settings_16x16.png diff --git a/src/com/gitblit/wicket/resources/file_vs_16x16.png b/resources/file_vs_16x16.png similarity index 100% rename from src/com/gitblit/wicket/resources/file_vs_16x16.png rename to resources/file_vs_16x16.png diff --git a/src/com/gitblit/wicket/resources/file_world_16x16.png b/resources/file_world_16x16.png similarity index 100% rename from src/com/gitblit/wicket/resources/file_world_16x16.png rename to resources/file_world_16x16.png diff --git a/src/com/gitblit/wicket/resources/file_zip_16x16.png b/resources/file_zip_16x16.png similarity index 100% rename from src/com/gitblit/wicket/resources/file_zip_16x16.png rename to resources/file_zip_16x16.png diff --git a/src/com/gitblit/wicket/resources/folder_16x16.png b/resources/folder_16x16.png similarity index 100% rename from src/com/gitblit/wicket/resources/folder_16x16.png rename to resources/folder_16x16.png diff --git a/src/com/gitblit/wicket/resources/gitblit.css b/resources/gitblit.css similarity index 93% rename from src/com/gitblit/wicket/resources/gitblit.css rename to resources/gitblit.css index 498c1a77..29474188 100644 --- a/src/com/gitblit/wicket/resources/gitblit.css +++ b/resources/gitblit.css @@ -221,7 +221,7 @@ div.search { div.search input { vertical-align: top; - background: url(/com/gitblit/wicket/resources/search-icon.png) no-repeat 4px center; + background: url(search-icon.png) no-repeat 4px center; color: #ddd; background-color: #000070; border: 1px solid transparent; diff --git a/resources/gitblt-favicon.png b/resources/gitblt-favicon.png new file mode 100644 index 0000000000000000000000000000000000000000..c3c6dc1bfa55ba892a9d0646b056bb0a584b0c80 GIT binary patch literal 534 zcmV+x0_pvUP)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2ipb_ z5DW&2ILcoD00EXsL_t(I%cYaQYg17a$3OSwB{85i>!a!)Ak;+!C2LbkJ9dhYsU(xQ zDAGx~wZtseP_bmuMWl2Pq)SUDrG(Hbf}{9@ibFwATN=qrz7Fr@<(fQ+;1|y2-tRs4 z+&u#^$@*fG$AbVObaS z1N0iS2+BkOrYkUC_c+luje{bfLQH@`TSpSJRnRi(S?wi&YL?^ON4o$@gNhd4asb-? zfHDaHau)NdV_>amegV%d{+ko0?2T(W15AX=4$x@%P`;vbzyr&*jwJHSu=BpmlQ-E= z6Xi$zy#=}la-ATJ@csA@<3D~=S^xk5 literal 0 HcmV?d00001 diff --git a/src/com/gitblit/wicket/resources/gitblt-logo.png b/resources/gitblt-logo.png similarity index 100% rename from src/com/gitblit/wicket/resources/gitblt-logo.png rename to resources/gitblt-logo.png diff --git a/src/com/gitblit/wicket/resources/gitblt2.png b/resources/gitblt2.png similarity index 100% rename from src/com/gitblit/wicket/resources/gitblt2.png rename to resources/gitblt2.png diff --git a/src/com/gitblit/wicket/resources/gitblt_25.png b/resources/gitblt_25.png similarity index 100% rename from src/com/gitblit/wicket/resources/gitblt_25.png rename to resources/gitblt_25.png diff --git a/src/com/gitblit/wicket/resources/gitweb-favicon.png b/resources/gitweb-favicon.png similarity index 100% rename from src/com/gitblit/wicket/resources/gitweb-favicon.png rename to resources/gitweb-favicon.png diff --git a/src/com/gitblit/wicket/resources/lock_16x16.png b/resources/lock_16x16.png similarity index 100% rename from src/com/gitblit/wicket/resources/lock_16x16.png rename to resources/lock_16x16.png diff --git a/src/com/gitblit/wicket/resources/lock_go_16x16.png b/resources/lock_go_16x16.png similarity index 100% rename from src/com/gitblit/wicket/resources/lock_go_16x16.png rename to resources/lock_go_16x16.png diff --git a/src/com/gitblit/wicket/resources/lock_pull_16x16.png b/resources/lock_pull_16x16.png similarity index 100% rename from src/com/gitblit/wicket/resources/lock_pull_16x16.png rename to resources/lock_pull_16x16.png diff --git a/src/com/gitblit/wicket/resources/markdown.css b/resources/markdown.css similarity index 100% rename from src/com/gitblit/wicket/resources/markdown.css rename to resources/markdown.css diff --git a/src/com/gitblit/wicket/resources/pixel.png b/resources/pixel.png similarity index 100% rename from src/com/gitblit/wicket/resources/pixel.png rename to resources/pixel.png diff --git a/src/com/gitblit/wicket/resources/search-icon.png b/resources/search-icon.png similarity index 100% rename from src/com/gitblit/wicket/resources/search-icon.png rename to resources/search-icon.png diff --git a/src/com/gitblit/wicket/resources/shield_16x16.png b/resources/shield_16x16.png similarity index 100% rename from src/com/gitblit/wicket/resources/shield_16x16.png rename to resources/shield_16x16.png diff --git a/src/com/gitblit/wicket/resources/tag_16x16.png b/resources/tag_16x16.png similarity index 100% rename from src/com/gitblit/wicket/resources/tag_16x16.png rename to resources/tag_16x16.png diff --git a/src/com/gitblit/wicket/resources/user_16x16.png b/resources/user_16x16.png similarity index 100% rename from src/com/gitblit/wicket/resources/user_16x16.png rename to resources/user_16x16.png diff --git a/src/com/gitblit/wicket/resources/welcome.mkd b/resources/welcome.mkd similarity index 100% rename from src/com/gitblit/wicket/resources/welcome.mkd rename to resources/welcome.mkd diff --git a/src/WEB-INF/web.xml b/src/WEB-INF/web.xml new file mode 100644 index 00000000..d5d3288f --- /dev/null +++ b/src/WEB-INF/web.xml @@ -0,0 +1,125 @@ + + + + + + + + + + + + + + SyndicationServlet + com.gitblit.SyndicationServlet + + + SyndicationServlet + /feed/* + + + + + + ZipServlet + com.gitblit.DownloadZipServlet + + + ZipServlet + /zip/* + + + + + + GitFilter + com.gitblit.GitFilter + + + GitFilter + /git/* + + + + + + SyndicationFilter + com.gitblit.SyndicationFilter + + + SyndicationFilter + /feed/* + + + + + + wicketFilter + + org.apache.wicket.protocol.http.WicketFilter + + + applicationClassName + com.gitblit.wicket.GitBlitWebApp + + + ignorePaths + + git/,feed/,zip/ + + + + wicketFilter + /* + + \ No newline at end of file diff --git a/src/com/gitblit/AccessRestrictionFilter.java b/src/com/gitblit/AccessRestrictionFilter.java index 3aca1039..625eaa99 100644 --- a/src/com/gitblit/AccessRestrictionFilter.java +++ b/src/com/gitblit/AccessRestrictionFilter.java @@ -16,6 +16,7 @@ package com.gitblit; import java.io.IOException; +import java.nio.charset.Charset; import java.security.Principal; import java.text.MessageFormat; import java.util.Enumeration; @@ -32,6 +33,7 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; +import org.eclipse.jgit.util.Base64; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -114,7 +116,8 @@ public abstract class AccessRestrictionFilter implements Filter { if (authorization != null && authorization.startsWith(BASIC)) { // Authorization: Basic base64credentials String base64Credentials = authorization.substring(BASIC.length()).trim(); - String credentials = StringUtils.decodeBase64(base64Credentials); + String credentials = new String(Base64.decode(base64Credentials), + Charset.forName("UTF-8")); if (GitBlit.isDebugMode()) { logger.info(MessageFormat.format("AUTH: {0} ({1})", authorization, credentials)); } @@ -131,7 +134,8 @@ public abstract class AccessRestrictionFilter implements Filter { // authenticated request permitted. // pass processing to the restricted servlet. newSession(accessRequest, httpResponse); - logger.info("ARF: " + fullUrl + " (" + HttpServletResponse.SC_CONTINUE + ") authenticated"); + logger.info("ARF: " + fullUrl + " (" + HttpServletResponse.SC_CONTINUE + + ") authenticated"); chain.doFilter(accessRequest, httpResponse); return; } @@ -163,7 +167,8 @@ public abstract class AccessRestrictionFilter implements Filter { } if (GitBlit.isDebugMode()) { - logger.info("ARF: " + fullUrl + " (" + HttpServletResponse.SC_CONTINUE + ") unauthenticated"); + logger.info("ARF: " + fullUrl + " (" + HttpServletResponse.SC_CONTINUE + + ") unauthenticated"); } // unauthenticated request permitted. // pass processing to the restricted servlet. @@ -202,19 +207,19 @@ public abstract class AccessRestrictionFilter implements Filter { @Override public void destroy() { } - + /** * Wraps a standard HttpServletRequest and overrides user principal methods. */ public static class AccessRestrictionRequest extends ServletRequestWrapper { private UserModel user; - + public AccessRestrictionRequest(HttpServletRequest req) { super(req); user = new UserModel("anonymous"); } - + void setUser(UserModel user) { this.user = user; } diff --git a/src/com/gitblit/Build.java b/src/com/gitblit/Build.java index 30c4aa00..90224f08 100644 --- a/src/com/gitblit/Build.java +++ b/src/com/gitblit/Build.java @@ -312,10 +312,10 @@ public class Build { "c7adc475ca40c288c93054e0f4fe58f3a98c0cb5"); public static final MavenObject JETTY = new MavenObject("Jetty", - "org/eclipse/jetty/aggregate", "jetty-all", "7.4.1.v20110513", 1500000, 1000000, - 4100000, "1e2de9ed25a7c6ae38717d5ffdc7cfcd6be4bd46", - "7b6279d16ce8f663537d9faf55ea353e748dbbaa", - "fa06212e751296f1a7abc15c843b135bf49a112b"); + "org/eclipse/jetty/aggregate", "jetty-webapp", "7.4.2.v20110526", 1000000, 680000, + 2720000, "56331143afa22d24d9faba96e86e6371b0686c7c", + "9f38230fd589e29c8be0fc3c80fb51c5093c2e1e", + "0d48212889c25252c5c14bef62703e28215d80cc"); public static final MavenObject SERVLET = new MavenObject("Servlet 2.5", "javax/servlet", "servlet-api", "2.5", 105000, 158000, 0, @@ -363,8 +363,8 @@ public class Build { "3d32d958b2f7aa58388af5701ea3aafc433e573f", "c37518b67ea85af485dd61fe854137eeacc50318"); - public static final MavenObject JUNIT = new MavenObject("JUnit", "junit", "junit", "3.8.2", - 120000, 0, 0, "07e4cde26b53a9a0e3fe5b00d1dbbc7cc1d46060", "", ""); + public static final MavenObject JUNIT = new MavenObject("JUnit", "junit", "junit", "4.8.2", + 237000, 0, 0, "c94f54227b08100974c36170dcb53329435fe5ad", "", ""); public static final MavenObject MARKDOWNPAPERS = new MavenObject("MarkdownPapers", "org/tautua/markdownpapers", "markdownpapers-core", "1.0.0", 87000, 58000, 278000, diff --git a/src/com/gitblit/BuildWebXml.java b/src/com/gitblit/BuildWebXml.java new file mode 100644 index 00000000..3b687f6d --- /dev/null +++ b/src/com/gitblit/BuildWebXml.java @@ -0,0 +1,80 @@ +/* + * Copyright 2011 gitblit.com. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.gitblit; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.FileReader; +import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; +import java.util.Properties; + +public class BuildWebXml { + private static final String PARAMS = ""; + + private static final String [] STRIP_TOKENS = { "" }; + + private static final String PARAM_PATTERN = "\n\t\n\t\t{0}\n\t\t{1}\n\t\n"; + + public static void main(String[] args) throws Exception { + // Read the current Gitblit properties + // TODO extract the comments and inject them into web.xml too + FileInputStream fis = new FileInputStream(new File("distrib/gitblit.properties")); + Properties fileSettings = new Properties(); + fileSettings.load(fis); + fis.close(); + List keys = new ArrayList(fileSettings.stringPropertyNames()); + Collections.sort(keys); + + StringBuilder parameters = new StringBuilder(); + for (String key : keys) { + if (!skipKey(key)) { + String value = fileSettings.getProperty(key); + parameters.append(MessageFormat.format(PARAM_PATTERN, key, value)); + } + } + + // Read the prototype web.xml file + File webxml = new File("src/WEB-INF/web.xml"); + char [] buffer = new char[(int) webxml.length()]; + FileReader reader = new FileReader(webxml); + reader.read(buffer); + reader.close(); + String webXmlContent = new String(buffer); + + // Insert the Gitblit properties into the prototype web.xml + for (String stripToken:STRIP_TOKENS) { + webXmlContent = webXmlContent.replace(stripToken, ""); + } + int idx = webXmlContent.indexOf(PARAMS); + StringBuilder sb = new StringBuilder(); + sb.append(webXmlContent.substring(0, idx)); + sb.append(parameters.toString()); + sb.append(webXmlContent.substring(idx + PARAMS.length())); + + // Save the merged web.xml to the war build folder + FileOutputStream os = new FileOutputStream(new File("war/WEB-INF/web.xml"), false); + os.write(sb.toString().getBytes()); + os.close(); + } + + private static boolean skipKey(String key) { + return key.startsWith(Keys.server._ROOT); + } +} diff --git a/src/com/gitblit/Constants.java b/src/com/gitblit/Constants.java index 68e7b67e..b874a7b0 100644 --- a/src/com/gitblit/Constants.java +++ b/src/com/gitblit/Constants.java @@ -33,14 +33,12 @@ public class Constants { public static final String PROPERTIES_FILE = "gitblit.properties"; - public static final String GIT_SERVLET_PATH = "/git/"; + public static final String GIT_PATH = "/git/"; - public static final String ZIP_SERVLET_PATH = "/zip/"; + public static final String ZIP_PATH = "/zip/"; - public static final String SYNDICATION_SERVLET_PATH = "/feed/"; + public static final String SYNDICATION_PATH = "/feed/"; - public static final String RESOURCE_PATH = "/com/gitblit/wicket/resources/"; - public static final String BORDER = "***********************************************************"; public static enum AccessRestrictionType { diff --git a/src/com/gitblit/DownloadZipServlet.java b/src/com/gitblit/DownloadZipServlet.java index 3b02cbac..d36b94d2 100644 --- a/src/com/gitblit/DownloadZipServlet.java +++ b/src/com/gitblit/DownloadZipServlet.java @@ -44,7 +44,7 @@ public class DownloadZipServlet extends HttpServlet { if (baseURL.length() > 0 && baseURL.charAt(baseURL.length() - 1) == '/') { baseURL = baseURL.substring(0, baseURL.length() - 1); } - return baseURL + Constants.ZIP_SERVLET_PATH + "?r=" + repository + return baseURL + Constants.ZIP_PATH + "?r=" + repository + (path == null ? "" : ("&p=" + path)) + (objectId == null ? "" : ("&h=" + objectId)); } diff --git a/src/com/gitblit/FileLoginService.java b/src/com/gitblit/FileLoginService.java index b59a7763..e239efc4 100644 --- a/src/com/gitblit/FileLoginService.java +++ b/src/com/gitblit/FileLoginService.java @@ -53,8 +53,7 @@ public class FileLoginService extends FileSettings implements ILoginService { if (user.password.equalsIgnoreCase(md5)) { returnedUser = user; } - } - if (user.password.equals(new String(password))) { + } else if (user.password.equals(new String(password))) { returnedUser = user; } return returnedUser; diff --git a/src/com/gitblit/GitBlit.java b/src/com/gitblit/GitBlit.java index fa593f92..1fa8b60f 100644 --- a/src/com/gitblit/GitBlit.java +++ b/src/com/gitblit/GitBlit.java @@ -45,7 +45,7 @@ import com.gitblit.utils.StringUtils; public class GitBlit implements ServletContextListener { - private static final GitBlit GITBLIT; + private static GitBlit gitblit; private final Logger logger = LoggerFactory.getLogger(GitBlit.class); @@ -53,45 +53,48 @@ public class GitBlit implements ServletContextListener { private File repositoriesFolder; - private boolean exportAll; + private boolean exportAll = true; private ILoginService loginService; private IStoredSettings storedSettings; - static { - GITBLIT = new GitBlit(); - } - - private GitBlit() { + public GitBlit() { + if (gitblit == null) { + // Singleton reference when running in standard servlet container + gitblit = this; + } } public static GitBlit self() { - return GITBLIT; + if (gitblit == null) { + gitblit = new GitBlit(); + } + return gitblit; } public static boolean getBoolean(String key, boolean defaultValue) { - return GITBLIT.storedSettings.getBoolean(key, defaultValue); + return self().storedSettings.getBoolean(key, defaultValue); } public static int getInteger(String key, int defaultValue) { - return GITBLIT.storedSettings.getInteger(key, defaultValue); + return self().storedSettings.getInteger(key, defaultValue); } public static String getString(String key, String defaultValue) { - return GITBLIT.storedSettings.getString(key, defaultValue); + return self().storedSettings.getString(key, defaultValue); } public static List getStrings(String key) { - return GITBLIT.storedSettings.getStrings(key); + return self().storedSettings.getStrings(key); } public static List getAllKeys(String startingWith) { - return GITBLIT.storedSettings.getAllKeys(startingWith); + return self().storedSettings.getAllKeys(startingWith); } public static boolean isDebugMode() { - return GITBLIT.storedSettings.getBoolean(Keys.web.debugMode, false); + return self().storedSettings.getBoolean(Keys.web.debugMode, false); } public List getOtherCloneUrls(String repositoryName) { @@ -103,6 +106,7 @@ public class GitBlit implements ServletContextListener { } public void setLoginService(ILoginService loginService) { + logger.info("Setting up login service " + loginService.toString()); this.loginService = loginService; } @@ -353,9 +357,32 @@ public class GitBlit implements ServletContextListener { public void configureContext(IStoredSettings settings) { logger.info("Reading configuration from " + settings.toString()); this.storedSettings = settings; - repositoriesFolder = new File(settings.getString(Keys.git.repositoriesFolder, "repos")); - exportAll = settings.getBoolean(Keys.git.exportAll, true); + repositoriesFolder = new File(settings.getString(Keys.git.repositoriesFolder, "git")); + logger.info("Git repositories folder " + repositoriesFolder.getAbsolutePath()); repositoryResolver = new FileResolver(repositoriesFolder, exportAll); + String realm = settings.getString(Keys.realm.realmFile, "users.properties"); + ILoginService loginService = null; + try { + // Check to see if this "file" is a login service class + Class realmClass = Class.forName(realm); + if (ILoginService.class.isAssignableFrom(realmClass)) { + loginService = (ILoginService) realmClass.newInstance(); + } + } catch (Throwable t) { + // Not a login service class OR other issue + // Use default file login service + File realmFile = new File(realm); + if (!realmFile.exists()) { + try { + realmFile.createNewFile(); + } catch (IOException x) { + logger.error( + MessageFormat.format("COULD NOT CREATE REALM FILE {0}!", realmFile), x); + } + } + loginService = new FileLoginService(realmFile); + } + setLoginService(loginService); } @Override diff --git a/src/com/gitblit/GitBlitServer.java b/src/com/gitblit/GitBlitServer.java index 4b6df709..3687e4db 100644 --- a/src/com/gitblit/GitBlitServer.java +++ b/src/com/gitblit/GitBlitServer.java @@ -30,10 +30,6 @@ import java.text.MessageFormat; import java.util.ArrayList; import java.util.List; -import org.apache.log4j.ConsoleAppender; -import org.apache.log4j.PatternLayout; -import org.apache.wicket.protocol.http.ContextParamWebApplicationFactory; -import org.apache.wicket.protocol.http.WicketFilter; import org.eclipse.jetty.server.Connector; import org.eclipse.jetty.server.Server; import org.eclipse.jetty.server.bio.SocketConnector; @@ -42,7 +38,6 @@ import org.eclipse.jetty.server.session.HashSessionManager; import org.eclipse.jetty.server.ssl.SslConnector; import org.eclipse.jetty.server.ssl.SslSelectChannelConnector; import org.eclipse.jetty.server.ssl.SslSocketConnector; -import org.eclipse.jetty.servlet.FilterHolder; import org.eclipse.jetty.servlet.FilterMapping; import org.eclipse.jetty.servlet.ServletHolder; import org.eclipse.jetty.util.thread.QueuedThreadPool; @@ -56,7 +51,6 @@ import com.beust.jcommander.Parameter; import com.beust.jcommander.ParameterException; import com.beust.jcommander.Parameters; import com.gitblit.utils.StringUtils; -import com.gitblit.wicket.GitBlitWebApp; public class GitBlitServer { @@ -121,26 +115,6 @@ public class GitBlitServer { */ private static void start(Params params) { FileSettings settings = params.FILESETTINGS; - String pattern = settings.getString(Keys.server.log4jPattern, - "%-5p %d{MM-dd HH:mm:ss.SSS} %-20.20c{1} %m%n"); - - // allow os override of logging pattern - String os = System.getProperty("os.name").toLowerCase(); - if (os.indexOf("windows") > -1) { - String winPattern = settings.getString(Keys.server.log4jPattern_windows, pattern); - if (!StringUtils.isEmpty(winPattern)) { - pattern = winPattern; - } - } else if (os.indexOf("linux") > -1) { - String linuxPattern = settings.getString(Keys.server.log4jPattern_linux, pattern); - if (!StringUtils.isEmpty(linuxPattern)) { - pattern = linuxPattern; - } - } - - PatternLayout layout = new PatternLayout(pattern); - org.apache.log4j.Logger rootLogger = org.apache.log4j.Logger.getRootLogger(); - rootLogger.addAppender(new ConsoleAppender(layout)); logger = LoggerFactory.getLogger(GitBlitServer.class); logger.info(Constants.BORDER); @@ -223,55 +197,23 @@ public class GitBlitServer { sessionManager.setSecureCookies(params.port <= 0 && params.securePort > 0); rootContext.getSessionHandler().setSessionManager(sessionManager); - // Wicket Filter - String wicketPathSpec = "/*"; - FilterHolder wicketFilter = new FilterHolder(WicketFilter.class); - wicketFilter.setInitParameter(ContextParamWebApplicationFactory.APP_CLASS_PARAM, - GitBlitWebApp.class.getName()); - wicketFilter.setInitParameter(WicketFilter.FILTER_MAPPING_PARAM, wicketPathSpec); - wicketFilter.setInitParameter(WicketFilter.IGNORE_PATHS_PARAM, "git/,feed/,zip/"); - rootContext.addFilter(wicketFilter, wicketPathSpec, FilterMapping.DEFAULT); - // JGit Filter and Servlet - if (settings.getBoolean(Keys.git.enableGitServlet, true)) { - String jgitPathSpec = Constants.GIT_SERVLET_PATH + "*"; - rootContext.addFilter(GitFilter.class, jgitPathSpec, FilterMapping.DEFAULT); - ServletHolder jGitServlet = rootContext.addServlet(GitServlet.class, jgitPathSpec); - jGitServlet.setInitParameter("base-path", params.repositoriesFolder); - jGitServlet.setInitParameter("export-all", - settings.getBoolean(Keys.git.exportAll, true) ? "1" : "0"); - } + String jgitPathSpec = Constants.GIT_PATH + "*"; + rootContext.addFilter(GitFilter.class, jgitPathSpec, FilterMapping.DEFAULT); + ServletHolder jGitServlet = rootContext.addServlet(GitServlet.class, jgitPathSpec); + jGitServlet.setInitParameter("base-path", params.repositoriesFolder); + jGitServlet.setInitParameter("export-all", "1"); - // Syndication Filter and Servlet - String feedPathSpec = Constants.SYNDICATION_SERVLET_PATH + "*"; - rootContext.addFilter(SyndicationFilter.class, feedPathSpec, FilterMapping.DEFAULT); - rootContext.addServlet(SyndicationServlet.class, feedPathSpec); - - // Zip Servlet - rootContext.addServlet(DownloadZipServlet.class, Constants.ZIP_SERVLET_PATH + "*"); - - // Login Service + // Ensure there is a defined Login Service String realmUsers = params.realmFile; if (StringUtils.isEmpty(realmUsers)) { logger.error(MessageFormat.format("PLEASE SPECIFY {0}!!", Keys.realm.realmFile)); return; } - File realmFile = new File(realmUsers); - if (!realmFile.exists()) { - try { - realmFile.createNewFile(); - } catch (IOException x) { - logger.error(MessageFormat.format("COULD NOT CREATE REALM FILE {0}!", realmUsers), - x); - return; - } - } - logger.info("Setting up login service from " + realmUsers); - FileLoginService loginService = new FileLoginService(realmFile); - GitBlit.self().setLoginService(loginService); - - logger.info("Git repositories folder " - + new File(params.repositoriesFolder).getAbsolutePath()); + + // Update settings +// settings.put(Keys.realm.realmFile, params.realmFile); +// settings.put(Keys.git.repositoriesFolder, params.repositoriesFolder); // Set the server's contexts server.setHandler(rootContext); diff --git a/src/com/gitblit/GitFilter.java b/src/com/gitblit/GitFilter.java index 5bd7b330..b3104426 100644 --- a/src/com/gitblit/GitFilter.java +++ b/src/com/gitblit/GitFilter.java @@ -65,6 +65,10 @@ public class GitFilter extends AccessRestrictionFilter { @Override protected boolean canAccess(RepositoryModel repository, UserModel user, String urlRequestType) { + if (!GitBlit.getBoolean(Keys.git.enableGitServlet, true)) { + // Git Servlet disabled + return false; + } if (repository.isFrozen || repository.accessRestriction.atLeast(AccessRestrictionType.PUSH)) { boolean authorizedUser = user.canAccessRepository(repository.name); if (urlRequestType.equals(gitReceivePack)) { diff --git a/src/com/gitblit/ILoginService.java b/src/com/gitblit/ILoginService.java index d7bfd017..0e706cf3 100644 --- a/src/com/gitblit/ILoginService.java +++ b/src/com/gitblit/ILoginService.java @@ -42,4 +42,6 @@ public interface ILoginService { boolean renameRole(String oldRole, String newRole); boolean deleteRole(String role); + + String toString(); } diff --git a/src/com/gitblit/IStoredSettings.java b/src/com/gitblit/IStoredSettings.java index 7108c068..403a0676 100644 --- a/src/com/gitblit/IStoredSettings.java +++ b/src/com/gitblit/IStoredSettings.java @@ -27,21 +27,25 @@ import com.gitblit.utils.StringUtils; public abstract class IStoredSettings { protected final Logger logger; - + public IStoredSettings(Class clazz) { logger = LoggerFactory.getLogger(clazz); } - + protected abstract Properties read(); public List getAllKeys(String startingWith) { - startingWith = startingWith.toLowerCase(); List keys = new ArrayList(); Properties props = read(); - for (Object o : props.keySet()) { - String key = o.toString(); - if (key.toLowerCase().startsWith(startingWith)) { - keys.add(key); + if (StringUtils.isEmpty(startingWith)) { + keys.addAll(props.stringPropertyNames()); + } else { + startingWith = startingWith.toLowerCase(); + for (Object o : props.keySet()) { + String key = o.toString(); + if (key.toLowerCase().startsWith(startingWith)) { + keys.add(key); + } } } return keys; diff --git a/src/com/gitblit/SyndicationServlet.java b/src/com/gitblit/SyndicationServlet.java index 19865fe5..66dc467a 100644 --- a/src/com/gitblit/SyndicationServlet.java +++ b/src/com/gitblit/SyndicationServlet.java @@ -43,7 +43,7 @@ public class SyndicationServlet extends HttpServlet { } StringBuilder url = new StringBuilder(); url.append(baseURL); - url.append(Constants.SYNDICATION_SERVLET_PATH); + url.append(Constants.SYNDICATION_PATH); url.append(repository); if (!StringUtils.isEmpty(objectId) || length > 0) { StringBuilder parameters = new StringBuilder("?"); diff --git a/src/com/gitblit/utils/JGitUtils.java b/src/com/gitblit/utils/JGitUtils.java index e8bb3bf2..5656efb3 100644 --- a/src/com/gitblit/utils/JGitUtils.java +++ b/src/com/gitblit/utils/JGitUtils.java @@ -402,36 +402,30 @@ public class JGitUtils { public static List getFilesInCommit(Repository r, RevCommit commit) { List list = new ArrayList(); - RevWalk rw = new RevWalk(r); - TreeWalk tw = new TreeWalk(r); + RevWalk rw = new RevWalk(r); try { if (commit == null) { ObjectId object = r.resolve(Constants.HEAD); commit = rw.parseCommit(object); - } - RevTree commitTree = commit.getTree(); + } - tw.reset(); - tw.setRecursive(true); if (commit.getParentCount() == 0) { - tw.addTree(commitTree); + TreeWalk tw = new TreeWalk(r); + tw.reset(); + tw.setRecursive(true); + tw.addTree(commit.getTree()); while (tw.next()) { list.add(new PathChangeModel(tw.getPathString(), tw.getPathString(), 0, tw .getRawMode(0), commit.getId().getName(), ChangeType.ADD)); } + tw.release(); } else { RevCommit parent = rw.parseCommit(commit.getParent(0).getId()); - RevTree parentTree = parent.getTree(); - tw.addTree(parentTree); - tw.addTree(commitTree); - tw.setFilter(TreeFilter.ANY_DIFF); - - RawTextComparator cmp = RawTextComparator.DEFAULT; DiffFormatter df = new DiffFormatter(DisabledOutputStream.INSTANCE); df.setRepository(r); - df.setDiffComparator(cmp); + df.setDiffComparator(RawTextComparator.DEFAULT); df.setDetectRenames(true); - List diffs = df.scan(parentTree, commitTree); + List diffs = df.scan(parent.getTree(), commit.getTree()); for (DiffEntry diff : diffs) { if (diff.getChangeType().equals(ChangeType.DELETE)) { list.add(new PathChangeModel(diff.getOldPath(), diff.getOldPath(), 0, diff @@ -447,8 +441,7 @@ public class JGitUtils { } catch (Throwable t) { LOGGER.error("failed to determine files in commit!", t); } finally { - rw.dispose(); - tw.release(); + rw.dispose(); } return list; } diff --git a/src/com/gitblit/utils/StringUtils.java b/src/com/gitblit/utils/StringUtils.java index 363efc9c..b53b5e15 100644 --- a/src/com/gitblit/utils/StringUtils.java +++ b/src/com/gitblit/utils/StringUtils.java @@ -16,16 +16,12 @@ package com.gitblit.utils; import java.io.UnsupportedEncodingException; -import java.nio.charset.Charset; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; import java.util.ArrayList; import java.util.List; import java.util.regex.PatternSyntaxException; -import org.eclipse.jetty.util.log.Log; -import org.eclipse.jgit.util.Base64; - public class StringUtils { public static final String MD5_TYPE = "MD5:"; @@ -152,9 +148,10 @@ public class StringUtils { md.update(string.getBytes("iso-8859-1")); byte[] digest = md.digest(); return toHex(digest); - } catch (Exception e) { - Log.warn(e); - return null; + } catch (UnsupportedEncodingException u) { + throw new RuntimeException(u); + } catch (NoSuchAlgorithmException t) { + throw new RuntimeException(t); } } @@ -168,11 +165,7 @@ public class StringUtils { } return sb.toString(); } - - public static String decodeBase64(String base64) { - return new String(Base64.decode(base64), Charset.forName("UTF-8")); - } - + public static String getRootPath(String path) { if (path.indexOf('/') > -1) { return path.substring(0, path.lastIndexOf('/')); diff --git a/src/com/gitblit/utils/SyndicationUtils.java b/src/com/gitblit/utils/SyndicationUtils.java index 5763af3f..80a1b288 100644 --- a/src/com/gitblit/utils/SyndicationUtils.java +++ b/src/com/gitblit/utils/SyndicationUtils.java @@ -48,7 +48,7 @@ public class SyndicationUtils { feed.setDescription(description); SyndImageImpl image = new SyndImageImpl(); image.setTitle(Constants.NAME); - image.setUrl(hostUrl + Constants.RESOURCE_PATH + "gitblt_25.png"); + image.setUrl(hostUrl + "/gitblt_25.png"); image.setLink(hostUrl); feed.setImage(image); diff --git a/src/com/gitblit/wicket/GitBlitWebApp.properties b/src/com/gitblit/wicket/GitBlitWebApp.properties index 50a4ef42..2ed61fa6 100644 --- a/src/com/gitblit/wicket/GitBlitWebApp.properties +++ b/src/com/gitblit/wicket/GitBlitWebApp.properties @@ -66,7 +66,7 @@ gb.filesRenamed = {0} files renamed gb.missingUsername = Missing Username gb.edit = edit gb.searchTypeTooltip = Select Search Type -gb.searchTooltip = Search Git:Blit +gb.searchTooltip = Search Gitblit gb.delete = delete gb.docs = docs gb.accessRestriction = access restriction @@ -86,7 +86,7 @@ gb.viewRestricted = authenticated view, clone, & push gb.useTicketsDescription = distributed Ticgit issues gb.useDocsDescription = enumerates Markdown documentation in repository gb.showRemoteBranchesDescription = show remote branches -gb.canAdminDescription = can administer Git:Blit server +gb.canAdminDescription = can administer Gitblit server gb.permittedUsers = permitted users gb.isFrozen = is frozen gb.isFrozenDescription = deny push operations diff --git a/src/com/gitblit/wicket/WicketUtils.java b/src/com/gitblit/wicket/WicketUtils.java index 54f9648c..1897acac 100644 --- a/src/com/gitblit/wicket/WicketUtils.java +++ b/src/com/gitblit/wicket/WicketUtils.java @@ -169,7 +169,7 @@ public class WicketUtils { } public static ContextImage newImage(String wicketId, String file, String tooltip) { - ContextImage img = new ContextImage(wicketId, com.gitblit.Constants.RESOURCE_PATH + file); + ContextImage img = new ContextImage(wicketId, file); if (!StringUtils.isEmpty(tooltip)) { setHtmlTooltip(img, tooltip); } @@ -177,7 +177,7 @@ public class WicketUtils { } public static ContextRelativeResource getResource(String file) { - return new ContextRelativeResource(com.gitblit.Constants.RESOURCE_PATH + file); + return new ContextRelativeResource(file); } public static String getHostURL(Request request) { diff --git a/src/com/gitblit/wicket/pages/BasePage.html b/src/com/gitblit/wicket/pages/BasePage.html index 0da37d40..cc19fbcc 100644 --- a/src/com/gitblit/wicket/pages/BasePage.html +++ b/src/com/gitblit/wicket/pages/BasePage.html @@ -4,25 +4,21 @@ xml:lang="en" lang="en"> - + [page title] - - - - + + diff --git a/src/com/gitblit/wicket/pages/BasePage.java b/src/com/gitblit/wicket/pages/BasePage.java index 9031befd..5a0eb90f 100644 --- a/src/com/gitblit/wicket/pages/BasePage.java +++ b/src/com/gitblit/wicket/pages/BasePage.java @@ -63,7 +63,7 @@ public abstract class BasePage extends WebPage { if (siteName == null || siteName.trim().length() == 0) { siteName = Constants.NAME; } - add(new Label("siteName", siteName)); + add(new LinkPanel("siteName", null, siteName, RepositoriesPage.class, null)); add(new LinkPanel("repositoryName", null, repositoryName, SummaryPage.class, WicketUtils.newRepositoryParameter(repositoryName))); add(new Label("pageName", pageName)); @@ -122,6 +122,10 @@ public abstract class BasePage extends WebPage { HttpServletRequest req = servletWebRequest.getHttpServletRequest(); return req.getServerName(); } + + public void warn(String message, Throwable t) { + logger.warn(message, t); + } public void error(String message, boolean redirect) { logger.error(message); diff --git a/src/com/gitblit/wicket/pages/DocsPage.java b/src/com/gitblit/wicket/pages/DocsPage.java index 7f41b71b..2f899bbe 100644 --- a/src/com/gitblit/wicket/pages/DocsPage.java +++ b/src/com/gitblit/wicket/pages/DocsPage.java @@ -64,7 +64,8 @@ public class DocsPage extends RepositoryPage { .newPathParameter(repositoryName, entry.commitId, entry.path))); item.add(new BookmarkablePageLink("raw", RawPage.class, WicketUtils .newPathParameter(repositoryName, entry.commitId, entry.path))); - item.add(new BookmarkablePageLink("blame", BlobPage.class).setEnabled(false)); + item.add(new BookmarkablePageLink("blame", BlamePage.class, + WicketUtils.newPathParameter(repositoryName, entry.commitId, entry.path))); item.add(new BookmarkablePageLink("history", HistoryPage.class, WicketUtils .newPathParameter(repositoryName, entry.commitId, entry.path))); WicketUtils.setAlternatingBackground(item, counter); diff --git a/src/com/gitblit/wicket/pages/LoginPage.html b/src/com/gitblit/wicket/pages/LoginPage.html index 280453d5..5f9b779f 100644 --- a/src/com/gitblit/wicket/pages/LoginPage.html +++ b/src/com/gitblit/wicket/pages/LoginPage.html @@ -7,18 +7,14 @@ [page title] - - - - + +
- - Git:Blit
-
+ Gitblit
[name]
diff --git a/src/com/gitblit/wicket/pages/MarkdownPage.html b/src/com/gitblit/wicket/pages/MarkdownPage.html index a0f60904..1293f786 100644 --- a/src/com/gitblit/wicket/pages/MarkdownPage.html +++ b/src/com/gitblit/wicket/pages/MarkdownPage.html @@ -6,16 +6,14 @@ - - - + diff --git a/src/com/gitblit/wicket/pages/MarkdownPage.java b/src/com/gitblit/wicket/pages/MarkdownPage.java index 9202fb88..aaf12bad 100644 --- a/src/com/gitblit/wicket/pages/MarkdownPage.java +++ b/src/com/gitblit/wicket/pages/MarkdownPage.java @@ -39,7 +39,8 @@ public class MarkdownPage extends RepositoryPage { RevCommit commit = JGitUtils.getCommit(r, objectId); // markdown page links - add(new Label("blameLink", getString("gb.blame"))); + add(new BookmarkablePageLink("blameLink", BlamePage.class, + WicketUtils.newPathParameter(repositoryName, objectId, markdownPath))); add(new BookmarkablePageLink("historyLink", HistoryPage.class, WicketUtils.newPathParameter(repositoryName, objectId, markdownPath))); add(new BookmarkablePageLink("rawLink", RawPage.class, WicketUtils.newPathParameter( diff --git a/src/com/gitblit/wicket/pages/RepositoriesPage.html b/src/com/gitblit/wicket/pages/RepositoriesPage.html index da91cb2e..c8ab5978 100644 --- a/src/com/gitblit/wicket/pages/RepositoriesPage.html +++ b/src/com/gitblit/wicket/pages/RepositoriesPage.html @@ -4,9 +4,7 @@ xml:lang="en" lang="en"> - - - + diff --git a/src/com/gitblit/wicket/pages/RepositoriesPage.java b/src/com/gitblit/wicket/pages/RepositoriesPage.java index b0e5e579..f97adff5 100644 --- a/src/com/gitblit/wicket/pages/RepositoriesPage.java +++ b/src/com/gitblit/wicket/pages/RepositoriesPage.java @@ -86,7 +86,7 @@ public class RepositoriesPage extends BasePage { message = MarkdownUtils.transformMarkdown(reader); } catch (Throwable t) { message = "Failed to read " + file; - error(message, t, false); + warn(message, t); } } else { message = messageSource + " is not a valid file."; diff --git a/src/com/gitblit/wicket/pages/RepositoryPage.html b/src/com/gitblit/wicket/pages/RepositoryPage.html index cff7d068..e793a1e9 100644 --- a/src/com/gitblit/wicket/pages/RepositoryPage.html +++ b/src/com/gitblit/wicket/pages/RepositoryPage.html @@ -19,7 +19,7 @@ diff --git a/src/com/gitblit/wicket/pages/RepositoryPage.java b/src/com/gitblit/wicket/pages/RepositoryPage.java index cf14ee19..00ed7554 100644 --- a/src/com/gitblit/wicket/pages/RepositoryPage.java +++ b/src/com/gitblit/wicket/pages/RepositoryPage.java @@ -40,8 +40,6 @@ import org.eclipse.jgit.diff.DiffEntry.ChangeType; import org.eclipse.jgit.lib.PersonIdent; import org.eclipse.jgit.lib.Repository; import org.eclipse.jgit.revwalk.RevCommit; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; import com.gitblit.GitBlit; import com.gitblit.Keys; @@ -65,20 +63,19 @@ public abstract class RepositoryPage extends BasePage { private RepositoryModel m; - private final Logger logger = LoggerFactory.getLogger(RepositoryPage.class); - - private final Map knownPages = new HashMap() { + private final Map registeredPages = new HashMap() { private static final long serialVersionUID = 1L; { - put("summary", "gb.summary"); - put("log", "gb.log"); - put("branches", "gb.branches"); - put("tags", "gb.tags"); - put("tree", "gb.tree"); - put("tickets", "gb.tickets"); - put("edit", "gb.edit"); + put("summary", new PageRegistration("gb.summary", SummaryPage.class)); + put("log", new PageRegistration("gb.log", LogPage.class)); + put("branches", new PageRegistration("gb.branches", BranchesPage.class)); + put("tags", new PageRegistration("gb.tags", TagsPage.class)); + put("tree", new PageRegistration("gb.tree", TreePage.class)); + put("tickets", new PageRegistration("gb.tickets", TicketsPage.class)); + put("edit", new PageRegistration("gb.edit", EditRepositoryPage.class)); + put("docs", new PageRegistration("gb.docs", DocsPage.class)); } }; @@ -95,26 +92,17 @@ public abstract class RepositoryPage extends BasePage { RepositoryModel model = getRepositoryModel(); // standard page links - add(new BookmarkablePageLink("summary", SummaryPage.class, - WicketUtils.newRepositoryParameter(repositoryName))); - add(new BookmarkablePageLink("log", LogPage.class, - WicketUtils.newRepositoryParameter(repositoryName))); - add(new BookmarkablePageLink("branches", BranchesPage.class, - WicketUtils.newRepositoryParameter(repositoryName))); - add(new BookmarkablePageLink("tags", TagsPage.class, - WicketUtils.newRepositoryParameter(repositoryName))); - add(new BookmarkablePageLink("tree", TreePage.class, - WicketUtils.newRepositoryParameter(repositoryName))); + addRegisteredPageLink("summary"); + addRegisteredPageLink("log"); + addRegisteredPageLink("branches"); + addRegisteredPageLink("tags"); + addRegisteredPageLink("tree"); // per-repository extra page links List extraPageLinks = new ArrayList(); - - // Conditionally add tickets link if (model.useTickets && TicgitUtils.getTicketsBranch(r) != null) { extraPageLinks.add("tickets"); } - - // Conditionally add docs link if (model.useDocs) { extraPageLinks.add("docs"); } @@ -135,26 +123,19 @@ public abstract class RepositoryPage extends BasePage { extraPageLinks.add("edit"); } + final String pageName = getPageName(); + final String pageWicketId = getLinkWicketId(pageName); ListDataProvider extrasDp = new ListDataProvider(extraPageLinks); DataView extrasView = new DataView("extra", extrasDp) { private static final long serialVersionUID = 1L; public void populateItem(final Item item) { String extra = item.getModelObject(); - if (extra.equals("tickets")) { - item.add(new Label("extraSeparator", " | ")); - item.add(new LinkPanel("extraLink", null, getString("gb.tickets"), - TicketsPage.class, WicketUtils.newRepositoryParameter(repositoryName))); - } else if (extra.equals("docs")) { - item.add(new Label("extraSeparator", " | ")); - item.add(new LinkPanel("extraLink", null, getString("gb.docs"), DocsPage.class, - WicketUtils.newRepositoryParameter(repositoryName))); - } else if (extra.equals("edit")) { - item.add(new Label("extraSeparator", " | ")); - item.add(new LinkPanel("extraLink", null, getString("gb.edit"), - EditRepositoryPage.class, WicketUtils - .newRepositoryParameter(repositoryName))); - } + PageRegistration pageReg = registeredPages.get(extra); + item.add(new Label("extraSeparator", " | ")); + item.add(new LinkPanel("extraLink", null, getString(pageReg.translationKey), + pageReg.pageClass, WicketUtils.newRepositoryParameter(repositoryName)) + .setEnabled(!extra.equals(pageWicketId))); } }; add(extrasView); @@ -163,7 +144,7 @@ public abstract class RepositoryPage extends BasePage { .getRelativePathPrefixToContextRoot(), repositoryName, null, 0))); // disable current page - disablePageLink(getPageName()); + disableRegisteredPageLink(pageName); // add floating search form SearchForm searchForm = new SearchForm("searchForm", repositoryName); @@ -174,18 +155,31 @@ public abstract class RepositoryPage extends BasePage { setStatelessHint(true); } - public void disablePageLink(String pageName) { - for (String wicketId : knownPages.keySet()) { - String key = knownPages.get(wicketId); + public String getLinkWicketId(String pageName) { + for (String wicketId : registeredPages.keySet()) { + String key = registeredPages.get(wicketId).translationKey; String linkName = getString(key); if (linkName.equals(pageName)) { - Component c = get(wicketId); - if (c != null) { - c.setEnabled(false); - } - break; + return wicketId; } } + return null; + } + + public void disableRegisteredPageLink(String pageName) { + String wicketId = getLinkWicketId(pageName); + if (!StringUtils.isEmpty(wicketId)) { + Component c = get(wicketId); + if (c != null) { + c.setEnabled(false); + } + } + } + + private void addRegisteredPageLink(String key) { + PageRegistration pageReg = registeredPages.get(key); + add(new BookmarkablePageLink(key, pageReg.pageClass, + WicketUtils.newRepositoryParameter(repositoryName))); } protected void addSyndicationDiscoveryLink() { @@ -339,6 +333,16 @@ public abstract class RepositoryPage extends BasePage { return WicketUtils.newPathParameter(repositoryName, objectId, path); } + private static class PageRegistration { + final String translationKey; + final Class pageClass; + + PageRegistration(String translationKey, Class pageClass) { + this.translationKey = translationKey; + this.pageClass = pageClass; + } + } + private static class SearchForm extends StatelessForm { private static final long serialVersionUID = 1L; diff --git a/src/com/gitblit/wicket/pages/SummaryPage.html b/src/com/gitblit/wicket/pages/SummaryPage.html index 7784a471..bbf89798 100644 --- a/src/com/gitblit/wicket/pages/SummaryPage.html +++ b/src/com/gitblit/wicket/pages/SummaryPage.html @@ -5,9 +5,7 @@ lang="en"> - - - + diff --git a/src/com/gitblit/wicket/pages/SummaryPage.java b/src/com/gitblit/wicket/pages/SummaryPage.java index 0d0db86b..e31375c0 100644 --- a/src/com/gitblit/wicket/pages/SummaryPage.java +++ b/src/com/gitblit/wicket/pages/SummaryPage.java @@ -122,7 +122,7 @@ public class SummaryPage extends RepositoryPage { } StringBuilder sb = new StringBuilder(); sb.append(WicketUtils.getHostURL(getRequestCycle().getRequest())); - sb.append(Constants.GIT_SERVLET_PATH); + sb.append(Constants.GIT_PATH); sb.append(repositoryName); repositoryUrls.add(sb.toString()); } else { diff --git a/src/com/gitblit/wicket/panels/RepositoriesPanel.html b/src/com/gitblit/wicket/panels/RepositoriesPanel.html index 1e609e10..7e090e80 100644 --- a/src/com/gitblit/wicket/panels/RepositoriesPanel.html +++ b/src/com/gitblit/wicket/panels/RepositoriesPanel.html @@ -21,9 +21,7 @@
- - - + @@ -41,9 +39,7 @@ - - - + Repository Description @@ -57,9 +53,7 @@ - - - + Repository Description @@ -83,7 +77,7 @@ - + diff --git a/src/com/gitblit/wicket/panels/SearchPanel.html b/src/com/gitblit/wicket/panels/SearchPanel.html index 7c8f96f2..bfbcb6ba 100644 --- a/src/com/gitblit/wicket/panels/SearchPanel.html +++ b/src/com/gitblit/wicket/panels/SearchPanel.html @@ -8,8 +8,10 @@ -
[search header]
+
[search header]
+ +
: [search string] ([search type])
diff --git a/src/com/gitblit/wicket/panels/SearchPanel.java b/src/com/gitblit/wicket/panels/SearchPanel.java index 5f82a428..759040e6 100644 --- a/src/com/gitblit/wicket/panels/SearchPanel.java +++ b/src/com/gitblit/wicket/panels/SearchPanel.java @@ -19,6 +19,7 @@ import java.util.Date; import java.util.List; import java.util.Map; +import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.markup.html.link.BookmarkablePageLink; import org.apache.wicket.markup.repeater.Item; import org.apache.wicket.markup.repeater.data.DataView; @@ -72,9 +73,10 @@ public class SearchPanel extends BasePanel { hasMore = commits.size() >= itemsPerPage; // header - add(new LinkPanel("header", "title", commit == null ? "" : commit.getShortMessage(), - CommitPage.class, WicketUtils.newObjectParameter(repositoryName, - commit == null ? "" : commit.getName()))); + add(new CommitHeaderPanel("commitHeader", repositoryName, commit)); + + add(new Label("searchString", value)); + add(new Label("searchType", searchType.toString())); ListDataProvider dp = new ListDataProvider(commits); DataView searchView = new DataView("commit", dp) { diff --git a/src/com/gitblit/wicket/panels/UsersPanel.html b/src/com/gitblit/wicket/panels/UsersPanel.html index 39074b2f..eed2a887 100644 --- a/src/com/gitblit/wicket/panels/UsersPanel.html +++ b/src/com/gitblit/wicket/panels/UsersPanel.html @@ -12,9 +12,7 @@
@@ -30,9 +28,7 @@
- - - + diff --git a/src/com/gitblit/wicket/resources/gitblt-favicon.png b/src/com/gitblit/wicket/resources/gitblt-favicon.png deleted file mode 100644 index f6ac154018a66981c856f5c151486d590f10c817..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 380 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`jKx9jP7LeL$-D$|*pj^6T^Rm@ z;DWu&Cj&(|3p^r=85p>QL70(Y)*K0-AbW|YuPgg)78Vgp(QP|L)qp~OJY5_^EKZ-j zykD=yQH1rw{hF{fN8I*u#yNBZEefk*Y(1xaqHN0S6)vj-SBhk9byC^GG`qvk(fQBL zS&?e9-#affIO&;oZg26kd(}pN9*Y*c^gNhbp|Gw)Hfht>nfLzhnpKss)Xj8Z^U|K5 zt7Tq0V)l53KF1_gi;~i5X7) zzJ1ATC9~)^@4XsZrc?#(trduUBf9ai8hc+|fkKCO(k{=03k5GH?oim)@oj$XPX7MQ W4fjPNXI%h>1B0ilpUXO@geCw!+@5Cu diff --git a/src/log4j.properties b/src/log4j.properties index 16f12363..dc6dd2b5 100644 --- a/src/log4j.properties +++ b/src/log4j.properties @@ -1,12 +1,66 @@ -log4j.debug=false +#------------------------------------------------------------------------------ +# +# The following properties set the logging levels and log appender. The +# log4j.rootCategory variable defines the default log level and one or more +# appenders. For the console, use 'S'. For the daily rolling file, use 'R'. +# For an HTML formatted log, use 'H'. +# +# To override the default (rootCategory) log level, define a property of the +# form (see below for available values): +# +# log4j.logger. = +# +# Available logger names: +# TODO +# +# Possible Log Levels: +# FATAL, ERROR, WARN, INFO, DEBUG +# +#------------------------------------------------------------------------------ +log4j.rootCategory=INFO, S -log4j.rootLogger=INFO -log4j.logger.org=INFO -log4j.logger.com=INFO -log4j.logger.net=INFO +#log4j.rootLogger=INFO +#log4j.logger.org=INFO +#log4j.logger.com=INFO +#log4j.logger.net=INFO -log4j.logger.com.gitblit=DEBUG +#log4j.logger.com.gitblit=DEBUG log4j.logger.org.apache.wicket=INFO log4j.logger.org.apache.wicket.RequestListenerInterface=WARN log4j.logger.org.apache.wicket.protocol.http.HttpSessionStore=WARN + +#------------------------------------------------------------------------------ +# +# The following properties configure the console (stdout) appender. +# See http://logging.apache.org/log4j/docs/api/index.html for details. +# +#------------------------------------------------------------------------------ +log4j.appender.S = org.apache.log4j.ConsoleAppender +log4j.appender.S.layout = org.apache.log4j.PatternLayout +log4j.appender.S.layout.ConversionPattern = %-5p %m%n + +#------------------------------------------------------------------------------ +# +# The following properties configure the Daily Rolling File appender. +# See http://logging.apache.org/log4j/docs/api/index.html for details. +# +#------------------------------------------------------------------------------ +log4j.appender.R = org.apache.log4j.DailyRollingFileAppender +log4j.appender.R.File = logs/gitblit.log +log4j.appender.R.Append = true +log4j.appender.R.DatePattern = '.'yyy-MM-dd +log4j.appender.R.layout = org.apache.log4j.PatternLayout +log4j.appender.R.layout.ConversionPattern = %d{yyyy-MM-dd HH:mm:ss} %c{1} [%p] %m%n + +#------------------------------------------------------------------------------ +# +# The following properties configure the Rolling File appender in HTML. +# See http://logging.apache.org/log4j/docs/api/index.html for details. +# +#------------------------------------------------------------------------------ +log4j.appender.H = org.apache.log4j.RollingFileAppender +log4j.appender.H.File = logs/gitblit.html +log4j.appender.H.MaxFileSize = 100KB +log4j.appender.H.Append = false +log4j.appender.H.layout = org.apache.log4j.HTMLLayout -- 2.39.5
- - - + [username]