* Adds a new metadata helper and methods to PostPresenter to have metas on post pages. * Adds tests to post controller to check correctness of metas * Add methods to PersonPresenter to have metas on profile pages * Correct meta data helper test * Update PersonPresenter, add test to PeopleController * Creates TagPresenter. Display tag metas on tag index page * Updata meta data helper spec * Not displaying bio as the description meta on profile page for now. Privacy concerns to be cleared. * Set meta info as hashes in presenters * Move original hardcoded metas info to config/defaults.yml * metas_tags include by default the general metas, update views * Update code style, clean views * Renames TagPresenter StreamTagPresenter, updates TagController spec * Add a default_metas entry to diaspora.yml.example * Align metas hash in presenters, refactor meta data helper * Use bio as description meta if user has a public profile * Rename StreamTagPresenter to TagStreamPresenter
36 lines
742 B
Ruby
36 lines
742 B
Ruby
class BasePresenter
|
|
attr_reader :current_user
|
|
include Rails.application.routes.url_helpers
|
|
|
|
class << self
|
|
def new(*args)
|
|
return NilPresenter.new if args[0].nil?
|
|
super *args
|
|
end
|
|
|
|
def as_collection(collection, method=:as_json, *args)
|
|
collection.map{|object| self.new(object, *args).send(method) }
|
|
end
|
|
end
|
|
|
|
def initialize(presentable, curr_user=nil)
|
|
@presentable = presentable
|
|
@current_user = curr_user
|
|
end
|
|
|
|
def method_missing(method, *args)
|
|
@presentable.public_send(method, *args)
|
|
end
|
|
|
|
class NilPresenter
|
|
def method_missing(method, *args)
|
|
nil
|
|
end
|
|
end
|
|
|
|
private
|
|
|
|
def default_url_options
|
|
{host: AppConfig.pod_uri.host, port: AppConfig.pod_uri.port}
|
|
end
|
|
end
|