Esempio n. 1
0
 this.handle = function(req, res, next) {
     var path = Url.parse(req.url).pathname;
     
     this.indexRe = this.indexRe || new RegExp("^" + lang.escapeRegExp(this.options.baseUrl) + "(?:\\/(?:index.html?)?)?$");
     this.workspaceRe = this.workspaceRe || new RegExp("^" + lang.escapeRegExp(this.options.davPrefix) + "(\\/|$)");
     
     if (path.match(this.indexRe)) {            
         if (req.method !== "GET")
             return next();
         this.$serveIndex(req, res, next);
     }
     else if (path.match(this.workspaceRe)) {
         if (!this.davInited) {
             if(process.platform == "sunos"){
                 this.davServer.plugins["codesearch"].GREP_CMD = __dirname+"/../../support/gnu-builds/grep-sunos";
                 this.davServer.plugins["filesearch"].FIND_CMD = __dirname+"/../../support/gnu-builds/find-sunos";
             }
             this.davServer.plugins["permission"] = DavPermission;
             this.davInited = true;
             this.emit("configureDav", this.davServer);
         }
         this.davServer.permissions = this.getPermissions(req);
         this.davServer.exec(req, res);
     } else {
         next();
     }
 };
Esempio n. 2
0
    logNodeStream : function(data, stream, useOutput) {
        var colors = {
            30: "#eee",
            31: "red",
            32: "green",
            33: "yellow",
            34: "blue",
            35: "magenta",
            36: "cyan",
            37: "#eee"
        };

        workspaceDir = ide.workspaceDir;
        davPrefix = ide.davPrefix;

        var lines = data.split("\n");
        var style = "color:#eee;";
        var log = [];
        // absolute workspace files
        var wsRe = new RegExp(lang.escapeRegExp(workspaceDir) + "\\/([^:]*)(:\\d+)(:\\d+)*", "g");
        // relative workspace files
        var wsrRe = /(?:\s|^|\.\/)([\w\_\$-]+(?:\/[\w\_\$-]+)+(?:\.[\w\_\$]+))?(\:\d+)(\:\d+)*/g;

        for (var i=0; i<lines.length; i++) {
            if (!lines[i]) continue;
            log.push("<div class='item'><span style='" + style + "'>" + lines[i]
                .replace(wsRe, "<a href='javascript:void(0)' onclick='require(\"ext/console/console\").jump(\"" + davPrefix + "/$1\", \"$2\", \"$3\")'>"+workspaceDir+"/$1$2$3</a>")
                .replace(wsrRe, "<a href='javascript:void(0)' onclick='require(\"ext/console/console\").jump(\"" + davPrefix + "/$1\", \"$2\", \"$3\")'>$1$2$3</a>")
                .replace(/\s{2,}/g, function(str) {
                    return lang.stringRepeat("&nbsp;", str.length)
                })
                .replace(/(((http:\/\/)|(www\.))[\w\d\.-]*(:\d+)?(\/[\w\d]+)?)/, "<a href='$1' target='_blank'>$1</a>")
                // tty escape sequences (http://ascii-table.com/ansi-escape-sequences.php)
                .replace(/(\u0007|\u001b)\[(K|2J)/g, "")
                .replace(/\033\[(?:(\d+);)?(\d+)m/g, function(m, extra, color) {
                    style = "color:" + (colors[color] || "#eee");
                    if (extra == 1) {
                        style += ";font-weight=bold"
                    } else if (extra == 4) {
                        style += ";text-decoration=underline";
                    }
                    return "</span><span style='" + style + "'>"
                }) + "</span></div>");
        }

        (useOutput ? txtOutput : txtConsole).addValue(log.join(""));
    },
Esempio n. 3
0
    this.$assembleRegExp = function() {
        if (this.$options.regExp) {
            var needle = this.$options.needle;
        } else {
            needle = lang.escapeRegExp(this.$options.needle);
        }

        if (this.$options.wholeWord) {
            needle = "\\b" + needle + "\\b";
        }

        var modifier = "g";
        if (!this.$options.caseSensitive) {
            modifier += "i";
        }

        var re = new RegExp(needle, modifier);
        return re;
    };