File: todo.rb

package info (click to toggle)
hiki 0.8.6-1etch1
  • links: PTS
  • area: main
  • in suites: etch
  • size: 1,772 kB
  • ctags: 1,746
  • sloc: ruby: 20,067; lisp: 926; sh: 269; makefile: 10
file content (23 lines) | stat: -rw-r--r-- 541 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# $Id: todo.rb,v 1.5 2004/02/15 02:48:35 hitoshi Exp $
# Copyright (C) 2002-2003 TAKEUCHI Hitoshi <hitoshi@namaraii.com>

def todo(p, num = 8)
  todo_re = /^(\d\d?)\s+(.+)(\d\d\d\d-\d\d-\d\d)?$/

  todo_list = []

  n = @db.load(p.unescapeHTML) || ''
  n.scan(todo_re) do |i|
    todo_list << {:priority => $1.to_i, :todo => $2}
  end

  todo_list.sort! {|a, b| b[:priority] <=> a[:priority]}

  s= ""
  c = 0
  todo_list.each do |t|
    break if (c += 1) > num
    s << "#{'%02d' % t[:priority]} #{t[:todo].escapeHTML}<br>\n"
  end
  s
end