class Siteleaf::Site
Attributes
created_at[R]
defaults[RW]
domain[RW]
id[R]
metadata[RW]
timezone[RW]
title[RW]
updated_at[R]
user_id[R]
Public Class Methods
find_by_domain(domain)
click to toggle source
# File lib/siteleaf/site.rb, line 7 def self.find_by_domain(domain) results = Client.get self.endpoint result = results.find {|d| d['domain'] == domain } self.new(result) if result end
import(attrs)
click to toggle source
# File lib/siteleaf/site.rb, line 13 def self.import(attrs) result = Client.post "import", attrs Job.new(id: result["job_id"]) if result end
Public Instance Methods
collections()
click to toggle source
# File lib/siteleaf/site.rb, line 28 def collections result = Client.get "#{entity_endpoint}/collections" result.map { |r| Collection.new(r) } if result.is_a? Array end
filename()
click to toggle source
# File lib/siteleaf/site.rb, line 55 def filename "_config.yml" end
full_url()
click to toggle source
# File lib/siteleaf/site.rb, line 51 def full_url "http://#{domain}" end
pages()
click to toggle source
# File lib/siteleaf/site.rb, line 23 def pages result = Client.get "#{entity_endpoint}/pages" result.map { |r| Page.new(r) } if result.is_a? Array end
posts()
click to toggle source
# File lib/siteleaf/site.rb, line 33 def posts Collection.new(path: 'posts', site_id: id).documents end
preview()
click to toggle source
# File lib/siteleaf/site.rb, line 46 def preview result = Client.post "#{entity_endpoint}/preview", {} Job.new(id: result["job_id"]) if result end
publish()
click to toggle source
# File lib/siteleaf/site.rb, line 41 def publish result = Client.post "#{entity_endpoint}/publish", {} Job.new(id: result["job_id"]) if result end
sha()
click to toggle source
# File lib/siteleaf/site.rb, line 59 def sha Siteleaf::GitHash.string(to_file) end
source_files(dir = '.', opts = {})
click to toggle source
# File lib/siteleaf/site.rb, line 18 def source_files(dir = '.', opts = {}) result = Client.get ::File.join(entity_endpoint, "source", dir), opts result.map { |r| SourceFile.new(r.merge('site_id' => id)) } if result.is_a? Array end
uploads()
click to toggle source
# File lib/siteleaf/site.rb, line 37 def uploads Collection.new(path: 'uploads', site_id: id).files end