From 546250f60b923c120960e7a1ad9f8176008ce6eb Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Tue, 20 Apr 2010 21:05:22 +0100 Subject: [PATCH] Load wiki link data at startup and shorten some file names --- app/helpers/browse_helper.rb | 5 ++--- config/initializers/wiki_pages.rb | 1 + config/{wiki-tag-and-key-description.yml => wiki_pages.yml} | 2 +- ...nd-tag-description-pages-from-wiki => update-wiki-pages} | 6 +++--- 4 files changed, 7 insertions(+), 7 deletions(-) create mode 100644 config/initializers/wiki_pages.rb rename config/{wiki-tag-and-key-description.yml => wiki_pages.yml} (99%) rename script/misc/{update-key-and-tag-description-pages-from-wiki => update-wiki-pages} (93%) 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); -- 2.39.5