From 1cdf0536c164b7329029ba6aac0dd27d5e00820b Mon Sep 17 00:00:00 2001 From: Jacques Distler Date: Tue, 27 Jan 2009 11:35:05 -0600 Subject: [PATCH] Fix BlahTeX/PNG The BlahTeX/PNG code was busted by Revision 344. Fixed now. Ari better supply me with a test suite, so this doesn't happen again. --- app/controllers/file_controller.rb | 4 ++++ app/models/web.rb | 8 ++++++++ config/routes.rb | 1 + 3 files changed, 13 insertions(+) diff --git a/app/controllers/file_controller.rb b/app/controllers/file_controller.rb index 9123a6a4..203fd2d3 100644 --- a/app/controllers/file_controller.rb +++ b/app/controllers/file_controller.rb @@ -36,6 +36,10 @@ class FileController < ApplicationController end end end + + def blahtex_png + send_file(@web.blahtex_pngs_path + '/' + params['id']) + end def delete @file_name = params['id'] diff --git a/app/models/web.rb b/app/models/web.rb index 3f6c8042..21348282 100644 --- a/app/models/web.rb +++ b/app/models/web.rb @@ -125,6 +125,14 @@ class Web < ActiveRecord::Base end end + def blahtex_pngs_path + if default_web? + "#{RAILS_ROOT}/webs/files/pngs" + else + "#{RAILS_ROOT}/webs/#{self.address}/files/pngs" + end + end + private # Returns an array of all the wiki words in any current revision diff --git a/config/routes.rb b/config/routes.rb index e361d89e..d98f88d2 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -19,6 +19,7 @@ ActionController::Routing::Routes.draw do |map| connect_to_web map, ':web/remove_orphaned_pages', :controller => 'admin', :action => 'remove_orphaned_pages' connect_to_web map, ':web/remove_orphaned_pages_in_category', :controller => 'admin', :action => 'remove_orphaned_pages_in_category' connect_to_web map, ':web/file/delete/:id', :controller => 'file', :action => 'delete', :requirements => {:id => /[-._\w]+/}, :id => nil + connect_to_web map, ':web/files/pngs/:id', :controller => 'file', :action => 'blahtex_png', :requirements => {:id => /[-._\w]+/}, :id => nil connect_to_web map, ':web/files/:id', :controller => 'file', :action => 'file', :requirements => {:id => /[-._\w]+/}, :id => nil connect_to_web map, ':web/file_list/:sort_order', :controller => 'wiki', :action => 'file_list', :sort_order => nil connect_to_web map, ':web/import/:id', :controller => 'file', :action => 'import'