dato 0.1.21 → 0.1.22

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: d6df40edef1f8ec088780bf5465eed032d37f853
4
- data.tar.gz: b9a2c1fecc384e608aa7fd483fa8af4ad3a7058b
3
+ metadata.gz: 144ffa9b811678f73e5aaafceb4142e8b55aa1b1
4
+ data.tar.gz: 743a63ec3d45593af332b52198d8e642ccbb89e9
5
5
  SHA512:
6
- metadata.gz: 96981103eb1441d212ad4932a3b595a1dca7f1b01fc47bfe4a78a385c96e612dcd685efab2603d8b82501f003f0389766f65b7aeba8081561c5114272392b8a8
7
- data.tar.gz: 1b782b8acade363c81060cc31c29ca34fc93a7730f2d4b8df2363308986d6ff160d3d8e5d6e5f2cf84d5590eb505125f3ddc25fa00afcb032518c68df2039e5d
6
+ metadata.gz: 87c5ac87dfb9c5930b9093161ae9e6b01e827c2b11358feb26acb1aef69366ebeda418bfeb02678643df2ab2f6e30dddd67dc4672faa1bdcc74c75209a0b80b3
7
+ data.tar.gz: e6149a6e77bfe83400eb8a8badf9439d2cbf96fef79bf7c9e300a9cbaea0658e6a42847c71768ab4c740175ddd04bbea3a62acb072644553b541638f839a8fce
data/README.md CHANGED
@@ -15,7 +15,7 @@ Ruby client for the DatoCMS API.
15
15
 
16
16
  This gem can be used in different ways, so the documentation is split up in different files:
17
17
 
18
- * [I want to use the content of a DatoCMS site in my static website (Hugo, Jeckyll, etc.)](https://github.com/datocms/ruby-datocms-client/blob/master/docs/dato-cli.md);
18
+ * [I want to use the content of a DatoCMS site in my static website (Hugo, Jekyll, etc.)](https://github.com/datocms/ruby-datocms-client/blob/master/docs/dato-cli.md);
19
19
  * [I want to edit the contents of an existing DatoCMS site programmatically](https://github.com/datocms/ruby-datocms-client/blob/master/docs/site-api-client.md);
20
20
  * [I want to create new DatoCMS sites programmatically](https://github.com/datocms/ruby-datocms-client/blob/master/docs/account-api-client.md).
21
21
 
data/docs/dato-cli.md CHANGED
@@ -45,11 +45,36 @@ DatoCMS commands:
45
45
  dato help [COMMAND] # Describe available commands or one specific command
46
46
  ```
47
47
 
48
- Hurray!!
48
+ Great! Now the easiest way to dump all the remote data into local files is to create a `dato.config.rb` file into your project root directory with the following content:
49
49
 
50
- ## Step-by-step integration guide
50
+ ```ruby
51
+ # dato.config.rb
52
+ dato.available_locales.each do |locale|
53
+ directory "content/#{locale}" do
54
+ I18n.with_locale(locale) do
55
+ create_data_file "site.yml", :yaml, dato.site.to_hash
56
+ dato.item_types.each do |item_type|
57
+ create_data_file "#{item_type.api_key}.yml", :yaml,
58
+ dato.items_of_type(item_type).map(&:to_hash)
59
+ end
60
+ end
61
+ end
62
+ end
63
+ ```
64
+
65
+ And run the following command:
66
+
67
+ ```
68
+ $ bundle exec dato dump --token=SITE_READONLY_TOKEN
69
+ ```
70
+
71
+ Hurray! A new `content` directory should have been generated with a Yaml file for each item type and the site itself!
51
72
 
52
- Now, just to make things more down-to-heart, suppose we're working with a Hugo website with the following structure:
73
+ ## Hugo step-by-step integration guide
74
+
75
+ That's just the beginning: it probably makes more sense if you generate local files following the precise guidelines of the static site generator you're using. You can easily configure the `dato.config.rb` file to achieve that.
76
+
77
+ Just to make things more down-to-heart, suppose we're working with a Hugo website with the following structure:
53
78
 
54
79
  ```
55
80
  .
@@ -71,7 +96,7 @@ Now, just to make things more down-to-heart, suppose we're working with a Hugo w
71
96
  └── ...
72
97
  ```
73
98
 
74
- Our job is to generate the Markdown files in the `content` directory from the data contained in our DatoCMS site. Also the Toml files contained in the in the `data` directory need the same treatment.
99
+ Our job is to generate the Markdown files in the `content` directory from the data contained in our DatoCMS site. The Toml files contained in the in the `data` directory need to be generated as well.
75
100
 
76
101
  ### Set up the site
77
102
 
@@ -92,9 +117,7 @@ Using the DatoCMS web interface, we first create the following Item types:
92
117
 
93
118
  ### Writing the config file
94
119
 
95
- We then define how content stored in DatoCMS needs to be translated into local files using a config file placed in your project root folder called `dato.config.rb`.
96
-
97
- Let's start with posts:
120
+ We then define how content stored in DatoCMS needs to be translated into local files inside the `dato.config.rb` config file. Let's start with posts:
98
121
 
99
122
  ```ruby
100
123
  directory "content/post" do
@@ -26,9 +26,9 @@ module Dato
26
26
 
27
27
  def slug(prefix_with_id: true)
28
28
  return item_type.api_key.humanize.parameterize if singleton?
29
- return id.to_s unless title_attribute
29
+ return id.to_s unless title_field_api_key
30
30
 
31
- title = send(title_attribute)
31
+ title = send(title_field_api_key)
32
32
  if title && prefix_with_id
33
33
  "#{id}-#{title.parameterize[0..50]}"
34
34
  elsif title
@@ -38,6 +38,14 @@ module Dato
38
38
  end
39
39
  end
40
40
 
41
+ def title_field_api_key
42
+ title_field = fields.find do |field|
43
+ field.field_type == 'string' &&
44
+ field.appeareance[:type] == 'title'
45
+ end
46
+ title_field && title_field.api_key
47
+ end
48
+
41
49
  def singleton?
42
50
  item_type.singleton
43
51
  end
@@ -140,14 +148,6 @@ module Dato
140
148
  super
141
149
  end
142
150
  end
143
-
144
- def title_attribute
145
- title_field = fields.find do |field|
146
- field.field_type == 'string' &&
147
- field.appeareance[:type] == 'title'
148
- end
149
- title_field && title_field.api_key
150
- end
151
151
  end
152
152
  end
153
153
  end
data/lib/dato/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Dato
3
- VERSION = '0.1.21'
3
+ VERSION = '0.1.22'
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dato
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.21
4
+ version: 0.1.22
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefano Verna
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-09-08 00:00:00.000000000 Z
11
+ date: 2016-09-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler