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.
 
 
 
 
 

47 lines
1.0 KiB

  1. module PostsHelper
  2. def post_to_poi(post)
  3. # http://layar.com/documentation/browser/api/getpois-response/
  4. {
  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. end
  30. def decode_entities(s)
  31. HTMLEntities.new.decode s
  32. end
  33. def clean_description(s)
  34. if s.nil?
  35. return ""
  36. end
  37. if s.size > 137
  38. s = s[0..136] + '...'
  39. end
  40. decode_entities(s.gsub(/<.+?>/, ''))
  41. end
  42. end