]> git.openstreetmap.org Git - rails.git/commitdiff
Load wiki link data at startup and shorten some file names
authorTom Hughes <tom@compton.nu>
Tue, 20 Apr 2010 20:05:22 +0000 (21:05 +0100)
committerTom Hughes <tom@compton.nu>
Tue, 20 Apr 2010 20:05:22 +0000 (21:05 +0100)
app/helpers/browse_helper.rb
config/initializers/wiki_pages.rb [new file with mode: 0644]
config/wiki_pages.yml [moved from config/wiki-tag-and-key-description.yml with 99% similarity]
script/misc/update-wiki-pages [moved from script/misc/update-key-and-tag-description-pages-from-wiki with 93% similarity]

index 6ec3fb591c017d1d3848c9259b9874c468781be4..1d0b02df03e88229b7b86b72bb626c04d4ae0357 100644 (file)
@@ -35,12 +35,11 @@ module BrowseHelper
 private
 
   def wiki_link(type, lookup)
-    wiki_data = YAML.load_file("#{RAILS_ROOT}/config/wiki-tag-and-key-description.yml")
     locale = I18n.locale.to_s
 
-    if page = wiki_data[locale][type][lookup] rescue nil
+    if page = WIKI_PAGES[locale][type][lookup] rescue nil
       url = "http://wiki.openstreetmap.org/wiki/#{page}?uselang=#{locale}"
-    elsif page = wiki_data["en"][type][lookup] rescue nil
+    elsif page = WIKI_PAGES["en"][type][lookup] rescue nil
       url = "http://wiki.openstreetmap.org/wiki/#{page}?uselang=#{locale}"
     end
 
diff --git a/config/initializers/wiki_pages.rb b/config/initializers/wiki_pages.rb
new file mode 100644 (file)
index 0000000..dbaa4dd
--- /dev/null
@@ -0,0 +1 @@
+WIKI_PAGES = YAML.load_file("#{RAILS_ROOT}/config/wiki_pages.yml")
similarity index 99%
rename from config/wiki-tag-and-key-description.yml
rename to config/wiki_pages.yml
index b4545d9f9062059139717c67479eca9d3079d78d..92856e0ab5ad6868ea59479d04e0323d973f5c3b 100644 (file)
@@ -1,4 +1,4 @@
-# THIS FILE IS AUTOGENERATED WITH THE script/misc/update-key-and-tag-description-pages-from-wiki
+# THIS FILE IS AUTOGENERATED WITH THE script/misc/update-wiki-pages
 # PROGRAM DO NOT MANUALLY EDIT IT
 
 ---
similarity index 93%
rename from script/misc/update-key-and-tag-description-pages-from-wiki
rename to script/misc/update-wiki-pages
index d40ca0bdb994351b93aa32689f5504273f8a61c3..15dd1b6a0a1767ffcb42a3b6c22d2a3677421f25 100644 (file)
@@ -19,11 +19,11 @@ use Test::More 'no_plan';
 
 =head1 NAME
 
-update-key-and-tag-description-pages-from-wiki - Screen-scrape the wiki for key/value wiki description pages
+update-wiki-pages - Screen-scrape the wiki for key/value wiki description pages
 
 =head1 SYNOPSIS
 
-    perl script/misc/update-key-and-tag-description-pages-from-wiki config/wiki-tag-and-key-description.yml 
+    perl script/misc/update-wiki-pages config/wiki_pages.yml 
 
 =head1 BUGS
 
@@ -77,7 +77,7 @@ ok(1, "Got a total of $count{$_} ${_}s") for qw[ key value ];
 
 # Dump to .yml file
 open my $out, ">", $ARGV[0] or die "Can't open file '$ARGV[0]' supplied on the command line";
-say $out "# THIS FILE IS AUTOGENERATED WITH THE script/misc/update-key-and-tag-description-pages-from-wiki";
+say $out "# THIS FILE IS AUTOGENERATED WITH THE script/misc/update-wiki-pages";
 say $out "# PROGRAM DO NOT MANUALLY EDIT IT";
 say $out "";
 say $out Dump(\%feature);