From: Tom Hughes Date: Tue, 20 Apr 2010 20:05:22 +0000 (+0100) Subject: Load wiki link data at startup and shorten some file names X-Git-Tag: live~6387^2~1^2 X-Git-Url: https://git.openstreetmap.org/rails.git/commitdiff_plain/546250f60b923c120960e7a1ad9f8176008ce6eb Load wiki link data at startup and shorten some file names --- diff --git a/app/helpers/browse_helper.rb b/app/helpers/browse_helper.rb index 6ec3fb591..1d0b02df0 100644 --- a/app/helpers/browse_helper.rb +++ b/app/helpers/browse_helper.rb @@ -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 index 000000000..dbaa4ddac --- /dev/null +++ b/config/initializers/wiki_pages.rb @@ -0,0 +1 @@ +WIKI_PAGES = YAML.load_file("#{RAILS_ROOT}/config/wiki_pages.yml") diff --git a/config/wiki-tag-and-key-description.yml b/config/wiki_pages.yml similarity index 99% rename from config/wiki-tag-and-key-description.yml rename to config/wiki_pages.yml index b4545d9f9..92856e0ab 100644 --- a/config/wiki-tag-and-key-description.yml +++ b/config/wiki_pages.yml @@ -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 --- diff --git a/script/misc/update-key-and-tag-description-pages-from-wiki b/script/misc/update-wiki-pages similarity index 93% rename from script/misc/update-key-and-tag-description-pages-from-wiki rename to script/misc/update-wiki-pages index d40ca0bdb..15dd1b6a0 100644 --- a/script/misc/update-key-and-tag-description-pages-from-wiki +++ b/script/misc/update-wiki-pages @@ -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);