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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7590917b93c7be32e78e3500b1a4528c23974e9c89d16727eda30e37b3676364
4
- data.tar.gz: 5d8d1886a6d2a6ff929c57027b4574b6002b129fb05be00c3e0c3c17b716ee58
3
+ metadata.gz: 83798e7aea6d7d42a6c9c8babc2198db0b2e7380c3fa3d2acdddf3b7d07f96a4
4
+ data.tar.gz: d1d92ba199159059d566e525b37f8c9246e4893cd69cd127dd6e406c67b155dc
5
5
  SHA512:
6
- metadata.gz: 41264182e4e1acfe7adb01610075e9d0059bc133d7eec293447de6ac75b494b7bdbbb49eb0eb8616c11b3d338e702be6576222aaf5d4358b662e33b6302c9e21
7
- data.tar.gz: 67b51942ea58a1d939201651d81e4852235f178f2fab1f685fa2fb67a58ce95b6c62d40ae17a1fdaa318ef41b8378867f8026d808387bcf246c8e8ed279917c6
6
+ metadata.gz: 4fc421cfa034cd7eb12e838608d2c3a377b2f6ee5c99716cc6d034a06adfdc26fe62777e5297ca177c81f433dd1eea8fc9ed73b94f7d6a6c3c3f9228cbd7c1e3
7
+ data.tar.gz: 67c589854ca435ea521511228d5f1ee1e99544d93d03d81b65e92edf1f49182afb200d51d5a501cebd8ca7c67a4970596f1d9f9cbcdbc7bbee137661ccc5dda8
@@ -1,3 +1,3 @@
1
1
  module JekyllBloggerGenerator
2
- VERSION = '0.1.0'
2
+ VERSION = '0.2.0'
3
3
  end
@@ -11,19 +11,14 @@ module Jekyll
11
11
  end
12
12
 
13
13
  def generate(site)
14
- read_blog(
15
- site,
16
- @blogger.get_blog_by_url(blogger_config['url']),
17
- blogger_config['list_post_parameters']
18
- ) if blogger_config['url']
19
-
20
- blogger_config['urls'].each do |url|
21
- if url.is_a?(Hash)
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 read_blog(site, blog, list_post_parameters = {})
36
- parameters = {
37
- max_results: 500
38
- }.merge(list_post_parameters || {}).deep_symbolize_keys
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
- loop do
41
- list_posts = @blogger.list_posts(blog.id, **parameters)
38
+ dir = blog.url[/^https?:\/\/([^.]+)\./, 1]
42
39
 
43
- list_posts.items.each do |post|
44
- doc = BloggerDocument.new(post, site: site, collection: site.posts, blog_url: blog.url)
45
- doc.read
46
- site.posts.docs << doc
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
- break if (parameters[:page_token] = list_posts.next_page_token).nil?
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.1.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-06-29 00:00:00.000000000 Z
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