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.6 KiB

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