Package com.vaadin.sass.internal

Examples of com.vaadin.sass.internal.ScssStylesheet


            for (FileInfo fileInfo : scssFiles) {
                logger.log(TreeLogger.INFO, "   " + fileInfo.originalScssPath
                        + " -> " + fileInfo.getOriginalCssPath());

                try {
                    ScssStylesheet scss = ScssStylesheet.get(fileInfo
                            .getAbsolutePath());
                    if (!fileInfo.isMixin()) {
                        scss.compile();
                        InputStream is = new ByteArrayInputStream(scss
                                .printState().getBytes());

                        toReturn.add(this.emitInputStream(logger, is,
                                fileInfo.getOriginalCssPath()));
                    }
View Full Code Here


        String stylesCssName = stylesCssDir + variant + ".css";

        // Process as SASS file
        String sassFile = stylesCssDir + variant + ".scss";

        ScssStylesheet scss = ScssStylesheet.get(sassFile);
        if (scss == null) {
            throw new IllegalArgumentException("SASS file: " + sassFile
                    + " not found");
        }
        scss.compile();
        String filteredScss = scss.printState().replace("@version@", version);

        BufferedWriter out = new BufferedWriter(new FileWriter(stylesCssName));
        out.write(cssHeader.toString());
        out.write(filteredScss);
        out.close();
View Full Code Here

    }

    private ScssCacheEntry compileScssOnTheFly(String filename,
            String scssFilename, ServletContext sc) throws IOException {
        String realFilename = sc.getRealPath(scssFilename);
        ScssStylesheet scss = ScssStylesheet.get(realFilename);
        if (scss == null) {
            // Not a file in the file system (WebContent directory). Use the
            // identifier directly (VAADIN/themes/.../styles.css) so
            // ScssStylesheet will try using the class loader.
            if (scssFilename.startsWith("/")) {
                scssFilename = scssFilename.substring(1);
            }

            scss = ScssStylesheet.get(scssFilename);
        }

        if (scss == null) {
            getLogger()
                    .log(Level.WARNING,
                            "Scss file {0} exists but ScssStylesheet was not able to find it",
                            scssFilename);
            return null;
        }
        try {
            getLogger().log(Level.FINE, "Compiling {0} for request to {1}",
                    new Object[] { realFilename, filename });
            scss.compile();
        } catch (Exception e) {
            getLogger().log(Level.WARNING, "Scss compilation failed", e);
            return null;
        }

        return new ScssCacheEntry(scss.printState(), scss.getSourceUris());
    }
View Full Code Here

    private final ScssStylesheet styleSheet;
    Stack<Node> nodeStack = new Stack<Node>();

    public SCSSDocumentHandlerImpl() {
        this(new ScssStylesheet());
    }
View Full Code Here

        }

        // You can set the resolver; if none is set, VaadinResolver will be used
        // ScssStylesheet.setStylesheetResolvers(new VaadinResolver());

        ScssStylesheet scss = ScssStylesheet.get(input);
        if (scss == null) {
            System.err.println("The scss file " + input
                    + " could not be found.");
            return;
        }

        scss.compile();
        if (output == null) {
            System.out.println(scss.toString());
        } else {
            writeFile(output, scss.toString());
        }
    }
View Full Code Here

        String stylesCssName = stylesCssDir + variant + ".css";

        // Process as SASS file
        String sassFile = stylesCssDir + variant + ".scss";

        ScssStylesheet scss = ScssStylesheet.get(sassFile);
        if (scss == null) {
            throw new IllegalArgumentException("SASS file: " + sassFile
                    + " not found");
        }
        scss.compile();
        BufferedWriter out = new BufferedWriter(new FileWriter(stylesCssName));
        out.write(cssHeader.toString());
        out.write(scss.toString().replace("@version@", version));
        out.close();

        System.out.println("Compiled CSS to " + stylesCssName + " ("
                + scss.toString().length() + " bytes)");

        createSprites(themeFolder, themeName);
        File oldCss = new File(stylesCssName);
        File newCss = new File(stylesCssDir + variant + "-sprite.css");
View Full Code Here

import com.vaadin.sass.internal.util.StringUtil;

public class ImportNodeHandler {

    public static void traverse(Node node) {
        ScssStylesheet styleSheet = null;
        if (node instanceof ScssStylesheet) {
            styleSheet = (ScssStylesheet) node;
        } else {
            // iterate to parents of node, find ScssStylesheet
            Node parent = node.getParentNode();
            while (parent != null && !(parent instanceof ScssStylesheet)) {
                parent = parent.getParentNode();
            }
            if (parent instanceof ScssStylesheet) {
                styleSheet = (ScssStylesheet) parent;
            }
        }
        if (styleSheet == null) {
            throw new ParseException("Nested import in an invalid context");
        }
        ArrayList<Node> c = new ArrayList<Node>(node.getChildren());
        for (Node n : c) {
            if (n instanceof ImportNode) {
                ImportNode importNode = (ImportNode) n;
                if (!importNode.isPureCssImport()) {
                    try {
                        StringBuilder filePathBuilder = new StringBuilder(
                                styleSheet.getFileName());
                        filePathBuilder.append(File.separatorChar).append(
                                importNode.getUri());
                        if (!filePathBuilder.toString().endsWith(".scss")) {
                            filePathBuilder.append(".scss");
                        }

                        // set parent's charset to imported node.
                        ScssStylesheet imported = ScssStylesheet.get(
                                filePathBuilder.toString(),
                                styleSheet.getCharset());
                        if (imported == null) {
                            imported = ScssStylesheet.get(importNode.getUri());
                        }
                        if (imported == null) {
                            throw new FileNotFoundException(importNode.getUri()
                                    + " (parent: "
                                    + ScssStylesheet.get().getFileName() + ")");
                        }

                        traverse(imported);

                        String prefix = getUrlPrefix(importNode.getUri());
                        if (prefix != null) {
                            updateUrlInImportedSheet(imported, prefix);
                        }

                        node.appendChildrenAfter(
                                new ArrayList<Node>(imported.getChildren()),
                                importNode);
                        node.removeChild(importNode);
                    } catch (CSSException e) {
                        e.printStackTrace();
                    } catch (IOException e) {
View Full Code Here

            return true;
        }

        synchronized (SCSS_MUTEX) {
            String realFilename = sc.getRealPath(scssFilename);
            ScssStylesheet scss = ScssStylesheet.get(realFilename);
            if (scss == null) {
                // Not a file in the file system (WebContent directory). Use the
                // identifier directly (VAADIN/themes/.../styles.css) so
                // ScssStylesheet will try using the class loader.
                if (scssFilename.startsWith("/")) {
                    scssFilename = scssFilename.substring(1);
                }

                scss = ScssStylesheet.get(scssFilename);
            }

            if (scss == null) {
                getLogger()
                        .log(Level.WARNING,
                                "Scss file {0} exists but ScssStylesheet was not able to find it",
                                scssFilename);
                return false;
            }
            try {
                getLogger().log(Level.FINE, "Compiling {0} for request to {1}",
                        new Object[] { realFilename, filename });
                scss.compile();
            } catch (Exception e) {
                getLogger().log(Level.WARNING, "Scss compilation failed", e);
                return false;
            }

            // This is for development mode only so instruct the browser to
            // never
            // cache it
            response.setHeader("Cache-Control", "no-cache");
            final String mimetype = getService().getMimeType(filename);
            writeResponse(response, mimetype, scss.toString());

            return true;
        }
    }
View Full Code Here

    private final ScssStylesheet styleSheet;
    Stack<Node> nodeStack = new Stack<Node>();

    public SCSSDocumentHandlerImpl() {
        this(new ScssStylesheet());
    }
View Full Code Here

                        if (!filePathBuilder.toString().endsWith(".scss")) {
                            filePathBuilder.append(".scss");
                        }

                        // set parent's charset to imported node.
                        ScssStylesheet imported = ScssStylesheet.get(
                                filePathBuilder.toString(), node.getCharset());
                        if (imported == null) {
                            imported = ScssStylesheet.get(importNode.getUri());
                        }
                        if (imported == null) {
                            throw new FileNotFoundException(importNode.getUri()
                                    + " (parent: "
                                    + ScssStylesheet.get().getFileName() + ")");
                        }

                        traverse(imported);

                        String prefix = getUrlPrefix(importNode.getUri());
                        if (prefix != null) {
                            updateUrlInImportedSheet(imported, prefix);
                        }

                        Node pre = importNode;
                        for (Node importedChild : new ArrayList<Node>(
                                imported.getChildren())) {
                            node.appendChild(importedChild, pre);
                            pre = importedChild;
                        }
                        node.removeChild(importNode);
                    } catch (CSSException e) {
View Full Code Here

TOP

Related Classes of com.vaadin.sass.internal.ScssStylesheet

Copyright © 2018 www.massapicom. 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.