From 2a2843948c5064d7510b623a299c10020156117d Mon Sep 17 00:00:00 2001 From: Adrian Short Date: Thu, 11 Apr 2013 12:59:16 +0100 Subject: [PATCH] JSON output for Layar custom icons per feed --- app/controllers/posts_controller.rb | 2 +- app/helpers/posts_helper.rb | 14 ++++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index 7e16799..f7de3e8 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -13,7 +13,7 @@ class PostsController < ApplicationController layar_response = { :layer => @layer.layar_name, - :hotspots => @posts.collect { |p| post_to_poi(p) }, + :hotspots => @posts.collect { |p| post_to_poi(p, Subscription.where(:feed_id => p.feed_id, :layer_id => @layer.id).first) }, :errorCode => 0, # OK :errorString => "OK", :radius => params[:radius].to_f diff --git a/app/helpers/posts_helper.rb b/app/helpers/posts_helper.rb index 3e77a72..79f3b1e 100644 --- a/app/helpers/posts_helper.rb +++ b/app/helpers/posts_helper.rb @@ -1,8 +1,8 @@ module PostsHelper - def post_to_poi(post) + def post_to_poi(post, subscription) # http://layar.com/documentation/browser/api/getpois-response/ { - :id => post._id, + :id => post.id, :imageURL => "%s%s/assets/layar-icons/tal-logo-100.png" % [ request.protocol, request.env['HTTP_HOST'] ], :anchor => { :geolocation => { @@ -23,8 +23,14 @@ module PostsHelper :contentType => "text/html", :method => "GET", :activityType => 1 - } - ] + }, + ], + :object => { + :contentType => "image/vnd.layar.generic", + :url => subscription.icon_url, + :reducedURL => subscription.icon_url, + :size => 120 + } } end