diff --git a/app/controllers/wiki_controller.rb b/app/controllers/wiki_controller.rb index e21f841b..2e41b6ce 100644 --- a/app/controllers/wiki_controller.rb +++ b/app/controllers/wiki_controller.rb @@ -68,7 +68,7 @@ class WikiController < ApplicationController end def export_html - stylesheet = File.read(File.join(RAILS_ROOT, 'public', 'stylesheets', 'instiki.css')) + stylesheet = Rails.root.join('public', 'stylesheets', 'instiki.css').read export_pages_as_zip(html_ext) do |page| renderer = PageRenderer.new(page.revisions.last) @@ -423,7 +423,7 @@ class WikiController < ApplicationController file_prefix = "#{@web.address}-#{file_type}-" timestamp = @web.revised_at.strftime('%Y-%m-%d-%H-%M-%S') - file_path = File.join(@wiki.storage_path, file_prefix + timestamp + '.zip') + file_path = @wiki.storage_path.join(file_prefix + timestamp + '.zip') tmp_path = "#{file_path}.tmp" Zip::ZipOutputStream.open(tmp_path) do |zip_out| @@ -438,7 +438,7 @@ class WikiController < ApplicationController "" end end - FileUtils.rm_rf(Dir[File.join(@wiki.storage_path, file_prefix + '*.zip')]) + FileUtils.rm_rf(Dir[@wiki.storage_path.join(file_prefix + '*.zip')]) FileUtils.mv(tmp_path, file_path) send_file file_path end @@ -516,9 +516,9 @@ class WikiController < ApplicationController end def load_spam_patterns - spam_patterns_file = "#{RAILS_ROOT}/config/spam_patterns.txt" + spam_patterns_file = Rails.root.join('config', 'spam_patterns.txt') if File.exists?(spam_patterns_file) - File.readlines(spam_patterns_file).inject([]) { |patterns, line| patterns << Regexp.new(line.chomp, Regexp::IGNORECASE) } + spam_patterns_file.readlines.inject([]) { |patterns, line| patterns << Regexp.new(line.chomp, Regexp::IGNORECASE) } else [] end diff --git a/app/models/wiki.rb b/app/models/wiki.rb index cf5cfd18..8969a3be 100644 --- a/app/models/wiki.rb +++ b/app/models/wiki.rb @@ -1,7 +1,7 @@ class Wiki cattr_accessor :storage_path, :logger - self.storage_path = "#{RAILS_ROOT}/storage/" + self.storage_path = Rails.root.join('storage') def authenticate(password) password == (system.password || 'instiki') diff --git a/app/views/layouts/default.rhtml b/app/views/layouts/default.rhtml index 14cf63e6..505246af 100644 --- a/app/views/layouts/default.rhtml +++ b/app/views/layouts/default.rhtml @@ -20,7 +20,7 @@ h1#pageName, div.info, .newWikiWord a, a.existingWikiWord, .newWikiWord a:hover, [actiontype="toggle"]:hover, #TextileHelp h3 { color: #<%= @web ? @web.color : "393" %>; } - <%= File.read(RAILS_ROOT + '/public/stylesheets/instiki.css') if @inline_style %> + <%= Rails.root.join('public', 'stylesheets', 'instiki.css').read if @inline_style %> <%= stylesheet_link_tag 'instiki', :media => 'all' unless @inline_style %> <%= "" if @style_additions %> diff --git a/app/views/layouts/error.html.erb b/app/views/layouts/error.html.erb index e7033678..cbdd1596 100644 --- a/app/views/layouts/error.html.erb +++ b/app/views/layouts/error.html.erb @@ -12,10 +12,10 @@ h1#pageName, .newWikiWord a, a.existingWikiWord, .newWikiWord a:hover, #TextileHelp h3 { color: #<%= @web ? @web.color : "393" %>; } - <%= File.read(RAILS_ROOT + '/public/stylesheets/instiki.css') if @inline_style %> + <%= Rails.root.join('public', 'stylesheets', 'instiki.css').read if @inline_style %> - <%= stylesheet_link_tag 'instiki' unless @inline_style %> + <%= stylesheet_link_tag 'instiki', :media => 'all' unless @inline_style %>