| | |
| | | /*
|
| | | * Copyright 2011 gitblit.com.
|
| | | *
|
| | | * Licensed under the Apache License, Version 2.0 (the "License");
|
| | | * you may not use this file except in compliance with the License.
|
| | | * You may obtain a copy of the License at
|
| | | *
|
| | | * http://www.apache.org/licenses/LICENSE-2.0
|
| | | *
|
| | | * Unless required by applicable law or agreed to in writing, software
|
| | | * distributed under the License is distributed on an "AS IS" BASIS,
|
| | | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
| | | * See the License for the specific language governing permissions and
|
| | | * limitations under the License.
|
| | | */
|
| | | package com.gitblit.wicket;
|
| | |
|
| | | import org.apache.wicket.Application;
|
| | |
| | | import org.apache.wicket.Request;
|
| | | import org.apache.wicket.Response;
|
| | | import org.apache.wicket.Session;
|
| | | import org.apache.wicket.markup.html.WebPage;
|
| | | import org.apache.wicket.protocol.http.WebApplication;
|
| | | import org.apache.wicket.request.target.coding.MixedParamUrlCodingStrategy;
|
| | |
|
| | | import com.gitblit.GitBlit;
|
| | | import com.gitblit.Keys;
|
| | | import com.gitblit.wicket.pages.ActivityPage;
|
| | | import com.gitblit.wicket.pages.BlamePage;
|
| | | import com.gitblit.wicket.pages.BlobDiffPage;
|
| | | import com.gitblit.wicket.pages.BlobPage;
|
| | | import com.gitblit.wicket.pages.BranchesPage;
|
| | | import com.gitblit.wicket.pages.CommitDiffPage;
|
| | | import com.gitblit.wicket.pages.CommitPage;
|
| | | import com.gitblit.wicket.pages.DocsPage;
|
| | | import com.gitblit.wicket.pages.FederationRegistrationPage;
|
| | | import com.gitblit.wicket.pages.GravatarProfilePage;
|
| | | import com.gitblit.wicket.pages.HistoryPage;
|
| | | import com.gitblit.wicket.pages.LogPage;
|
| | | import com.gitblit.wicket.pages.MarkdownPage;
|
| | | import com.gitblit.wicket.pages.MetricsPage;
|
| | | import com.gitblit.wicket.pages.PatchPage;
|
| | | import com.gitblit.wicket.pages.RawPage;
|
| | | import com.gitblit.wicket.pages.RepositoriesPage;
|
| | | import com.gitblit.wicket.pages.ReviewProposalPage;
|
| | | import com.gitblit.wicket.pages.SearchPage;
|
| | | import com.gitblit.wicket.pages.SummaryPage;
|
| | | import com.gitblit.wicket.pages.TagPage;
|
| | |
| | | super.init();
|
| | |
|
| | | // Setup page authorization mechanism
|
| | | boolean useAuthentication = GitBlit.self().settings().getBoolean(Keys.web.authenticateViewPages, false) || GitBlit.self().settings().getBoolean(Keys.web.authenticateAdminPages, false);
|
| | | boolean useAuthentication = GitBlit.getBoolean(Keys.web.authenticateViewPages, false)
|
| | | || GitBlit.getBoolean(Keys.web.authenticateAdminPages, false);
|
| | | if (useAuthentication) {
|
| | | AuthorizationStrategy authStrategy = new AuthorizationStrategy();
|
| | | getSecuritySettings().setAuthorizationStrategy(authStrategy);
|
| | |
| | | }
|
| | |
|
| | | // Grab Browser info (like timezone, etc)
|
| | | if (GitBlit.self().settings().getBoolean(Keys.web.useClientTimezone, false)) {
|
| | | if (GitBlit.getBoolean(Keys.web.useClientTimezone, false)) {
|
| | | getRequestCycleSettings().setGatherExtendedBrowserInfo(true);
|
| | | }
|
| | |
|
| | | // configure the resource cache duration to 90 days for deployment
|
| | | if (!GitBlit.isDebugMode()) {
|
| | | getResourceSettings().setDefaultCacheDuration(90 * 86400);
|
| | | }
|
| | |
|
| | | // setup the standard gitweb-ish urls
|
| | | mount(new MixedParamUrlCodingStrategy("/summary", SummaryPage.class, new String[] { "r" }));
|
| | | mount(new MixedParamUrlCodingStrategy("/log", LogPage.class, new String[] { "r", "h" }));
|
| | | mount(new MixedParamUrlCodingStrategy("/tags", TagsPage.class, new String[] { "r" }));
|
| | | mount(new MixedParamUrlCodingStrategy("/branches", BranchesPage.class, new String[] { "r" }));
|
| | | mount(new MixedParamUrlCodingStrategy("/commit", CommitPage.class, new String[] { "r", "h" }));
|
| | | mount(new MixedParamUrlCodingStrategy("/tag", TagPage.class, new String[] { "r", "h" }));
|
| | | mount(new MixedParamUrlCodingStrategy("/tree", TreePage.class, new String[] { "r", "h", "f" }));
|
| | | mount(new MixedParamUrlCodingStrategy("/blob", BlobPage.class, new String[] { "r", "h", "f" }));
|
| | | mount(new MixedParamUrlCodingStrategy("/raw", RawPage.class, new String[] { "r", "h", "f" }));
|
| | | mount(new MixedParamUrlCodingStrategy("/blobdiff", BlobDiffPage.class, new String[] { "r", "h", "f" }));
|
| | | mount(new MixedParamUrlCodingStrategy("/commitdiff", CommitDiffPage.class, new String[] { "r", "h" }));
|
| | | mount(new MixedParamUrlCodingStrategy("/patch", PatchPage.class, new String[] { "r", "h", "f" }));
|
| | | mount(new MixedParamUrlCodingStrategy("/history", HistoryPage.class, new String[] { "r", "h", "f" }));
|
| | | mount(new MixedParamUrlCodingStrategy("/search", SearchPage.class, new String[] { "r", "h", "a", "c" }));
|
| | | mount("/summary", SummaryPage.class, "r");
|
| | | mount("/log", LogPage.class, "r", "h");
|
| | | mount("/tags", TagsPage.class, "r");
|
| | | mount("/branches", BranchesPage.class, "r");
|
| | | mount("/commit", CommitPage.class, "r", "h");
|
| | | mount("/tag", TagPage.class, "r", "h");
|
| | | mount("/tree", TreePage.class, "r", "h", "f");
|
| | | mount("/blob", BlobPage.class, "r", "h", "f");
|
| | | mount("/raw", RawPage.class, "r", "h", "f");
|
| | | mount("/blobdiff", BlobDiffPage.class, "r", "h", "f");
|
| | | mount("/commitdiff", CommitDiffPage.class, "r", "h");
|
| | | mount("/patch", PatchPage.class, "r", "h", "f");
|
| | | mount("/history", HistoryPage.class, "r", "h", "f");
|
| | | mount("/search", SearchPage.class);
|
| | | mount("/metrics", MetricsPage.class, "r");
|
| | | mount("/blame", BlamePage.class, "r", "h", "f");
|
| | |
|
| | | // setup ticket urls
|
| | | mount(new MixedParamUrlCodingStrategy("/tickets", TicketsPage.class, new String[] { "r" }));
|
| | | mount(new MixedParamUrlCodingStrategy("/ticket", TicketPage.class, new String[] { "r", "h", "f" }));
|
| | | mount("/tickets", TicketsPage.class, "r");
|
| | | mount("/ticket", TicketPage.class, "r", "h", "f");
|
| | |
|
| | | // setup the markdown urls
|
| | | mount(new MixedParamUrlCodingStrategy("/markdown", MarkdownPage.class, new String[] { "r", "h", "f" }));
|
| | | |
| | | // setup login/logout urls, if we are using authentication
|
| | | if (useAuthentication) {
|
| | | mount(new MixedParamUrlCodingStrategy("/login", LoginPage.class, new String[] {}));
|
| | | mount(new MixedParamUrlCodingStrategy("/logout", LogoutPage.class, new String[] {}));
|
| | | mount("/docs", DocsPage.class, "r");
|
| | | mount("/markdown", MarkdownPage.class, "r", "h", "f");
|
| | |
|
| | | // federation urls
|
| | | mount("/proposal", ReviewProposalPage.class, "t");
|
| | | mount("/registration", FederationRegistrationPage.class, "u", "n");
|
| | |
|
| | | mount("/activity", ActivityPage.class, "r", "h");
|
| | | mount("/gravatar", GravatarProfilePage.class, "h");
|
| | | }
|
| | |
|
| | | private void mount(String location, Class<? extends WebPage> clazz, String... parameters) {
|
| | | if (parameters == null) {
|
| | | parameters = new String[] {};
|
| | | }
|
| | | if (!GitBlit.getBoolean(Keys.web.mountParameters, true)) {
|
| | | parameters = new String[] {};
|
| | | }
|
| | | mount(new GitblitParamUrlCodingStrategy(location, clazz, parameters));
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | |
|
| | | @Override
|
| | | public final String getConfigurationType() {
|
| | | if (GitBlit.self().isDebugMode())
|
| | | if (GitBlit.isDebugMode()) {
|
| | | return Application.DEVELOPMENT;
|
| | | }
|
| | | return Application.DEPLOYMENT;
|
| | | }
|
| | |
|