Class: Publinator::Site
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Publinator::Site
- Defined in:
- app/models/publinator/site.rb
Instance Method Summary collapse
- #default_url ⇒ Object
-
#layout ⇒ Object
get the layout for the site.
- #parent ⇒ Object
- #publications(scope = 'published', sort = 'updated_at desc', publishable_type) ⇒ Object
- #url(path) ⇒ Object
Instance Method Details
#default_url ⇒ Object
24 25 26 27 28 29 30 |
# File 'app/models/publinator/site.rb', line 24 def default_url dn = domain_names.where(:default => true).first url = "http://" url += "#{dn.subdomain}." unless dn.subdomain.blank? url += "#{dn.name}" url end |
#layout ⇒ Object
TODO:
add ability to use a custom layout
get the layout for the site
11 12 13 14 15 16 17 |
# File 'app/models/publinator/site.rb', line 11 def layout begin abbr rescue ActionView::MissingTemplate "publinator/site" end end |
#parent ⇒ Object
19 20 21 22 |
# File 'app/models/publinator/site.rb', line 19 def parent return nil unless parent_id.present? Site.find(self.parent_id) end |
#publications(scope = 'published', sort = 'updated_at desc', publishable_type) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'app/models/publinator/site.rb', line 36 def publications(scope = 'published', sort = 'updated_at desc', publishable_type) if publishable_type.nil? pubs = Publication.for_site(self.id).send(scope).order(sort) else pubs = Publication.for_site(self.id).send(scope).where(:publishable_type => publishable_type).order(sort) end if parent pubs += parent.pubs # TODO: resort this collection return pubs end end |
#url(path) ⇒ Object
32 33 34 |
# File 'app/models/publinator/site.rb', line 32 def url(path) "#{default_url}#{path}" end |