siteleaf 1.0.6 → 1.0.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f1f74b22241c0bbed850ac4a6bbfeff180b3ff6e
4
- data.tar.gz: b1c3fbd743d203574c6a0417b06c7aa762b8c832
3
+ metadata.gz: 5f74c49a1f23b1a7fa9b7ed1887a6902fe8b124a
4
+ data.tar.gz: 8b6938a886900939e717d62e6a8d99769cfe2530
5
5
  SHA512:
6
- metadata.gz: 5dfeae6e9e4e418b6793b1a3025adb7a7c272e034392a1f3ec959d2daf238bb4b297c3056267cabbd8eae175087892f0a2ee71e6bd068a6d92f7f54db9fc5f6b
7
- data.tar.gz: 0f4c18a7a3736bf3eb556b96c79d5abe20471827e02517b19f0caeb128ce18b6b4724e3bc453b3a2d74835fae080f6f45ff5105fd24fef960fccc41f3dcf9224
6
+ metadata.gz: fc28e5260c862cf114e6b7714bad0bd0d668096befac16a5cb7924dc7913db633c75a09e9f7c205f16a417da96ea8b4418e72652db7168f6f34a48a159787ce2
7
+ data.tar.gz: e6f85fde2f3dba994740f17a4d56f9fcb9ab1cfbaa750c509e7ab41ca9959509f5f047e056824b3d7b7bb3341f8f3e610d61730534764794ea5dd7df4e5003c1
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
- Siteleaf Gem
2
- ============
1
+ For v2 see: https://github.com/siteleaf/siteleaf-gem/tree/2.0.0.pre
2
+
3
+ Siteleaf Gem (v1)
4
+ =================
3
5
 
4
6
  - [Installation](#installation)
5
7
  - [Using the CLI](#using-the-cli)
@@ -1,9 +1,9 @@
1
1
  module Siteleaf
2
2
  class Asset < Entity
3
3
 
4
- attr_accessor :file, :filename, :replace, :site_id, :page_id, :post_id, :theme_id
4
+ attr_accessor :file, :filename, :replace, :site_id, :page_id, :post_id, :theme_id, :meta
5
5
  attr_reader :id, :url, :content_type, :filesize, :checksum, :created_at, :updated_at
6
-
6
+
7
7
  def create_endpoint
8
8
  if !self.post_id.nil?
9
9
  "posts/#{self.post_id}/assets"
@@ -15,22 +15,22 @@ module Siteleaf
15
15
  "sites/#{self.site_id}/assets"
16
16
  end
17
17
  end
18
-
18
+
19
19
  def post
20
20
  Post.find(self.post_id) if self.post_id
21
21
  end
22
-
22
+
23
23
  def page
24
24
  Page.find(self.page_id) if self.page_id
25
25
  end
26
-
26
+
27
27
  def theme
28
28
  Theme.find(self.theme_id) if self.theme_id
29
29
  end
30
-
30
+
31
31
  def site
32
32
  Site.find(self.site_id) if self.site_id
33
33
  end
34
-
34
+
35
35
  end
36
36
  end
data/lib/siteleaf/page.rb CHANGED
@@ -3,54 +3,62 @@ module Siteleaf
3
3
 
4
4
  attr_accessor :title, :custom_slug, :body, :visibility, :published_at, :user_id, :site_id, :parent_id, :meta
5
5
  attr_reader :id, :slug, :url, :created_at, :updated_at, :assets
6
-
6
+
7
7
  def create_endpoint
8
8
  "sites/#{self.site_id}/pages"
9
9
  end
10
-
10
+
11
11
  def site
12
12
  Site.find(self.site_id) if self.site_id
13
13
  end
14
-
14
+
15
15
  def assets
16
16
  result = Client.get "pages/#{self.id}/assets"
17
17
  result.map { |r| Asset.new(r) } if result
18
18
  end
19
-
19
+
20
20
  def posts
21
21
  result = Client.get "pages/#{self.id}/posts"
22
22
  result.map { |r| Post.new(r) } if result
23
23
  end
24
-
24
+
25
25
  def pages
26
26
  result = Client.get "pages/#{self.id}?include=pages"
27
27
  result["pages"].map { |r| Page.new(r) } if result
28
28
  end
29
-
29
+
30
30
  def page
31
31
  Page.find(self.parent_id) if self.parent_id
32
32
  end
33
-
33
+
34
34
  def draft?
35
35
  visibility == 'draft'
36
36
  end
37
-
37
+
38
38
  def published?
39
39
  visibility == 'visible'
40
40
  end
41
-
41
+
42
42
  def filename
43
43
  "#{url.sub('/','')}.markdown"
44
44
  end
45
-
45
+
46
46
  def frontmatter
47
47
  attrs = {}
48
48
  attrs['title'] = title
49
49
  attrs['date'] = Time.parse(published_at).utc if published_at
50
50
  attrs['published'] = false if !published?
51
-
51
+
52
52
  meta.each{|m| attrs[m['key'].to_s.downcase] = m['value'].to_s == '' ? nil : m['value'].to_s.gsub("\r\n","\n")} unless meta.nil?
53
-
53
+
54
+ unless assets.to_a.empty?
55
+ attrs['assets'] = assets.map do |a|
56
+ asset = {'path' => "/uploads/#{a.filename}"}
57
+ a.meta.each{|m| asset[m['key'].to_s.downcase] = m['value'].to_s == '' ? nil : m['value'].to_s.gsub("\r\n","\n")} unless meta.nil?
58
+ asset
59
+ end
60
+ end
61
+
54
62
  if defined?(taxonomy) && !taxonomy.nil?
55
63
  taxonomy.each do |t|
56
64
  next if t['values'].empty?
@@ -59,12 +67,12 @@ module Siteleaf
59
67
  attrs[key] = t['values'].map{|v| v['value'] }
60
68
  end
61
69
  end
62
-
70
+
63
71
  attrs
64
72
  end
65
-
73
+
66
74
  def to_file(dir = 'export')
67
- assets = Dir.glob("#{dir}/_uploads/**/*").each_with_object({}) do |var, hash|
75
+ assets = Dir.glob("#{dir}/_uploads/**/*").each_with_object({}) do |var, hash|
68
76
  # remap assets to _uploads
69
77
  hash[var.sub("#{dir}/_uploads",'/assets')] = var.sub("#{dir}/_uploads",'/uploads')
70
78
  end
@@ -74,6 +82,6 @@ module Siteleaf
74
82
 
75
83
  (attrs_yaml + "---\n\n".freeze + body.to_s.gsub("\r\n","\n")).gsub(Regexp.union(assets.keys), assets)
76
84
  end
77
-
85
+
78
86
  end
79
- end
87
+ end
@@ -1,3 +1,3 @@
1
1
  module Siteleaf
2
- VERSION = "1.0.6"
2
+ VERSION = "1.0.7"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: siteleaf
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.6
4
+ version: 1.0.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Siteleaf
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-05 00:00:00.000000000 Z
11
+ date: 2016-05-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty