ZMediumToMarkdown 2.2.0 → 2.3.1

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: 59131f30d3ce40a59e476e9270d9f8c20695f55713768f6165d7c98083dffd9b
4
- data.tar.gz: cacafa3b157a789038412be2366087820581436c284672136e2db81332cdf2ff
3
+ metadata.gz: 759cc258f35760c2cfc66a4ea881a9e15c8410eaa6866ea9cba556c2abf6bcf3
4
+ data.tar.gz: ea86ca02af307bcc6081f608784fdddbdb34dcbe3e921452ed546cc51f01b5ec
5
5
  SHA512:
6
- metadata.gz: 28114bda2d2aadddf6dd549355c1f8914098c0f5695165499fd4eb367457949a1aaa2c5f02f418f78a3946148323df61233b6f494d64394bcdc54cda8529ef94
7
- data.tar.gz: 8c6e54715b0e7e4955da635d6f3d6e2fcf7309e257144d076aa7a543eec175b6620f1621686a11ad4d28f50cbafa0ddbfc3cc4bf662800ddb6af341fce4d351c
6
+ metadata.gz: 89c95f282a87e062bda24e2b5c436a4a56832720ea562ef2a34c213266ec575fb3e0a331c6b1e441ae7fdf4a6e850897a1bc1ba1ce622788ddf50c3be49bca2f
7
+ data.tar.gz: 12dd7659c1865a1a98e7682a4449b278a5342ab653b844365c61c36192ca04fd2ef20d321d064ec6452e370e6e4fc75375386d0af4fcd3d7a13c90f80a93fc73
data/lib/Helper.rb CHANGED
@@ -115,6 +115,11 @@ class Helper
115
115
  result += "image:\r\n"
116
116
  result += " path: /#{postInfo.previewImage}\r\n"
117
117
  end
118
+ if !postInfo.pinnedByCreatorAt.nil? && pinnedByCreatorAt > 0
119
+ result += "pin: true\r\n"
120
+ result += "pinned_at: #{postInfo.pinnedByCreatorAt.strftime('%Y-%m-%dT%H:%M:%S.%L%z')}\n"
121
+ end
122
+
118
123
  if isForJekyll
119
124
  result += "render_with_liquid: false\n"
120
125
  end
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, :collectionName, :description, :previewImage
14
+ attr_accessor :title, :tags, :creator, :firstPublishedAt, :latestPublishedAt, :pinnedByCreatorAt, :collectionName, :description, :previewImage
15
15
  end
16
16
 
17
17
  def self.getPostIDFromPostURLString(postURLString)
@@ -103,6 +103,11 @@ 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
+
106
111
  postInfo
107
112
  end
108
113
  end
@@ -235,18 +235,23 @@ class ZMediumFetcher
235
235
  absolutePath = URI.decode(postPathPolicy.getAbsolutePath("#{postWithDatePath}")) + ".md"
236
236
 
237
237
  fileLatestPublishedAt = nil
238
-
238
+ filePinnedByCreatorAt = nil
239
239
  if File.file?(absolutePath)
240
240
  lines = File.foreach(absolutePath).first(15)
241
241
  if lines.first&.start_with?("---")
242
- dateLine = lines.select { |line| line.start_with?("last_modified_at:") }.first
242
+ latestPublishedAtLine = lines.select { |line| line.start_with?("last_modified_at:") }.first
243
+ if !latestPublishedAtLine.nil?
244
+ fileLatestPublishedAt = Time.parse(latestPublishedAtLine[/^(last_modified_at:)\s+(\S*)/, 2]).to_i
245
+ end
246
+
247
+ pinnedByCreatorAtLine = lines.select { |line| line.start_with?("pinned_at:") }.first
243
248
  if !dateLine.nil?
244
- fileLatestPublishedAt = Time.parse(dateLine[/^(last_modified_at:)\s+(\S*)/, 2]).to_i
249
+ filePinnedByCreatorAt = Time.parse(pinnedByCreatorAtLine[/^(pinned_at:)\s+(\S*)/, 2]).to_i
245
250
  end
246
251
  end
247
252
  end
248
253
 
249
- if !fileLatestPublishedAt.nil? && fileLatestPublishedAt >= postInfo.latestPublishedAt.to_i
254
+ if (!fileLatestPublishedAt.nil? && fileLatestPublishedAt >= postInfo.latestPublishedAt.to_i) && filePinnedByCreatorAt == postInfo.pinnedByCreatorAt.to_i
250
255
  # Already downloaded and nothing has changed!, Skip!
251
256
  progress.currentPostParagraphIndex = paragraphs.length
252
257
  progress.message = "Skip, Post already downloaded and nothing has changed!"
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.2.0
4
+ version: 2.3.1
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.1.6
116
+ rubygems_version: 3.0.3
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