From 75a907eeabb2983bda2bd1081eacb8a7d94db63b Mon Sep 17 00:00:00 2001
From: James Moger <james.moger@gitblit.com>
Date: Mon, 24 Nov 2014 09:34:46 -0500
Subject: [PATCH] Add .bat and .cmd to the pretty print extensions

---
 src/main/java/com/gitblit/wicket/pages/BlobPage.java |   14 +++++++++++++-
 1 files changed, 13 insertions(+), 1 deletions(-)

diff --git a/src/main/java/com/gitblit/wicket/pages/BlobPage.java b/src/main/java/com/gitblit/wicket/pages/BlobPage.java
index f3d0bc9..df30e4c 100644
--- a/src/main/java/com/gitblit/wicket/pages/BlobPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/BlobPage.java
@@ -21,6 +21,7 @@
 
 import org.apache.wicket.Component;
 import org.apache.wicket.PageParameters;
+import org.apache.wicket.RedirectException;
 import org.apache.wicket.markup.html.basic.Label;
 import org.apache.wicket.markup.html.image.Image;
 import org.apache.wicket.markup.html.link.BookmarkablePageLink;
@@ -52,6 +53,10 @@
 		final String blobPath = WicketUtils.getPath(params);
 		String [] encodings = getEncodings();
 
+		if (StringUtils.isEmpty(objectId) && StringUtils.isEmpty(blobPath)) {
+			throw new RedirectException(TreePage.class, WicketUtils.newRepositoryParameter(repositoryName));
+		}
+
 		if (StringUtils.isEmpty(blobPath)) {
 			// blob by objectid
 
@@ -74,7 +79,7 @@
 			}
 
 			// see if we should redirect to the doc page
-			MarkupProcessor processor = new MarkupProcessor(app().settings());
+			MarkupProcessor processor = new MarkupProcessor(app().settings(), app().xssFilter());
 			for (String ext : processor.getMarkupExtensions()) {
 				if (ext.equals(extension)) {
 					setResponsePage(DocPage.class, params);
@@ -132,6 +137,7 @@
 						table = missingBlob(blobPath, commit);
 					} else {
 						table = generateSourceView(source, extension, type == 1);
+						addBottomScriptInline("jQuery(prettyPrint);");
 					}
 					add(new Label("blobText", table).setEscapeModelStrings(false));
 					add(new Image("blobImage").setVisible(false));
@@ -145,6 +151,7 @@
 					table = missingBlob(blobPath, commit);
 				} else {
 					table = generateSourceView(source, null, false);
+					addBottomScriptInline("jQuery(prettyPrint);");
 				}
 				add(new Label("blobText", table).setEscapeModelStrings(false));
 				add(new Image("blobImage").setVisible(false));
@@ -219,6 +226,11 @@
 	}
 
 	@Override
+	protected boolean isCommitPage() {
+		return true;
+	}
+
+	@Override
 	protected Class<? extends BasePage> getRepoNavPageClass() {
 		return TreePage.class;
 	}

--
Gitblit v1.9.1