| 94 | | # read in a tiddler from a .js and a .js.meta pair of files |
| 95 | | begin #use begin rescue block since there may not be a .meta file if the attributes are obtained from the .recipe file |
| 96 | | open(filename + ".meta") do |infile| |
| 97 | | infile.each_line do |line| |
| 98 | | c = line.index(':') |
| 99 | | if(c != nil) |
| 100 | | key = line[0, c].strip |
| 101 | | value = line[(c + 1)...line.length].strip |
| 102 | | key2 = key |
| 103 | | k = key.index('.') |
| 104 | | if(k != nil) |
| 105 | | key2 = key[(k + 1)...key.length] |
| 106 | | end |
| 107 | | if(@sliceAttributeNames.include?(key2)) |
| 108 | | @sliceAttributes[key2] = value |
| 109 | | else |
| 110 | | case key |
| 111 | | when "title" |
| 112 | | @title = value |
| 113 | | when "tiddler" |
| 114 | | @title = value |
| 115 | | when "modifier" |
| 116 | | @modifier = value |
| 117 | | when "created" |
| 118 | | @created = value |
| 119 | | when "modified" |
| 120 | | @modified = value |
| 121 | | when "tags" |
| 122 | | @tags = value |
| 123 | | else |
| 124 | | @extendedAttributes[key] = value |
| 125 | | end |
| 126 | | end |
| 127 | | end |
| 128 | | end |
| 129 | | end |
| 130 | | rescue |
| 131 | | end |
| 132 | | open(filename) do |infile| |
| 133 | | @contents = "" |
| 134 | | infile.each_line do |line| |
| 135 | | @contents << line unless(line.strip =~ /^\/\/#/) |
| 136 | | end |
| 137 | | unless filename =~ /^https?/ |
| 138 | | @created ||= infile.mtime.strftime("%Y%m%d%M%S") |
| 139 | | end |
| 140 | | #@modified ||= infile.ctime.strftime("%Y%m%d%M%S") |
| 141 | | end |
| 142 | | @title ||= File.basename(filename,".js") |
| | 94 | if(filename =~ /\.tdw$/) |
| | 95 | loadTiddlyWeb(filename) |
| | 96 | else |
| | 97 | loadJs(filename) |
| | 98 | end |
| | 253 | def loadJs(filename) |
| | 254 | # read in a tiddler from a .js and a .js.meta pair of files |
| | 255 | begin #use begin rescue block since there may not be a .meta file if the attributes are obtained from the .recipe file |
| | 256 | open(filename + ".meta") do |infile| |
| | 257 | infile.each_line do |line| |
| | 258 | readAttributes(line) |
| | 259 | end |
| | 260 | end |
| | 261 | rescue |
| | 262 | end |
| | 263 | open(filename) do |infile| |
| | 264 | @contents = "" |
| | 265 | infile.each_line do |line| |
| | 266 | @contents << line unless(line.strip =~ /^\/\/#/) |
| | 267 | end |
| | 268 | unless filename =~ /^https?/ |
| | 269 | @created ||= infile.mtime.strftime("%Y%m%d%M%S") |
| | 270 | end |
| | 271 | #@modified ||= infile.ctime.strftime("%Y%m%d%M%S") |
| | 272 | end |
| | 273 | @title ||= File.basename(filename,".js") |
| | 274 | end |
| | 275 | |
| | 276 | def loadTiddlyWeb(filename) |
| | 277 | # read in tiddler from a TiddlyWeb file |
| | 278 | @title = File.basename(filename.sub(/\/[0-9]+/,""),".tdw") |
| | 279 | open(filename) do |file| |
| | 280 | inAttributes = true |
| | 281 | @contents = "" |
| | 282 | file.each_line do |line| |
| | 283 | if(line.gsub(" ", "").gsub("\r", "")=="\n") |
| | 284 | inAttributes = false |
| | 285 | end |
| | 286 | if(inAttributes) |
| | 287 | readAttributes(line) |
| | 288 | else |
| | 289 | @contents << line |
| | 290 | end |
| | 291 | end |
| | 292 | end |
| | 293 | end |