middleman-dato 0.5.23 → 0.5.24

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: 5bc293093c90da1225666d2340792ba15695fd47
4
- data.tar.gz: c63604064575fff12f62e4560a501d853f02f56c
3
+ metadata.gz: 8ea2407f7c1f9ac3fcaca5adcb47bc2f6ac3785f
4
+ data.tar.gz: 98d081e1bb716dad649277d023d8acb389b1e1ff
5
5
  SHA512:
6
- metadata.gz: ce62b650cc4a2ae640f8c17f5deb74f71c2272bb0c993d5668b9cad5ec5f03ec4f64eab53e2f0dea9e9a88701373634fc322c2293f02d957167a207fa6761767
7
- data.tar.gz: 5c3ec5f9d18a9a247ce4d7f9e1e9695e06c929b27c2686809a6fb190156c782b7d3e9d3fe979ab290b54c405f074fa703c688d5213ebd5b4a0441a6225634874
6
+ metadata.gz: ca3280632ab6d349820407a098d57a53369a7e142dedeabc6009109104c55582da26f9c15fd9104711c1f8e61f1c71d80678baaed1fcd3700d47d13e8ffe7885
7
+ data.tar.gz: 58f973e3e4490aa575518e4b86f006bf940a9daf3397d701f00292531774d1596ecfa95c9e96e1396dff73b3d79d634f12367e22e55c594a85bf2a92b4d7deb2
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # middleman-dato
1
+ # DatoCMS extension for DatoCMS
2
2
 
3
- [![Build Status](https://travis-ci.org/datocms/middleman-dato.svg?branch=master)](https://travis-ci.org/datocms/middleman-dato)
3
+ [![Coverage Status](https://coveralls.io/repos/github/datocms/middleman-dato/badge.svg?branch=master)](https://coveralls.io/github/datocms/middleman-dato?branch=master) [![Build Status](https://travis-ci.org/datocms/middleman-dato.svg?branch=master)](https://travis-ci.org/datocms/middleman-dato) [![Gem Version](https://badge.fury.io/rb/middleman-dato.svg)](https://badge.fury.io/rb/middleman-dato)
4
4
 
5
5
  Middleman Dato is a Middleman extension to use the Middleman static site generator together with the API-driven DatoCMS, a fully customizable administrative backend for your static websites.
6
6
 
@@ -34,11 +34,29 @@ activate :dato,
34
34
 
35
35
  ## Middleman helpers
36
36
 
37
- ### `dato`
37
+ Using this extension you can access to any item stored in your site by item type.
38
+ Let's start with a basic example: in your Middleman `source/index.html.erb` file
39
+ add the following lines:
38
40
 
39
- Using this helper you can access to any item stored in your site by item type.
40
- That is, if your site has an Item Type with `article` as API identifier, you can get
41
- the complete array of items with `dato.articles` (yep, the identifier pluralized).
41
+ ```erb
42
+ <% dato.item_types.each do |item_type| %>
43
+ <h1>Items of type "<%= item_type.name %>"</h1>
44
+ <% dato.items_of_type(item_type).each do |item| %>
45
+ <pre><%= item.to_hash %></pre>
46
+ <% end %>
47
+ <% end %>
48
+ ```
49
+
50
+ Run the server with `bundle exec middleman` and you'll see the content of every
51
+ item you created on your DatoCMS site. Awesome!
52
+
53
+ ### Querying items
54
+
55
+ Beside dumping every content available, this extension makes it easy also to
56
+ return items belonging to a specific Item Type.
57
+
58
+ If your site has an Item Type with `article` as API identifier, you can get
59
+ the complete array of items with `dato.articles` — yep, **the API identifier pluralized**.
42
60
 
43
61
  If a Item Type is marked as Singleton (ie. `about_page`) you don't need to pluralize and
44
62
  a call to `dato.about_page` directly returns the Item (or `nil`, if still hasn't been created
@@ -49,7 +67,7 @@ You can query any Item field value with a method called like the field API ident
49
67
  If a Item Type has a String field with Title appeareance, than the item responds to `.slug`,
50
68
  returning a slugified version of the title itself (or the item identifier, if the title is empty).
51
69
 
52
- You can use this helper within Middleman `config.rb`, as well as within your views:
70
+ You can use these methods in the Middleman `config.rb` file, as well as within your views:
53
71
 
54
72
  ```ruby
55
73
  <% dato.articles.each do |article| %>
@@ -15,11 +15,17 @@ module MiddlemanDato
15
15
  end
16
16
 
17
17
  def title
18
- @title ||= seo_field_with_fallback(
19
- :title,
20
- item && item.title_field_api_key &&
21
- item.send(item.title_field_api_key)
22
- )
18
+ @title ||= begin
19
+ title_field = item.fields.find do |field|
20
+ field.field_type == 'string' &&
21
+ field.appeareance[:type] == 'title'
22
+ end
23
+
24
+ seo_field_with_fallback(
25
+ :title,
26
+ item && title_field && item.send(title_field.api_key)
27
+ )
28
+ end
23
29
  end
24
30
 
25
31
  def title_with_suffix
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module MiddlemanDato
3
- VERSION = '0.5.23'
3
+ VERSION = '0.5.24'
4
4
  end
@@ -20,6 +20,8 @@ Gem::Specification.new do |s|
20
20
  end
21
21
  s.require_paths = ['lib']
22
22
 
23
+ s.add_development_dependency('coveralls')
24
+
23
25
  s.add_runtime_dependency('middleman-core', ['>= 3.3.12'])
24
26
  s.add_runtime_dependency('dato', ['>= 0.1.22'])
25
27
  s.add_runtime_dependency('semantic')
data/spec/spec_helper.rb CHANGED
@@ -1,5 +1,12 @@
1
1
  # frozen_string_literal: true
2
2
  require 'simplecov'
3
+ require 'coveralls'
4
+
5
+ SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([
6
+ SimpleCov::Formatter::HTMLFormatter,
7
+ Coveralls::SimpleCov::Formatter
8
+ ])
9
+
3
10
  SimpleCov.start do
4
11
  add_filter '/spec/'
5
12
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: middleman-dato
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.23
4
+ version: 0.5.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stefano Verna
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-09-10 00:00:00.000000000 Z
11
+ date: 2016-11-04 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: coveralls
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: middleman-core
15
29
  requirement: !ruby/object:Gem::Requirement