File: demo.rb

package info (click to toggle)
aswiki 1.0.4-7
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 348 kB
  • ctags: 302
  • sloc: ruby: 2,189; makefile: 63; xml: 16; sh: 12
file content (61 lines) | stat: -rw-r--r-- 1,482 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
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# Copyritght (c) 2002 TANIGUCHI Takaki
# This program is distributed under the GNU GPL 2 or later.

require 'aswiki/plugin'
require 'cgi/session'

module AsWiki
  class NowPlugin < Plugin
    Name = 'now'
    def onview(line, b, e, av=[])
      return Time.now.strftime($TIMEFORMAT)
    end
  end
end

module AsWiki
  class LineNoPlugin < Plugin
    Name = 'lineno'
    def onview(line, b, e, av=[])
      return "lineno #{b}\n"
    end
  end
  class PrintblockPlugin < Plugin
    Name = 'printblock'
    def onview(line, b, e, av=[])
      return line.map{|l| b=b+1 ; ["#{b-1}: #{l}", Amrita::e(:br),"\n"] }
    end
  end
end

module AsWiki
  class ListPlugin < Plugin
    Name = 'list'
    include I18N
    def onpost(session)
      pname = session['pname']
      file = @repository.load(pname)
      file[session['begin'].to_i-1, 0 ] = "* #{CGI.new['item']}\n"
      @repository.save(pname, file.to_s)
    end
    def onview(line, b, e, av=[])
      session = CGI::Session.new(CGI::new, {'new_session'=>true,
				   'tmpdir' => $DIR_SESSION})
      session['pname'] = @name
      session['plugin'] = self.class
      session['begin'] = b
      session['end'] = e
      # session.close
      @data = {
	:session_id => session.session_id,
	:md5sum =>  Digest::MD5::new(@repository.load(@name).to_s).to_s,
	:msg_list_item => msg_list_item,
	:msg_list_add => msg_list_add,
      }
      # @view = load_template.expand_tree(data)
      load_parts
      return self
    end
  end
end