public CoffeeScriptCompiler(@Path("classpath:org/apache/tapestry5/webresources/internal/coffee-script.js") Resource mainCompiler, @Path("classpath:org/apache/tapestry5/webresources/internal/invoke-coffeescript.js") Resource shim, OperationTracker tracker) { executorPool = new RhinoExecutorPool(tracker, toList(mainCompiler, shim)); }
protected final void train_value(Path annotation, String value) { expect(annotation.value()).andReturn(value).atLeastOnce(); }
public CoffeeScriptCompiler(@Path("classpath:org/apache/tapestry5/webresources/internal/coffee-script.js") Resource mainCompiler, @Path("classpath:org/apache/tapestry5/webresources/internal/invoke-coffeescript.js") Resource shim, OperationTracker tracker) { executorPool = new RhinoExecutorPool(tracker, toList(mainCompiler, shim)); }
public boolean provideInjection(PlasticField field, ObjectLocator locator, MutableComponentModel componentModel) { Path path = field.getAnnotation(Path.class); if (path == null) { return false; } final String assetPath = path.value(); final String libraryName = componentModel.getLibraryName(); ComputedValue<Asset> computedAsset = new ComputedValue<Asset>() { public Asset get(InstanceContext context) { ComponentResources resources = context.get(ComponentResources.class); // Note how this works: the resources represents the actual instantiated class, and the libraryName // comes from the componentModel, potentially, the componentModel of a base class (which may have // a different library name than the subclass). return assetSource.getComponentAsset(resources, assetPath, libraryName); } }; field.injectComputed(computedAsset); return true; }
public TypeScriptCompiler(final OperationTracker tracker, @Path("classpath:org/apache/tapestry5/webresources/internal/typescript.js") final Resource typescript) { this.executorPool = new RhinoExecutorPool(tracker, Arrays.<Resource> asList(typescript, new ClasspathResource("org/apache/tapestry5/webresources/internal/invoke-typescript.js"))); }
/** * Provides the asset. If the expression does not identify an asset domain, with a prefix, it is assumed to be a * path on the classpath, relative to the root of the classpath. * * @param objectType the type of object (which must be Object or Asset) * @param locator not used */ public <T> T provide(Class<T> objectType, AnnotationProvider annotationProvider, ObjectLocator locator) { Path path = annotationProvider.getAnnotation(Path.class); if (path == null) return null; String expanded = symbolSource.expandSymbols(path.value()); Asset asset = source.getAsset(null, expanded, null); return typeCoercer.coerce(asset, objectType); } }
public class MissingAssetDemo { @Inject @Path("does-not-exist.txt") private Asset missing; }
public class TestPageForAsset { @Inject @Path("context:css/test.css") private Asset asset; public String getStylePath() { return asset.toClientURL(); } }
@Contribute(ModuleManager.class) public static void setupFoundationFramework(MappedConfiguration<String, Object> configuration, @Symbol(SymbolConstants.JAVASCRIPT_INFRASTRUCTURE_PROVIDER) String provider, @Path("classpath:org/apache/tapestry5/t5-core-dom-prototype.js") Resource domPrototype, @Path("classpath:org/apache/tapestry5/t5-core-dom-jquery.js") Resource domJQuery) { if (provider.equals("prototype")) { configuration.add("t5/core/dom", new JavaScriptModuleConfiguration(domPrototype)); } if (provider.equals("jquery")) { configuration.add("t5/core/dom", new JavaScriptModuleConfiguration(domJQuery)); } // If someone wants to support a different infrastructure, they should set the provider symbol to some other value // and contribute their own version of the t5/core/dom module. }
@Contribute(ModuleManager.class) public static void setupComponentsShims( MappedConfiguration<String, Object> configuration, @Inject @Path("/META-INF/modules/tjq/datefield.js") Resource datefield, @Inject @Path("${jquery.assets.root}/vendor/jquery.mousewheel.js") Resource jquerymousewheel, @Symbol(JQuerySymbolConstants.ADD_MOUSEWHEEL_EVENT) boolean mouseWheelIncluded) { configuration.add("t5/core/datefield", new JavaScriptModuleConfiguration(datefield)); if (mouseWheelIncluded) configuration.add("vendor/jquerymousewheel", new JavaScriptModuleConfiguration(jquerymousewheel) .dependsOn("jquery")); }
@Contribute(ModuleManager.class) public static void setupBaseModules(MappedConfiguration<String, Object> configuration, @Path("${tapestry.asset.root}/underscore-shim.js") Resource underscoreShim, @Path("${tapestry.asset.root}/jquery-shim.js") Resource jqueryShim, @Path("${tapestry.asset.root}/typeahead.js") Resource typeahead, @Path("${tapestry.asset.root}/moment-2.15.1.js") Resource moment, @Path("${" + SymbolConstants.BOOTSTRAP_ROOT + "}/js/transition.js") Resource transition) { // The underscore shim module allows Underscore to be injected configuration.add("underscore", new JavaScriptModuleConfiguration(underscoreShim)); configuration.add("jquery", new JavaScriptModuleConfiguration(jqueryShim)); configuration.add("bootstrap/transition", new AMDWrapper(transition).require("jquery", "$").asJavaScriptModuleConfiguration()); for (String name : new String[]{"affix", "alert", "button", "carousel", "collapse", "dropdown", "modal", "scrollspy", "tab", "tooltip"}) { Resource lib = transition.forFile(name + ".js"); configuration.add("bootstrap/" + name, new AMDWrapper(lib).require("bootstrap/transition").asJavaScriptModuleConfiguration()); } Resource popover = transition.forFile("popover.js"); configuration.add("bootstrap/popover", new AMDWrapper(popover).require("bootstrap/tooltip").asJavaScriptModuleConfiguration()); configuration.add("t5/core/typeahead", new JavaScriptModuleConfiguration(typeahead).dependsOn("jquery")); configuration.add("moment", new JavaScriptModuleConfiguration(moment)); }
@Path("${jquery.assets.root}/vendor/components/superfish/css/superfish-vertical.css") private Asset verticalAsset; @Path("${jquery.assets.root}/vendor/components/superfish/css/superfish-navbar.css") private Asset navBarAsset; @Path("${jquery.assets.root}/vendor/components/superfish/css/superfish.css") private Asset mainAsset;
@Path("context:images/tapestry_banner.gif") private Asset icon; @Path("tapestry-button.png") private Asset button; @Path("AssetDemo.properties") private Asset properties; @Path("context:css/ie-only.css") private Asset ieOnly; @Path("http://${d3.url}") private Asset httpAsset; @Path("https://${d3.url}") private Asset httpsAsset; @Path("//${d3.url}") private Asset protocolRelativeAsset; @Path("ftp://${d3.url}") private Asset ftpAsset; @Path("tapestry.png") private Asset logo;
@Path("${tapestry.asset.root}/ajax-loader.gif") private Asset spacerImage;