From 99d0d4fd66f3490b61c700065b7d16bc4e73f226 Mon Sep 17 00:00:00 2001 From: James Moger Date: Sat, 16 Nov 2013 11:42:06 -0500 Subject: Eliminate nearly all direct GitBlit singleton references in Wicket This is the first step towards modularization and injection. All direct references to the GitBlit singleton within the Wicket pages and panels have been replaced to proxy methods in the GitBlitWebApp singleton. There are still two Wicket classes which rely on the GitBlit singleton; those require manual instantiation (servlet 3). Change-Id: I0cdbbcf87959d590c446c99abb09c07c87c737bc --- src/main/java/com/gitblit/wicket/pages/SummaryPage.java | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'src/main/java/com/gitblit/wicket/pages/SummaryPage.java') diff --git a/src/main/java/com/gitblit/wicket/pages/SummaryPage.java b/src/main/java/com/gitblit/wicket/pages/SummaryPage.java index 5604be4e..9129302b 100644 --- a/src/main/java/com/gitblit/wicket/pages/SummaryPage.java +++ b/src/main/java/com/gitblit/wicket/pages/SummaryPage.java @@ -40,7 +40,6 @@ import org.wicketstuff.googlecharts.LineStyle; import org.wicketstuff.googlecharts.MarkerType; import org.wicketstuff.googlecharts.ShapeMarker; -import com.gitblit.GitBlit; import com.gitblit.Keys; import com.gitblit.models.Metric; import com.gitblit.models.RepositoryModel; @@ -67,11 +66,11 @@ public class SummaryPage extends RepositoryPage { public SummaryPage(PageParameters params) { super(params); - int numberCommits = GitBlit.getInteger(Keys.web.summaryCommitCount, 20); + int numberCommits = app().settings().getInteger(Keys.web.summaryCommitCount, 20); if (numberCommits <= 0) { numberCommits = 20; } - int numberRefs = GitBlit.getInteger(Keys.web.summaryRefsCount, 5); + int numberRefs = app().settings().getInteger(Keys.web.summaryRefsCount, 5); Repository r = getRepository(); final RepositoryModel model = getRepositoryModel(); @@ -82,8 +81,8 @@ public class SummaryPage extends RepositoryPage { List metrics = null; Metric metricsTotal = null; - if (!model.skipSummaryMetrics && GitBlit.getBoolean(Keys.web.generateActivityGraph, true)) { - metrics = GitBlit.self().getRepositoryDefaultMetrics(model, r); + if (!model.skipSummaryMetrics && app().settings().getBoolean(Keys.web.generateActivityGraph, true)) { + metrics = app().repositories().getRepositoryDefaultMetrics(model, r); metricsTotal = metrics.remove(0); } @@ -101,7 +100,7 @@ public class SummaryPage extends RepositoryPage { @Override public void populateItem(final Item item) { String ownername = item.getModelObject(); - UserModel ownerModel = GitBlit.self().getUserModel(ownername); + UserModel ownerModel = app().users().getUserModel(ownername); if (ownerModel != null) { item.add(new LinkPanel("owner", null, ownerModel.getDisplayName(), UserPage.class, WicketUtils.newUsernameParameter(ownerModel.username)).setRenderBodyOnly(true)); @@ -138,10 +137,10 @@ public class SummaryPage extends RepositoryPage { add(new TagsPanel("tagsPanel", repositoryName, r, numberRefs).hideIfEmpty()); add(new BranchesPanel("branchesPanel", getRepositoryModel(), r, numberRefs, false).hideIfEmpty()); - if (GitBlit.getBoolean(Keys.web.summaryShowReadme, false)) { + if (app().settings().getBoolean(Keys.web.summaryShowReadme, false)) { // show a readme on the summary page RevCommit head = JGitUtils.getCommit(r, null); - MarkupProcessor processor = new MarkupProcessor(GitBlit.getSettings()); + MarkupProcessor processor = new MarkupProcessor(app().settings()); MarkupDocument markupDoc = processor.getReadme(r, repositoryName, getBestCommitId(head)); if (markupDoc == null || markupDoc.markup == null) { add(new Label("readme").setVisible(false)); @@ -169,7 +168,7 @@ public class SummaryPage extends RepositoryPage { private void insertActivityGraph(List metrics) { if ((metrics != null) && (metrics.size() > 0) - && GitBlit.getBoolean(Keys.web.generateActivityGraph, true)) { + && app().settings().getBoolean(Keys.web.generateActivityGraph, true)) { IChartData data = WicketUtils.getChartData(metrics); ChartProvider provider = new ChartProvider(new Dimension(290, 100), ChartType.LINE, -- cgit v1.2.3