/** * installs the webjars resource finder and uses a set of default settings. * * @param app the wicket application */ public static void install(final WebApplication app) { install(app, null); }
@Override public void init(Application application) { if (WicketWebjars.isInstalled(application) == false) { WicketWebjars.install((org.apache.wicket.protocol.http.WebApplication) application); } }
/** * Install 2 default collector instances: (FileAssetPathCollector(WEBJARS_PATH_PREFIX), JarAssetPathCollector), * and a webjars resource finder. * * <p> * Factored out for easy (informal) pluggability. * </p> */ protected void configureWebJars() { IWebjarsSettings settings = new WebjarsSettings(); WicketWebjars.install(this, settings); }
/** * installs the webjars resource finder * * @param app the wicket application * @param settings the settings to use */ public static void install(WebApplication app, IWebjarsSettings settings) { final IWebjarsSettings existingSettings = settings(app); if (existingSettings == null) { if (settings == null) { settings = new WebjarsSettings(); } app.setMetaData(WEBJARS_SETTINGS_METADATA_KEY, settings); if (settings.useCdnResources()) { mountCDNMapper(app, settings.cdnUrl()); } final List<IResourceFinder> finders = app.getResourceSettings().getResourceFinders(); final WebjarsResourceFinder finder = new WebjarsResourceFinder(settings); if (!finders.contains(finder)) { finders.add(finder); } LOG.info("initialize wicket webjars with given settings: {}", settings); } }
WicketWebjars.install(this, webjarSettings); mountPackage("org.orienteer.core.web"); mountPackage("org.orienteer.core.resource"); if(renderStrategy!=null) getRequestCycleSettings().setRenderStrategy(renderStrategy); getJavaScriptLibrarySettings().setJQueryReference(new WebjarsJavaScriptResourceReference("jquery/current/jquery.min.js"));
@Test public void findFileWithoutVersion() throws ResourceStreamNotFoundException, IOException { WebjarsResourceFinder finder = new WebjarsResourceFinder(WicketWebjars.settings()); IResourceStream stream = finder.find(IWebjarsResourceReference.class, useRecent("/webjars/jquery/current/jquery.min.js")); assertThat(stream, is(not(nullValue()))); assertThat(IOUtils.toString(stream.getInputStream()), startsWith("/*! jQuery v2.2.1")); }
@Test public void isInstalled() throws Exception { WebApplication application = tester.getApplication(); assertThat(WicketWebjars.isInstalled(application), is(false)); WicketWebjars.install(application); assertThat(WicketWebjars.isInstalled(application), is(true)); } }
/** * https://github.com/l0rdn1kk0n/wicket-bootstrap/issues/280 * * Return {@code null} for missing resources */ @Test public void findNonExistingFile() { WebjarsResourceFinder finder = new WebjarsResourceFinder(WicketWebjars.settings()); assertNull(finder.find(String.class, "non existing")); }
public void reload(long wait) throws ServletException { if(!reloading) { LOG.info("Start reload doOrienteerFilter with doOrienteerFilter config: " + filterConfig); reloading = true; destroy(); try { Thread.currentThread().sleep(wait); } catch (InterruptedException e) { /*NOP*/ } OrienteerClassLoaderUtil.reindex(); init(filterConfig); WicketWebjars.reindex(OrienteerWebApplication.lookupApplication()); reloading = false; } }
@Override public void init(WebApplication webApplication) { WebjarsSettings settings = new WebjarsSettings(); WicketWebjars.install(webApplication, settings); wicketEndpointRepository.add(new WicketAutoConfig.Builder(this.getClass()) .withDetail("properties", props) .build()); }
/** * installs the webjars resource finder and uses a set of default settings. * * @param app the wicket application */ public static void install(final WebApplication app) { install(app, null); }
/** * installs the webjars resource finder * * @param app the wicket application * @param settings the settings to use */ public static void install(WebApplication app, IWebjarsSettings settings) { final IWebjarsSettings existingSettings = settings(app); if (existingSettings == null) { if (settings == null) { settings = new WebjarsSettings(); } app.setMetaData(WEBJARS_SETTINGS_METADATA_KEY, settings); if (settings.useCdnResources()) { mountCDNMapper(app, settings.cdnUrl()); } final List<IResourceFinder> finders = app.getResourceSettings().getResourceFinders(); final WebjarsResourceFinder finder = new WebjarsResourceFinder(settings); if (!finders.contains(finder)) { finders.add(finder); } LOG.info("initialize wicket webjars with given settings: {}", settings); } }
@Test public void findFile() throws ResourceStreamNotFoundException, IOException { WebjarsResourceFinder finder = new WebjarsResourceFinder(WicketWebjars.settings()); IResourceStream stream = finder.find(IWebjarsResourceReference.class, "/webjars/jquery/2.2.1/jquery.min.js"); assertThat(stream, is(not(nullValue()))); assertThat(IOUtils.toString(stream.getInputStream()), startsWith("/*! jQuery v2.2.1")); }
/** * https://github.com/l0rdn1kk0n/wicket-webjars/issues/20 * * Return {@code null} for missing resources */ @Test public void findWithNullScope() { WebjarsResourceFinder finder = new WebjarsResourceFinder(WicketWebjars.settings()); assertNull(finder.find(null, "non existing")); }
@Override public void init(WebApplication webApplication) { WebjarsSettings settings = new WebjarsSettings(); WicketWebjars.install(webApplication, settings); wicketEndpointRepository.add(new WicketAutoConfig.Builder(this.getClass()) .withDetail("properties", props) .build()); }
@Override protected void init() { super.init(); WicketWebjars.install(this); } });
@Test public void findOnGAE() throws ResourceStreamNotFoundException, IOException { System.setProperty("com.google.appengine.runtime.environment", "Production"); WebjarsResourceFinder finder = new WebjarsResourceFinder(WicketWebjars.settings()); IResourceStream stream = finder.find(IWebjarsResourceReference.class, "/webjars/jquery/2.2.1/jquery.min.js"); System.setProperty("com.google.appengine.runtime.environment", ""); assertThat(stream, is(not(nullValue()))); assertThat(IOUtils.toString(stream.getInputStream()), startsWith("/*! jQuery v2.2.1")); }
protected void initBootstrap() { LessCompilerConfigurationFactory lessConfigFactory = () -> { Configuration lessConfig = new Configuration(); lessConfig.setCompressing( RuntimeConfigurationType.DEPLOYMENT.equals(getConfigurationType())); return lessConfig; }; WicketWebjars.install(this); BootstrapLess.install(this, lessConfigFactory); Bootstrap.install(this); IBootstrapSettings settings = Bootstrap.getSettings(this); settings.setCssResourceReference(CustomBootstrapLessReference.get()); }
protected void initBootstrap() { LessCompilerConfigurationFactory lessConfigFactory = () -> { Configuration lessConfig = new Configuration(); lessConfig.setCompressing( RuntimeConfigurationType.DEPLOYMENT.equals(getConfigurationType())); return lessConfig; }; WicketWebjars.install(this); BootstrapLess.install(this, lessConfigFactory); Bootstrap.install(this); IBootstrapSettings settings = Bootstrap.getSettings(this); settings.setCssResourceReference(CustomBootstrapLessReference.get()); }
WicketWebjars.install((WebApplication) app, webjarsSettings);