From 90ad482ed22cfd4e0c3436b1c7958a5b9121090b Mon Sep 17 00:00:00 2001 From: Jacques Distler Date: Wed, 9 Jun 2010 11:47:39 -0500 Subject: [PATCH] Rename stringsupport.rb => instiki_stringsupport.rb --- app/controllers/file_controller.rb | 2 +- app/controllers/wiki_controller.rb | 2 +- app/helpers/application_helper.rb | 2 +- app/metal/itex.rb | 2 +- lib/chunks/category.rb | 2 +- lib/chunks/engines.rb | 2 +- lib/chunks/wiki.rb | 2 +- ...ingsupport.rb => instiki_stringsupport.rb} | 0 lib/sanitizer.rb | 2 +- lib/url_generator.rb | 2 +- lib/wiki_content.rb | 2 +- lib/wiki_words.rb | 2 +- test/functional/wiki_controller_test.rb | 2 +- test/unit/sanitizer_test.rb | 2 +- .../ext/math/mathml_engines/itex2mml.rb | 19 ++++++++++++------- .../maruku/ext/math/mathml_engines/none.rb | 5 +++++ 16 files changed, 30 insertions(+), 20 deletions(-) rename lib/{stringsupport.rb => instiki_stringsupport.rb} (100%) diff --git a/app/controllers/file_controller.rb b/app/controllers/file_controller.rb index e9ec6ae4..079b580e 100644 --- a/app/controllers/file_controller.rb +++ b/app/controllers/file_controller.rb @@ -1,7 +1,7 @@ # Controller responsible for serving files and pictures. require 'zip/zip' -require 'stringsupport' +require 'instiki_stringsupport' class FileController < ApplicationController diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb index 303b232a..50150cd3 100644 --- a/app/controllers/wiki_controller.rb +++ b/app/controllers/wiki_controller.rb @@ -2,7 +2,7 @@ require 'fileutils' require 'maruku' require 'maruku/ext/math' require 'zip/zip' -require 'stringsupport' +require 'instiki_stringsupport' require 'resolv' class WikiController < ApplicationController diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 81513882..5eb146bd 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,6 +1,6 @@ # The methods added to this helper will be available to all templates in the application. module ApplicationHelper -require 'stringsupport' +require 'instiki_stringsupport' # Accepts a container (hash, array, enumerable, your type) and returns a string of option tags. Given a container # where the elements respond to first and last (such as a two-element array), the "lasts" serve as option values and diff --git a/app/metal/itex.rb b/app/metal/itex.rb index 63e300bb..b9091c9f 100644 --- a/app/metal/itex.rb +++ b/app/metal/itex.rb @@ -1,7 +1,7 @@ # Allow the metal piece to run in isolation require(File.dirname(__FILE__) + "/../../config/environment") unless defined?(Rails) -require 'stringsupport' +require 'instiki_stringsupport' class Itex def self.call(env) diff --git a/lib/chunks/category.rb b/lib/chunks/category.rb index ddc05f99..ab90f088 100644 --- a/lib/chunks/category.rb +++ b/lib/chunks/category.rb @@ -1,5 +1,5 @@ require 'chunks/chunk' -require 'stringsupport' +require 'instiki_stringsupport' # The category chunk looks for "category: news" on a line by # itself and parses the terms after the ':' as categories. diff --git a/lib/chunks/engines.rb b/lib/chunks/engines.rb index b6bb4a13..9ecc9f97 100644 --- a/lib/chunks/engines.rb +++ b/lib/chunks/engines.rb @@ -1,7 +1,7 @@ $: << File.dirname(__FILE__) + "../../lib" require_dependency 'chunks/chunk' -require 'stringsupport' +require 'instiki_stringsupport' require 'maruku' require 'maruku/ext/math' require_dependency 'rdocsupport' diff --git a/lib/chunks/wiki.rb b/lib/chunks/wiki.rb index 66eb6426..193183b8 100644 --- a/lib/chunks/wiki.rb +++ b/lib/chunks/wiki.rb @@ -1,5 +1,5 @@ require 'chunks/chunk' -require 'stringsupport' +require 'instiki_stringsupport' # Contains all the methods for finding and replacing wiki related links. module WikiChunk diff --git a/lib/stringsupport.rb b/lib/instiki_stringsupport.rb similarity index 100% rename from lib/stringsupport.rb rename to lib/instiki_stringsupport.rb diff --git a/lib/sanitizer.rb b/lib/sanitizer.rb index e89cf812..dce68413 100644 --- a/lib/sanitizer.rb +++ b/lib/sanitizer.rb @@ -7,7 +7,7 @@ module Sanitizer require 'action_controller/vendor/html-scanner/html/tokenizer' require 'node' - require 'stringsupport' + require 'instiki_stringsupport' require 'set' acceptable_elements = Set.new %w[a abbr acronym address area article aside diff --git a/lib/url_generator.rb b/lib/url_generator.rb index 66c3b897..22e6bd27 100644 --- a/lib/url_generator.rb +++ b/lib/url_generator.rb @@ -1,4 +1,4 @@ -require 'stringsupport' +require 'instiki_stringsupport' class AbstractUrlGenerator diff --git a/lib/wiki_content.rb b/lib/wiki_content.rb index 91c8968d..a5dc473d 100644 --- a/lib/wiki_content.rb +++ b/lib/wiki_content.rb @@ -7,7 +7,7 @@ require_dependency 'chunks/wiki' require_dependency 'chunks/literal' require 'chunks/nowiki' require 'sanitizer' -require 'stringsupport' +require 'instiki_stringsupport' # Wiki content is just a string that can process itself with a chain of diff --git a/lib/wiki_words.rb b/lib/wiki_words.rb index 28a505c7..bc3e1824 100644 --- a/lib/wiki_words.rb +++ b/lib/wiki_words.rb @@ -1,7 +1,7 @@ #coding: utf-8 # Contains all the methods for finding and replacing wiki words -require 'stringsupport' +require 'instiki_stringsupport' module WikiWords # In order of appearance: Latin, greek, cyrillic, armenian diff --git a/test/functional/wiki_controller_test.rb b/test/functional/wiki_controller_test.rb index 21f69f1e..68088039 100644 --- a/test/functional/wiki_controller_test.rb +++ b/test/functional/wiki_controller_test.rb @@ -10,7 +10,7 @@ require 'wiki_controller' require 'rexml/document' require 'tempfile' require 'zip/zipfilesystem' -require 'stringsupport' +require 'instiki_stringsupport' # Raise errors beyond the default web-based presentation class WikiController; def rescue_action(e) logger.error(e); raise e end; end diff --git a/test/unit/sanitizer_test.rb b/test/unit/sanitizer_test.rb index b9d1b243..7579674a 100644 --- a/test/unit/sanitizer_test.rb +++ b/test/unit/sanitizer_test.rb @@ -4,7 +4,7 @@ require File.expand_path(File.join(File.dirname(__FILE__), '/../test_helper')) require 'sanitizer' require 'json' -require 'stringsupport' +require 'instiki_stringsupport' class SanitizerTest < Test::Unit::TestCase diff --git a/vendor/plugins/maruku/lib/maruku/ext/math/mathml_engines/itex2mml.rb b/vendor/plugins/maruku/lib/maruku/ext/math/mathml_engines/itex2mml.rb index 3ea4c394..9c45f24d 100644 --- a/vendor/plugins/maruku/lib/maruku/ext/math/mathml_engines/itex2mml.rb +++ b/vendor/plugins/maruku/lib/maruku/ext/math/mathml_engines/itex2mml.rb @@ -3,8 +3,18 @@ module MaRuKu module HTML def convert_to_mathml_itex2mml(kind, tex) return if $already_warned_itex2mml - require 'itextomml' - require 'stringsupport' + begin + require 'itextomml' + rescue LoadError => e + maruku_error "Could not load package 'itex2mml'.\nPlease install it." unless $already_warned_itex2mml + $already_warned_itex2mml = true + return nil + end + begin + require 'itex_stringsupport' + rescue LoadError + require 'instiki_stringsupport' + end parser = Itex2MML::Parser.new mathml = @@ -17,11 +27,6 @@ module MaRuKu end return Document.new(mathml.to_utf8, :respect_whitespace => :all).root - rescue LoadError => e - # TODO: Properly scope this global - maruku_error "Could not load package 'itex2mml'.\nPlease install it." unless $already_warned_itex2mml - $already_warned_itex2mml = true - nil rescue REXML::ParseException => e maruku_error "Invalid MathML TeX: \n#{tex.gsub(/^/, 'tex>')}\n\n #{e.inspect}" nil diff --git a/vendor/plugins/maruku/lib/maruku/ext/math/mathml_engines/none.rb b/vendor/plugins/maruku/lib/maruku/ext/math/mathml_engines/none.rb index e44408e8..ce25b5c4 100644 --- a/vendor/plugins/maruku/lib/maruku/ext/math/mathml_engines/none.rb +++ b/vendor/plugins/maruku/lib/maruku/ext/math/mathml_engines/none.rb @@ -6,6 +6,11 @@ module MaRuKu; module Out; module HTML # or return an empty array on error # return [] # or have a string parsed by REXML: + begin + require 'itex_stringsupport' + rescue LoadError + require 'instiki_stringsupport' + end tex = tex.escapeHTML mathml = "#{tex}" return Document.new(mathml).root