protected final void train_getAsset(AssetSource source, Resource root, String path, Locale locale, Asset asset) { expect(source.getAsset(root, path, locale)).andReturn(asset); }
public List<Asset> getJavaScriptLibraries() { String jQueryUIPath = symbolSource.valueForSymbol(JQuerySymbolConstants.JQUERY_UI_PATH); if ( ! jQueryUIPath.endsWith("/")) { jQueryUIPath += "/"; } final List<Asset> javaScriptStack = new ArrayList<Asset>(); javaScriptStack.add(assetSource.getClasspathAsset(String.format("%s/datepicker.js", jQueryUIPath))); final Asset datePickerI18nAsset = getLocaleAsset(threadLocale.getLocale(), jQueryUIPath); if (includeDatePickerI18N && datePickerI18nAsset != null) { javaScriptStack.add(datePickerI18nAsset); } javaScriptStack.add(assetSource.getExpandedAsset("${assets.path}/components/datefield/datefield.js")); return javaScriptStack; }
public Asset map(String assetPath) { return assetSource.getComponentAsset(resources, assetPath, libraryName); } }).toArray(Asset.class);
public Asset map(String path) { Asset asset = assetSource.getExpandedAsset(path); return asset; } };
protected final void train_getClasspathAsset(AssetSource source, String path, Locale locale, Asset asset) { expect(source.getClasspathAsset(path, locale)).andReturn(asset); }
@Inject private AssetSource assetSource; @Inject private Locale locale; public String getImageURL() { URL assetUrl = assetSource.getContextAsset("img/score/overall/" + getImageFilename(), locale).toURL(); return assetUrl.toString(); }
public Resource coerce(String input) { return assetSource.resourceForPath(input); } }));
boolean setupRender() { if (!componentResources.isBound("path")) { logger.warn("You have to specify a path for the showSource component"); return false; } if (componentResources.isBound("endLine")) { if (endLine < beginLine) { logger.warn("The endLine parameter has to be greater than beginLine"); return false; } } /** * Init the Default parameter for the jQuery plugin */ defaultSpecs = new JSONObject(); if (beginLine > 0) { defaultSpecs.put("firstLineNumber", beginLine); } defaultSpecs.put("readOnly", true); defaultSpecs.put("lineNumbers", true); // defaultSpecs.put("clipboard", defaultSpecs.put( "clipboard", assetSource.getUnlocalizedAsset( "META-INF/modules/tjq/source.js").toClientURL()); return true; }
public Asset map(String path) { return assetSource.getExpandedAsset(path); } };
protected final void train_getClasspathAsset(AssetSource source, String path, Asset asset) { expect(source.getClasspathAsset(path)).andReturn(asset); }
public Binding newBinding(String description, ComponentResources container, ComponentResources component, String expression, Location location) { Asset asset = source.getContextAsset(expression, container.getLocale()); return new AssetBinding(location, description, asset); } }
public boolean handleAssetRequest(Request request, Response response, String extraPath) throws IOException { ChecksumPath path = new ChecksumPath(streamer, baseFolder, extraPath); final boolean handled; if (classpathAssetProtectionRule.block(path.resourcePath)) { handled = false; } else { Resource resource = assetSource.resourceForPath(path.resourcePath); handled = path.stream(resource); } return handled; } }
public Asset map(String value) { return assetSource.getExpandedAsset(value); }
Asset asset = assetSource.getAsset(baseResource, url, null);
private Asset getLocaleAsset(Locale locale, String jQueryUIPath) { final String prefix = String.format("%s/i18n/datepicker-%s", jQueryUIPath, locale.getLanguage()); final Resource withCountryExtension = typeCoercer.coerce(String.format("%s-%s.js", prefix, locale.getCountry()), Resource.class); if (withCountryExtension.exists()) { return assetSource.getClasspathAsset(withCountryExtension.getPath()); } final Resource withLanguageExtension = typeCoercer.coerce(String.format("%s.js", prefix), Resource.class); if (withLanguageExtension.exists()) { return assetSource.getClasspathAsset(withLanguageExtension.getPath()); } return null; }
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); } };
public ModuleManagerImpl(ResponseCompressionAnalyzer compressionAnalyzer, AssetSource assetSource, Map<String, JavaScriptModuleConfiguration> configuration, Messages globalMessages, StreamableResourceSource streamableResourceSource, @Symbol(SymbolConstants.COMPACT_JSON) boolean compactJSON, @Symbol(SymbolConstants.PRODUCTION_MODE) boolean productionMode, @Symbol(SymbolConstants.MODULE_PATH_PREFIX) String modulePathPrefix, PathConstructor pathConstructor) { this.compressionAnalyzer = compressionAnalyzer; this.globalMessages = globalMessages; this.compactJSON = compactJSON; basePath = pathConstructor.constructClientPath(modulePathPrefix); compressedBasePath = pathConstructor.constructClientPath(modulePathPrefix + ".gz"); classpathRoot = assetSource.resourceForPath(""); extensions = CollectionFactory.newSet("js"); extensions.addAll(streamableResourceSource.fileExtensionsForContentType(InternalConstants.JAVASCRIPT_CONTENT_TYPE)); baseConfig = buildBaseConfig(configuration, !productionMode); }
public List<Asset> getJavaScriptLibraries() { final List<Asset> javaScriptStack = new ArrayList<Asset>(); javaScriptStack.add(assetSource.getExpandedAsset("${assets.path}/components/slider/slider.js")); javaScriptStack.add(assetSource.getExpandedAsset("${jquery.ui.path}/jquery.ui.mouse.js")); javaScriptStack.add(assetSource.getExpandedAsset("${jquery.ui.path}/jquery.ui.slider.js")); return javaScriptStack; }
/** * 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); } }
@Test public void get_classpath_asset() { AssetFactory factory = mockAssetFactory(); ThreadLocale threadLocale = mockThreadLocale(); Asset asset = mockAsset(); Resource expectedResource = baseResource.forFile("SimpleComponent_en_GB.properties"); train_getRootResource(factory, rootResource); train_createAsset(factory, expectedResource, asset); Map<String, AssetFactory> configuration = Collections.singletonMap("classpath", factory); replay(); AssetSource source = new AssetSourceImpl(threadLocale, configuration, null, null, tracker); // First try creates it: assertSame(source.getClasspathAsset("org/apache/tapestry5/internal/services/SimpleComponent.properties", Locale.UK), asset); verify(); }