| | |
| | |
|
| | | public class BlobPage extends RepositoryPage {
|
| | |
|
| | | protected String fileExtension;
|
| | |
|
| | | public BlobPage(PageParameters params) {
|
| | | super(params);
|
| | |
|
| | |
| | | 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
|
| | |
| | | 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));
|
| | |
| | | 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();
|
| | |
| | | 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\">");
|
| | | }
|