The code powering m.abunchtell.com https://m.abunchtell.com
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.
 
 
 
 

42 wiersze
1.0 KiB

  1. require 'singleton'
  2. class TagManager
  3. include Singleton
  4. include RoutingHelper
  5. def unique_tag(date, id, type)
  6. "tag:#{Rails.configuration.x.local_domain},#{date.strftime('%Y-%m-%d')}:objectId=#{id}:objectType=#{type}"
  7. end
  8. def unique_tag_to_local_id(tag, expected_type)
  9. matches = Regexp.new("objectId=([\\d]+):objectType=#{expected_type}").match(tag)
  10. return matches[1] unless matches.nil?
  11. end
  12. def local_id?(id)
  13. id.start_with?("tag:#{Rails.configuration.x.local_domain}")
  14. end
  15. def uri_for(target)
  16. return target.uri if target.respond_to?(:local?) && !target.local?
  17. case target.object_type
  18. when :person
  19. account_url(target)
  20. else
  21. unique_tag(target.stream_entry.created_at, target.stream_entry.activity_id, target.stream_entry.activity_type)
  22. end
  23. end
  24. def url_for(target)
  25. return target.url if target.respond_to?(:local?) && !target.local?
  26. case target.object_type
  27. when :person
  28. account_url(target)
  29. else
  30. account_stream_entry_url(target.account, target.stream_entry)
  31. end
  32. end
  33. end