| | |
| | | import ro.fortsoft.pf4j.PluginState; |
| | | import ro.fortsoft.pf4j.PluginWrapper; |
| | | |
| | | import com.gitblit.AvatarGenerator; |
| | | import com.gitblit.IStoredSettings; |
| | | import com.gitblit.Keys; |
| | | import com.gitblit.extensions.GitblitWicketPlugin; |
| | |
| | | import com.gitblit.manager.IUserManager; |
| | | import com.gitblit.tickets.ITicketService; |
| | | import com.gitblit.transport.ssh.IPublicKeyManager; |
| | | import com.gitblit.utils.XssFilter; |
| | | import com.gitblit.wicket.pages.ActivityPage; |
| | | import com.gitblit.wicket.pages.BlamePage; |
| | | import com.gitblit.wicket.pages.BlobDiffPage; |
| | |
| | | |
| | | private final IStoredSettings settings; |
| | | |
| | | private final XssFilter xssFilter; |
| | | |
| | | private final IRuntimeManager runtimeManager; |
| | | |
| | | private final IPluginManager pluginManager; |
| | |
| | | this.publicKeyManagerProvider = publicKeyManagerProvider; |
| | | this.ticketServiceProvider = ticketServiceProvider; |
| | | this.settings = runtimeManager.getSettings(); |
| | | this.xssFilter = runtimeManager.getXssFilter(); |
| | | this.runtimeManager = runtimeManager; |
| | | this.pluginManager = pluginManager; |
| | | this.notificationManager = notificationManager; |
| | |
| | | |
| | | // setup the standard gitweb-ish urls |
| | | mount("/repositories", RepositoriesPage.class); |
| | | mount("/overview", OverviewPage.class, "r", "h"); |
| | | mount("/overview", OverviewPage.class, "r"); |
| | | mount("/summary", SummaryPage.class, "r"); |
| | | mount("/reflog", ReflogPage.class, "r", "h"); |
| | | mount("/reflog", ReflogPage.class, "r"); |
| | | mount("/commits", LogPage.class, "r", "h"); |
| | | mount("/log", LogPage.class, "r", "h"); |
| | | mount("/tags", TagsPage.class, "r"); |
| | |
| | | mount("/mytickets", MyTicketsPage.class, "r", "h"); |
| | | |
| | | // setup the markup document urls |
| | | mount("/docs", DocsPage.class, "r"); |
| | | mount("/docs", DocsPage.class, "r", "h"); |
| | | mount("/doc", DocPage.class, "r", "h", "f"); |
| | | |
| | | // federation urls |
| | |
| | | } |
| | | } |
| | | |
| | | // customize the Wicket class resolver to load from plugins |
| | | // customize the Wicket class resolver to load from plugins |
| | | IClassResolver coreResolver = getApplicationSettings().getClassResolver(); |
| | | PluginClassResolver classResolver = new PluginClassResolver(coreResolver, pluginManager); |
| | | getApplicationSettings().setClassResolver(classResolver); |
| | | PluginClassResolver classResolver = new PluginClassResolver(coreResolver, pluginManager); |
| | | getApplicationSettings().setClassResolver(classResolver); |
| | | |
| | | getMarkupSettings().setDefaultMarkupEncoding("UTF-8"); |
| | | |
| | | buildAvatarGenerator(); |
| | | |
| | | } |
| | | |
| | | /* (non-Javadoc) |
| | |
| | | if (!settings.getBoolean(Keys.web.mountParameters, true)) { |
| | | parameters = new String[] {}; |
| | | } |
| | | mount(new GitblitParamUrlCodingStrategy(settings, location, clazz, parameters)); |
| | | mount(new GitblitParamUrlCodingStrategy(settings, xssFilter, location, clazz, parameters)); |
| | | |
| | | // map the mount point to the cache control definition |
| | | if (clazz.isAnnotationPresent(CacheControl.class)) { |
| | |
| | | @Override |
| | | public IStoredSettings settings() { |
| | | return settings; |
| | | } |
| | | |
| | | /* (non-Javadoc) |
| | | * @see com.gitblit.wicket.Webapp#xssFilter() |
| | | */ |
| | | @Override |
| | | public XssFilter xssFilter() { |
| | | return xssFilter; |
| | | } |
| | | |
| | | /* (non-Javadoc) |
| | |
| | | public static GitBlitWebApp get() { |
| | | return (GitBlitWebApp) WebApplication.get(); |
| | | } |
| | | |
| | | AvatarGenerator generator = null; |
| | | @SuppressWarnings("unchecked") |
| | | private void buildAvatarGenerator() { |
| | | Class<AvatarGenerator> clazz; |
| | | try { |
| | | clazz = (Class<AvatarGenerator>) getClass().getClassLoader().loadClass(settings.getString(Keys.web.avatarClass, "com.gitblit.GravatarGenerator")); |
| | | generator = clazz.newInstance(); |
| | | generator.configure(settings); |
| | | } catch (ClassNotFoundException | SecurityException | InstantiationException | IllegalAccessException e) { |
| | | throw new RuntimeException(e); |
| | | } |
| | | |
| | | } |
| | | |
| | | public String buildAvatarUrl(String username, String emailaddress, String cssClass, int width, boolean identicon) { |
| | | if (width <= 0) { |
| | | width = 50; |
| | | } |
| | | if(generator != null) { |
| | | return (String) generator.getURL(username, emailaddress, identicon, width); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | | } |