Show
Ignore:
Timestamp:
12/11/07 23:46:45 (5 years ago)
Author:
cho45
Message:

lang/javascript/blosxom.rhino/blosxom.rhino.js:

path_info によるフィルタリングを実装

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • lang/javascript/blosxom.rhino/blosxom.rhino.js

    r3053 r3055  
    2525                        return b.datetime.valueOf() - a.datetime.valueOf(); 
    2626                }); 
     27 
     28                var path_info = this.getenv("PATH_INFO") || "/intro"; 
     29                if (path_info.match(RegExp("^/(\\d{4})(?:/(\\d\\d)(?:/(\\d\\d))?)?"))) { 
     30                        var year = +RegExp.$1, month = RegExp.$2 - 1, day = +RegExp.$3; 
     31                        entries = entries.filter(function (i) { 
     32                                return [ 
     33                                        {k:"getFullYear",v:year}, 
     34                                        {k:"getMonth", v:month}, 
     35                                        {k:"getDate",v:day} 
     36                                ].every(function (j) { 
     37                                        // p([j.k, i.datetime[j.k](), j.v]); 
     38                                        return (j.v <= 0) || i.datetime[j.k]() == j.v 
     39                                }); 
     40                        }); 
     41                } else { 
     42                        try { 
     43                                entries = entries.filter(function (i) { 
     44                                        if (i.name == path_info) throw ["only-match", i]; 
     45                                        return RegExp("^"+path_info).test(i.name); 
     46                                }); 
     47                        } catch (e) { 
     48                                if (e[0] != "only-match") throw e; 
     49                                // only match 
     50                                entries = [e[1]]; 
     51                        } 
     52                } 
     53 
     54 
    2755                var template = new EJS(this._readLines("template.html").join("\n")); 
    28                 // p(entries); 
     56//              p(entries); 
     57//              return; 
    2958 
    3059                System.out.println(template.run({ 
     
    83112 
    84113        getenv : function (name) { 
    85                 return String(System.getenv(name)); 
     114                return String(System.getenv(name) || ""); 
    86115        }, 
    87116}; 
     
    114143 
    115144new BlosxomRhino({ 
    116         title    : "Blosxo.Rhino!", 
     145        title    : "Blosxom.Rhino!", 
    117146        data_dir : "data", 
    118147}).run();