Examples of CssCompiler


Examples of com.dotcms.enterprise.csspreproc.CSSCompiler

            }
           
            // choose compiler based on the request URI
            Class<? extends CSSCompiler> compilerClass = reqURI.startsWith("/DOTSASS/") ? SassCompiler.class
                                           (reqURI.startsWith("/DOTLESS/") ? LessCompiler.class : null);
            CSSCompiler compiler = compilerClass.getConstructor(Host.class,String.class,boolean.class).newInstance(host,uri,live);
           
            // check if the asset exists
            String actualUri =  uri.substring(0, uri.lastIndexOf('.')) + "." + compiler.getDefaultExtension();
            Identifier ident = APILocator.getIdentifierAPI().find(host, actualUri);
            if(ident==null || !InodeUtils.isSet(ident.getId())) {
                resp.sendError(404);
                return;
            }
           
            // get the asset in order to build etag and check permissions
            long defLang=APILocator.getLanguageAPI().getDefaultLanguage().getId();
            FileAsset fileasset;
            try {
                fileasset = APILocator.getFileAssetAPI().fromContentlet(
                    APILocator.getContentletAPI().findContentletByIdentifier(ident.getId(), live, defLang, user, true));
            }
            catch(DotSecurityException ex) {
                resp.sendError(403);
                return;
            }
           
            boolean userHasEditPerms = false;
            if(!live) {
                userHasEditPerms = APILocator.getPermissionAPI().doesUserHavePermission(fileasset,PermissionAPI.PERMISSION_EDIT,user);
                if(req.getParameter("recompile")!=null && userHasEditPerms) {
                    CacheLocator.getCSSCache().remove(host.getIdentifier(), actualUri, false);
                    CacheLocator.getCSSCache().remove(host.getIdentifier(), actualUri, true);
                }
            }
           
            CachedCSS cache = CacheLocator.getCSSCache().get(host.getIdentifier(), actualUri, live, user);
           
            byte[] responseData=null;
            Date cacheMaxDate=null;
            CachedCSS cacheObject=null;
           
            if(cache==null || cache.data==null) {
                // do compile!
                synchronized(ident.getId().intern()) {
                    cache = CacheLocator.getCSSCache().get(host.getIdentifier(), actualUri, live, user);
                    if(cache==null || cache.data==null) {
                        Logger.debug(this, "compiling css data for "+host.getHostname()+":"+uri);
                       
                        try {
                            compiler.compile();
                        }
                        catch(Throwable ex) {
                            Logger.error(this, "Error compiling "+host.getHostname()+":"+uri, ex);
                            throw new Exception(ex);
                        }
                       
                        // build cache object
                        ContentletVersionInfo vinfo = APILocator.getVersionableAPI().getContentletVersionInfo(ident.getId(), defLang);
                        CachedCSS newcache = new CachedCSS();
                        newcache.data = compiler.getOutput();
                        newcache.hostId = host.getIdentifier();
                        newcache.uri = actualUri;
                        newcache.live = live;
                        newcache.modDate = vinfo.getVersionTs();
                        newcache.imported = new ArrayList<ImportedAsset>();
                        for(String importUri : compiler.getAllImportedURI()) {
                            // newcache entry for the imported asset
                            ImportedAsset asset = new ImportedAsset();
                            asset.uri = importUri;
                            Identifier ii;
                            if(importUri.startsWith("//")) {
                                importUri=importUri.substring(2);
                                String hn=importUri.substring(0, importUri.indexOf('/'));
                                String uu=importUri.substring(importUri.indexOf('/'));
                                ii = APILocator.getIdentifierAPI().find(APILocator.getHostAPI().findByName(hn, user, live),uu);
                            }
                            else {
                                ii = APILocator.getIdentifierAPI().find(host, importUri);
                            }
                            ContentletVersionInfo impInfo = APILocator.getVersionableAPI().getContentletVersionInfo(ii.getId(), defLang);
                            asset.modDate = impInfo.getVersionTs();
                            newcache.imported.add(asset);
                            Logger.debug(this, host.getHostname()+":"+actualUri+" imports-> "+importUri);
                           
                            // actual cache entry for the imported asset. If needed
                            synchronized(ii.getId().intern()) {
                                if(CacheLocator.getCSSCache().get(ii.getHostId(), importUri, live, user)==null) {
                                    CachedCSS entry = new CachedCSS();
                                    entry.data = null;
                                    entry.hostId = ii.getHostId();
                                    entry.imported = new ArrayList<ImportedAsset>();
                                    entry.live = live;
                                    entry.modDate = impInfo.getVersionTs();
                                    entry.uri = importUri;
                                    CacheLocator.getCSSCache().add(entry);
                                }
                            }
                        }
                        CacheLocator.getCSSCache().add(newcache);
                        cacheMaxDate = newcache.getMaxDate();
                        cacheObject = newcache;
                        responseData = compiler.getOutput();
                    }
                }
            }
           
            if(responseData==null) {
View Full Code Here

Examples of com.volantis.styling.compiler.CSSCompiler

    private void checkNormalization(
            Document actualXml, String expectedStyledElements,
            List indexedProperties,
            final String deviceCSS) {
        CSSCompiler compiler = StylingFactory.getDefaultInstance()
                .createDeviceCSSCompiler(DeviceOutlook.OPTIMISTIC);
        CompiledStyleSheet deviceStyleSheet = compiler.compile(
                new StringReader(deviceCSS), null);

        PropertyDetailsSet detailsSet =
                PropertyDetailsSetHelper.getDetailsSet(indexedProperties);
View Full Code Here

Examples of com.volantis.styling.compiler.CSSCompiler

        // Create a CSS compiler.
        CSSCompilerBuilder builder = new CSSCompilerBuilder();
        builder.setStyleSheetCompilerFactory(
                ThemeStyleSheetCompilerFactory.getDefaultInstance());
        CSSCompiler cssCompiler = builder.getCSSCompiler();

        final CompiledStyleSheet compiledStyleSheet =
            cssCompiler.compile(reader, null);

        pageContext.getStylingEngine().pushStyleSheet(compiledStyleSheet);
    }
View Full Code Here

Examples of com.volantis.styling.compiler.CSSCompiler

        try {
            // Create a CSS compiler.
            CSSCompilerBuilder builder = new CSSCompilerBuilder();
            builder.setStyleSheetCompilerFactory(
                    DefaultStyleSheetCompilerFactory.getDefaultInstance());
            CSSCompiler cssCompiler = builder.getCSSCompiler();

            // convert the css into StyleSheet
            final InputStreamReader reader = new InputStreamReader(
                    cssInputResourceStream);
            compiledStyleSheet = cssCompiler.compile(reader, null);

        } catch (ExceptionInInitializerError e) {
        }

        return compiledStyleSheet;
View Full Code Here

Examples of com.volantis.styling.compiler.CSSCompiler

        ExtractorConfigurationBuilder extractorBuilder =
                extractorFactory.createConfigurationBuilder();
        extractorBuilder.setDetailsSet(detailsSet);
        extractorBuilder.setSupportedShorthands(supportedShorthands);

        CSSCompiler compiler = StylingFactory.getDefaultInstance()
                .createDeviceCSSCompiler(DeviceOutlook.OPTIMISTIC);
        CompiledStyleSheet deviceStyleSheet = compiler.compile(
                new StringReader(DevicePolicyConstants.DEFAULT_DISPLAY_CSS), null);
        extractorBuilder.setDeviceStyleSheet(deviceStyleSheet);

        ExtractorConfiguration configuration =
                extractorBuilder.buildConfiguration();
View Full Code Here

Examples of com.volantis.styling.compiler.CSSCompiler

        // Create a CSS compiler.
        CSSCompilerBuilder compilerBuilder = new CSSCompilerBuilder();
        StyleSheetCompilerFactory compilerFactory =
                getStyleSheetCompilerFactory();
        compilerBuilder.setStyleSheetCompilerFactory(compilerFactory);
        CSSCompiler cssCompiler = compilerBuilder.getCSSCompiler();

        CompiledStyleSheet defaultCompiledStyleSheet;
        try {
            URL url = getClass().getResource("/com/volantis/mcs/runtime/default.css");
            InputStream stream = url.openStream();
            defaultCompiledStyleSheet = cssCompiler.compile(
                    new InputStreamReader(stream), null);
        } catch (IOException e) {
            throw new ExtendedRuntimeException(e);
        }
View Full Code Here

Examples of com.volantis.styling.compiler.CSSCompiler

        // The default display values used by the device.
        defaultCSS = DevicePolicyConstants.DEFAULT_DISPLAY_CSS + defaultCSS;

        StylingFactory factory = StylingFactory.getDefaultInstance();
        CSSCompiler compiler = factory.createDeviceCSSCompiler(
                DeviceOutlook.REALISTIC);

        return compiler.compile(new StringReader(defaultCSS), sourceDescription);
    }
View Full Code Here

Examples of com.volantis.styling.compiler.CSSCompiler

        // =====================================================================
        //   Test Expectations
        // =====================================================================

        CSSCompiler compiler = factory.createDeviceCSSCompiler(DeviceOutlook.REALISTIC);
        CompiledStyleSheet compiledSheet = compiler.compile(new StringReader(
                "* {text-align: left}" +
                "a {font-family: <not-set>}" +
                "a:link {font-size: <unknown> !-medium}" +
                "a:link:hover {color: <default>}" +
                "a:first-letter:link {color: green}"),
View Full Code Here

Examples of com.volantis.styling.compiler.CSSCompiler

        // Create a CSS compiler.
        CSSCompilerBuilder builder = new CSSCompilerBuilder();
        builder.setStyleSheetCompilerFactory(
                DefaultStyleSheetCompilerFactory.getDefaultInstance());
        CSSCompiler cssCompiler = builder.getCSSCompiler();

        // Compile and push the system default style sheet into the styling
        // engine.
        CompiledStyleSheet defaultCompiledStyleSheet;
        try {
            URL url = getClass().getResource("/com/volantis/mcs/runtime/default.css");
            InputStream stream = url.openStream();
            defaultCompiledStyleSheet = cssCompiler.compile(
                    new InputStreamReader(stream), null);
        } catch (IOException e) {
            throw new ExtendedRuntimeException(e);
        }
        stylingEngine.pushStyleSheet(defaultCompiledStyleSheet);
View Full Code Here

Examples of com.volantis.styling.compiler.CSSCompiler

            builder.setProject(pageContext.getCurrentProject());
            builder.setBaseURL(pageContext.getBaseURL());
            builder.setStyleSheetCompilerFactory(
                    ThemeStyleSheetCompilerFactory.getDefaultInstance());
            builder.setParserMode(CSSParserMode.LAX);
            CSSCompiler cssCompiler = builder.getCSSCompiler();

            // Parse and compile the style sheet.
            CompiledStyleSheet compiledStyleSheet =
                    cssCompiler.compile(new StringReader(css), null);

            // adding style sheet to the list of style sheets
            // that should be stored for current element
            StylingEngine stylingEngine = pageContext.getStylingEngine();
            stylingEngine.addNestedStyleSheet(compiledStyleSheet);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.