All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.lonelystorm.air.asset.sightly.IncludeAssetLibrary Maven / Gradle / Ivy

Go to download

The LonelyStorm Air Asset library provides support to be able to compile SASS files at runtime.

There is a newer version: 0.1.8
Show newest version
package com.lonelystorm.air.asset.sightly;

import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.Set;

import com.adobe.cq.sightly.WCMUse;
import com.lonelystorm.air.asset.models.AssetLibrary;
import com.lonelystorm.air.asset.models.AssetTheme;
import com.lonelystorm.air.asset.services.LibraryResolver;
import com.lonelystorm.air.asset.util.AssetLibraryUtil;

public class IncludeAssetLibrary extends WCMUse {

    private Set libraries;

    private Set subLibraries;

    @Override
    public void activate() throws Exception {
        LibraryResolver resolver = getSlingScriptHelper().getService(LibraryResolver.class);
        String categories = get("categories", String.class);
        String themes = get("themes", String.class);

        libraries = AssetLibraryUtil.categories(resolver, categories);
        subLibraries = AssetLibraryUtil.themes(resolver, libraries, themes);
    }

    public String include() {
        StringWriter sw = new StringWriter();
        PrintWriter writer = new PrintWriter(sw);

        for (AssetLibrary library : libraries) {
            writer.println(AssetLibraryUtil.include(library.getPath(), "css"));
        }

        for (AssetTheme theme : subLibraries) {
            writer.println(AssetLibraryUtil.include(theme.getPath(), "css"));
        }

        return sw.toString();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy