From 0aa6ec14e181c5b0cf530be6a9ac79c586fd609e Mon Sep 17 00:00:00 2001 From: James Moger Date: Sun, 9 Oct 2011 09:53:13 -0400 Subject: Indicate current page on documentation. --- build.xml | 2 + resources/bootstrap.gb.css | 4 + src/com/gitblit/build/BuildSite.java | 221 ++++++++++++++++++----------------- 3 files changed, 121 insertions(+), 106 deletions(-) diff --git a/build.xml b/build.xml index 9a589711..99c6e2e1 100644 --- a/build.xml +++ b/build.xml @@ -209,6 +209,7 @@ + @@ -438,6 +439,7 @@ + diff --git a/resources/bootstrap.gb.css b/resources/bootstrap.gb.css index 6ff047b1..aa6c4095 100644 --- a/resources/bootstrap.gb.css +++ b/resources/bootstrap.gb.css @@ -52,6 +52,10 @@ hr { background-position: center bottom; } +.topbar .active a { + background-color: transparent !important; +} + .breadcrumb { margin-top: 5px !important; margin-bottom: 5px !important; diff --git a/src/com/gitblit/build/BuildSite.java b/src/com/gitblit/build/BuildSite.java index 0746a6b7..efff5a34 100644 --- a/src/com/gitblit/build/BuildSite.java +++ b/src/com/gitblit/build/BuildSite.java @@ -56,7 +56,7 @@ import com.gitblit.utils.StringUtils; public class BuildSite { private static final String SPACE_DELIMITED = "SPACE-DELIMITED"; - + private static final String CASE_SENSITIVE = "CASE-SENSITIVE"; private static final String RESTART_REQUIRED = "RESTART REQUIRED"; @@ -91,24 +91,6 @@ public class BuildSite { System.out.println(MessageFormat.format("Generating site from {0} Markdown Docs in {1} ", markdownFiles.length, sourceFolder.getAbsolutePath())); - String linkPattern = "
  • {1}
  • "; - StringBuilder sb = new StringBuilder(); - for (File file : markdownFiles) { - String documentName = getDocumentName(file); - if (!params.skips.contains(documentName)) { - String displayName = documentName; - if (aliasMap.containsKey(documentName)) { - displayName = aliasMap.get(documentName); - } else { - displayName = displayName.replace('_', ' '); - } - String fileName = documentName + ".html"; - sb.append(MessageFormat.format(linkPattern, fileName, displayName)); - sb.append(" | "); - } - } - sb.setLength(sb.length() - 3); - sb.trimToSize(); String htmlHeader = FileUtils.readContent(new File(params.pageHeader), "\n"); @@ -120,105 +102,105 @@ public class BuildSite { } } String htmlFooter = FileUtils.readContent(new File(params.pageFooter), "\n"); - String links = sb.toString(); - String header = MessageFormat.format(htmlHeader, Constants.FULL_NAME, links); - if (!StringUtils.isEmpty(params.analyticsSnippet)) { - File snippet = new File(params.analyticsSnippet); - if (snippet.exists()) { - String htmlSnippet = FileUtils.readContent(snippet, "\n"); - header = header.replace("", htmlSnippet); - } - } final String date = new SimpleDateFormat("yyyy-MM-dd").format(new Date()); final String footer = MessageFormat.format(htmlFooter, "generated " + date); for (File file : markdownFiles) { + String documentName = getDocumentName(file); + if (params.skips.contains(documentName)) { + continue; + } try { - String documentName = getDocumentName(file); - if (!params.skips.contains(documentName)) { - String fileName = documentName + ".html"; - System.out.println(MessageFormat.format(" {0} => {1}", file.getName(), - fileName)); - String rawContent = FileUtils.readContent(file, "\n"); - String markdownContent = rawContent; - - Map> nomarkdownMap = new HashMap>(); - - // extract sections marked as no-markdown - int nmd = 0; - for (String token : params.nomarkdown) { - StringBuilder strippedContent = new StringBuilder(); - - String nomarkdownKey = "%NOMARKDOWN" + nmd + "%"; - String[] kv = token.split(":", 2); - String beginToken = kv[0]; - String endToken = kv[1]; - - // strip nomarkdown chunks from markdown and cache them - List chunks = new Vector(); - int beginCode = 0; - int endCode = 0; - while ((beginCode = markdownContent.indexOf(beginToken, endCode)) > -1) { - if (endCode == 0) { - strippedContent.append(markdownContent.substring(0, beginCode)); - } else { - strippedContent.append(markdownContent - .substring(endCode, beginCode)); - } - strippedContent.append(nomarkdownKey); - endCode = markdownContent.indexOf(endToken, beginCode); - chunks.add(markdownContent.substring(beginCode, endCode)); - nomarkdownMap.put(nomarkdownKey, chunks); - } - - // get remainder of text - if (endCode < markdownContent.length()) { - strippedContent.append(markdownContent.substring(endCode, - markdownContent.length())); - } - markdownContent = strippedContent.toString(); - nmd++; + String links = createLinks(file, markdownFiles, aliasMap, params.skips); + String header = MessageFormat.format(htmlHeader, Constants.FULL_NAME, links); + if (!StringUtils.isEmpty(params.analyticsSnippet)) { + File snippet = new File(params.analyticsSnippet); + if (snippet.exists()) { + String htmlSnippet = FileUtils.readContent(snippet, "\n"); + header = header.replace("", htmlSnippet); } + } - // transform markdown to html - String content = transformMarkdown(markdownContent.toString()); - - // reinsert nomarkdown chunks - for (Map.Entry> nomarkdown : nomarkdownMap.entrySet()) { - for (String chunk : nomarkdown.getValue()) { - content = content.replaceFirst(nomarkdown.getKey(), chunk); + String fileName = documentName + ".html"; + System.out.println(MessageFormat.format(" {0} => {1}", file.getName(), fileName)); + String rawContent = FileUtils.readContent(file, "\n"); + String markdownContent = rawContent; + + Map> nomarkdownMap = new HashMap>(); + + // extract sections marked as no-markdown + int nmd = 0; + for (String token : params.nomarkdown) { + StringBuilder strippedContent = new StringBuilder(); + + String nomarkdownKey = "%NOMARKDOWN" + nmd + "%"; + String[] kv = token.split(":", 2); + String beginToken = kv[0]; + String endToken = kv[1]; + + // strip nomarkdown chunks from markdown and cache them + List chunks = new Vector(); + int beginCode = 0; + int endCode = 0; + while ((beginCode = markdownContent.indexOf(beginToken, endCode)) > -1) { + if (endCode == 0) { + strippedContent.append(markdownContent.substring(0, beginCode)); + } else { + strippedContent.append(markdownContent.substring(endCode, beginCode)); } + strippedContent.append(nomarkdownKey); + endCode = markdownContent.indexOf(endToken, beginCode); + chunks.add(markdownContent.substring(beginCode, endCode)); + nomarkdownMap.put(nomarkdownKey, chunks); } - for (String token : params.substitutions) { - String[] kv = token.split("=", 2); - content = content.replace(kv[0], kv[1]); - } - for (String token : params.regex) { - String[] kv = token.split("!!!", 2); - content = content.replaceAll(kv[0], kv[1]); - } - for (String alias : params.properties) { - String[] kv = alias.split("=", 2); - String loadedContent = generatePropertiesContent(new File(kv[1])); - content = content.replace(kv[0], loadedContent); - } - for (String alias : params.loads) { - String[] kv = alias.split("=", 2); - String loadedContent = FileUtils.readContent(new File(kv[1]), "\n"); - loadedContent = StringUtils.escapeForHtml(loadedContent, false); - loadedContent = StringUtils.breakLinesForHtml(loadedContent); - content = content.replace(kv[0], loadedContent); + // get remainder of text + if (endCode < markdownContent.length()) { + strippedContent.append(markdownContent.substring(endCode, + markdownContent.length())); } - OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream( - new File(destinationFolder, fileName)), Charset.forName("UTF-8")); - writer.write(header); - if (!StringUtils.isEmpty(htmlAdSnippet)) { - writer.write(htmlAdSnippet); + markdownContent = strippedContent.toString(); + nmd++; + } + + // transform markdown to html + String content = transformMarkdown(markdownContent.toString()); + + // reinsert nomarkdown chunks + for (Map.Entry> nomarkdown : nomarkdownMap.entrySet()) { + for (String chunk : nomarkdown.getValue()) { + content = content.replaceFirst(nomarkdown.getKey(), chunk); } - writer.write(content); - writer.write(footer); - writer.close(); } + + for (String token : params.substitutions) { + String[] kv = token.split("=", 2); + content = content.replace(kv[0], kv[1]); + } + for (String token : params.regex) { + String[] kv = token.split("!!!", 2); + content = content.replaceAll(kv[0], kv[1]); + } + for (String alias : params.properties) { + String[] kv = alias.split("=", 2); + String loadedContent = generatePropertiesContent(new File(kv[1])); + content = content.replace(kv[0], loadedContent); + } + for (String alias : params.loads) { + String[] kv = alias.split("=", 2); + String loadedContent = FileUtils.readContent(new File(kv[1]), "\n"); + loadedContent = StringUtils.escapeForHtml(loadedContent, false); + loadedContent = StringUtils.breakLinesForHtml(loadedContent); + content = content.replace(kv[0], loadedContent); + } + OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(new File( + destinationFolder, fileName)), Charset.forName("UTF-8")); + writer.write(header); + if (!StringUtils.isEmpty(htmlAdSnippet)) { + writer.write(htmlAdSnippet); + } + writer.write(content); + writer.write(footer); + writer.close(); } catch (Throwable t) { System.err.println("Failed to transform " + file.getName()); t.printStackTrace(); @@ -237,6 +219,33 @@ public class BuildSite { return displayName; } + private static String createLinks(File currentFile, File[] markdownFiles, + Map aliasMap, List skips) { + String linkPattern = "
  • {1}
  • "; + String currentLinkPattern = "
  • {1}
  • "; + StringBuilder sb = new StringBuilder(); + for (File file : markdownFiles) { + String documentName = getDocumentName(file); + if (!skips.contains(documentName)) { + String displayName = documentName; + if (aliasMap.containsKey(documentName)) { + displayName = aliasMap.get(documentName); + } else { + displayName = displayName.replace('_', ' '); + } + String fileName = documentName + ".html"; + if (currentFile.getName().equals(file.getName())) { + sb.append(MessageFormat.format(currentLinkPattern, fileName, displayName)); + } else { + sb.append(MessageFormat.format(linkPattern, fileName, displayName)); + } + } + } + sb.setLength(sb.length() - 3); + sb.trimToSize(); + return sb.toString(); + } + private static String generatePropertiesContent(File propertiesFile) throws Exception { // Read the current Gitblit properties BufferedReader propertiesReader = new BufferedReader(new FileReader(propertiesFile)); -- cgit v1.2.3 From 5d253a0fba287a01779dde5ec932598bb8876426 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Fri, 30 Sep 2011 16:43:33 +0800 Subject: o Adding support for customizing the webapp's context path. --- src/com/gitblit/GitBlitServer.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/com/gitblit/GitBlitServer.java b/src/com/gitblit/GitBlitServer.java index 5c8c5fe4..1b079de8 100644 --- a/src/com/gitblit/GitBlitServer.java +++ b/src/com/gitblit/GitBlitServer.java @@ -209,7 +209,7 @@ public class GitBlitServer { // Root WebApp Context WebAppContext rootContext = new WebAppContext(); - rootContext.setContextPath("/"); + rootContext.setContextPath(settings.getString(Keys.server.contextPath, "/")); rootContext.setServer(server); rootContext.setWar(location.toExternalForm()); rootContext.setTempDirectory(tempDir); -- cgit v1.2.3 From 0dccce1b5cffce03124f001ae03b66962f36fee6 Mon Sep 17 00:00:00 2001 From: Trygve Laugstøl Date: Mon, 10 Oct 2011 21:38:18 +0800 Subject: o Adding missing properties to gitblit.properties for adjusting the context path. --- distrib/gitblit.properties | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/distrib/gitblit.properties b/distrib/gitblit.properties index 5b2b576a..78931f27 100644 --- a/distrib/gitblit.properties +++ b/distrib/gitblit.properties @@ -501,3 +501,9 @@ server.storePassword = gitblit # SINCE 0.5.0 # RESTART REQUIRED server.shutdownPort = 8081 + +# Context path for the application. +# +# SINCE 0.7.0+ +# RESTART REQUIRED +server.contextPath = / -- cgit v1.2.3 From 70b492b89bdad54abc10795d12f306d8972d94a7 Mon Sep 17 00:00:00 2001 From: James Moger Date: Mon, 10 Oct 2011 19:11:35 -0400 Subject: Documentation. Updated snapshot to 0.7.0. Merged server.contextPath. --- distrib/gitblit.properties | 14 +++++------ docs/00_index.mkd | 1 + docs/03_faq.mkd | 6 +++-- docs/04_releases.mkd | 1 + src/com/gitblit/Constants.java | 2 +- .../wicket/GitblitParamUrlCodingStrategy.java | 28 ++++++++++++++++++++++ 6 files changed, 42 insertions(+), 10 deletions(-) diff --git a/distrib/gitblit.properties b/distrib/gitblit.properties index 78931f27..64358da6 100644 --- a/distrib/gitblit.properties +++ b/distrib/gitblit.properties @@ -114,7 +114,7 @@ web.showFederationRegistrations = false # This can point to a file with Markdown content. # Specifying "gitblit" uses the internal login message. # -# SINCE 0.6.1 +# SINCE 0.7.0 web.loginMessage = gitblit # This is the message displayed above the repositories table. @@ -453,6 +453,12 @@ server.tempFolder = temp # RESTART REQUIRED server.useNio = true +# Context path for the application. +# +# SINCE 0.7.0 +# RESTART REQUIRED +server.contextPath = / + # Standard http port to serve. <= 0 disables this connector. # On Unix/Linux systems, ports < 1024 require root permissions. # Recommended value: 80 or 8080 @@ -501,9 +507,3 @@ server.storePassword = gitblit # SINCE 0.5.0 # RESTART REQUIRED server.shutdownPort = 8081 - -# Context path for the application. -# -# SINCE 0.7.0+ -# RESTART REQUIRED -server.contextPath = / diff --git a/docs/00_index.mkd b/docs/00_index.mkd index cf165db5..ddb609f7 100644 --- a/docs/00_index.mkd +++ b/docs/00_index.mkd @@ -35,6 +35,7 @@ Gitblit requires a Java 6 Runtime Environment (JRE) or a Java 6 Development Kit - fixed: Null pointer exception if did not set federation strategy (issue 20) - fixed: Gitblit GO allows SSL renegotiation if running on Java 1.6.0_22 or later - added: IUserService.setup(IStoredSettings) for custom user service implementations +- added: setting to control Gitblit GO context path for proxy setups
    **New:** *server.contextPath = /* issues, binaries, and sources @ [Google Code][googlecode]
    sources @ [Github][gitbltsrc] diff --git a/docs/03_faq.mkd b/docs/03_faq.mkd index 12ceada6..f690f266 100644 --- a/docs/03_faq.mkd +++ b/docs/03_faq.mkd @@ -36,12 +36,14 @@ Run the server as *root* (security concern) or change the ports you are serving ### Gitblit WAR will not authenticate any users?! Confirm that the <context-param> *realm.userService* value in your `web.xml` file actually points to a `users.properties` file. -### Gitblit won't open my grouped repository (/group/myrepo.git) or browse my branch/tag/ref?! -This is likely an url encoding/decoding problem related to your servlet container's security. There are two possible workarounds for this issue. In `gitblit.properties` or `web.xml`: +### Gitblit won't open my grouped repository (/group/myrepo.git) or browse my log/branch/tag/ref?! +This is likely an url encoding/decoding problem with forward slashes. There are two possible workarounds for this issue. In `gitblit.properties` or `web.xml`: 1. try setting *web.mountParameters* to *false*.
    This changes the url scheme from mounted (*/commit/myrepo.git/abcdef*) to parameterized (*/commit/?r=myrepo.git&h=abcdef*). 2. try changing *web.forwardSlashCharacter* to an asterisk or a **!** +Also, if you are running Gitblit behind a proxy, you must ensure that the proxy does not decode and then re-encode request urls with interpretation of *%2F*. If you are using Apache mod_proxy, specify [AllowEncodedSlashes NoDecode](http://httpd.apache.org/docs/2.2/mod/core.html#allowencodedslashes). + ## General Interest Questions ### Gitblit? What kind of name is that? diff --git a/docs/04_releases.mkd b/docs/04_releases.mkd index 214e35cb..303883bd 100644 --- a/docs/04_releases.mkd +++ b/docs/04_releases.mkd @@ -10,6 +10,7 @@ - fixed: Null pointer exception if did not set federation strategy (issue 20) - fixed: Gitblit GO allows SSL renegotiation if running on Java 1.6.0_22 or later - added: IUserService.setup(IStoredSettings) for custom user service implementations +- added: setting to control Gitblit GO context path for proxy setups
    **New:** *server.contextPath = /* ### Older Releases diff --git a/src/com/gitblit/Constants.java b/src/com/gitblit/Constants.java index f4541c9f..a5b7c4f1 100644 --- a/src/com/gitblit/Constants.java +++ b/src/com/gitblit/Constants.java @@ -29,7 +29,7 @@ public class Constants { // The build script extracts this exact line so be careful editing it // and only use A-Z a-z 0-9 .-_ in the string. - public static final String VERSION = "0.6.1-SNAPSHOT"; + public static final String VERSION = "0.7.0-SNAPSHOT"; // The build script extracts this exact line so be careful editing it // and only use A-Z a-z 0-9 .-_ in the string. diff --git a/src/com/gitblit/wicket/GitblitParamUrlCodingStrategy.java b/src/com/gitblit/wicket/GitblitParamUrlCodingStrategy.java index 3248a082..fb86fb0e 100644 --- a/src/com/gitblit/wicket/GitblitParamUrlCodingStrategy.java +++ b/src/com/gitblit/wicket/GitblitParamUrlCodingStrategy.java @@ -15,8 +15,15 @@ */ package com.gitblit.wicket; +import java.text.MessageFormat; + +import org.apache.wicket.IRequestTarget; import org.apache.wicket.Page; +import org.apache.wicket.PageParameters; +import org.apache.wicket.request.RequestParameters; import org.apache.wicket.request.target.coding.MixedParamUrlCodingStrategy; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import com.gitblit.GitBlit; import com.gitblit.Keys; @@ -33,6 +40,8 @@ import com.gitblit.Keys; */ public class GitblitParamUrlCodingStrategy extends MixedParamUrlCodingStrategy { + private Logger logger = LoggerFactory.getLogger(GitblitParamUrlCodingStrategy.class); + /** * Construct. * @@ -78,4 +87,23 @@ public class GitblitParamUrlCodingStrategy extends MixedParamUrlCodingStrategy { } return super.urlDecodePathComponent(value); } + + /** + * Gets the decoded request target. + * + * @param requestParameters + * the request parameters + * @return the decoded request target + */ + @Override + public IRequestTarget decode(RequestParameters requestParameters) { + final String parametersFragment = requestParameters.getPath().substring( + getMountPath().length()); + logger.debug(MessageFormat + .format("REQ: {0} PARAMS {1}", getMountPath(), parametersFragment)); + + final PageParameters parameters = new PageParameters(decodeParameters(parametersFragment, + requestParameters.getParameters())); + return super.decode(requestParameters); + } } \ No newline at end of file -- cgit v1.2.3