devdaily home | apple | java | perl | unix | directory | blog

What this is

This file is included in the DevDaily.com "Ruby Source Code Warehouse" project. The intent of this project is to help you "Learn Ruby by Example" TM.

Other links

The source code

# Copyritght (c) 2002 TANIGUCHI Takaki
# This program is distributed under the GNU GPL 2 or later.

require 'aswiki/plugin'
require 'aswiki/attachdb'
require 'cgi/session'
require 'bdb'

module AsWiki
  class AttachPlugin < Plugin
    Name = 'attach'
    def onpost(session, file)
      pname = session['pname']
      adb =  AsWiki::AttachDB.new
      adb.savefile(pname, file[0])
    end
    def onview(line, b, e, av=[])
      session = CGI::Session.new(CGI::new, {'tmpdir' => $DIR_SESSION,
				   'new_session'=>true})
      session['pname'] = @name
      session['plugin'] = self.class

      adb =  AsWiki::AttachDB.new
      @data ={:_session_id => session.session_id,
	:item => adb.listfile(@name)
      }
      # @view = load_template.expand_tree(data)
      load_parts
      return self
    end
    attr_reader :data
  end
  class AttachIncludePlugin < Plugin
    Name = 'attachinclude'
    # #attachinclude num
    def onview(line, b, e, av=[])
      num = av[1]
      adb =  AsWiki::AttachDB.new
      ret = adb.querybynum(num)
      @data = {
	:url  => cgiurl([['c','download'],['num',num]]),
	:mime => ret[:type].gsub(/\r|\n/,''),
	:name => ret[:filename],
      }

      load_parts('attach')
      return self
    end
  end
end




Copyright 1998-2008 Alvin Alexander
All Rights Reserved.
 
devdaily.com is based in louisville, kentucky, and this web site is hosted by godaddy.com