dato 0.2.7 → 0.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rspec +1 -1
- data/.rubocop.yml +1 -1
- data/.ruby-version +1 -1
- data/dato.gemspec +1 -0
- data/docs/site-api-client.md +1 -0
- data/exe/dato +3 -0
- data/lib/dato.rb +2 -0
- data/lib/dato/dump/operation/add_to_data_file.rb +2 -0
- data/lib/dato/dump/operation/create_data_file.rb +3 -0
- data/lib/dato/dump/operation/create_post.rb +3 -0
- data/lib/dato/local/field_type/file.rb +2 -1
- data/lib/dato/local/field_type/image.rb +3 -1
- data/lib/dato/local/item.rb +5 -1
- data/lib/dato/local/items_repo.rb +31 -13
- data/lib/dato/local/site.rb +5 -1
- data/lib/dato/utils/favicon_tags_builder.rb +85 -0
- data/lib/dato/utils/meta_tags/article_modified_time.rb +15 -0
- data/lib/dato/utils/meta_tags/article_publisher.rb +18 -0
- data/lib/dato/utils/meta_tags/base.rb +55 -0
- data/lib/dato/utils/meta_tags/description.rb +24 -0
- data/lib/dato/utils/meta_tags/image.rb +33 -0
- data/lib/dato/utils/meta_tags/og_locale.rb +15 -0
- data/lib/dato/utils/meta_tags/og_site_name.rb +18 -0
- data/lib/dato/utils/meta_tags/og_type.rb +18 -0
- data/lib/dato/utils/meta_tags/robots.rb +14 -0
- data/lib/dato/utils/meta_tags/title.rb +46 -0
- data/lib/dato/utils/meta_tags/twitter_card.rb +14 -0
- data/lib/dato/utils/meta_tags/twitter_site.rb +18 -0
- data/lib/dato/utils/seo_tags_builder.rb +45 -0
- data/lib/dato/version.rb +1 -1
- data/lib/dato/watch/site_change_watcher.rb +36 -0
- metadata +32 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e8bd9232f5d7494629388a5faf7e29af279a3892
|
4
|
+
data.tar.gz: 4a2a9ce729001fac5cbbaefe1066693e4bac0848
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10bcef46db03d23cdf7ee723b01e19a50a878ac5d707890adbad735dff3c11f9b2105a6b9f8d850e6938bce665b403c69a073b1d6cf4df03922818f6dcb38c42
|
7
|
+
data.tar.gz: 6fafa7598ffab0f0939c08664fb9531c89ba1a31836a54f64102cc2b60841c94f802afcb6031068e600ea5a10b2910ef849b3188aa89931c1cb3f7b57aa10e36
|
data/.rspec
CHANGED
@@ -1,2 +1,2 @@
|
|
1
|
-
--format
|
1
|
+
--format progress
|
2
2
|
--color
|
data/.rubocop.yml
CHANGED
data/.ruby-version
CHANGED
@@ -1 +1 @@
|
|
1
|
-
2.
|
1
|
+
2.3.1
|
data/dato.gemspec
CHANGED
data/docs/site-api-client.md
CHANGED
data/exe/dato
CHANGED
data/lib/dato.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
require 'fileutils'
|
2
3
|
require 'dato/dump/format'
|
3
4
|
|
4
5
|
module Dato
|
@@ -15,6 +16,8 @@ module Dato
|
|
15
16
|
end
|
16
17
|
|
17
18
|
def perform
|
19
|
+
FileUtils.mkdir_p(File.dirname(path))
|
20
|
+
|
18
21
|
File.open(File.join(context.path, path), 'w') do |file|
|
19
22
|
file.write Format.dump(format, value)
|
20
23
|
end
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
require 'fileutils'
|
2
3
|
require 'dato/dump/format'
|
3
4
|
|
4
5
|
module Dato
|
@@ -16,6 +17,8 @@ module Dato
|
|
16
17
|
end
|
17
18
|
|
18
19
|
def perform
|
20
|
+
FileUtils.mkdir_p(File.dirname(path))
|
21
|
+
|
19
22
|
File.open(File.join(context.path, path), 'w') do |file|
|
20
23
|
file.write Format.frontmatter_dump(
|
21
24
|
frontmatter_format,
|
data/lib/dato/local/item.rb
CHANGED
@@ -13,7 +13,7 @@ module Dato
|
|
13
13
|
extend Forwardable
|
14
14
|
|
15
15
|
attr_reader :entity
|
16
|
-
def_delegators :entity, :id
|
16
|
+
def_delegators :entity, :id
|
17
17
|
|
18
18
|
def initialize(entity, items_repo)
|
19
19
|
@entity = entity
|
@@ -52,6 +52,10 @@ module Dato
|
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
+
def seo_meta_tags
|
56
|
+
Utils::SeoTagsBuilder.new(self, @items_repo.site).meta_tags
|
57
|
+
end
|
58
|
+
|
55
59
|
def singleton?
|
56
60
|
item_type.singleton
|
57
61
|
end
|
@@ -50,9 +50,9 @@ module Dato
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def items_of_type(item_type)
|
53
|
-
method
|
53
|
+
method = item_type_methods[item_type]
|
54
54
|
|
55
|
-
if singleton
|
55
|
+
if item_type.singleton
|
56
56
|
Array(@collections_by_type[method])
|
57
57
|
else
|
58
58
|
@collections_by_type[method]
|
@@ -64,6 +64,7 @@ module Dato
|
|
64
64
|
def build_cache!
|
65
65
|
build_item_type_methods!
|
66
66
|
build_collections_by_type!
|
67
|
+
build_singletons_by_type!
|
67
68
|
end
|
68
69
|
|
69
70
|
def build_item_type_methods!
|
@@ -76,24 +77,27 @@ module Dato
|
|
76
77
|
clashing_keys = singleton_keys & collection_keys
|
77
78
|
|
78
79
|
item_types.each do |item_type|
|
79
|
-
singleton = item_type.singleton
|
80
80
|
pluralized_api_key = item_type.api_key.pluralize
|
81
|
-
|
81
|
+
|
82
|
+
method = if item_type.singleton
|
83
|
+
item_type.api_key
|
84
|
+
else
|
85
|
+
pluralized_api_key
|
86
|
+
end
|
82
87
|
|
83
88
|
if clashing_keys.include?(pluralized_api_key)
|
84
|
-
suffix = singleton ? 'instance' : 'collection'
|
89
|
+
suffix = item_type.singleton ? 'instance' : 'collection'
|
85
90
|
method = "#{method}_#{suffix}"
|
86
91
|
end
|
87
92
|
|
88
|
-
@item_type_methods[item_type] =
|
93
|
+
@item_type_methods[item_type] = method.to_sym
|
89
94
|
end
|
90
95
|
end
|
91
96
|
|
92
97
|
def build_collections_by_type!
|
93
98
|
item_types.each do |item_type|
|
94
|
-
method
|
95
|
-
|
96
|
-
@collections_by_type[method] = if singleton
|
99
|
+
method = item_type_methods[item_type]
|
100
|
+
@collections_by_type[method] = if item_type.singleton
|
97
101
|
nil
|
98
102
|
else
|
99
103
|
ItemCollection.new
|
@@ -102,16 +106,30 @@ module Dato
|
|
102
106
|
|
103
107
|
item_entities.each do |item_entity|
|
104
108
|
item = Item.new(item_entity, self)
|
105
|
-
method
|
109
|
+
method = item_type_methods[item_entity.item_type]
|
106
110
|
|
107
|
-
|
108
|
-
@collections_by_type[method] = item
|
109
|
-
else
|
111
|
+
unless item_entity.item_type.singleton
|
110
112
|
@collections_by_type[method].push item
|
111
113
|
end
|
112
114
|
|
113
115
|
@items_by_id[item.id] = item
|
114
116
|
end
|
117
|
+
|
118
|
+
item_types.each do |item_type|
|
119
|
+
method = item_type_methods[item_type]
|
120
|
+
if !item_type.singleton && item_type.sortable
|
121
|
+
@collections_by_type[method].sort_by!(&:position)
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
126
|
+
def build_singletons_by_type!
|
127
|
+
item_types.each do |item_type|
|
128
|
+
method = item_type_methods[item_type]
|
129
|
+
if item_type.singleton
|
130
|
+
@collections_by_type[method] = @items_by_id[item_type.singleton_item.id]
|
131
|
+
end
|
132
|
+
end
|
115
133
|
end
|
116
134
|
|
117
135
|
def item_entities
|
data/lib/dato/local/site.rb
CHANGED
@@ -25,10 +25,14 @@ module Dato
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def to_s
|
28
|
-
"#<Site id=#{id} site_name=#{
|
28
|
+
"#<Site id=#{id} site_name=#{name}>"
|
29
29
|
end
|
30
30
|
alias inspect to_s
|
31
31
|
|
32
|
+
def favicon_meta_tags(theme_color = nil)
|
33
|
+
Utils::FaviconTagsBuilder.new(self, theme_color).meta_tags
|
34
|
+
end
|
35
|
+
|
32
36
|
def to_hash
|
33
37
|
attributes = [
|
34
38
|
:id, :name, :locales, :theme_hue, :domain, :internal_domain,
|
@@ -0,0 +1,85 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
module Dato
|
3
|
+
module Utils
|
4
|
+
class FaviconTagsBuilder
|
5
|
+
attr_reader :theme_color, :site
|
6
|
+
|
7
|
+
APPLE_TOUCH_ICON_SIZES = [57, 60, 72, 76, 114, 120, 144, 152, 180].freeze
|
8
|
+
ICON_SIZES = [16, 32, 96, 192].freeze
|
9
|
+
WINDOWS_SIZES = [[70, 70], [150, 150], [310, 310], [310, 150]].freeze
|
10
|
+
|
11
|
+
def initialize(site, theme_color)
|
12
|
+
@site = site
|
13
|
+
@theme_color = theme_color
|
14
|
+
end
|
15
|
+
|
16
|
+
def meta_tags
|
17
|
+
[
|
18
|
+
build_icon_tags,
|
19
|
+
build_apple_icon_tags,
|
20
|
+
build_windows_tags,
|
21
|
+
build_color_tags,
|
22
|
+
build_app_name_tag
|
23
|
+
].flatten.compact
|
24
|
+
end
|
25
|
+
|
26
|
+
def build_apple_icon_tags
|
27
|
+
return unless site.favicon
|
28
|
+
|
29
|
+
APPLE_TOUCH_ICON_SIZES.map do |size|
|
30
|
+
link_tag(
|
31
|
+
'apple-touch-icon',
|
32
|
+
url(size),
|
33
|
+
sizes: "#{size}x#{size}"
|
34
|
+
)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def build_icon_tags
|
39
|
+
return unless site.favicon
|
40
|
+
|
41
|
+
ICON_SIZES.map do |size|
|
42
|
+
link_tag(
|
43
|
+
'icon',
|
44
|
+
url(size),
|
45
|
+
sizes: "#{size}x#{size}",
|
46
|
+
type: "image/#{site.favicon.format}"
|
47
|
+
)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def build_windows_tags
|
52
|
+
return unless site.favicon
|
53
|
+
|
54
|
+
WINDOWS_SIZES.map do |(w, h)|
|
55
|
+
meta_tag("msapplication-square#{w}x#{h}logo", url(w, h))
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def build_app_name_tag
|
60
|
+
meta_tag('application-name', site.name)
|
61
|
+
end
|
62
|
+
|
63
|
+
def build_color_tags
|
64
|
+
return unless theme_color
|
65
|
+
|
66
|
+
[
|
67
|
+
meta_tag('theme-color', theme_color),
|
68
|
+
meta_tag('msapplication-TileColor', theme_color)
|
69
|
+
]
|
70
|
+
end
|
71
|
+
|
72
|
+
def url(width, height = width)
|
73
|
+
site.favicon.url(w: width, h: height)
|
74
|
+
end
|
75
|
+
|
76
|
+
def meta_tag(name, value)
|
77
|
+
{ tag_name: 'meta', attributes: { name: name, content: value } }
|
78
|
+
end
|
79
|
+
|
80
|
+
def link_tag(rel, href, attrs = {})
|
81
|
+
{ tag_name: 'link', attributes: attrs.merge(rel: rel, href: href) }
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'dato/utils/meta_tags/base'
|
3
|
+
require 'time'
|
4
|
+
|
5
|
+
module Dato
|
6
|
+
module Utils
|
7
|
+
module MetaTags
|
8
|
+
class ArticleModifiedTime < Base
|
9
|
+
def build
|
10
|
+
og_tag('article:modified_time', item.updated_at.iso8601) if item
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'dato/utils/meta_tags/base'
|
3
|
+
|
4
|
+
module Dato
|
5
|
+
module Utils
|
6
|
+
module MetaTags
|
7
|
+
class ArticlePublisher < Base
|
8
|
+
def build
|
9
|
+
og_tag('article:publisher', facebook_page_url) if facebook_page_url
|
10
|
+
end
|
11
|
+
|
12
|
+
def facebook_page_url
|
13
|
+
site.global_seo && site.global_seo.facebook_page_url
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'forwardable'
|
3
|
+
require 'dato/local/field_type/seo'
|
4
|
+
require 'active_support/core_ext/object/blank'
|
5
|
+
|
6
|
+
module Dato
|
7
|
+
module Utils
|
8
|
+
module MetaTags
|
9
|
+
class Base
|
10
|
+
attr_reader :site, :item
|
11
|
+
|
12
|
+
def initialize(item, site)
|
13
|
+
@item = item
|
14
|
+
@site = site
|
15
|
+
end
|
16
|
+
|
17
|
+
def seo_field_with_fallback(attribute, alternative)
|
18
|
+
fallback_seo = site.global_seo && site.global_seo.fallback_seo
|
19
|
+
|
20
|
+
seo_field = item &&
|
21
|
+
item.fields.detect { |f| f.field_type == 'seo' }
|
22
|
+
|
23
|
+
item_seo_value = seo_field &&
|
24
|
+
item.send(seo_field.api_key) &&
|
25
|
+
item.send(seo_field.api_key).send(attribute)
|
26
|
+
|
27
|
+
fallback_seo_value = fallback_seo &&
|
28
|
+
fallback_seo.send(attribute)
|
29
|
+
|
30
|
+
item_seo_value || alternative || fallback_seo_value
|
31
|
+
end
|
32
|
+
|
33
|
+
def tag(tag_name, attributes)
|
34
|
+
{ tag_name: tag_name, attributes: attributes }
|
35
|
+
end
|
36
|
+
|
37
|
+
def meta_tag(name, content)
|
38
|
+
tag('meta', name: name, content: content)
|
39
|
+
end
|
40
|
+
|
41
|
+
def og_tag(property, content)
|
42
|
+
tag('meta', property: property, content: content)
|
43
|
+
end
|
44
|
+
|
45
|
+
def card_tag(name, content)
|
46
|
+
meta_tag(name, content)
|
47
|
+
end
|
48
|
+
|
49
|
+
def content_tag(tag_name, content)
|
50
|
+
{ tag_name: tag_name, content: content }
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'dato/utils/meta_tags/base'
|
3
|
+
|
4
|
+
module Dato
|
5
|
+
module Utils
|
6
|
+
module MetaTags
|
7
|
+
class Description < Base
|
8
|
+
def build
|
9
|
+
return unless description.present?
|
10
|
+
|
11
|
+
[
|
12
|
+
meta_tag('description', description),
|
13
|
+
og_tag('og:description', description),
|
14
|
+
card_tag('twitter:description', description)
|
15
|
+
]
|
16
|
+
end
|
17
|
+
|
18
|
+
def description
|
19
|
+
@description ||= seo_field_with_fallback(:description, nil)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'dato/utils/meta_tags/base'
|
3
|
+
|
4
|
+
module Dato
|
5
|
+
module Utils
|
6
|
+
module MetaTags
|
7
|
+
class Image < Base
|
8
|
+
def build
|
9
|
+
return unless image
|
10
|
+
|
11
|
+
[
|
12
|
+
og_tag('og:image', image.url),
|
13
|
+
card_tag('twitter:image', image.url)
|
14
|
+
]
|
15
|
+
end
|
16
|
+
|
17
|
+
def image
|
18
|
+
@image ||= seo_field_with_fallback(:image, item_image)
|
19
|
+
end
|
20
|
+
|
21
|
+
def item_image
|
22
|
+
item && item.fields
|
23
|
+
.select { |field| field.field_type == 'image' }
|
24
|
+
.map { |field| item.send(field.api_key) }
|
25
|
+
.compact
|
26
|
+
.find do |image|
|
27
|
+
image.width >= 200 && image.height >= 200
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'dato/utils/meta_tags/base'
|
3
|
+
|
4
|
+
module Dato
|
5
|
+
module Utils
|
6
|
+
module MetaTags
|
7
|
+
class OgLocale < Base
|
8
|
+
def build
|
9
|
+
locale = I18n.locale
|
10
|
+
og_tag('og:locale', "#{locale}_#{locale.upcase}")
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'dato/utils/meta_tags/base'
|
3
|
+
|
4
|
+
module Dato
|
5
|
+
module Utils
|
6
|
+
module MetaTags
|
7
|
+
class OgSiteName < Base
|
8
|
+
def build
|
9
|
+
card_tag('og:site_name', site_name) if site_name
|
10
|
+
end
|
11
|
+
|
12
|
+
def site_name
|
13
|
+
site.global_seo && site.global_seo.site_name
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'dato/utils/meta_tags/base'
|
3
|
+
|
4
|
+
module Dato
|
5
|
+
module Utils
|
6
|
+
module MetaTags
|
7
|
+
class OgType < Base
|
8
|
+
def build
|
9
|
+
if !item || item.singleton?
|
10
|
+
og_tag('og:type', 'website')
|
11
|
+
else
|
12
|
+
og_tag('og:type', 'article')
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'dato/utils/meta_tags/base'
|
3
|
+
|
4
|
+
module Dato
|
5
|
+
module Utils
|
6
|
+
module MetaTags
|
7
|
+
class Title < Base
|
8
|
+
def build
|
9
|
+
return unless item_title
|
10
|
+
|
11
|
+
[
|
12
|
+
content_tag('title', item_title_with_suffix),
|
13
|
+
og_tag('og:title', item_title),
|
14
|
+
card_tag('twitter:title', item_title)
|
15
|
+
]
|
16
|
+
end
|
17
|
+
|
18
|
+
def title_field
|
19
|
+
item && item.fields.find do |field|
|
20
|
+
field.field_type == 'string' &&
|
21
|
+
field.appeareance[:type] == 'title'
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def item_title
|
26
|
+
@item_title ||= seo_field_with_fallback(
|
27
|
+
:title,
|
28
|
+
title_field && item.send(title_field.api_key)
|
29
|
+
)
|
30
|
+
end
|
31
|
+
|
32
|
+
def suffix
|
33
|
+
(site.global_seo && site.global_seo.title_suffix) || ''
|
34
|
+
end
|
35
|
+
|
36
|
+
def item_title_with_suffix
|
37
|
+
if (item_title + suffix).size <= 60
|
38
|
+
item_title + suffix
|
39
|
+
else
|
40
|
+
item_title
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'dato/utils/meta_tags/base'
|
3
|
+
|
4
|
+
module Dato
|
5
|
+
module Utils
|
6
|
+
module MetaTags
|
7
|
+
class TwitterSite < Base
|
8
|
+
def build
|
9
|
+
card_tag('twitter:site', twitter_account) if twitter_account
|
10
|
+
end
|
11
|
+
|
12
|
+
def twitter_account
|
13
|
+
site.global_seo && site.global_seo.twitter_account
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
require 'dato/utils/meta_tags/title'
|
3
|
+
require 'dato/utils/meta_tags/description'
|
4
|
+
require 'dato/utils/meta_tags/image'
|
5
|
+
require 'dato/utils/meta_tags/robots'
|
6
|
+
require 'dato/utils/meta_tags/og_locale'
|
7
|
+
require 'dato/utils/meta_tags/og_type'
|
8
|
+
require 'dato/utils/meta_tags/og_site_name'
|
9
|
+
require 'dato/utils/meta_tags/article_modified_time'
|
10
|
+
require 'dato/utils/meta_tags/article_publisher'
|
11
|
+
require 'dato/utils/meta_tags/twitter_card'
|
12
|
+
require 'dato/utils/meta_tags/twitter_site'
|
13
|
+
|
14
|
+
module Dato
|
15
|
+
module Utils
|
16
|
+
class SeoTagsBuilder
|
17
|
+
META_TAGS = [
|
18
|
+
MetaTags::Title,
|
19
|
+
MetaTags::Description,
|
20
|
+
MetaTags::Image,
|
21
|
+
MetaTags::Robots,
|
22
|
+
MetaTags::OgLocale,
|
23
|
+
MetaTags::OgType,
|
24
|
+
MetaTags::OgSiteName,
|
25
|
+
MetaTags::ArticleModifiedTime,
|
26
|
+
MetaTags::ArticlePublisher,
|
27
|
+
MetaTags::TwitterCard,
|
28
|
+
MetaTags::TwitterSite
|
29
|
+
].freeze
|
30
|
+
|
31
|
+
attr_reader :site, :item
|
32
|
+
|
33
|
+
def initialize(item, site)
|
34
|
+
@item = item
|
35
|
+
@site = site
|
36
|
+
end
|
37
|
+
|
38
|
+
def meta_tags
|
39
|
+
META_TAGS.map do |klass|
|
40
|
+
klass.new(item, site).build
|
41
|
+
end.flatten.compact
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/lib/dato/version.rb
CHANGED
@@ -0,0 +1,36 @@
|
|
1
|
+
require 'pusher-client'
|
2
|
+
|
3
|
+
module Dato
|
4
|
+
module Watch
|
5
|
+
class SiteChangeWatcher
|
6
|
+
attr_reader :site_id
|
7
|
+
|
8
|
+
PUSHER_API_KEY = '75e6ef0fe5d39f481626'
|
9
|
+
|
10
|
+
def initialize(site_id)
|
11
|
+
PusherClient.logger.level = Logger::WARN
|
12
|
+
@site_id = site_id
|
13
|
+
@socket = nil
|
14
|
+
end
|
15
|
+
|
16
|
+
def connect(&block)
|
17
|
+
return if connected?
|
18
|
+
|
19
|
+
@socket = PusherClient::Socket.new(PUSHER_API_KEY, secure: true)
|
20
|
+
@socket.subscribe("site-#{site_id}")
|
21
|
+
@socket.bind('site:change', &block)
|
22
|
+
@socket.connect(true)
|
23
|
+
|
24
|
+
self
|
25
|
+
end
|
26
|
+
|
27
|
+
def connected?
|
28
|
+
@socket && @socket.connected
|
29
|
+
end
|
30
|
+
|
31
|
+
def disconnect!
|
32
|
+
connected? && @socket.disconnect
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
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.
|
4
|
+
version: 0.3.0
|
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-
|
11
|
+
date: 2016-12-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -318,6 +318,20 @@ dependencies:
|
|
318
318
|
- - ">="
|
319
319
|
- !ruby/object:Gem::Version
|
320
320
|
version: '0'
|
321
|
+
- !ruby/object:Gem::Dependency
|
322
|
+
name: dotenv
|
323
|
+
requirement: !ruby/object:Gem::Requirement
|
324
|
+
requirements:
|
325
|
+
- - ">="
|
326
|
+
- !ruby/object:Gem::Version
|
327
|
+
version: '0'
|
328
|
+
type: :runtime
|
329
|
+
prerelease: false
|
330
|
+
version_requirements: !ruby/object:Gem::Requirement
|
331
|
+
requirements:
|
332
|
+
- - ">="
|
333
|
+
- !ruby/object:Gem::Version
|
334
|
+
version: '0'
|
321
335
|
description: Ruby client for DatoCMS API
|
322
336
|
email:
|
323
337
|
- s.verna@cantierecreativo.net
|
@@ -403,7 +417,22 @@ files:
|
|
403
417
|
- lib/dato/site/repo/user.rb
|
404
418
|
- lib/dato/upload/file.rb
|
405
419
|
- lib/dato/upload/image.rb
|
420
|
+
- lib/dato/utils/favicon_tags_builder.rb
|
421
|
+
- lib/dato/utils/meta_tags/article_modified_time.rb
|
422
|
+
- lib/dato/utils/meta_tags/article_publisher.rb
|
423
|
+
- lib/dato/utils/meta_tags/base.rb
|
424
|
+
- lib/dato/utils/meta_tags/description.rb
|
425
|
+
- lib/dato/utils/meta_tags/image.rb
|
426
|
+
- lib/dato/utils/meta_tags/og_locale.rb
|
427
|
+
- lib/dato/utils/meta_tags/og_site_name.rb
|
428
|
+
- lib/dato/utils/meta_tags/og_type.rb
|
429
|
+
- lib/dato/utils/meta_tags/robots.rb
|
430
|
+
- lib/dato/utils/meta_tags/title.rb
|
431
|
+
- lib/dato/utils/meta_tags/twitter_card.rb
|
432
|
+
- lib/dato/utils/meta_tags/twitter_site.rb
|
433
|
+
- lib/dato/utils/seo_tags_builder.rb
|
406
434
|
- lib/dato/version.rb
|
435
|
+
- lib/dato/watch/site_change_watcher.rb
|
407
436
|
homepage: https://github.com/datocms/ruby-datocms-client
|
408
437
|
licenses:
|
409
438
|
- MIT
|
@@ -424,7 +453,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
424
453
|
version: '0'
|
425
454
|
requirements: []
|
426
455
|
rubyforge_project:
|
427
|
-
rubygems_version: 2.
|
456
|
+
rubygems_version: 2.5.1
|
428
457
|
signing_key:
|
429
458
|
specification_version: 4
|
430
459
|
summary: Ruby client for DatoCMS API
|