diff options
author | James Moger <james.moger@gitblit.com> | 2011-04-27 21:22:12 -0400 |
---|---|---|
committer | James Moger <james.moger@gitblit.com> | 2011-04-27 21:22:12 -0400 |
commit | f97bf09263fe8ef7ba4dcf231dfe7b8265b1e0df (patch) | |
tree | b36da52ab523f1b6af9f00409703edfbfe77ccfe /src/com/gitblit/wicket/pages | |
parent | 3e087ada55f8b0e83b146578b695552db9dc8d97 (diff) | |
download | gitblit-f97bf09263fe8ef7ba4dcf231dfe7b8265b1e0df.tar.gz gitblit-f97bf09263fe8ef7ba4dcf231dfe7b8265b1e0df.zip |
Centralized markdown transforms. Moved config ops to GitBlit.
Diffstat (limited to 'src/com/gitblit/wicket/pages')
-rw-r--r-- | src/com/gitblit/wicket/pages/EditRepositoryPage.java | 20 | ||||
-rw-r--r-- | src/com/gitblit/wicket/pages/RepositoriesPage.java | 16 | ||||
-rw-r--r-- | src/com/gitblit/wicket/pages/SummaryPage.java | 4 |
3 files changed, 10 insertions, 30 deletions
diff --git a/src/com/gitblit/wicket/pages/EditRepositoryPage.java b/src/com/gitblit/wicket/pages/EditRepositoryPage.java index e2905683..6201b22b 100644 --- a/src/com/gitblit/wicket/pages/EditRepositoryPage.java +++ b/src/com/gitblit/wicket/pages/EditRepositoryPage.java @@ -7,10 +7,8 @@ import org.apache.wicket.markup.html.form.CheckBox; import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.TextField;
import org.apache.wicket.model.CompoundPropertyModel;
-import org.eclipse.jgit.lib.Repository;
import com.gitblit.GitBlit;
-import com.gitblit.utils.JGitUtils;
import com.gitblit.wicket.AdminPage;
import com.gitblit.wicket.BasePage;
import com.gitblit.wicket.WicketUtils;
@@ -33,36 +31,30 @@ public class EditRepositoryPage extends BasePage { super(params);
isCreate = false;
String name = WicketUtils.getRepositoryName(params);
- Repository r = GitBlit.self().getRepository(name);
- String description = JGitUtils.getRepositoryDescription(r);
- String owner = JGitUtils.getRepositoryOwner(r);
- String group = JGitUtils.getRepositoryGroup(r);
- RepositoryModel model = new RepositoryModel(name, description, owner, new Date());
- model.group = group;
- model.useTickets = JGitUtils.getRepositoryUseTickets(r);
- model.useDocs = JGitUtils.getRepositoryUseDocs(r);
- model.useRestrictedAccess = JGitUtils.getRepositoryRestrictedAccess(r);
+ RepositoryModel model = GitBlit.self().getRepositoryModel(name);
setupPage(model);
}
- protected void setupPage(final RepositoryModel repository) {
+ protected void setupPage(final RepositoryModel repositoryModel) {
if (isCreate) {
super.setupPage("", getString("gb.newRepository"));
} else {
super.setupPage("", getString("gb.edit"));
}
- CompoundPropertyModel<RepositoryModel> model = new CompoundPropertyModel<RepositoryModel>(repository);
+ CompoundPropertyModel<RepositoryModel> model = new CompoundPropertyModel<RepositoryModel>(repositoryModel);
Form<RepositoryModel> form = new Form<RepositoryModel>("editForm", model) {
private static final long serialVersionUID = 1L;
@Override
protected void onSubmit() {
- GitBlit.self().editRepository(repository, isCreate);
+ GitBlit.self().editRepositoryModel(repositoryModel, isCreate);
setRedirect(true);
setResponsePage(RepositoriesPage.class);
}
};
+
+ // field names reflective match RepositoryModel fields
form.add(new TextField<String>("name").setEnabled(isCreate));
form.add(new TextField<String>("description"));
form.add(new TextField<String>("owner"));
diff --git a/src/com/gitblit/wicket/pages/RepositoriesPage.java b/src/com/gitblit/wicket/pages/RepositoriesPage.java index a7ec963a..c834604d 100644 --- a/src/com/gitblit/wicket/pages/RepositoriesPage.java +++ b/src/com/gitblit/wicket/pages/RepositoriesPage.java @@ -4,7 +4,6 @@ import java.io.File; import java.io.FileReader;
import java.io.InputStream;
import java.io.InputStreamReader;
-import java.io.StringWriter;
import java.util.Collections;
import java.util.Comparator;
import java.util.Iterator;
@@ -23,7 +22,6 @@ import org.apache.wicket.markup.repeater.data.DataView; import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;
import org.apache.wicket.resource.ContextRelativeResource;
-import org.tautua.markdownpapers.Markdown;
import com.gitblit.GitBlit;
import com.gitblit.Keys;
@@ -63,12 +61,7 @@ public class RepositoriesPage extends BasePage { ContextRelativeResource res = WicketUtils.getResource("welcome.mkd");
InputStream is = res.getResourceStream().getInputStream();
InputStreamReader reader = new InputStreamReader(is);
- StringWriter writer = new StringWriter();
- Markdown markdown = new Markdown();
- markdown.transform(reader, writer);
- message = writer.toString().trim();
- reader.close();
- writer.close();
+ message = StringUtils.transformMarkdown(reader);
} catch (Throwable t) {
message = "Failed to read default welcome message!";
error(message, t);
@@ -80,12 +73,7 @@ public class RepositoriesPage extends BasePage { if (file.exists()) {
try {
FileReader reader = new FileReader(file);
- StringWriter writer = new StringWriter();
- Markdown markdown = new Markdown();
- markdown.transform(reader, writer);
- message = writer.toString().trim();
- reader.close();
- writer.close();
+ message = StringUtils.transformMarkdown(reader);
} catch (Throwable t) {
message = "Failed to read " + file;
error(message, t);
diff --git a/src/com/gitblit/wicket/pages/SummaryPage.java b/src/com/gitblit/wicket/pages/SummaryPage.java index 0c4c5953..78a58f77 100644 --- a/src/com/gitblit/wicket/pages/SummaryPage.java +++ b/src/com/gitblit/wicket/pages/SummaryPage.java @@ -57,8 +57,8 @@ public class SummaryPage extends RepositoryPage { }
// repository description
- add(new Label("repositoryDescription", description));
- add(new Label("repositoryOwner", JGitUtils.getRepositoryOwner(r)));
+ add(new Label("repositoryDescription", getRepositoryModel().description));
+ add(new Label("repositoryOwner", getRepositoryModel().owner));
add(WicketUtils.createTimestampLabel("repositoryLastChange", JGitUtils.getLastChange(r), getTimeZone()));
if (metricsTotal == null) {
|