ZMediumToMarkdown 1.6.0 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/Helper.rb +6 -1
- data/lib/Parsers/IMGParser.rb +7 -2
- data/lib/Parsers/IframeParser.rb +1 -1
- data/lib/Post.rb +8 -1
- data/lib/ZMediumFetcher.rb +5 -2
- 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: 92b412153da4daf0a7594c1558a847412863405eec14da02325984a22bc855a8
|
4
|
+
data.tar.gz: ccdf1c0e166323323f55b91fc0991b3eae1da0ad070e2b884b3b30266661c03b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 120c75b800992a2a815c058430326f6b279f52f08ba4484465fdf7eca31b8460f1170bdd30956c1bfd771a3fbb0d5763a21e9327530e80e76250d52551a4ec9f
|
7
|
+
data.tar.gz: ffb13239eabe2a6f302a093dfea6309eaaaa3eee0ffb960ee9798f96969c922de6a287b3c8ac47aca1c8b4af2f51adcc52bdf2470e59f8cf12420338a03e019b
|
data/lib/Helper.rb
CHANGED
@@ -77,10 +77,15 @@ class Helper
|
|
77
77
|
end
|
78
78
|
|
79
79
|
def self.createPostInfo(postInfo)
|
80
|
+
|
81
|
+
title = postInfo.title.gsub("[","")
|
82
|
+
title = title.gsub("]","")
|
83
|
+
|
80
84
|
result = "---\n"
|
81
|
-
result += "title: #{
|
85
|
+
result += "title: #{title}\n"
|
82
86
|
result += "author: #{postInfo.creator}\n"
|
83
87
|
result += "date: #{postInfo.firstPublishedAt.strftime('%Y-%m-%dT%H:%M:%S.%LZ')}\n"
|
88
|
+
result += "categories: #{postInfo.collectionName}\n"
|
84
89
|
result += "tags: [#{postInfo.tags.join(",")}]\n"
|
85
90
|
result += "---\n"
|
86
91
|
result += "\r\n"
|
data/lib/Parsers/IMGParser.rb
CHANGED
@@ -18,11 +18,16 @@ class IMGParser < Parser
|
|
18
18
|
imagePathPolicy = PathPolicy.new(pathPolicy.getAbsolutePath(nil), paragraph.postID)
|
19
19
|
absolutePath = imagePathPolicy.getAbsolutePath(fileName)
|
20
20
|
|
21
|
+
comment = ""
|
22
|
+
if paragraph.text != ""
|
23
|
+
comment = " \"#{paragraph.text}\""
|
24
|
+
end
|
25
|
+
|
21
26
|
if ImageDownloader.download(absolutePath, imageURL)
|
22
27
|
relativePath = "#{pathPolicy.getRelativePath(nil)}/#{imagePathPolicy.getRelativePath(fileName)}"
|
23
|
-
""
|
24
29
|
else
|
25
|
-
""
|
26
31
|
end
|
27
32
|
else
|
28
33
|
if !nextParser.nil?
|
data/lib/Parsers/IframeParser.rb
CHANGED
data/lib/Post.rb
CHANGED
@@ -9,7 +9,7 @@ require 'date'
|
|
9
9
|
class Post
|
10
10
|
|
11
11
|
class PostInfo
|
12
|
-
attr_accessor :title, :tags, :creator, :firstPublishedAt, :latestPublishedAt
|
12
|
+
attr_accessor :title, :tags, :creator, :firstPublishedAt, :latestPublishedAt, :collectionName
|
13
13
|
end
|
14
14
|
|
15
15
|
def self.getPostIDFromPostURLString(postURLString)
|
@@ -68,6 +68,13 @@ class Post
|
|
68
68
|
postInfo.creator = content&.dig(creatorRef, "name")
|
69
69
|
end
|
70
70
|
|
71
|
+
colletionRef = content&.dig("Post:#{postID}", "collection", "__ref")
|
72
|
+
if !colletionRef.nil?
|
73
|
+
postInfo.collectionName = content&.dig(colletionRef, "name")
|
74
|
+
end
|
75
|
+
|
76
|
+
|
77
|
+
|
71
78
|
firstPublishedAt = content&.dig("Post:#{postID}", "firstPublishedAt")
|
72
79
|
if !firstPublishedAt.nil?
|
73
80
|
postInfo.firstPublishedAt = Time.at(0, firstPublishedAt, :millisecond)
|
data/lib/ZMediumFetcher.rb
CHANGED
@@ -26,6 +26,7 @@ require "PathPolicy"
|
|
26
26
|
require "Request"
|
27
27
|
require "Post"
|
28
28
|
require "User"
|
29
|
+
require 'date'
|
29
30
|
|
30
31
|
class ZMediumFetcher
|
31
32
|
|
@@ -204,7 +205,7 @@ class ZMediumFetcher
|
|
204
205
|
|
205
206
|
postPathPolicy = PathPolicy.new(pathPolicy.getAbsolutePath(nil), "posts")
|
206
207
|
|
207
|
-
imagePathPolicy = PathPolicy.new(postPathPolicy.getAbsolutePath(nil), "
|
208
|
+
imagePathPolicy = PathPolicy.new(postPathPolicy.getAbsolutePath(nil), "assets")
|
208
209
|
startParser = buildParser(imagePathPolicy)
|
209
210
|
|
210
211
|
progress.totalPostParagraphsLength = paragraphs.length
|
@@ -212,7 +213,9 @@ class ZMediumFetcher
|
|
212
213
|
progress.message = "Converting Post..."
|
213
214
|
progress.printLog()
|
214
215
|
|
215
|
-
|
216
|
+
postWithDatePath = "#{postInfo.firstPublishedAt.strftime("%Y-%m-%d")}-#{postPath}"
|
217
|
+
|
218
|
+
absolutePath = postPathPolicy.getAbsolutePath("#{postWithDatePath}.md")
|
216
219
|
|
217
220
|
# if markdown file is exists and last modification time is >= latestPublishedAt(last update post time on medium)
|
218
221
|
if File.file?(absolutePath) && File.mtime(absolutePath) >= postInfo.latestPublishedAt
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ZMediumToMarkdown
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.6.
|
4
|
+
version: 1.6.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ZhgChgLi
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-06-
|
11
|
+
date: 2022-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|