diff options
author | Kensuke Matsuzaki <zakki@peppermint.jp> | 2013-04-15 17:39:19 +0900 |
---|---|---|
committer | Kensuke Matsuzaki <zakki@peppermint.jp> | 2013-04-16 00:41:38 +0900 |
commit | ed566a162c780faa0d6c84fac8fbbd3738586445 (patch) | |
tree | f4f5ad17c9cbb55e60d387479a9bdf892f73f4c8 /src/main/java/com/gitblit/wicket/pages/BlobPage.java | |
parent | 2a0933d238e24c5fe92f2f450e26bc52438123fe (diff) | |
download | gitblit-ed566a162c780faa0d6c84fac8fbbd3738586445.tar.gz gitblit-ed566a162c780faa0d6c84fac8fbbd3738586445.zip |
Load prettify's lang-*.js extentions.
Diffstat (limited to 'src/main/java/com/gitblit/wicket/pages/BlobPage.java')
-rw-r--r-- | src/main/java/com/gitblit/wicket/pages/BlobPage.java | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/main/java/com/gitblit/wicket/pages/BlobPage.java b/src/main/java/com/gitblit/wicket/pages/BlobPage.java index ab0f0f16..295b2eb7 100644 --- a/src/main/java/com/gitblit/wicket/pages/BlobPage.java +++ b/src/main/java/com/gitblit/wicket/pages/BlobPage.java @@ -39,6 +39,8 @@ import com.gitblit.wicket.panels.PathBreadcrumbsPanel; public class BlobPage extends RepositoryPage {
+ protected String fileExtension;
+
public BlobPage(PageParameters params) {
super(params);
@@ -128,10 +130,11 @@ public class BlobPage extends RepositoryPage { if (source == null) {
table = missingBlob(blobPath, commit);
} else {
- table = generateSourceView(source, type == 1);
+ table = generateSourceView(source, extension, type == 1);
}
add(new Label("blobText", table).setEscapeModelStrings(false));
add(new Image("blobImage").setVisible(false));
+ fileExtension = extension;
}
} else {
// plain text
@@ -140,7 +143,7 @@ public class BlobPage extends RepositoryPage { if (source == null) {
table = missingBlob(blobPath, commit);
} else {
- table = generateSourceView(source, false);
+ table = generateSourceView(source, null, false);
}
add(new Label("blobText", table).setEscapeModelStrings(false));
add(new Image("blobImage").setVisible(false));
@@ -156,8 +159,8 @@ public class BlobPage extends RepositoryPage { sb.append("</div>");
return sb.toString();
}
-
- protected String generateSourceView(String source, boolean prettyPrint) {
+
+ protected String generateSourceView(String source, String extension, boolean prettyPrint) {
String [] lines = source.split("\n");
StringBuilder sb = new StringBuilder();
@@ -180,7 +183,7 @@ public class BlobPage extends RepositoryPage { sb.append("<td id=\"lines\">");
sb.append("<div class=\"sourceview\">");
if (prettyPrint) {
- sb.append("<pre class=\"prettyprint\">");
+ sb.append("<pre class=\"prettyprint lang-" + extension + "\">");
} else {
sb.append("<pre class=\"plainprint\">");
}
|