GeoRSS aggregator and Layar augmented reality server
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

преди 12 години
преди 12 години
преди 12 години
преди 11 години
преди 11 години
преди 11 години
преди 11 години
преди 11 години
преди 11 години
преди 12 години
преди 12 години
преди 11 години
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. res[:icon] = {
  42. :url => subscription.icon_url
  43. }
  44. # http://layar.com/documentation/browser/api/getpois-response/hotspots/
  45. res[:transform] = {
  46. :rotate => {
  47. :rel => true,
  48. :axis => { :x => 0, :y => 0, :z => 1 },
  49. :angle => 0
  50. },
  51. :translate => { :x => 0, :y =>0, :z => ENV['APOLLO_TRANSLATE_Z'] || 1.75 },
  52. # :scale => calculate_scale(post.distance.to_i),
  53. :distance => post.distance
  54. }
  55. end
  56. res
  57. end
  58. def decode_entities(s)
  59. HTMLEntities.new.decode s
  60. end
  61. def clean_description(s)
  62. if s.nil?
  63. return ""
  64. end
  65. if s.size > 137
  66. s = s[0..136] + '...'
  67. end
  68. decode_entities(s.gsub(/<.+?>/, ''))
  69. end
  70. def calculate_scale(distance)
  71. scale = 1.0
  72. scale = 0.5 if distance < 100.0
  73. scale = distance / 1000.0 if distance > 1000.0
  74. scale
  75. end
  76. end