Class: Siteleaf::Site
Instance Attribute Summary collapse
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#defaults ⇒ Object
Returns the value of attribute defaults.
-
#domain ⇒ Object
Returns the value of attribute domain.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#metadata ⇒ Object
Returns the value of attribute metadata.
-
#timezone ⇒ Object
Returns the value of attribute timezone.
-
#title ⇒ Object
Returns the value of attribute title.
-
#updated_at ⇒ Object
readonly
Returns the value of attribute updated_at.
-
#user_id ⇒ Object
readonly
Returns the value of attribute user_id.
Attributes inherited from Entity
Class Method Summary collapse
Instance Method Summary collapse
- #collections ⇒ Object
- #filename ⇒ Object
- #full_url ⇒ Object
- #pages ⇒ Object
- #posts ⇒ Object
- #preview ⇒ Object
- #publish ⇒ Object
- #sha ⇒ Object
- #source_files(dir = '.', opts = {}) ⇒ Object
- #uploads ⇒ Object
- #users ⇒ Object
Methods inherited from Entity
all, #attributes, #attributes=, class_name, create, #create_endpoint, delete, #delete, endpoint, #entity_endpoint, find, #identifier, #initialize, #save
Constructor Details
This class inherits a constructor from Siteleaf::Entity
Instance Attribute Details
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
5 6 7 |
# File 'lib/siteleaf/site.rb', line 5 def created_at @created_at end |
#defaults ⇒ Object
Returns the value of attribute defaults.
4 5 6 |
# File 'lib/siteleaf/site.rb', line 4 def defaults @defaults end |
#domain ⇒ Object
Returns the value of attribute domain.
4 5 6 |
# File 'lib/siteleaf/site.rb', line 4 def domain @domain end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
5 6 7 |
# File 'lib/siteleaf/site.rb', line 5 def id @id end |
#metadata ⇒ Object
Returns the value of attribute metadata.
4 5 6 |
# File 'lib/siteleaf/site.rb', line 4 def @metadata end |
#timezone ⇒ Object
Returns the value of attribute timezone.
4 5 6 |
# File 'lib/siteleaf/site.rb', line 4 def timezone @timezone end |
#title ⇒ Object
Returns the value of attribute title.
4 5 6 |
# File 'lib/siteleaf/site.rb', line 4 def title @title end |
#updated_at ⇒ Object (readonly)
Returns the value of attribute updated_at.
5 6 7 |
# File 'lib/siteleaf/site.rb', line 5 def updated_at @updated_at end |
#user_id ⇒ Object (readonly)
Returns the value of attribute user_id.
5 6 7 |
# File 'lib/siteleaf/site.rb', line 5 def user_id @user_id end |
Class Method Details
Instance Method Details
#collections ⇒ Object
28 29 30 31 |
# 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 ⇒ Object
60 61 62 |
# File 'lib/siteleaf/site.rb', line 60 def filename "_config.yml" end |
#full_url ⇒ Object
56 57 58 |
# File 'lib/siteleaf/site.rb', line 56 def full_url "http://#{domain}" end |
#pages ⇒ Object
23 24 25 26 |
# 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 ⇒ Object
33 34 35 |
# File 'lib/siteleaf/site.rb', line 33 def posts Collection.new(path: 'posts', site_id: id).documents end |
#preview ⇒ Object
46 47 48 49 |
# 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 ⇒ Object
41 42 43 44 |
# 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 ⇒ Object
64 65 66 |
# File 'lib/siteleaf/site.rb', line 64 def sha Siteleaf::GitHash.string(to_file) end |
#source_files(dir = '.', opts = {}) ⇒ Object
18 19 20 21 |
# 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 ⇒ Object
37 38 39 |
# File 'lib/siteleaf/site.rb', line 37 def uploads Collection.new(path: 'uploads', site_id: id).files end |