aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJochen Topf <jochen@topf.org>2011-04-13 10:14:33 +0200
committerJochen Topf <jochen@topf.org>2011-04-13 10:14:33 +0200
commitd64ea936c4ac4a6c877dfce1e6a2fa71a42e0950 (patch)
tree08b98b972f70c823f0dfa8be4938d8203b4b4165
parent968aeb70370bda68361a46c264469e831d6e1a08 (diff)
downloadtaginfo-d64ea936c4ac4a6c877dfce1e6a2fa71a42e0950.tar
taginfo-d64ea936c4ac4a6c877dfce1e6a2fa71a42e0950.tar.gz
Added JSONP support
-rw-r--r--README4
-rw-r--r--examples/jsonp.html21
-rwxr-xr-xweb/taginfo.rb3
3 files changed, 27 insertions, 1 deletions
diff --git a/README b/README
index d7e59a7..529a6e8 100644
--- a/README
+++ b/README
@@ -22,6 +22,7 @@ PREREQUISITES
Uses
* Mongrel
* Sinatra web framework http://www.sinatrarb.com/
+ * Rack Contrib Gem (for Rack::JSONP)
* JSON gem (install with gem, Debian/Ubuntu packages are too old and buggy)
* jQuery (www.jquery.com), necessary files are included
* Flexigrid (Originally from http://code.google.com/p/flexigrid/
@@ -36,7 +37,7 @@ Debian/Ubuntu packages:
rubygems
Gems:
- gem install mongrel rack sinatra json
+ gem install mongrel rack rack-contrib sinatra json
DATA IMPORT
@@ -44,6 +45,7 @@ DATA IMPORT
See http://wiki.openstreetmap.org/wiki/Taginfo/Running
+
WEB USER INTERFACE
------------------
diff --git a/examples/jsonp.html b/examples/jsonp.html
new file mode 100644
index 0000000..b9ceb38
--- /dev/null
+++ b/examples/jsonp.html
@@ -0,0 +1,21 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
+<html>
+ <head>
+ <title>Taginfo JSONP Test</title>
+ <meta http-equiv="content-type" content="text/html; charset=utf-8" />
+ <script>
+var result;
+function jsonp(data) {
+ result = data;
+}
+ </script>
+ <script src="http://taginfo.openstreetmap.de/api/2/db/keys?include=prevalent_values&page=1&rp=15&sortname=count_all&sortorder=desc&qtype=key&callback=jsonp"></script>
+ <script>
+var key = result.data[0].key;
+alert(key);
+ </script>
+ </head>
+ <body>
+ <h1>Taginfo JSONP Test</h1>
+ </body>
+</html>
diff --git a/web/taginfo.rb b/web/taginfo.rb
index af9e4de..78b0a04 100755
--- a/web/taginfo.rb
+++ b/web/taginfo.rb
@@ -33,6 +33,7 @@ require 'sqlite3'
require 'sinatra/base'
require 'sinatra/r18n'
+require 'rack/contrib'
require 'lib/utils.rb'
require 'lib/javascript.rb'
@@ -62,6 +63,8 @@ class Taginfo < Sinatra::Base
register Sinatra::R18n
+ use Rack::JSONP
+
mime_type :opensearch, 'application/opensearchdescription+xml'
configure do