use of com.adobe.granite.ui.clientlibs.HtmlLibrary in project acs-aem-commons by Adobe-Consulting-Services.
the class VersionedClientlibsTransformerFactory method getUriInfo.
@Nonnull
UriInfo getUriInfo(@Nullable final String uri, @Nonnull ResourceResolver resourceResolver) {
if (uri != null) {
Matcher matcher = FILTER_PATTERN.matcher(uri);
if (matcher.matches()) {
final String libraryPath = matcher.group(1);
final String md5 = matcher.group(2);
final String extension = matcher.group(3);
LibraryType libraryType;
if (LibraryType.CSS.extension.substring(1).equals(extension)) {
libraryType = LibraryType.CSS;
} else {
libraryType = LibraryType.JS;
}
final HtmlLibrary htmlLibrary = getLibrary(libraryType, libraryPath, resourceResolver);
return new UriInfo(libraryPath + "." + extension, md5, libraryType, htmlLibrary);
}
}
return new UriInfo("", "", null, null);
}
use of com.adobe.granite.ui.clientlibs.HtmlLibrary in project aem-core-wcm-components by Adobe-Marketing-Cloud.
the class ClientLibrariesImpl method getInline.
/**
* Returns a concatenated string of the content of all the client libraries, given a library type.
*
* @param libraryType - the type of the library
*
* @return The concatenated string of the content of all the client libraries
*/
private String getInline(LibraryType libraryType) {
Collection<ClientLibrary> clientlibs = htmlLibraryManager.getLibraries(categoriesArray, libraryType, true, false);
// Iterate through the clientlibs and aggregate their content.
StringBuilder output = new StringBuilder();
for (ClientLibrary clientlib : clientlibs) {
HtmlLibrary htmlLibrary = htmlLibraryManager.getLibrary(libraryType, clientlib.getPath());
if (htmlLibrary != null) {
try {
output.append(IOUtils.toString(htmlLibrary.getInputStream(htmlLibraryManager.isMinifyEnabled()), StandardCharsets.UTF_8));
} catch (IOException e) {
LOG.error("Error getting input stream from clientlib with path '{}'.", clientlib.getPath());
}
}
}
return output.toString();
}
Aggregations