GeoRSS aggregator and Layar augmented reality server
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。
 
 
 
 
 

75 行
1.8 KiB

  1. module PostsHelper
  2. def post_to_poi(post, subscription)
  3. # http://layar.com/documentation/browser/api/getpois-response/
  4. if subscription.layer.icon_url.blank?
  5. image_url = "%s%s/assets/layar-icons/tal-logo-100.png" % [ request.protocol, request.env['HTTP_HOST'] ]
  6. else
  7. image_url = subscription.layer.icon_url
  8. end
  9. res = {
  10. :id => post.id,
  11. :imageURL => image_url,
  12. :anchor => {
  13. :geolocation => {
  14. :lat => post.lat,
  15. :lon => post.lon,
  16. :alt => 0
  17. }
  18. },
  19. :text => {
  20. :title => decode_entities(post.title),
  21. :description => clean_description(post.summary),
  22. :footnote => "From #{post.feed_title}"
  23. },
  24. :actions => [
  25. {
  26. :label => "Read more...",
  27. :uri => post.url,
  28. :contentType => "text/html",
  29. :method => "GET",
  30. :activityType => 1
  31. },
  32. ]
  33. }
  34. unless subscription.icon_url.blank?
  35. res[:object] = {
  36. :contentType => "image/vnd.layar.generic",
  37. :url => subscription.icon_url,
  38. :reducedURL => subscription.icon_url,
  39. :size => subscription.icon_size
  40. }
  41. # http://layar.com/documentation/browser/api/getpois-response/hotspots/
  42. res[:transform] = {
  43. :rotate => {
  44. :rel => true,
  45. :axis => { :x => 0, :y => 0, :z => 1 },
  46. :angle => 0
  47. },
  48. :translate => { :x => 0, :y => -0.075, :z => 0 },
  49. :scale => 1.0
  50. }
  51. end
  52. res
  53. end
  54. def decode_entities(s)
  55. HTMLEntities.new.decode s
  56. end
  57. def clean_description(s)
  58. if s.nil?
  59. return ""
  60. end
  61. if s.size > 137
  62. s = s[0..136] + '...'
  63. end
  64. decode_entities(s.gsub(/<.+?>/, ''))
  65. end
  66. end