aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJochen Topf <jochen@topf.org>2014-05-16 12:13:23 +0200
committerJochen Topf <jochen@topf.org>2014-05-16 12:13:23 +0200
commit0909954e215283d1ca0e393d109e98c859e7e662 (patch)
treeb1943e4729a81a8fd3695da866925cf4587d37ec
parent5f71ac169272f2b8ddb18437bf41942641c51d85 (diff)
downloadtaginfo-0909954e215283d1ca0e393d109e98c859e7e662.tar
taginfo-0909954e215283d1ca0e393d109e98c859e7e662.tar.gz
Add request url to API json output.
-rw-r--r--web/lib/api/v4/key.rb5
-rw-r--r--web/lib/api/v4/keys.rb3
-rw-r--r--web/lib/api/v4/relation.rb4
-rw-r--r--web/lib/api/v4/relations.rb1
-rw-r--r--web/lib/api/v4/search.rb4
-rw-r--r--web/lib/api/v4/tag.rb4
-rw-r--r--web/lib/api/v4/tags.rb2
-rw-r--r--web/lib/api/v4/wiki.rb1
-rw-r--r--web/lib/utils.rb3
9 files changed, 24 insertions, 3 deletions
diff --git a/web/lib/api/v4/key.rb b/web/lib/api/v4/key.rb
index d084110..1cbb817 100644
--- a/web/lib/api/v4/key.rb
+++ b/web/lib/api/v4/key.rb
@@ -59,6 +59,7 @@ class Taginfo < Sinatra::Base
:page => @ap.page,
:rp => @ap.results_per_page,
:total => total,
+ :url => request.url,
:data => res.map{ |row| {
:other_key => row['other_key'],
:together_count => row['together_count'].to_i,
@@ -184,7 +185,8 @@ class Taginfo < Sinatra::Base
return {
:total => 4,
- :data => out
+ :url => request.url,
+ :data => out
}.to_json
end
@@ -272,6 +274,7 @@ class Taginfo < Sinatra::Base
:page => @ap.page,
:rp => @ap.results_per_page,
:total => total.to_i,
+ :url => request.url,
:data => res.map{ |row| {
:value => row['value'],
:count => row['count_' + filter_type].to_i,
diff --git a/web/lib/api/v4/keys.rb b/web/lib/api/v4/keys.rb
index d715656..01739f7 100644
--- a/web/lib/api/v4/keys.rb
+++ b/web/lib/api/v4/keys.rb
@@ -114,6 +114,7 @@ class Taginfo < Sinatra::Base
:page => @ap.page,
:rp => @ap.results_per_page,
:total => total,
+ :url => request.url,
:data => res.map{ |row| h = {
:key => row['key'],
:count_all => row['count_all'].to_i,
@@ -167,6 +168,7 @@ class Taginfo < Sinatra::Base
:page => @ap.page,
:rp => @ap.results_per_page,
:total => total,
+ :url => request.url,
:data => res.map{ |row|
lang_hash = Hash.new
row['langs'].split(',').each{ |l|
@@ -252,6 +254,7 @@ class Taginfo < Sinatra::Base
:page => @ap.page,
:rp => @ap.results_per_page,
:total => total,
+ :url => request.url,
:data => res.map{ |row| {
:key => row['key'],
:count_all => row['count_all'].to_i,
diff --git a/web/lib/api/v4/relation.rb b/web/lib/api/v4/relation.rb
index 4fdd936..1f7cc0f 100644
--- a/web/lib/api/v4/relation.rb
+++ b/web/lib/api/v4/relation.rb
@@ -53,6 +53,7 @@ class Taginfo < Sinatra::Base
:page => @ap.page,
:rp => @ap.results_per_page,
:total => total,
+ :url => request.url,
:data => res.map{ |row| {
:rtype => row['rtype'],
:role => row['role'],
@@ -99,7 +100,8 @@ class Taginfo < Sinatra::Base
return {
:total => 4,
- :data => out
+ :url => request.url,
+ :data => out
}.to_json
end
diff --git a/web/lib/api/v4/relations.rb b/web/lib/api/v4/relations.rb
index 9389f84..faa334b 100644
--- a/web/lib/api/v4/relations.rb
+++ b/web/lib/api/v4/relations.rb
@@ -60,6 +60,7 @@ class Taginfo < Sinatra::Base
:page => @ap.page,
:rp => @ap.results_per_page,
:total => total,
+ :url => request.url,
:data => res.map{ |row| {
:rtype => row['rtype'],
:count => row['count'].to_i,
diff --git a/web/lib/api/v4/search.rb b/web/lib/api/v4/search.rb
index edc2710..c1a2012 100644
--- a/web/lib/api/v4/search.rb
+++ b/web/lib/api/v4/search.rb
@@ -41,6 +41,7 @@ class Taginfo < Sinatra::Base
:page => @ap.page,
:rp => @ap.results_per_page,
:total => total,
+ :url => request.url,
:data => res.map{ |row| {
:key => row['key'],
:value => row['value'],
@@ -77,6 +78,7 @@ class Taginfo < Sinatra::Base
:page => @ap.page,
:rp => @ap.results_per_page,
:total => total,
+ :url => request.url,
:data => res.map{ |row| {
:key => row['key'],
:value => row['value']
@@ -117,6 +119,7 @@ class Taginfo < Sinatra::Base
:page => @ap.page,
:rp => @ap.results_per_page,
:total => total,
+ :url => request.url,
:data => res.map{ |row| {
:rtype => row['rtype'],
:role => row['role'],
@@ -158,6 +161,7 @@ class Taginfo < Sinatra::Base
:page => @ap.page,
:rp => @ap.results_per_page,
:total => total,
+ :url => request.url,
:data => res.map{ |row| {
:key => row['key'],
:value => row['value'],
diff --git a/web/lib/api/v4/tag.rb b/web/lib/api/v4/tag.rb
index 08626d4..778fd4a 100644
--- a/web/lib/api/v4/tag.rb
+++ b/web/lib/api/v4/tag.rb
@@ -73,6 +73,7 @@ class Taginfo < Sinatra::Base
:page => @ap.page,
:rp => @ap.results_per_page,
:total => total,
+ :url => request.url,
:data => res.map{ |row| {
:other_key => row['other_key'],
:other_value => row['other_value'],
@@ -203,7 +204,8 @@ class Taginfo < Sinatra::Base
return {
:total => 4,
- :data => out
+ :url => request.url,
+ :data => out
}.to_json
end
diff --git a/web/lib/api/v4/tags.rb b/web/lib/api/v4/tags.rb
index 37dfd94..77863a8 100644
--- a/web/lib/api/v4/tags.rb
+++ b/web/lib/api/v4/tags.rb
@@ -84,6 +84,7 @@ class Taginfo < Sinatra::Base
return {
:total => res.size,
+ :url => request.url,
:data => res.map{ |row| {
:key => row['key'],
:value => row['value'],
@@ -149,6 +150,7 @@ class Taginfo < Sinatra::Base
:page => @ap.page,
:rp => @ap.results_per_page,
:total => total,
+ :url => request.url,
:data => res.map{ |row| {
:key => row['skey'],
:value => row['svalue'],
diff --git a/web/lib/api/v4/wiki.rb b/web/lib/api/v4/wiki.rb
index 45f85b8..9c9be4f 100644
--- a/web/lib/api/v4/wiki.rb
+++ b/web/lib/api/v4/wiki.rb
@@ -29,6 +29,7 @@ class Taginfo < Sinatra::Base
return {
:total => res.size,
+ :url => request.url,
:data => res.map{ |row| {
:code => row['code'],
:native_name => row['native_name'],
diff --git a/web/lib/utils.rb b/web/lib/utils.rb
index 7d64538..f802956 100644
--- a/web/lib/utils.rb
+++ b/web/lib/utils.rb
@@ -208,6 +208,7 @@ def get_josm_style_rules_result(total, res)
:page => @ap.page,
:rp => @ap.results_per_page,
:total => total,
+ :url => request.url,
:data => res.map{ |row| {
:key => row['k'],
:value => row['v'],
@@ -226,6 +227,7 @@ def paging_results(array)
[ :total, :INT, 'Total number of results.' ],
[ :page, :INT, 'Result page number (first has page number 1).' ],
[ :rp, :INT, 'Results per page.' ],
+ [ :url, :STRING, 'URL of the request.' ],
[ :data, :ARRAY_OF_HASHES, 'Array with results.', array ]
];
end
@@ -233,6 +235,7 @@ end
def no_paging_results(array)
return [
[ :total, :INT, 'Total number of results.' ],
+ [ :url, :STRING, 'URL of the request.' ],
[ :data, :ARRAY_OF_HASHES, 'Array with results.', array ]
];
end