From 37218f57f1b53a5f0b1a3d4e4444e8d80b5d667c Mon Sep 17 00:00:00 2001 From: Jochen Topf Date: Mon, 10 Oct 2011 20:38:34 +0200 Subject: Add taginfo-config.rb to read config from command line. I added bin/taginfo-config.rb to easily access the config file from the command line. This is now used in sources/db/update.sh and sources/update_all.sh. This, again, reduces the places in the distribution where things needed to be changed for each instance. --- bin/taginfo-config.rb | 20 ++++++++++++++++++++ sources/db/update.sh | 2 +- sources/update_all.sh | 8 ++++---- taginfo-config-example.json | 46 +++++++++++++++++++++++++++++++++++++++++++++ taginfo-config.json | 34 --------------------------------- web/lib/config.rb | 2 +- 6 files changed, 72 insertions(+), 40 deletions(-) create mode 100755 bin/taginfo-config.rb create mode 100644 taginfo-config-example.json delete mode 100644 taginfo-config.json diff --git a/bin/taginfo-config.rb b/bin/taginfo-config.rb new file mode 100755 index 0000000..fbeb163 --- /dev/null +++ b/bin/taginfo-config.rb @@ -0,0 +1,20 @@ +#!/usr/bin/ruby +# +# taginfo-config.rb [KEY] +# + +require 'rubygems' +require 'json' + +require File.expand_path(File.dirname(__FILE__)) + '/../web/lib/config.rb' + +TaginfoConfig.read + +value = TaginfoConfig.get(ARGV[0]) +if value.nil? + puts '' + exit 1 +end + +puts value + diff --git a/sources/db/update.sh b/sources/db/update.sh index 5adf383..19d3518 100755 --- a/sources/db/update.sh +++ b/sources/db/update.sh @@ -21,7 +21,7 @@ if [ "x" = "x$DIR" ]; then fi if [ "x" = "x$PLANETFILE" ]; then - PLANETFILE=/osm/planet/var/current-planet.osm.pbf + PLANETFILE=`../../bin/taginfo-config.rb sources.db.planetfile` fi echo "`$DATECMD` Start db..." diff --git a/sources/update_all.sh b/sources/update_all.sh index 6e2aeac..c9fbc40 100755 --- a/sources/update_all.sh +++ b/sources/update_all.sh @@ -16,14 +16,14 @@ # #------------------------------------------------------------------------------ -# These sources will be downloaded from http://taginfo.openstreetmap.de/download/ +# These sources will be downloaded from http://taginfo.openstreetmap.org/download/ # Note that this will NOT work for the "db" source! Well, you can download it, # but it will fail later, because the database is changed by the master.sql # scripts. -SOURCES_DOWNLOAD="" +SOURCES_DOWNLOAD=`../bin/taginfo-config.rb sources.download` # These sources will be created from the actual sources -SOURCES_CREATE="josm potlatch merkaartor wiki db" +SOURCES_CREATE=`../bin/taginfo-config.rb sources.create` #------------------------------------------------------------------------------ @@ -50,7 +50,7 @@ for source in $SOURCES_DOWNLOAD; do echo "=====================================" echo "Downloading $source..." mkdir -p $DIR/$source - wget --quiet -O $DIR/download/taginfo-$source.db.bz2 http://taginfo.openstreetmap.de/download/taginfo-$source.db.bz2 + wget --quiet -O $DIR/download/taginfo-$source.db.bz2 http://taginfo.openstreetmap.org/download/taginfo-$source.db.bz2 bzcat $DIR/download/taginfo-$source.db.bz2 >$DIR/$source/taginfo-$source.db echo "Done." done diff --git a/taginfo-config-example.json b/taginfo-config-example.json new file mode 100644 index 0000000..ff2f0a2 --- /dev/null +++ b/taginfo-config-example.json @@ -0,0 +1,46 @@ +// This is an example of a Taginfo config file. +// Copy it to the directory above and name it 'taginfo-config.json', then change your local settings. +{ + // You probably want to change all these. + "instance": { + // Used in the title of all HTML pages. + "name": "Test Taginfo", + // Description that appears if you click on the instance icon in the upper left. + "description": "This is a Taginfo test instance. To change this text or the icon above change your taginfo-config.json.", + // URL path to instance icon in the upper left. + "icon": "/img/instance.png" + }, + "tagcloud": { + "number_of_tags": 200 + }, + // For the geodistribution map. If you change this, you also have to change the C++ code in tagstats. + "geodistribution": { + "width": 720, + "height": 360, + "background_image": "/img/worldp.png" + }, + "xapi": { + // URL prefix for the XAPI/JOSM links on the key and tag pages. + // "url_prefix": "http://www.informationfreeway.org/api/0.6/" + "url_prefix": "http://open.mapquestapi.com/xapi/api/0.6/" + }, + "opensearch": { + // For the OpenSearchDescription. You have to change at least the shortname and the contact for your instance. + "shortname": "Taginfo Test Instance", + "contact": "somebody@example.com", + "description": "Find metadata about OpenStreetMap tags", + "tags": "osm openstreetmap tag tags taginfo" + }, + "sources": { + // These sources will be downloaded from http://taginfo.openstreetmap.org/download/ + // Note that this will NOT work for the "db" source! Well, you can download it, + // but it will fail later, because the database is changed by the master.sql + // scripts. + "download": "josm potlatch merkaartor wiki", + // These sources will be created from the actual sources. + "create": "db", + "db": { + "planetfile": "/osm/planet/var/current-planet.osm.pbf" + } + } +} diff --git a/taginfo-config.json b/taginfo-config.json deleted file mode 100644 index cf37ca4..0000000 --- a/taginfo-config.json +++ /dev/null @@ -1,34 +0,0 @@ -// This is an example of a Taginfo config file. -// Copy it to the directory above where you found this example file. -{ - // You probably want to change all these. - "instance": { - // Used in the title of all HTML pages. - "name": "Test Taginfo", - // Description that appears if you click on the instance icon in the upper left. - "description": "This is a Taginfo test instance. To change this text or the icon above change your taginfo-config.json.", - // URL path to instance icon in the upper left. - "icon": "/img/instance.png" - }, - "tagcloud": { - "number_of_tags": 200 - }, - // For the geodistribution map. If you change this, you also have to change the C++ code in tagstats. - "geodistribution": { - "width": 720, - "height": 360, - "background_image": "/img/worldp.png" - }, - "xapi": { - // URL prefix for the XAPI/JOSM links on the key and tag pages. - // "url_prefix": "http://www.informationfreeway.org/api/0.6/" - "url_prefix": "http://open.mapquestapi.com/xapi/api/0.6/" - }, - "opensearch": { - // For the OpenSearchDescription. You have to change at least the shortname and the contact for your instance. - "shortname": "Taginfo Test Instance", - "contact": "somebody@example.com", - "description": "Find metadata about OpenStreetMap tags", - "tags": "osm openstreetmap tag tags taginfo" - } -} diff --git a/web/lib/config.rb b/web/lib/config.rb index 135337d..c901921 100644 --- a/web/lib/config.rb +++ b/web/lib/config.rb @@ -5,7 +5,7 @@ class TaginfoConfig @@config = {} def self.read - open('../../taginfo-config.json') do |file| + open(File.expand_path(File.dirname(__FILE__)) + '/../../../taginfo-config.json') do |file| @@config = JSON.parse(file.gets(nil)) end end -- cgit v1.2.3