loaded_lang = 'en'
# Load English defaults
- en = YAML::load(File.open("#{RAILS_ROOT}/config/potlatch/locales/en.yml"))["en"]
+ en = YAML::load(File.open("#{Rails.root}/config/potlatch/locales/en.yml"))["en"]
if lang == 'en'
return [loaded_lang, en]
else
# Use English as a fallback
begin
- other = YAML::load(File.open("#{RAILS_ROOT}/config/potlatch/locales/#{lang}.yml"))[lang]
+ other = YAML::load(File.open("#{Rails.root}/config/potlatch/locales/#{lang}.yml"))[lang]
loaded_lang = lang
rescue
other = en
end
def getlocales
- Dir.glob("#{RAILS_ROOT}/config/potlatch/locales/*").collect { |f| File.basename(f, ".yml") }
+ Dir.glob("#{Rails.root}/config/potlatch/locales/*").collect { |f| File.basename(f, ".yml") }
end
##
<div id="mapkey">
<table class="mapkey-table">
- <% YAML.load_file("#{RAILS_ROOT}/config/key.yml").each do |name,data| %>
+ <% YAML.load_file("#{Rails.root}/config/key.yml").each do |name,data| %>
<% if params[:layer] == name %>
<% data.each do |entry| %>
<% if params[:zoom].to_i >= entry['min_zoom'] && params[:zoom].to_i <= entry['max_zoom'] %>
I18n::Backend::Simple.send(:include, I18n::Backend::Pluralization)
I18n::Backend::Simple.send(:include, I18n::Backend::PluralizationFallback)
-I18n.load_path << RAILS_ROOT + "/config/pluralizers.rb"
+I18n.load_path << "#{Rails.root}/config/pluralizers.rb"
I18n::Backend::Simple.send(:include, I18n::Backend::Fallbacks)
-WIKI_PAGES = YAML.load_file("#{RAILS_ROOT}/config/wiki_pages.yml")
+WIKI_PAGES = YAML.load_file("#{Rails.root}/config/wiki_pages.yml")
add_primary_key :languages, [:code]
- Language.load(RAILS_ROOT + "/config/languages.yml")
+ Language.load("#{Rails.root}/config/languages.yml")
add_foreign_key :users, [:locale], :languages, [:code]
add_foreign_key :diary_entries, [:language_code], :languages, [:code]
end
def self.legal_text_for_country(country_code)
- file_name = File.join(RAILS_ROOT, "config", "legales", country_code.to_s + ".yml")
- file_name = File.join(RAILS_ROOT, "config", "legales", DEFAULT_LEGALE + ".yml") unless File.exist? file_name
+ file_name = File.join(Rails.root, "config", "legales", country_code.to_s + ".yml")
+ file_name = File.join(Rails.root, "config", "legales", DEFAULT_LEGALE + ".yml") unless File.exist? file_name
YAML::load_file(file_name)
end
end
when 'FalseClass'
0.chr+encodedouble(0)
else
- RAILS_DEFAULT_LOGGER.error("Unexpected Ruby type for AMF conversion: "+n.class.to_s)
+ Rails.logger.error("Unexpected Ruby type for AMF conversion: "+n.class.to_s)
end
end
# [3] colours, [4] casing, [5] areas, [6] autotags
# (all hashes)
def self.get_presets
- RAILS_DEFAULT_LOGGER.info(" Message: getpresets")
+ Rails.logger.info(" Message: getpresets")
# Read preset menus
presets={}
presettype=''
presetcategory=''
# StringIO.open(txt) do |file|
- File.open("#{RAILS_ROOT}/config/potlatch/presets.txt") do |file|
+ File.open("#{Rails.root}/config/potlatch/presets.txt") do |file|
file.each_line {|line|
t=line.chomp
if (t=~/(\w+)\/(\w+)/) then
# Read colours/styling
colours={}; casing={}; areas={}
- File.open("#{RAILS_ROOT}/config/potlatch/colours.txt") do |file|
+ File.open("#{Rails.root}/config/potlatch/colours.txt") do |file|
file.each_line {|line|
t=line.chomp
if (t=~/(\w+)\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)/) then
# Read relations colours/styling
relcolours={}; relalphas={}; relwidths={}
- File.open("#{RAILS_ROOT}/config/potlatch/relation_colours.txt") do |file|
+ File.open("#{Rails.root}/config/potlatch/relation_colours.txt") do |file|
file.each_line {|line|
t=line.chomp
if (t=~/(\w+)\s+([^\s]+)\s+([^\s]+)\s+([^\s]+)/) then
# Read POI presets
icon_list=[]; icon_tags={};
- File.open("#{RAILS_ROOT}/config/potlatch/icon_presets.txt") do |file|
+ File.open("#{Rails.root}/config/potlatch/icon_presets.txt") do |file|
file.each_line {|line|
(icon,tags)=line.chomp.split("\t")
icon_list.push(icon)
# Read auto-complete
autotags={}; autotags['point']={}; autotags['way']={}; autotags['POI']={};
- File.open("#{RAILS_ROOT}/config/potlatch/autocomplete.txt") do |file|
+ File.open("#{Rails.root}/config/potlatch/autocomplete.txt") do |file|
file.each_line {|line|
t=line.chomp
if (t=~/^([\w:]+)\/(\w+)\s+(.+)$/) then
rots_response = Net::HTTP.get_response(URI.parse("http://localhost:1123/"))
rescue
# It isn't, so start a new instance.
- rots = IO.popen(RAILS_ROOT + "/vendor/gems/rots-0.2.1/bin/rots --silent")
+ rots = IO.popen("#{Rails.root}/vendor/gems/rots-0.2.1/bin/rots --silent")
# Wait for up to 30 seconds for the server to start and respond before continuing
for i in (1 .. 30)