Sha256: f3d4a617dc6e7d59d9e182dd25663e9db843089cf0746b02569b9d7c98af5162

Contents?: true

Size: 690 Bytes

Versions: 12

Compression:

Stored size: 690 Bytes

Contents

module Siteleaf
  class Site < Entity

    attr_accessor :title, :domain, :timezone
    attr_reader :id, :user_id, :created_at, :updated_at
    
    def self.find_by_domain(domain)
      result = Client.get "sites", {"domain" => domain}
      self.new(result.first) if result and result.size >= 1
    end
    
    def pages
      result = Client.get "sites/#{self.id}/pages"
      result.map { |r| Page.new(r) } if result
    end
    
    def resolve(url = '/')
      Client.get "sites/#{self.id}/resolve", {"url" => url}
    end
    
    def preview(url = '/', template = nil)
      Client.post "sites/#{self.id}/preview.html", {"url" => url, "template" => template}
    end
    
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
siteleaf-0.9.11 lib/siteleaf/site.rb
siteleaf-0.9.10 lib/siteleaf/site.rb
siteleaf-0.9.9 lib/siteleaf/site.rb
siteleaf-0.9.8 lib/siteleaf/site.rb
siteleaf-0.9.7 lib/siteleaf/site.rb
siteleaf-0.9.6 lib/siteleaf/site.rb
siteleaf-0.9.5 lib/siteleaf/site.rb
siteleaf-0.9.3 lib/siteleaf/site.rb
siteleaf-0.9.2 lib/siteleaf/site.rb
siteleaf-0.9.1 lib/siteleaf/site.rb
siteleaf-0.9.0 lib/siteleaf/site.rb
siteleaf-0.8.3 lib/siteleaf/site.rb