Package kiss

Examples of kiss.XML


     *
     * @param file
     */
    private synchronized XML rebuild(Path file) {
        long now = new Date().getTime();
        XML html = I.xml(file);

        // append live coding script
        html.find("script[src=\"application.js\"]").after(I
                .xml("script")
                .attr("type", "text/javascript")
                .attr("src", "live.js"));

        // ignore cache
        for (XML link : html.find("link[rel=stylesheet]")) {
            String href = link.attr("href");

            if (href.length() != 0 && !href.startsWith("http://") && !href.startsWith("htttps://")) {
                link.attr("href", href + "?" + now);
            }
        }

        for (XML link : html.find("script[src]")) {
            String src = link.attr("src");

            if (src.length() != 0 && !src.startsWith("http://") && !src.startsWith("htttps://")) {
                link.attr("src", src + "?" + now);
            }
View Full Code Here


            this.connection.setMaxIdleTime(Integer.MAX_VALUE);

            // observe html
            Events<WatchEvent<Path>> observable = I.observe(html);

            XML xml = I.xml(html);

            // observe js
            for (XML js : xml.find("script[src]")) {
                String src = js.attr("src");

                if (src.length() != 0 && !src.startsWith("http://") && !src.startsWith("https://")) {
                    observable = observable.merge(observeFile(src));
                }
            }
            observable = observable.merge(observeFile("live.js"));

            // observe css
            for (XML css : xml.find("link[rel=stylesheet]")) {
                String href = css.attr("href");

                if (href.length() != 0 && !href.startsWith("http://") && !href.startsWith("https://")) {
                    observable = observable.merge(observeFile(href));
                }
View Full Code Here

     * </p>
     *
     * @param file
     */
    private void buildHTML() throws Exception {
        XML html = I.xml("html");
        XML head = html.child("head");
        head.child("meta").attr("charset", "utf-8");
        head.child("link").attr("type", "text/css").attr("rel", "stylesheet").attr("href", "normalize.css");
        head.child("link").attr("type", "text/css").attr("rel", "stylesheet").attr("href", config.root.relativize(css));

        XML body = html.child("body");
        body.child("header").attr("id", "Header");
        body.child("div").attr("id", "Content");
        body.child("footer").attr("id", "Footer");

        body.child("script").attr("type", "text/javascript").attr("src", "pointer-events.js");
        body.child("script").attr("type", "text/javascript").attr("src", "boot.js");
        body.child("script").attr("type", "text/javascript").attr("src", config.root.relativize(js));

        html.to(new HTMLWriter(Files.newBufferedWriter(this.html, I.$encoding)));
    }
View Full Code Here

TOP

Related Classes of kiss.XML

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.