commit | author | age
|
f13c4c
|
1 |
/*
|
JM |
2 |
* Copyright 2011 gitblit.com.
|
|
3 |
*
|
|
4 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
5 |
* you may not use this file except in compliance with the License.
|
|
6 |
* You may obtain a copy of the License at
|
|
7 |
*
|
|
8 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
9 |
*
|
|
10 |
* Unless required by applicable law or agreed to in writing, software
|
|
11 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
12 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13 |
* See the License for the specific language governing permissions and
|
|
14 |
* limitations under the License.
|
|
15 |
*/
|
c1c3c6
|
16 |
package com.gitblit.wicket.pages;
|
JM |
17 |
|
|
18 |
import java.util.List;
|
|
19 |
|
|
20 |
import org.apache.wicket.PageParameters;
|
|
21 |
import org.apache.wicket.markup.html.basic.Label;
|
|
22 |
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
|
|
23 |
import org.apache.wicket.markup.repeater.Item;
|
|
24 |
import org.apache.wicket.markup.repeater.data.DataView;
|
|
25 |
import org.apache.wicket.markup.repeater.data.ListDataProvider;
|
|
26 |
import org.eclipse.jgit.lib.Repository;
|
|
27 |
|
|
28 |
import com.gitblit.GitBlit;
|
|
29 |
import com.gitblit.Keys;
|
1f9dae
|
30 |
import com.gitblit.models.PathModel;
|
c1c3c6
|
31 |
import com.gitblit.utils.ByteFormat;
|
JM |
32 |
import com.gitblit.utils.JGitUtils;
|
|
33 |
import com.gitblit.wicket.WicketUtils;
|
1f9dae
|
34 |
import com.gitblit.wicket.panels.LinkPanel;
|
c1c3c6
|
35 |
|
JM |
36 |
public class DocsPage extends RepositoryPage {
|
|
37 |
|
|
38 |
public DocsPage(PageParameters params) {
|
|
39 |
super(params);
|
|
40 |
|
|
41 |
Repository r = getRepository();
|
2a7306
|
42 |
List<String> extensions = GitBlit.getStrings(Keys.web.markdownExtensions);
|
c1c3c6
|
43 |
List<PathModel> paths = JGitUtils.getDocuments(r, extensions);
|
JM |
44 |
|
|
45 |
final ByteFormat byteFormat = new ByteFormat();
|
|
46 |
|
|
47 |
add(new Label("header", getString("gb.docs")));
|
2a7306
|
48 |
|
c1c3c6
|
49 |
// documents list
|
JM |
50 |
ListDataProvider<PathModel> pathsDp = new ListDataProvider<PathModel>(paths);
|
|
51 |
DataView<PathModel> pathsView = new DataView<PathModel>("document", pathsDp) {
|
|
52 |
private static final long serialVersionUID = 1L;
|
2a7306
|
53 |
int counter;
|
c1c3c6
|
54 |
|
JM |
55 |
public void populateItem(final Item<PathModel> item) {
|
|
56 |
PathModel entry = item.getModelObject();
|
|
57 |
item.add(WicketUtils.newImage("docIcon", "file_world_16x16.png"));
|
|
58 |
item.add(new Label("docSize", byteFormat.format(entry.size)));
|
a2709d
|
59 |
item.add(new LinkPanel("docName", "list", entry.name, BlobPage.class, WicketUtils
|
JM |
60 |
.newPathParameter(repositoryName, entry.commitId, entry.path)));
|
c1c3c6
|
61 |
|
JM |
62 |
// links
|
2a7306
|
63 |
item.add(new BookmarkablePageLink<Void>("view", BlobPage.class, WicketUtils
|
JM |
64 |
.newPathParameter(repositoryName, entry.commitId, entry.path)));
|
|
65 |
item.add(new BookmarkablePageLink<Void>("raw", RawPage.class, WicketUtils
|
|
66 |
.newPathParameter(repositoryName, entry.commitId, entry.path)));
|
85c2e6
|
67 |
item.add(new BookmarkablePageLink<Void>("blame", BlamePage.class, WicketUtils
|
JM |
68 |
.newPathParameter(repositoryName, entry.commitId, entry.path)));
|
2a7306
|
69 |
item.add(new BookmarkablePageLink<Void>("history", HistoryPage.class, WicketUtils
|
JM |
70 |
.newPathParameter(repositoryName, entry.commitId, entry.path)));
|
c1c3c6
|
71 |
WicketUtils.setAlternatingBackground(item, counter);
|
JM |
72 |
counter++;
|
|
73 |
}
|
|
74 |
};
|
|
75 |
add(pathsView);
|
|
76 |
}
|
|
77 |
|
|
78 |
@Override
|
|
79 |
protected String getPageName() {
|
|
80 |
return getString("gb.docs");
|
|
81 |
}
|
|
82 |
}
|