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.

преди 11 години
преди 11 години
преди 12 години
преди 12 години
преди 12 години
преди 11 години
преди 11 години
преди 11 години
преди 11 години
преди 11 години
преди 12 години
преди 12 години
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. distance = post.distance.to_i
  10. scale = 1.0
  11. scale = 0.5 if distance < 100.0
  12. scale = distance / 1000.0 if distance > 1000.0
  13. res = {
  14. :id => post.id,
  15. :imageURL => image_url,
  16. :anchor => {
  17. :geolocation => {
  18. :lat => post.lat,
  19. :lon => post.lon,
  20. :alt => 0
  21. }
  22. },
  23. :text => {
  24. :title => decode_entities(post.title),
  25. :description => clean_description(post.summary),
  26. :footnote => "From #{post.feed_title}"
  27. },
  28. :actions => [
  29. {
  30. :label => "Read more...",
  31. :uri => post.url,
  32. :contentType => "text/html",
  33. :method => "GET",
  34. :activityType => 1
  35. },
  36. ]
  37. }
  38. unless subscription.icon_url.blank?
  39. res[:object] = {
  40. :contentType => "image/vnd.layar.generic",
  41. :url => subscription.icon_url,
  42. :reducedURL => subscription.icon_url,
  43. :size => subscription.icon_size
  44. }
  45. # http://layar.com/documentation/browser/api/getpois-response/hotspots/
  46. res[:transform] = {
  47. :rotate => {
  48. :rel => true,
  49. :axis => { :x => 0, :y => 0, :z => 1 },
  50. :angle => 0
  51. },
  52. :translate => { :x => 0, :y => -0.075, :z => ENV['APOLLO_TRANSLATE_Z'] || 1.75 },
  53. :scale => scale
  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. end