middleman-dato 0.8.0.pre → 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/LICENSE +21 -0
- data/README.md +1 -1
- data/lib/middleman_dato/middleman_extension.rb +14 -14
- data/lib/middleman_dato/version.rb +1 -1
- data/middleman-dato.gemspec +2 -2
- metadata +13 -15
- data/lib/middleman_dato/watcher.rb +0 -44
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 14dc83a3c03593fa661f17504f49124d193b56cf6d851289a78e6f09ddccc66b
|
4
|
+
data.tar.gz: 2d07e39d17d648d5624570167451cb3c552b36aad41ed1aa7260286c9b5aff4a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4ecd6cc01862bc26227219c39cfe056669577860c8ebcbf4c9bc8cfb70ba43acc5002ad15d1d9d5d258a8e53bfca85b5dfa8b929fc8cf652d907e880a7ff62f4
|
7
|
+
data.tar.gz: 5ba4ffd3009976c5057dda14c4372230307050fdd3b6010718c1d63722049d6c657e4078a9b8f47eab183af8866900ebd9024a1ef2ef236654518743b26ad1c3
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2019 Cantiere Creativo SRL
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# DatoCMS extension for
|
1
|
+
# DatoCMS extension for Middleman
|
2
2
|
|
3
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
|
|
@@ -1,10 +1,9 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require 'middleman-core'
|
3
4
|
require 'middleman-core/version'
|
4
5
|
require 'dato/site/client'
|
5
6
|
require 'dato/local/loader'
|
6
|
-
require 'dato/watch/site_change_watcher'
|
7
|
-
require 'middleman_dato/watcher'
|
8
7
|
require 'dato/utils/seo_tags_builder'
|
9
8
|
require 'dato/utils/favicon_tags_builder'
|
10
9
|
require 'dotenv'
|
@@ -13,10 +12,11 @@ module MiddlemanDato
|
|
13
12
|
class MiddlemanExtension < ::Middleman::Extension
|
14
13
|
attr_reader :loader
|
15
14
|
|
16
|
-
option :token, ENV['DATO_API_TOKEN'], '
|
17
|
-
option :api_base_url, 'https://site-api.datocms.com', '
|
15
|
+
option :token, ENV['DATO_API_TOKEN'], 'Project API token'
|
16
|
+
option :api_base_url, 'https://site-api.datocms.com', 'API Base URL'
|
18
17
|
option :live_reload, true, 'Live reload of content coming from DatoCMS'
|
19
|
-
option :
|
18
|
+
option :preview, false, 'Show latest (unpublished) version of your content'
|
19
|
+
option :environment, nil, 'Environment to fetch data from'
|
20
20
|
|
21
21
|
option :base_url, nil, 'Website base URL (deprecated)'
|
22
22
|
option :domain, nil, 'Site domain (deprecated)'
|
@@ -27,22 +27,21 @@ module MiddlemanDato
|
|
27
27
|
def initialize(app, options_hash = {}, &block)
|
28
28
|
super
|
29
29
|
|
30
|
+
return if app.mode?(:config)
|
31
|
+
|
30
32
|
@loader = loader = Dato::Local::Loader.new(
|
31
33
|
client,
|
32
|
-
options_hash[:
|
34
|
+
options_hash[:preview]
|
33
35
|
)
|
34
36
|
|
35
|
-
|
37
|
+
loader.load
|
36
38
|
|
37
39
|
app.after_configuration do
|
38
40
|
if options_hash[:live_reload] && !app.build?
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
app.before_shutdown do
|
44
|
-
if options_hash[:live_reload] && !app.build?
|
45
|
-
Watcher.instance.shutdown(app)
|
41
|
+
loader.watch do
|
42
|
+
puts "DatoCMS content changed!"
|
43
|
+
app.sitemap.rebuild_resource_list!(:touched_dato_content)
|
44
|
+
end
|
46
45
|
end
|
47
46
|
end
|
48
47
|
end
|
@@ -61,6 +60,7 @@ module MiddlemanDato
|
|
61
60
|
@client ||= Dato::Site::Client.new(
|
62
61
|
token,
|
63
62
|
base_url: options[:api_base_url],
|
63
|
+
environment: options[:environment],
|
64
64
|
extra_headers: {
|
65
65
|
'X-Reason' => 'dump',
|
66
66
|
'X-SSG' => 'middleman'
|
data/middleman-dato.gemspec
CHANGED
@@ -23,7 +23,7 @@ Gem::Specification.new do |s|
|
|
23
23
|
s.add_development_dependency('coveralls')
|
24
24
|
|
25
25
|
s.add_runtime_dependency 'middleman-core', ['>= 4.1.10']
|
26
|
-
s.add_runtime_dependency 'dato', ['>= 0.
|
26
|
+
s.add_runtime_dependency 'dato', ['>= 0.7.16']
|
27
27
|
s.add_runtime_dependency 'activesupport'
|
28
|
-
s.add_runtime_dependency 'dotenv'
|
28
|
+
s.add_runtime_dependency 'dotenv', ['<= 2.1']
|
29
29
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: middleman-dato
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Stefano Verna
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-10-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: coveralls
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 0.
|
47
|
+
version: 0.7.16
|
48
48
|
type: :runtime
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: 0.
|
54
|
+
version: 0.7.16
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: activesupport
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -70,16 +70,16 @@ dependencies:
|
|
70
70
|
name: dotenv
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
72
72
|
requirements:
|
73
|
-
- - "
|
73
|
+
- - "<="
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: '
|
75
|
+
version: '2.1'
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
|
-
- - "
|
80
|
+
- - "<="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: '
|
82
|
+
version: '2.1'
|
83
83
|
description: Fetches data from a Dato site
|
84
84
|
email:
|
85
85
|
- s.verna@cantierecreativo.net
|
@@ -93,12 +93,12 @@ files:
|
|
93
93
|
- ".rubocop.yml"
|
94
94
|
- ".travis.yml"
|
95
95
|
- Gemfile
|
96
|
+
- LICENSE
|
96
97
|
- README.md
|
97
98
|
- Rakefile
|
98
99
|
- lib/middleman-dato.rb
|
99
100
|
- lib/middleman_dato/middleman_extension.rb
|
100
101
|
- lib/middleman_dato/version.rb
|
101
|
-
- lib/middleman_dato/watcher.rb
|
102
102
|
- middleman-dato.gemspec
|
103
103
|
- spec/spec_helper.rb
|
104
104
|
homepage: http://cantierecreativo.net
|
@@ -115,14 +115,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
115
115
|
version: '0'
|
116
116
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
117
117
|
requirements:
|
118
|
-
- - "
|
118
|
+
- - ">="
|
119
119
|
- !ruby/object:Gem::Version
|
120
|
-
version:
|
120
|
+
version: '0'
|
121
121
|
requirements: []
|
122
|
-
|
123
|
-
rubygems_version: 2.5.1
|
122
|
+
rubygems_version: 3.0.3
|
124
123
|
signing_key:
|
125
124
|
specification_version: 4
|
126
125
|
summary: Fetches data from a Dato site
|
127
|
-
test_files:
|
128
|
-
- spec/spec_helper.rb
|
126
|
+
test_files: []
|
@@ -1,44 +0,0 @@
|
|
1
|
-
require 'singleton'
|
2
|
-
|
3
|
-
module MiddlemanDato
|
4
|
-
class Watcher
|
5
|
-
include Singleton
|
6
|
-
|
7
|
-
def initialize
|
8
|
-
@site_id = nil
|
9
|
-
@apps = []
|
10
|
-
@watcher = nil
|
11
|
-
end
|
12
|
-
|
13
|
-
def watch(app, loader, site_id)
|
14
|
-
@app = app
|
15
|
-
@loader = loader
|
16
|
-
|
17
|
-
if site_id != @site_id
|
18
|
-
if @watcher && @watcher.connected?
|
19
|
-
@apps = []
|
20
|
-
@watcher.disconnect!
|
21
|
-
end
|
22
|
-
|
23
|
-
@apps = [ app.object_id ]
|
24
|
-
@site_id = site_id
|
25
|
-
@watcher = Dato::Watch::SiteChangeWatcher.new(site_id).connect do
|
26
|
-
print "DatoCMS content changed, refreshing data..."
|
27
|
-
@loader.load
|
28
|
-
puts " done!"
|
29
|
-
@app.sitemap.rebuild_resource_list!(:touched_dato_content)
|
30
|
-
end
|
31
|
-
else
|
32
|
-
@apps[@apps.size - 1] = app.object_id
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def shutdown(app)
|
37
|
-
if @watcher && @watcher.connected? && @apps == [ app.object_id ]
|
38
|
-
@watcher.disconnect!
|
39
|
-
end
|
40
|
-
|
41
|
-
@apps.delete(app.object_id)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|