Index: app/models/chunks/wiki.rb =================================================================== --- app/models/chunks/wiki.rb (revision 1) +++ app/models/chunks/wiki.rb (working copy) @@ -53,7 +53,7 @@ class Image < WikiLink def self.pattern - Regexp.new('(\\\\)?!(' + WikiWords::WIKI_WORD_PATTERN + ')!', 0, "utf-8") + Regexp.new('(\\\\)?!(Thumbnail|Image)?(' + WikiWords::WIKI_WORD_PATTERN + ')!', 0, "utf-8") end attr_reader :page_name @@ -62,7 +62,12 @@ puts "got a match" super(match_data) @escape = match_data[1] - @page_name = match_data[2] + if match_data[2] and !match_data[2].strip.empty? + @type = match_data[2].strip.intern + else + @type = :Thumbnail + end + @page_name = match_data[3] end def escaped_text() (@escape.nil? ? nil : page_name) end @@ -77,9 +82,15 @@ when :publish " \"#{@page_name}\" " else - "" + - " \"#{@page_name}\" " + - "" + if @type == :Thumbnail + "" + + " \"#{@page_name}\" " + + "" + else + "" + + " \"#{@page_name}\" " + + "" + end end } end Index: app/controllers/wiki.rb =================================================================== --- app/controllers/wiki.rb (revision 1) +++ app/controllers/wiki.rb (working copy) @@ -1,6 +1,7 @@ require "cgi" require "redcloth_for_tex" require "formats" +require 'RMagick' class WikiController < ActionControllerServlet EXPORT_DIRECTORY = File.dirname(__FILE__) + "/../../storage/" unless const_defined?("EXPORT_DIRECTORY") @@ -218,6 +219,20 @@ end end + def thumbnail + if page = wiki.read_page(web_address, page_name) + @res["Content-Type"] = page.content_type + + image = Magick::Image.from_blob(page.content).first + image.change_geometry!('100x100') { |cols, rows, img| img.resize!(cols, rows) } + image.format = 'JPEG' + content = image.to_blob + @res["Content-Length"] = content.size + @res.body = content + end + end + + def tex @page = wiki.read_page(web_address, page_name) @tex_content = RedClothForTex.new(@page.content).to_tex @@ -427,4 +442,4 @@ $stderr << "#{@req.meta_vars['HTTP_X_FORWARDED_FOR']} || #{@req.meta_vars['REMOTE_ADDR']}" @req.meta_vars["HTTP_X_FORWARDED_FOR"] || @req.meta_vars["REMOTE_ADDR"] end -end \ No newline at end of file +end