Esempio n. 1
0
                patterns = $.Array.map(list, function (item, index) {

                    var src = Attribute.get(item, 'src');
                    if (!src) {
                        console.log('JsList 块里的 script 标签必须含有 src 属性:'.bgRed, item);
                        throw new Error();
                    }

                    var index = Lines.getIndex(lines, item, startIndex);
                    var line = lines[index];    //整一行的 html。

                    //所在的行给注释掉了,忽略
                    if (Lines.commented(line, item)) {
                        return null;
                    }

                    startIndex = index + 1; //下次搜索的起始行号
                    
                    if (Url.checkFull(src)) { //是绝对(外部)地址
                        console.log('JsList 块里的 script 标签 src 属性不能引用外部地址:'.bgRed, item);
                        throw new Error();
                    }

                    src = Path.format(src);
                    return src;
                });
Esempio n. 2
0
            list = $.Array.map(list, function (item, index) {

                var href = Attribute.get(item, 'href');
                if (!href) {
                    return null;
                }

                var index = Lines.getIndex(lines, item, startIndex);
                startIndex = index + 1;     //下次搜索的起始行号。 这里要先加

                var line = lines[index];    //整一行的 html。
                lines[index] = null;        //先清空,后续会在 mix() 中重新计算而填进去。

                //所在的行给注释掉了,忽略
                if (Lines.commented(line, item)) {
                    return null;
                }

                var file = Path.join(meta.dir, href);

                return {
                    'file': file,
                    'index': index,     //行号,从 0 开始。
                    'html': item,       //标签的 html 内容。
                    'line': line,       //整一行的 html 内容。
                };
            });
Esempio n. 3
0
            list = $.Array.map(list, function (item, index) {

                //不含有 src 属性,忽略掉。
                var src = Attribute.get(item, 'src');
                if (!src) {
                    return null;
                }

                //该 script 标签出现在 JsList 块里,忽略掉。
                if (JsList.has(item)) {
                    return null;
                }

                var index = Lines.getIndex(lines, item, startIndex);
                var line = lines[index];    //整一行的 html。
                lines[index] = null;        //先清空,后续会在 mix() 中重新计算而填进去。

                //所在的行给注释掉了,忽略掉。
                if (Lines.commented(line, item)) {
                    return null;
                }


                startIndex = index + 1; //下次搜索的起始行号
            
                var suffix = Url.suffix(src);
                var prefix = suffix ? src.slice(0, -suffix.length) : src;
                var ext = $.String.endsWith(prefix, debug) ? debug :
                        $.String.endsWith(prefix, min) ? min :
                        path.extname(prefix);

                var name = ext ? prefix.slice(0, -ext.length) : prefix;

                var file = '';

                if (!Url.checkFull(src)) { //不是绝对(外部)地址
                    file = Path.format(src);
                    file = Path.join(meta.dir, file);
             
                    FileRefs.add(file);
                }
                


                return {
                    'file': file,       //完整的物理路径。 如果是外部地址,则为空字符串。
                    'src': src,         //原始地址,带 query 和 hash 部分。
                    'suffix': suffix,   //扩展名之后的部分,包括 '?' 在内的 query 和 hash 一整体。
                    'name': name,       //扩展名之前的部分。
                    'ext': ext,         //路径中的后缀名,如 '.debug.js'|'.min.js'|'.js'。
                    'index': index,     //行号,从 0 开始。
                    'html': item,       //标签的 html 内容。
                    'line': line,       //整一行的 html 内容。
                    'build': {},        //记录 build() 的输出结果。
                };

            });
Esempio n. 4
0
            list = $.Array.map(list, function (item, index) {

                var index = Lines.getIndex(lines, item, startIndex);
                var line = lines[index]; //整一行的 html
                startIndex = index + 1; //下次搜索的起始行号

                //所在的行给注释掉了,忽略
                if (Lines.commented(line, item)) {
                    return null;
                }

                var href = Attribute.get(item, 'href');
                if (!href) {
                    return null;
                }

                var file = '';
                var prefix = Attribute.get(item, 'prefix');

                if (prefix) {
                    var selector = ' ' + prefix + '="' + href + '"';  //如 ` data-panel="/User/List" `
                    var matches = LogicFile.get(selector);

                    file = matches[0];

                    if (!file) {
                        console.log('无法找到内容中含有 '.bgRed, selector.bgYellow, ' 的 html 文件'.bgRed);
                        throw new Error();
                    }

                    if (matches.length > 1) {
                        console.log('找到多个内容中含有 '.bgRed, selector.bgYellow, ' 的 html 文件'.bgRed);
                        Log.logArray(matches, 'yellow');
                        throw new Error();
                    }

                    href = Path.relative(meta.dir, file);
                }
                else {
                    //以 '/' 开头,如 '/panel.html',则补充完名称。
                    if (href.slice(0, 1) == '/') {
                        href = meta.base + href;
                    }

                    file = path.join(meta.dir, href);
                }
                

                href = Path.format(href);
                file = Path.format(file);

                FileRefs.add(file); //添加文件引用计数。
               

                var pad = line.indexOf(item);       //前导空格数
                pad = new Array(pad + 1).join(' '); //产生指定数目的空格

                var dir = Path.dirname(file);


                //递归下级页面

                //下级节点的基目录,根据当前页面的文件名得到
                var ext = path.extname(file);
                var base = path.basename(file, ext);


                var master = File.read(file);
                var links = new HtmlLinks(dir, { 'base': base });
                var list = links.parse(master);

                if (list && list.length > 0) {
                    console.log('复合片段'.bgMagenta, file.bgMagenta);
                }
            
                return {
                    'href': href,   //原始地址
                    'file': file,   //完整的物理路径。 
                    'index': index, //行号,从 0 开始
                    'html': item,   //标签的 html 内容
                    'line': line,   //整一行的 html 内容
                    'pad': pad,     //前导空格
                    'dir': dir,     //所在的目录
                    'name': base,   //基本名称,如 'CardList'
                    'links': links,  //下级页面
                };

            });