ZMediumToMarkdown 2.3.1 → 2.3.3
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/bin/ZMediumToMarkdown +2 -2
- data/lib/Helper.rb +2 -3
- data/lib/Post.rb +1 -6
- data/lib/User.rb +1 -1
- data/lib/ZMediumFetcher.rb +9 -9
- 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: 6abe968b9138fb7c30ab6be53ca74027d4ae8c9299567adcc8f582c026481114
|
4
|
+
data.tar.gz: 66f88e416f91e669ed997facb3a0be2637d926945459fc2e294b0654cfd2abda
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d108da172e00592f2176590af7a451d91323b23b5144caa073ceaf8cd445a79fd162bcef323397a97deb07ec59f6b1b1f7d64b3a8ff651bd484e4db44f83e280
|
7
|
+
data.tar.gz: 698c219f4b6abbf7cb4ea9d8ff11dec1b3aa204887fe91c9075058c3dbec0e4c9b8041d50bc165330d42d7a32f269aa9c56fb4eea5b3df703880e06cc1ffb5bc
|
data/bin/ZMediumToMarkdown
CHANGED
@@ -27,7 +27,7 @@ class Main
|
|
27
27
|
|
28
28
|
opts.on('-pPOST_URL', '--postURL=POST_URL', 'Downloading single post') do |postURL|
|
29
29
|
outputFilePath = PathPolicy.new("#{filePath}/Output", "Output")
|
30
|
-
fetcher.downloadPost(postURL, outputFilePath)
|
30
|
+
fetcher.downloadPost(postURL, outputFilePath, nil)
|
31
31
|
|
32
32
|
Helper.printNewVersionMessageIfExists()
|
33
33
|
end
|
@@ -43,7 +43,7 @@ class Main
|
|
43
43
|
opts.on('-kPOST_URL', '--jekyllPostURL=POST_URL', 'Downloading single post with Jekyll friendly') do |postURL|
|
44
44
|
outputFilePath = PathPolicy.new(filePath, "")
|
45
45
|
fetcher.isForJekyll = true
|
46
|
-
fetcher.downloadPost(postURL, outputFilePath)
|
46
|
+
fetcher.downloadPost(postURL, outputFilePath, nil)
|
47
47
|
|
48
48
|
Helper.printNewVersionMessageIfExists()
|
49
49
|
end
|
data/lib/Helper.rb
CHANGED
@@ -94,7 +94,7 @@ class Helper
|
|
94
94
|
end
|
95
95
|
end
|
96
96
|
|
97
|
-
def self.createPostInfo(postInfo, isForJekyll)
|
97
|
+
def self.createPostInfo(postInfo, isPin, isForJekyll)
|
98
98
|
title = postInfo.title&.gsub("[","")
|
99
99
|
title = title&.gsub("]","")
|
100
100
|
|
@@ -115,9 +115,8 @@ class Helper
|
|
115
115
|
result += "image:\r\n"
|
116
116
|
result += " path: /#{postInfo.previewImage}\r\n"
|
117
117
|
end
|
118
|
-
if !
|
118
|
+
if !isPin.nil? && isPin == true
|
119
119
|
result += "pin: true\r\n"
|
120
|
-
result += "pinned_at: #{postInfo.pinnedByCreatorAt.strftime('%Y-%m-%dT%H:%M:%S.%L%z')}\n"
|
121
120
|
end
|
122
121
|
|
123
122
|
if isForJekyll
|
data/lib/Post.rb
CHANGED
@@ -11,7 +11,7 @@ require 'PathPolicy'
|
|
11
11
|
|
12
12
|
class Post
|
13
13
|
class PostInfo
|
14
|
-
attr_accessor :title, :tags, :creator, :firstPublishedAt, :latestPublishedAt, :
|
14
|
+
attr_accessor :title, :tags, :creator, :firstPublishedAt, :latestPublishedAt, :collectionName, :description, :previewImage
|
15
15
|
end
|
16
16
|
|
17
17
|
def self.getPostIDFromPostURLString(postURLString)
|
@@ -103,11 +103,6 @@ class Post
|
|
103
103
|
postInfo.latestPublishedAt = Time.at(0, latestPublishedAt, :millisecond)
|
104
104
|
end
|
105
105
|
|
106
|
-
pinnedByCreatorAt = content&.dig("Post:#{postID}", "pinnedByCreatorAt")
|
107
|
-
if !pinnedByCreatorAt.nil?
|
108
|
-
postInfo.pinnedByCreatorAt = Time.at(0, pinnedByCreatorAt, :millisecond)
|
109
|
-
end
|
110
|
-
|
111
106
|
postInfo
|
112
107
|
end
|
113
108
|
end
|
data/lib/User.rb
CHANGED
data/lib/ZMediumFetcher.rb
CHANGED
@@ -119,7 +119,7 @@ class ZMediumFetcher
|
|
119
119
|
h1Parser
|
120
120
|
end
|
121
121
|
|
122
|
-
def downloadPost(postURL, pathPolicy)
|
122
|
+
def downloadPost(postURL, pathPolicy, isPin)
|
123
123
|
postID = Post.getPostIDFromPostURLString(postURL)
|
124
124
|
|
125
125
|
if isForJekyll
|
@@ -235,7 +235,7 @@ class ZMediumFetcher
|
|
235
235
|
absolutePath = URI.decode(postPathPolicy.getAbsolutePath("#{postWithDatePath}")) + ".md"
|
236
236
|
|
237
237
|
fileLatestPublishedAt = nil
|
238
|
-
|
238
|
+
filePin = false
|
239
239
|
if File.file?(absolutePath)
|
240
240
|
lines = File.foreach(absolutePath).first(15)
|
241
241
|
if lines.first&.start_with?("---")
|
@@ -244,14 +244,14 @@ class ZMediumFetcher
|
|
244
244
|
fileLatestPublishedAt = Time.parse(latestPublishedAtLine[/^(last_modified_at:)\s+(\S*)/, 2]).to_i
|
245
245
|
end
|
246
246
|
|
247
|
-
|
248
|
-
if !
|
249
|
-
|
247
|
+
pinLine = lines.select { |line| line.start_with?("pin:") }.first
|
248
|
+
if !pinLine.nil?
|
249
|
+
filePin = pinLine[/^(pin:)\s+(\S*)/, 2].downcase == "true"
|
250
250
|
end
|
251
251
|
end
|
252
252
|
end
|
253
253
|
|
254
|
-
if (!fileLatestPublishedAt.nil? && fileLatestPublishedAt >= postInfo.latestPublishedAt.to_i) &&
|
254
|
+
if (!fileLatestPublishedAt.nil? && fileLatestPublishedAt >= postInfo.latestPublishedAt.to_i) && (!isPin.nil? && isPin == filePin)
|
255
255
|
# Already downloaded and nothing has changed!, Skip!
|
256
256
|
progress.currentPostParagraphIndex = paragraphs.length
|
257
257
|
progress.message = "Skip, Post already downloaded and nothing has changed!"
|
@@ -260,7 +260,7 @@ class ZMediumFetcher
|
|
260
260
|
Helper.createDirIfNotExist(postPathPolicy.getAbsolutePath(nil))
|
261
261
|
File.open(absolutePath, "w+") do |file|
|
262
262
|
# write postInfo into top
|
263
|
-
postMetaInfo = Helper.createPostInfo(postInfo, isForJekyll)
|
263
|
+
postMetaInfo = Helper.createPostInfo(postInfo, isPin, isForJekyll)
|
264
264
|
if !postMetaInfo.nil?
|
265
265
|
file.puts(postMetaInfo)
|
266
266
|
end
|
@@ -318,7 +318,7 @@ class ZMediumFetcher
|
|
318
318
|
nextID = postPageInfo["nextID"]
|
319
319
|
end while !nextID.nil?
|
320
320
|
|
321
|
-
@usersPostURLs = postURLS
|
321
|
+
@usersPostURLs = postURLS.map{ |post| post["url"] }
|
322
322
|
|
323
323
|
progress.totalPostsLength = postURLS.length
|
324
324
|
progress.currentPostIndex = 0
|
@@ -335,7 +335,7 @@ class ZMediumFetcher
|
|
335
335
|
postURLS.each do |postURL|
|
336
336
|
begin
|
337
337
|
# todo: unless File.exists? Post.getPostPathFromPostURLString(postURL) +".md"
|
338
|
-
downloadPost(postURL, downloadPathPolicy)
|
338
|
+
downloadPost(postURL["url"], downloadPathPolicy, postURL["pin"])
|
339
339
|
rescue => e
|
340
340
|
puts e
|
341
341
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ZMediumToMarkdown
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.3.
|
4
|
+
version: 2.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ZhgChgLi
|
@@ -113,7 +113,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
113
113
|
- !ruby/object:Gem::Version
|
114
114
|
version: '0'
|
115
115
|
requirements: []
|
116
|
-
rubygems_version: 3.
|
116
|
+
rubygems_version: 3.1.6
|
117
117
|
signing_key:
|
118
118
|
specification_version: 4
|
119
119
|
summary: This project can help you to make an auto-sync or auto-backup service from
|