jekyll-blogger-generator 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jekyll-blogger-generator/version.rb +1 -1
- data/lib/jekyll/blogger_generator.rb +44 -24
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 83798e7aea6d7d42a6c9c8babc2198db0b2e7380c3fa3d2acdddf3b7d07f96a4
|
4
|
+
data.tar.gz: d1d92ba199159059d566e525b37f8c9246e4893cd69cd127dd6e406c67b155dc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4fc421cfa034cd7eb12e838608d2c3a377b2f6ee5c99716cc6d034a06adfdc26fe62777e5297ca177c81f433dd1eea8fc9ed73b94f7d6a6c3c3f9228cbd7c1e3
|
7
|
+
data.tar.gz: 67c589854ca435ea521511228d5f1ee1e99544d93d03d81b65e92edf1f49182afb200d51d5a501cebd8ca7c67a4970596f1d9f9cbcdbc7bbee137661ccc5dda8
|
@@ -11,19 +11,14 @@ module Jekyll
|
|
11
11
|
end
|
12
12
|
|
13
13
|
def generate(site)
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
read_blog(site, @blogger.get_blog_by_url(url['url']), url['list_post_parameters'] || blogger_config['list_post_parameters'])
|
23
|
-
else
|
24
|
-
read_blog(site, @blogger.get_blog_by_url(url), blogger_config['list_post_parameters'])
|
25
|
-
end
|
26
|
-
end if blogger_config['urls']
|
14
|
+
urls = [] << blogger_config['url'] << blogger_config['urls']
|
15
|
+
|
16
|
+
urls.flatten.compact.each do |url|
|
17
|
+
blog = @blogger.get_blog_by_url(url['url'] || url)
|
18
|
+
|
19
|
+
create_pages(site, blog, url['list_page_parameters'])
|
20
|
+
create_posts(site, blog, url['list_post_parameters'])
|
21
|
+
end
|
27
22
|
end
|
28
23
|
|
29
24
|
private
|
@@ -32,21 +27,46 @@ module Jekyll
|
|
32
27
|
@blogger_config ||= @config['blogger'] || {}
|
33
28
|
end
|
34
29
|
|
35
|
-
def
|
36
|
-
|
37
|
-
|
38
|
-
|
30
|
+
def create_pages(site, blog, list_page_parameters)
|
31
|
+
list_page_parameters = blogger_config['list_page_parameters'] if list_page_parameters.nil?
|
32
|
+
list_page_parameters = {} if list_page_parameters.nil?
|
33
|
+
|
34
|
+
if list_page_parameters
|
35
|
+
parameters = {
|
36
|
+
}.merge(list_page_parameters).deep_symbolize_keys
|
39
37
|
|
40
|
-
|
41
|
-
list_posts = @blogger.list_posts(blog.id, **parameters)
|
38
|
+
dir = blog.url[/^https?:\/\/([^.]+)\./, 1]
|
42
39
|
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
40
|
+
@blogger.list_pages(blog.id, **parameters).items.each do |page|
|
41
|
+
blogger_page = PageWithoutAFile.new(site, site.source, dir, page.url[/^.+\/p\/(.+)/, 1])
|
42
|
+
blogger_page.content = page.content
|
43
|
+
blogger_page.data.merge!(page.to_h.deep_stringify_keys, source: 'Blogger')
|
44
|
+
blogger_page.data.delete('content')
|
45
|
+
site.pages << blogger_page
|
47
46
|
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def create_posts(site, blog, list_post_parameters)
|
51
|
+
list_post_parameters = blogger_config['list_post_parameters'] if list_post_parameters.nil?
|
52
|
+
list_post_parameters = {} if list_post_parameters.nil?
|
53
|
+
|
54
|
+
if list_post_parameters
|
55
|
+
parameters = {
|
56
|
+
max_results: 500
|
57
|
+
}.merge(list_post_parameters).deep_symbolize_keys
|
48
58
|
|
49
|
-
|
59
|
+
loop do
|
60
|
+
list_posts = @blogger.list_posts(blog.id, **parameters)
|
61
|
+
|
62
|
+
list_posts.items.each do |post|
|
63
|
+
doc = BloggerDocument.new(post, site: site, collection: site.posts, blog_url: blog.url)
|
64
|
+
doc.read
|
65
|
+
site.posts.docs << doc
|
66
|
+
end
|
67
|
+
|
68
|
+
break if (parameters[:page_token] = list_posts.next_page_token).nil?
|
69
|
+
end
|
50
70
|
end
|
51
71
|
end
|
52
72
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-blogger-generator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Susco
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-07-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: google-apis-blogger_v3
|