class Kamishibai::Webserver
Public Class Methods
get_or_post(path, opts={}, &block)
click to toggle source
# File lib/kamishibai/webserver.rb, line 200 def self.get_or_post(path, opts={}, &block) get(path, opts, &block) post(path, opts, &block) end
Public Instance Methods
input_check( bookcode, page )
click to toggle source
precheck the input from url
# File lib/kamishibai/webserver.rb, line 111 def input_check( bookcode, page ) page = page.to_i if $db.has_bookcode?( bookcode ) @book = $db.get_book( bookcode ) else not_found "No such book code. #{ bookcode }" end unless @book.pages not_found "Book contain no images. #{ bookcode } #{ @book.fullpath }" end if page < 1 or page > @book.pages not_found "No such page. #{ page } #{ bookcode } #{ @book.fullpath }" end if ! FileTest.exists?( @book.fullpath ) not_found "File don't exists. #{ bookcode } #{ @book.fullpath }" end if ! FileTest.file?( @book.fullpath ) not_found "Not a file. #{ bookcode } #{ @book.fullpath }" end end
pregex()
click to toggle source
regular expression from POST keyword search
# File lib/kamishibai/webserver.rb, line 138 def pregex keyword = request['keyword'].untaint keyword = keyword.gsub(' ','.+') return Regexp.new( keyword, Regexp::IGNORECASE ) end