1 --- raggle.backup 2010-10-25 08:08:07.626468032 -0400
2 +++ raggle 2010-10-25 08:18:56.812190806 -0400
13 - when /^trade/: '(tm)'
14 - when /^#8212$/n: ","
15 - when /^#8217$/n: "'"
16 - when /^#8218$/n: ","
18 + when 'nbsp' then ' '
19 + when /^quot$/ni then '"'
20 + when /^lt$/ni then '<'
21 + when /^gt$/ni then '>'
22 + when /^copy/ then '(c)'
23 + when /^trade/ then '(tm)'
24 + when /^#8212$/n then ","
25 + when /^#8217$/n then "'"
26 + when /^#8218$/n then ","
28 r = $1.to_i # Integer() interprets leading zeros as octal
29 if !r.between?(0, 255) && munge_uni
34 - when /^#x([0-9a-f]+)$/ni
35 + when /^#x([0-9a-f]+)$/ni then
37 if !r.between?(0, 255) && munge_uni
38 UNICODE_LUT[r] ? UNICODE_LUT[r] : munge_str
40 Parser::each_token(@source) do |token, data, attributes|
41 #puts "C: #{@context[-1]} T: #{token} D: <#{data}> L: #{@lines.inspect}"
45 if @context[-1] == :in_pre
46 tmp = data.split("\n", -1)
53 + when :START_TAG then
54 @current_attributes = attributes
57 context_enter(@context, tag)
58 call_actions(tag, :start)
63 context_exit(@context, tag)
65 max_items = outline.attributes['max_items'] || nil
66 priority = outline.attributes['priority'].to_i || $config['default_feed_priority']
67 # the following properties take effect unless overridden on CLI
68 - if outline.attributes['refresh']: opml_refresh = outline.attributes['refresh'].to_i
69 + if outline.attributes['refresh']
70 + opml_refresh = outline.attributes['refresh'].to_i
71 else opml_refresh = nil; end # fixes clobberation
72 frefresh = refresh || opml_refresh || $config['default_feed_refresh']
73 fsave_items = save_items || outline.attributes['save_items'] || false
76 die "Parsing #{file_name} failed: #{parse_err.message}" unless $wins
78 - if $wins: Interfaces::NcursesInterface::set_status($config['msg_bad_uri'])
80 + Interfaces::NcursesInterface::set_status($config['msg_bad_uri'])
81 else die err.message; end
85 raise "Couldn't open output file \"#{file_name}\"."
88 - if $wins: Interfaces::NcursesInterface::set_status($config['msg_bad_uri'])
90 + Interfaces::NcursesInterface::set_status($config['msg_bad_uri'])
91 else die err.message; end
94 @@ -2010,53 +2013,53 @@
96 gopts.each do |opt, arg|
101 ret['url'] = arg if arg && arg.size > 0
107 + when'--delete' then
108 ret['mode'] = 'delete'
110 - when '--invalidate'
111 + when '--invalidate' then
112 ret['mode'] = 'invalidate'
115 + when '--update' then
116 ret['mode'] = 'update'
117 ret['id'] = (arg && (arg != 'all')) ? arg.to_i : 'all'
118 - when '--config': $config['config_path'] = arg
119 - when '--force': ret['force'] = true
120 - when '--list': ret['mode'] = 'list'
121 - when '--title': ret['title'] = arg
122 - when '--url': ret['url'] = arg
123 - when '--refresh': ret['refresh'] = arg.to_i
125 + when '--config' then $config['config_path'] = arg
126 + when '--force' then ret['force'] = true
127 + when '--list' then ret['mode'] = 'list'
128 + when '--title' then ret['title'] = arg
129 + when '--url' then ret['url'] = arg
130 + when '--refresh' then ret['refresh'] = arg.to_i
131 + when '--version' then
132 puts "Raggle v#$VERSION"
134 - when '--priority': ret['priority'] = arg.to_i
135 - when '--purge': ret['mode'] = 'purge'
137 + when '--priority' then ret['priority'] = arg.to_i
138 + when '--purge' then ret['mode'] = 'purge'
141 - when '--lock-title': ret['lock_title?'] = true
142 - when '--unlock-title': ret['lock_title?'] = false
143 - when '--save-items': ret['save_items?'] = true
145 + when '--lock-title' then ret['lock_title?'] = true
146 + when '--unlock-title' then ret['lock_title?'] = false
147 + when '--save-items' then ret['save_items?'] = true
149 ret['max_items'] = arg.to_i
150 ret['save_items?'] = true if ret['max_items'] > 0
151 - when '--unsave-items': ret['save_items?'] = false
152 - when '--verbose': $config['verbose'] = true
153 - when '--import-opml'
154 + when '--unsave-items' then ret['save_items?'] = false
155 + when '--verbose' then $config['verbose'] = true
156 + when '--import-opml' then
157 ret['mode'] = 'import_opml'
158 ret['opml_file'] = arg
159 - when '--export-opml'
160 + when '--export-opml' then
161 ret['mode'] = 'export_opml'
162 ret['opml_file'] = arg
163 - when '--diag': $config['diag'] = true
164 - when '--default-config'
165 + when '--diag' then $config['diag'] = true
166 + when '--default-config' then
167 ret['mode'] = 'default_config'
168 - when '--ascii': ret['ascii'] = true
170 + when '--ascii' then ret['ascii'] = true
171 + when '--server' then
172 if $HAVE_LIB['webrick']
173 $config['run_http_server'] = true
174 $config['http_server']['port'] = arg.to_i \
175 @@ -2064,16 +2067,16 @@
177 die 'Missing WEBrick, can\'t run HTTP Server.'
179 - when '--drb-server'
180 + when '--drb-server' then
182 $config['run_drb_server'] = true
184 die "Missing DRb, can't run DRb Server."
188 ret['mode'] = 'find_feeds'
189 ret['find_str'] = arg
195 @@ -2153,30 +2156,30 @@
197 def CLI::handle_mode(opts)
205 added = Engine::add_feed opts
206 Engine::save_feed_list if added
210 Engine::delete_feed opts['id']
211 Engine::save_feed_list
214 + when 'invalidate' then
215 Engine::invalidate_feed opts['id']
216 Engine::save_feed_list
220 Engine::edit_feed opts['id'], opts
221 Engine::save_feed_list
226 Engine::save_feed_list
231 Engine.start_grab_log
233 @@ -2193,21 +2196,21 @@
234 Engine::save_feed_list
239 Engine::purge_feed_cache
242 + when 'import_opml' then
243 OPML::import opts['opml_file'], opts['refresh'], opts['lock_title?'], opts['save_items?'],
245 Engine::save_feed_list
248 + when 'export_opml' then
249 OPML::export opts['opml_file']
252 + when 'find_feeds' then
253 CLI::find_feeds(opts['find_str'])
255 - when 'default_config'
256 + when 'default_config' then
260 @@ -2333,10 +2336,10 @@
262 def Key::close_window
264 - when NcursesInterface::get_win_id('find'): $wins[$a_win].close(true)
265 - when NcursesInterface::get_win_id('cat'): $wins[$a_win].close(true)
266 - when NcursesInterface::get_win_id('keys'): $wins[$a_win].close(true)
267 - when NcursesInterface::get_win_id('edit'): $wins[$a_win].close(true)
268 + when NcursesInterface::get_win_id('find') then $wins[$a_win].close(true)
269 + when NcursesInterface::get_win_id('cat') then $wins[$a_win].close(true)
270 + when NcursesInterface::get_win_id('keys') then $wins[$a_win].close(true)
271 + when NcursesInterface::get_win_id('edit') then $wins[$a_win].close(true)
275 @@ -3404,16 +3407,19 @@
278 case feedopt # create options hash to pass to engine
280 - if str =~ /true/i: newopts = {feedopt => true}
281 + when 'save_items?' then
283 + newopts = {feedopt => true}
284 else newopts = {feedopt => false}; end
285 - when 'priority', 'refresh'
286 + when 'priority', 'refresh' then
287 newopts = {feedopt => str.to_i}
289 - if str =~ /none|nil/i: newopts = {feedopt => nil}
290 + when 'max_items' then
291 + if str =~ /none|nil/i
292 + newopts = {feedopt => nil}
293 else newopts = {feedopt => str.to_i}; end
295 - if str =~ /\bnone\b|\bnil\b/i: newopts = {feedopt => nil}
296 + when 'category' then
297 + if str =~ /\bnone\b|\bnil\b/i
298 + newopts = {feedopt => nil}
299 else newopts = {feedopt => str}; end
300 else newopts = {feedopt => str}
302 @@ -3575,7 +3581,7 @@
303 item_content = item_content.gsub(/href\s*=\s*["']([^'"]+?)['"]/m) {
306 - when (/^(\w+):\/\//): m
307 + when (/^(\w+):\/\//) then m
309 # attempt to merge URI with host_uri. if that fails,
310 # log a warning, then fall back to the unmodified string
311 @@ -3599,7 +3605,7 @@
312 # fix host-relative item URL
313 item_url = feed['items'][id]['url'].dup
314 item_url = case item_url
315 - when (/(\w+):\/\//): item_url
316 + when (/(\w+):\/\//) then item_url
317 else [host_uri, item_url].join('/')
320 @@ -3665,8 +3671,8 @@
321 # get browser command
322 cmd = $config['browser_cmd'].map { |cmd_part|
324 - when /%s/: cmd_part % url.escape
325 - when '${browser}': $config['browser']
326 + when /%s/ then cmd_part % url.escape
327 + when '${browser}' then $config['browser']
331 @@ -3833,7 +3839,8 @@
332 # if it's not nil, then add it to our list
334 if url && url.length > 0
335 - if title: added = Engine::add_feed({ 'url' => url, 'title' => title })
337 + added = Engine::add_feed({ 'url' => url, 'title' => title })
338 else added = Engine::add_feed({ 'url' => url }); end
339 NcursesInterface::populate_feed_win
341 @@ -3996,7 +4003,7 @@
346 + when :csv_file then
347 # expand bookmark file path
348 path = Engine::expand_str(bmb[:path])
350 @@ -4020,11 +4027,11 @@
351 status = $config['msg_bm_file_err'] % [path, err.to_s]
352 NcursesInterface::set_status(status)
357 system(bmb[:path], title, url, tags, ext)
364 @@ -4043,7 +4050,7 @@
366 # database-specific connection stuff
370 unless $HAVE_LIB['mysql']
371 raise $config['msg_bm_db_missing'] % 'Mysql'
373 @@ -4052,7 +4059,7 @@
374 db = Mysql::connect(bmb[:host], bmb[:user], bmb[:pass])
375 db.select_db(bmb[:dbname])
376 quote_meth = Mysql::method(:escape_string)
379 unless $HAVE_LIB['sqlite']
380 raise $config['msg_bm_db_missing'] % 'SQLite'
382 @@ -4112,13 +4119,13 @@
384 key = key.gsub(/^KEY_/, '')
386 - when 'DC': key = 'Delete'
387 - when ' ': key = 'Space'
388 - when 'NPAGE': key = 'Page Down'
389 - when 'PPAGE': key = 'Page Up'
390 - when '\f': key = 'Control-L'
391 - when ' ': key = 'Tab'
392 - when /^\d$/: key = '1-9'
393 + when 'DC' then key = 'Delete'
394 + when ' ' then key = 'Space'
395 + when 'NPAGE' then key = 'Page Down'
396 + when 'PPAGE' then key = 'Page Up'
397 + when '\f' then key = 'Control-L'
398 + when ' ' then key = 'Tab'
399 + when /^\d$/ then key = '1-9'
401 unless key == old_key # remove cruft if key info updated
402 keys[key] = keys[old_key]
403 @@ -4251,9 +4258,9 @@
405 $config['theme']['window_order'].each { |i|
407 - when /feed/: cl = NcursesInterface::ListWindow
408 - when /item/: cl = NcursesInterface::ListWindow
409 - when /desc/: cl = NcursesInterface::TextWindow
410 + when /feed/ then cl = NcursesInterface::ListWindow
411 + when /item/ then cl = NcursesInterface::ListWindow
412 + when /desc/ then cl = NcursesInterface::TextWindow
414 raise "Unknown window #{i}"
416 @@ -4285,7 +4292,7 @@
420 - when Ncurses::KEY_MOUSE
421 + when Ncurses::KEY_MOUSE then
422 mev = Ncurses::MEVENT.new
423 Ncurses.getmouse(mev)
425 @@ -4388,27 +4395,27 @@
426 cat = $1 if req.query_string =~ /category=([^&]+)/
432 - when 'invalidate_all'
433 + when 'invalidate_all' then
434 Engine::invalidate_feed(-1)
438 url = $1 if req.query_string =~ /url=(.*)$/
439 added = Engine::add_feed({ 'url' => url })
440 $feed_thread.run if added and $config['update_after_add']
443 if req.query_string =~ /id=(\d+)/
445 Engine::delete_feed(id)
448 + when 'invalidate' then
449 if req.query_string =~ /id=(\d+)/
451 Engine::invalidate_feed(id)
454 - when 'save_feed_list'
455 + when 'save_feed_list' then
456 Engine::save_feed_list