GeoRSS aggregator and Layar augmented reality server
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

posts_helper.rb 1.8 KiB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  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 => ENV['APOLLO_TRANSLATE_Z'] || 1.75 },
  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