| | |
| | | public abstract class BasePage extends SessionPage {
|
| | |
|
| | | private final Logger logger;
|
| | | |
| | |
|
| | | private transient TimeUtils timeUtils;
|
| | |
|
| | | public BasePage() {
|
| | |
| | | logger = LoggerFactory.getLogger(getClass());
|
| | | customizeHeader();
|
| | | }
|
| | | |
| | |
|
| | | private void customizeHeader() {
|
| | | if (GitBlit.getBoolean(Keys.web.useResponsiveLayout, true)) {
|
| | | add(CSSPackageResource.getHeaderContribution("bootstrap/css/bootstrap-responsive.css"));
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | protected String getLanguageCode() {
|
| | | return GitBlitWebSession.get().getLocale().getLanguage();
|
| | | }
|
| | | |
| | |
|
| | | protected String getCountryCode() {
|
| | | return GitBlitWebSession.get().getLocale().getCountry().toLowerCase();
|
| | | }
|
| | | |
| | |
|
| | | protected TimeUtils getTimeUtils() {
|
| | | if (timeUtils == null) {
|
| | | ResourceBundle bundle; |
| | | ResourceBundle bundle;
|
| | | try {
|
| | | bundle = ResourceBundle.getBundle("com.gitblit.wicket.GitBlitWebApp", GitBlitWebSession.get().getLocale());
|
| | | } catch (Throwable t) {
|
| | |
| | | }
|
| | | return timeUtils;
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | protected void onBeforeRender() {
|
| | | if (GitBlit.isDebugMode()) {
|
| | |
| | | }
|
| | | super.onAfterRender();
|
| | | }
|
| | | |
| | |
|
| | | @Override
|
| | | protected void setHeaders(WebResponse response) {
|
| | | int expires = GitBlit.getInteger(Keys.web.pageCacheExpires, 0);
|
| | |
| | | super.setHeaders(response);
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * Sets the last-modified header date, if appropriate, for this page. The
|
| | | * date used is determined by the CacheControl annotation.
|
| | | * |
| | | *
|
| | | */
|
| | | protected void setLastModified() {
|
| | | if (getClass().isAnnotationPresent(CacheControl.class)) {
|
| | |
| | | }
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * Sets the last-modified header field and the expires field.
|
| | | * |
| | | *
|
| | | * @param when
|
| | | */
|
| | | protected final void setLastModified(Date when) {
|
| | | if (when == null) {
|
| | | return;
|
| | | }
|
| | | |
| | |
|
| | | if (when.before(GitBlit.getBootDate())) {
|
| | | // last-modified can not be before the Gitblit boot date
|
| | | // this helps ensure that pages are properly refreshed after a
|
| | | // server config change
|
| | | when = GitBlit.getBootDate();
|
| | | }
|
| | | |
| | |
|
| | | int expires = GitBlit.getInteger(Keys.web.pageCacheExpires, 0);
|
| | | WebResponse response = (WebResponse) getResponse();
|
| | | response.setLastModifiedTime(Time.valueOf(when));
|
| | |
| | | }
|
| | | return map;
|
| | | }
|
| | | |
| | |
|
| | | protected Map<AccessPermission, String> getAccessPermissions() {
|
| | | Map<AccessPermission, String> map = new LinkedHashMap<AccessPermission, String>();
|
| | | for (AccessPermission type : AccessPermission.values()) {
|
| | |
| | | }
|
| | | return map;
|
| | | }
|
| | | |
| | |
|
| | | protected Map<FederationStrategy, String> getFederationTypes() {
|
| | | Map<FederationStrategy, String> map = new LinkedHashMap<FederationStrategy, String>();
|
| | | for (FederationStrategy type : FederationStrategy.values()) {
|
| | |
| | | }
|
| | | return map;
|
| | | }
|
| | | |
| | |
|
| | | protected Map<AuthorizationControl, String> getAuthorizationControls() {
|
| | | Map<AuthorizationControl, String> map = new LinkedHashMap<AuthorizationControl, String>();
|
| | | for (AuthorizationControl type : AuthorizationControl.values()) {
|
| | |
| | | HttpServletRequest req = servletWebRequest.getHttpServletRequest();
|
| | | return req.getServerName();
|
| | | }
|
| | | |
| | |
|
| | | protected List<ProjectModel> getProjectModels() {
|
| | | final UserModel user = GitBlitWebSession.get().getUser();
|
| | | List<ProjectModel> projects = GitBlit.self().getProjectModels(user, true);
|
| | | return projects;
|
| | | }
|
| | | |
| | |
|
| | | protected List<ProjectModel> getProjects(PageParameters params) {
|
| | | if (params == null) {
|
| | | return getProjectModels();
|
| | |
| | | public void warn(String message, Throwable t) {
|
| | | logger.warn(message, t);
|
| | | }
|
| | | |
| | |
|
| | | public void error(String message, boolean redirect) {
|
| | | error(message, null, redirect ? getApplication().getHomePage() : null);
|
| | | }
|
| | |
| | | public void error(String message, Throwable t, boolean redirect) {
|
| | | error(message, t, getApplication().getHomePage());
|
| | | }
|
| | | |
| | |
|
| | | public void error(String message, Throwable t, Class<? extends Page> toPage) {
|
| | | error(message, t, toPage, null);
|
| | | }
|
| | | |
| | |
|
| | | public void error(String message, Throwable t, Class<? extends Page> toPage, PageParameters params) {
|
| | | if (t == null) {
|
| | | logger.error(message + " for " + GitBlitWebSession.get().getUsername());
|