sutty-migration 0.3.3 → 0.3.4
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c1f1e56381a9e282ccff520293e16f0e8db930dc2f42d677a9e0d009f2d94e09
|
4
|
+
data.tar.gz: 52ea0428940d4cd225fdbb7fc94fc110a6a6c070fe9e760027f4435f6eb92e22
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 78b02124119406fa7357c7c2abf22e36dfab4297d2d8a6c7ed78c3ac438a0812da6f36e34f1ae332ef5282d8f5844e3090eb3e98e76cf40cdd3c4b6f25dafa6f
|
7
|
+
data.tar.gz: e5749eeca2cec6462e73e8a8acd288685a8aaa2fc7c841cc2f3824af5d97faac2f6ae6fe359ebdfc5ebdcfc8257c682c07ef10f7e0b18896f139fb77dbca5e82
|
@@ -20,7 +20,7 @@ module SuttyMigration
|
|
20
20
|
#
|
21
21
|
# @return [String]
|
22
22
|
def dest
|
23
|
-
@dest ||= URI(attachment_url).path.sub(%r{\A/}, '')
|
23
|
+
@dest ||= CGI.unescape(URI(attachment_url).path.sub(%r{\A/}, ''))
|
24
24
|
end
|
25
25
|
|
26
26
|
# Metadata, with file information as a Hash
|
@@ -40,7 +40,7 @@ module SuttyMigration
|
|
40
40
|
def download(progress: true)
|
41
41
|
return true if File.exist? dest
|
42
42
|
|
43
|
-
::Jekyll.logger.info
|
43
|
+
::Jekyll.logger.info 'Downloading:', dest
|
44
44
|
|
45
45
|
FileUtils.mkdir_p File.dirname(dest)
|
46
46
|
|
@@ -9,6 +9,8 @@ module SuttyMigration
|
|
9
9
|
class Post
|
10
10
|
attr_reader :wordpress, :item
|
11
11
|
|
12
|
+
SLASH = '/'
|
13
|
+
|
12
14
|
# @param :wordpress [SuttyMigration::WordpressXml]
|
13
15
|
# @param :item [Nokogiri::XML::Element]
|
14
16
|
def initialize(wordpress:, item:)
|
@@ -17,7 +19,7 @@ module SuttyMigration
|
|
17
19
|
end
|
18
20
|
|
19
21
|
def inspect
|
20
|
-
"
|
22
|
+
"#<#{self.class.name} title=\"#{title}\">"
|
21
23
|
end
|
22
24
|
|
23
25
|
# Post ID
|
@@ -31,7 +33,16 @@ module SuttyMigration
|
|
31
33
|
#
|
32
34
|
# @return [String]
|
33
35
|
def permalink
|
34
|
-
@permalink ||=
|
36
|
+
@permalink ||=
|
37
|
+
begin
|
38
|
+
p = attribute_value('link').sub(wordpress.url, '')
|
39
|
+
|
40
|
+
if !p.end_with?(SLASH) && File.extname(p).empty?
|
41
|
+
p << SLASH
|
42
|
+
end
|
43
|
+
|
44
|
+
p.squeeze(SLASH)
|
45
|
+
end
|
35
46
|
end
|
36
47
|
|
37
48
|
# Title
|
@@ -52,7 +63,7 @@ module SuttyMigration
|
|
52
63
|
#
|
53
64
|
# @return [String]
|
54
65
|
def slug
|
55
|
-
@slug ||= attribute_value('post_name')
|
66
|
+
@slug ||= attribute_value('post_name').tr(SLASH, '-').squeeze('-').sub(/\A-+/, '').sub(/-+\z/, '')
|
56
67
|
end
|
57
68
|
|
58
69
|
# Publication date.
|
@@ -70,9 +81,12 @@ module SuttyMigration
|
|
70
81
|
|
71
82
|
# Modification date.
|
72
83
|
#
|
73
|
-
# @return [Time]
|
84
|
+
# @return [Time, nil]
|
74
85
|
def last_modified_at
|
75
|
-
@last_modified_at ||=
|
86
|
+
@last_modified_at ||=
|
87
|
+
if (date = attribute_value('post_modified_gmt'))
|
88
|
+
::Jekyll::Utils.parse_date(date)
|
89
|
+
end
|
76
90
|
end
|
77
91
|
|
78
92
|
# Content as HTML, with site URL removed.
|
@@ -105,7 +119,7 @@ module SuttyMigration
|
|
105
119
|
@tags ||= item.css('category').select do |c|
|
106
120
|
c[:domain] == 'post_tag'
|
107
121
|
end.map do |c|
|
108
|
-
wordpress.tags[c[:nicename]]
|
122
|
+
wordpress.tags[c[:nicename]] || { id: 0, title: c.text.strip, slug: c[:nicename] }
|
109
123
|
end
|
110
124
|
end
|
111
125
|
|
@@ -116,7 +130,7 @@ module SuttyMigration
|
|
116
130
|
@categories ||= item.css('category').select do |c|
|
117
131
|
c[:domain] == 'category'
|
118
132
|
end.map do |c|
|
119
|
-
wordpress.categories[c[:nicename]]
|
133
|
+
wordpress.categories[c[:nicename]] || { id: 0, title: c.text.strip, slug: c[:nicename], parent: nil }
|
120
134
|
end
|
121
135
|
end
|
122
136
|
|
@@ -162,9 +176,9 @@ module SuttyMigration
|
|
162
176
|
|
163
177
|
# Get a value from the attribute
|
164
178
|
#
|
165
|
-
# @return [String]
|
179
|
+
# @return [String, nil]
|
166
180
|
def attribute_value(key)
|
167
|
-
item.at_css(key)
|
181
|
+
item.at_css(key)&.text
|
168
182
|
end
|
169
183
|
end
|
170
184
|
end
|
@@ -86,7 +86,7 @@ module SuttyMigration
|
|
86
86
|
slug: attribute_value(category, 'category_nicename')
|
87
87
|
}
|
88
88
|
}
|
89
|
-
end.reduce(&:merge)
|
89
|
+
end.reduce(&:merge) || {}
|
90
90
|
end
|
91
91
|
|
92
92
|
# Tags with attributes, indexed by slug
|
@@ -101,7 +101,7 @@ module SuttyMigration
|
|
101
101
|
slug: attribute_value(tag, 'tag_slug')
|
102
102
|
}
|
103
103
|
}
|
104
|
-
end.reduce(&:merge)
|
104
|
+
end.reduce(&:merge) || {}
|
105
105
|
end
|
106
106
|
|
107
107
|
# Posts, indexed by ID
|
@@ -146,9 +146,9 @@ module SuttyMigration
|
|
146
146
|
#
|
147
147
|
# @param [Nokogiri::XML::Element]
|
148
148
|
# @param [String]
|
149
|
-
# @return [String]
|
149
|
+
# @return [String,nil]
|
150
150
|
def attribute_value(element, attribute)
|
151
|
-
element.at_css(attribute)
|
151
|
+
element.at_css(attribute)&.text
|
152
152
|
end
|
153
153
|
end
|
154
154
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sutty-migration
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- f
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-08-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: jekyll
|
@@ -214,7 +214,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
214
214
|
- !ruby/object:Gem::Version
|
215
215
|
version: '0'
|
216
216
|
requirements: []
|
217
|
-
rubygems_version: 3.
|
217
|
+
rubygems_version: 3.3.27
|
218
218
|
signing_key:
|
219
219
|
specification_version: 4
|
220
220
|
summary: Jekyll data migration for Sutty
|