From 336e57d6b4858cb910e4c6f341f15737e8b1c5c6 Mon Sep 17 00:00:00 2001 From: Jacques Distler Date: Fri, 28 Aug 2009 11:10:34 -0500 Subject: [PATCH] Pathname Objects Web#files_path and Web#blatex_pngs_path now return Pathname objects. Based on JHerdman's http://github.com/jherdman/instiki/commit/5d1e8f420b4fcd6502c1cfa00d57002bea2868e0 but requires several other changes to the code (which assumed a string). Also, test for itex2MML 1.3.10 (you should update that too). --- app/controllers/file_controller.rb | 4 ++-- app/models/web.rb | 13 +++++-------- app/models/wiki_file.rb | 2 +- test/unit/page_renderer_test.rb | 11 +++++++++-- 4 files changed, 17 insertions(+), 13 deletions(-) diff --git a/app/controllers/file_controller.rb b/app/controllers/file_controller.rb index 03817c2a..2e293641 100644 --- a/app/controllers/file_controller.rb +++ b/app/controllers/file_controller.rb @@ -26,7 +26,7 @@ class FileController < ApplicationController end else # no form supplied, this is a request to download the file - file = @web.files_path + '/' + @file_name + file = @web.files_path.join(@file_name) if File.exists?(file) send_file(file) else @@ -38,7 +38,7 @@ class FileController < ApplicationController end def blahtex_png - send_file(@web.blahtex_pngs_path + '/' + params['id']) + send_file(@web.blahtex_pngs_path.join(params['id'])) end def delete diff --git a/app/models/web.rb b/app/models/web.rb index b2e7e6c2..c9571738 100644 --- a/app/models/web.rb +++ b/app/models/web.rb @@ -128,21 +128,18 @@ class Web < ActiveRecord::Base "#{File.expand_path(dir)} and add files to it." end end - + def files_path + path = Rails.root.join("webs") if default_web? - "#{RAILS_ROOT}/webs/files" + path.join("files") else - "#{RAILS_ROOT}/webs/#{self.address}/files" + path.join(address, "files") end end def blahtex_pngs_path - if default_web? - "#{RAILS_ROOT}/webs/files/pngs" - else - "#{RAILS_ROOT}/webs/#{self.address}/files/pngs" - end + files_path.join("pngs") end private diff --git a/app/models/wiki_file.rb b/app/models/wiki_file.rb index ba122662..5e9a5d21 100644 --- a/app/models/wiki_file.rb +++ b/app/models/wiki_file.rb @@ -46,7 +46,7 @@ class WikiFile < ActiveRecord::Base end def content_path - web.files_path + '/' + file_name + web.files_path.join(file_name) end def write_content_to_file diff --git a/test/unit/page_renderer_test.rb b/test/unit/page_renderer_test.rb index 3e170fcb..71277f91 100644 --- a/test/unit/page_renderer_test.rb +++ b/test/unit/page_renderer_test.rb @@ -211,6 +211,13 @@ END_THM end def test_have_latest_itex2mml + assert_markup_parsed_as( + %{

equation A\314\262

}, + "equation $\\underline{A}$") + assert_markup_parsed_as( %{

equation } + @@ -220,13 +227,13 @@ END_THM assert_markup_parsed_as( %{

blackboard digits: math} + - %{bb123

}, + %{bb123

}, "blackboard digits: $\mathbb{123}$") assert_markup_parsed_as( %{

\\rlap: 123

}, + %{ width='0'>123

}, '\rlap: $\rlap{123}$') end