jekyll-import 0.20.0 → 0.22.0
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/README.markdown +2 -1
- data/lib/jekyll/commands/import.rb +1 -1
- data/lib/jekyll-import/importers/blogger.rb +54 -66
- data/lib/jekyll-import/importers/csv.rb +2 -2
- data/lib/jekyll-import/importers/dotclear.rb +147 -88
- data/lib/jekyll-import/importers/drupal6.rb +7 -3
- data/lib/jekyll-import/importers/drupal8.rb +65 -0
- data/lib/jekyll-import/importers/drupal_common.rb +6 -5
- data/lib/jekyll-import/importers/easyblog.rb +7 -7
- data/lib/jekyll-import/importers/enki.rb +4 -4
- data/lib/jekyll-import/importers/joomla.rb +8 -8
- data/lib/jekyll-import/importers/joomla3.rb +8 -8
- data/lib/jekyll-import/importers/jrnl.rb +4 -4
- data/lib/jekyll-import/importers/marley.rb +1 -1
- data/lib/jekyll-import/importers/medium.rb +36 -0
- data/lib/jekyll-import/importers/mephisto.rb +3 -3
- data/lib/jekyll-import/importers/mt.rb +10 -10
- data/lib/jekyll-import/importers/pluxml.rb +3 -3
- data/lib/jekyll-import/importers/roller.rb +12 -12
- data/lib/jekyll-import/importers/rss.rb +64 -27
- data/lib/jekyll-import/importers/s9y_database.rb +270 -56
- data/lib/jekyll-import/importers/textpattern.rb +5 -5
- data/lib/jekyll-import/importers/tumblr.rb +5 -5
- data/lib/jekyll-import/importers/typo.rb +6 -6
- data/lib/jekyll-import/importers/wordpress.rb +16 -16
- data/lib/jekyll-import/importers/wordpressdotcom.rb +3 -3
- data/lib/jekyll-import/version.rb +1 -1
- metadata +34 -46
@@ -16,16 +16,16 @@ module JekyllImport
|
|
16
16
|
DEFAULTS = {
|
17
17
|
"engine" => "mysql",
|
18
18
|
"password" => "",
|
19
|
-
"host" => "
|
19
|
+
"host" => "127.0.0.1",
|
20
20
|
"prefix" => "",
|
21
21
|
"port" => "3306",
|
22
22
|
"types" => %w(blog story article),
|
23
23
|
}.freeze
|
24
24
|
|
25
25
|
def specify_options(c)
|
26
|
-
c.option "engine", "--engine [mysql|postgresql]", "Database engine (default: #{DEFAULTS["engine"].inspect})"
|
27
26
|
c.option "dbname", "--dbname DB", "Database name"
|
28
27
|
c.option "user", "--user USER", "Database user name"
|
28
|
+
c.option "engine", "--engine [mysql|postgresql]", "Database engine (default: #{DEFAULTS["engine"].inspect})"
|
29
29
|
c.option "password", "--password PW", "Database user's password (default: #{DEFAULTS["password"].inspect})"
|
30
30
|
c.option "host", "--host HOST", "Database host name (default: #{DEFAULTS["host"].inspect})"
|
31
31
|
c.option "port", "--port PORT", "Database port name (default: #{DEFAULTS["port"].inspect})"
|
@@ -47,9 +47,9 @@ module JekyllImport
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def process(options)
|
50
|
-
engine = options.fetch("engine", DEFAULTS["engine"])
|
51
50
|
dbname = options.fetch("dbname")
|
52
51
|
user = options.fetch("user")
|
52
|
+
engine = options.fetch("engine", DEFAULTS["engine"])
|
53
53
|
pass = options.fetch("password", DEFAULTS["password"])
|
54
54
|
host = options.fetch("host", DEFAULTS["host"])
|
55
55
|
port = options.fetch("port", DEFAULTS["port"])
|
@@ -68,6 +68,7 @@ module JekyllImport
|
|
68
68
|
src_dir = conf["source"]
|
69
69
|
|
70
70
|
dirs = {
|
71
|
+
:_aliases => src_dir,
|
71
72
|
:_posts => File.join(src_dir, "_posts").to_s,
|
72
73
|
:_drafts => File.join(src_dir, "_drafts").to_s,
|
73
74
|
:_layouts => Jekyll.sanitized_path(src_dir, conf["layouts_dir"].to_s),
|
@@ -146,10 +147,10 @@ module JekyllImport
|
|
146
147
|
|
147
148
|
if partition.first.length.positive?
|
148
149
|
dir = "#{partition.first}/"
|
149
|
-
FileUtils.mkdir_p
|
150
|
+
FileUtils.mkdir_p "#{dirs[:_aliases]}/#{dir}"
|
150
151
|
end
|
151
152
|
|
152
|
-
File.open("#{dir}#{file}.md", "w") do |f|
|
153
|
+
File.open("#{dirs[:_aliases]}/#{dir}#{file}.md", "w") do |f|
|
153
154
|
f.puts "---"
|
154
155
|
f.puts "layout: refresh"
|
155
156
|
f.puts "permalink: #{dir}#{file}/"
|
@@ -10,12 +10,12 @@ module JekyllImport
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def self.specify_options(c)
|
13
|
-
c.option "dbname", "--dbname", "Database name"
|
14
|
-
c.option "user", "--user", "Database user name"
|
15
|
-
c.option "password", "--password", "Database user's password (default: '')"
|
16
|
-
c.option "host", "--host", "Database host name"
|
17
|
-
c.option "section", "--section", "
|
18
|
-
c.option "prefix", "--prefix", "Table prefix name"
|
13
|
+
c.option "dbname", "--dbname", "Database name."
|
14
|
+
c.option "user", "--user", "Database user name."
|
15
|
+
c.option "password", "--password", "Database user's password. (default: '')"
|
16
|
+
c.option "host", "--host", "Database host name. (default: 'localhost')"
|
17
|
+
c.option "section", "--section", "Section ID. (default: '1')"
|
18
|
+
c.option "prefix", "--prefix", "Table prefix name. (default: 'jos_')"
|
19
19
|
end
|
20
20
|
|
21
21
|
def self.require_deps
|
@@ -32,7 +32,7 @@ module JekyllImport
|
|
32
32
|
dbname = options.fetch("dbname")
|
33
33
|
user = options.fetch("user")
|
34
34
|
pass = options.fetch("password", "")
|
35
|
-
host = options.fetch("host", "
|
35
|
+
host = options.fetch("host", "127.0.0.1")
|
36
36
|
section = options.fetch("section", "1")
|
37
37
|
table_prefix = options.fetch("prefix", "jos_")
|
38
38
|
|
@@ -20,10 +20,10 @@ module JekyllImport
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def self.specify_options(c)
|
23
|
-
c.option "dbname", "--dbname", "Database name"
|
24
|
-
c.option "user", "--user", "
|
25
|
-
c.option "password", "--password",
|
26
|
-
c.option "host", "--host", "Database name"
|
23
|
+
c.option "dbname", "--dbname", "Database name."
|
24
|
+
c.option "user", "--user", "User name."
|
25
|
+
c.option "password", "--password", "Database password. (default: '')"
|
26
|
+
c.option "host", "--host", "Database host name. (default: 'localhost')"
|
27
27
|
end
|
28
28
|
|
29
29
|
def self.require_deps
|
@@ -10,13 +10,13 @@ module JekyllImport
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def self.specify_options(c)
|
13
|
-
c.option "dbname", "--dbname", "Database name"
|
14
|
-
c.option "user", "--user", "Database user name"
|
15
|
-
c.option "password", "--password", "Database user's password (default: '')"
|
16
|
-
c.option "host", "--host", "Database host name"
|
17
|
-
c.option "port", "--port", "Database port"
|
18
|
-
c.option "section", "--section", "
|
19
|
-
c.option "prefix", "--prefix", "Table prefix name"
|
13
|
+
c.option "dbname", "--dbname", "Database name."
|
14
|
+
c.option "user", "--user", "Database user name."
|
15
|
+
c.option "password", "--password", "Database user's password. (default: '')"
|
16
|
+
c.option "host", "--host", "Database host name. (default: 'localhost')"
|
17
|
+
c.option "port", "--port", "Database port. (default: '3306')"
|
18
|
+
c.option "section", "--section", "Section ID. (default: '1')"
|
19
|
+
c.option "prefix", "--prefix", "Table prefix name. (default: 'jos_')"
|
20
20
|
end
|
21
21
|
|
22
22
|
def self.require_deps
|
@@ -33,7 +33,7 @@ module JekyllImport
|
|
33
33
|
dbname = options.fetch("dbname")
|
34
34
|
user = options.fetch("user")
|
35
35
|
pass = options.fetch("password", "")
|
36
|
-
host = options.fetch("host", "
|
36
|
+
host = options.fetch("host", "127.0.0.1")
|
37
37
|
port = options.fetch("port", 3306).to_i
|
38
38
|
section = options.fetch("section", "1")
|
39
39
|
table_prefix = options.fetch("prefix", "jos_")
|
@@ -10,13 +10,13 @@ module JekyllImport
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def self.specify_options(c)
|
13
|
-
c.option "dbname", "--dbname", "Database name"
|
14
|
-
c.option "user", "--user", "Database user name"
|
15
|
-
c.option "password", "--password", "Database user's password (default: '')"
|
16
|
-
c.option "host", "--host", "Database host name"
|
17
|
-
c.option "port", "--port", "Database port"
|
18
|
-
c.option "category", "--category", "ID of the category"
|
19
|
-
c.option "prefix", "--prefix", "Table prefix name"
|
13
|
+
c.option "dbname", "--dbname", "Database name."
|
14
|
+
c.option "user", "--user", "Database user name."
|
15
|
+
c.option "password", "--password", "Database user's password. (default: '')"
|
16
|
+
c.option "host", "--host", "Database host name. (default: 'localhost')"
|
17
|
+
c.option "port", "--port", "Database port. (default: '3306')"
|
18
|
+
c.option "category", "--category", "ID of the category. (default: '0')"
|
19
|
+
c.option "prefix", "--prefix", "Table prefix name. (default: 'jos_')"
|
20
20
|
end
|
21
21
|
|
22
22
|
def self.require_deps
|
@@ -33,7 +33,7 @@ module JekyllImport
|
|
33
33
|
dbname = options.fetch("dbname")
|
34
34
|
user = options.fetch("user")
|
35
35
|
pass = options.fetch("password", "")
|
36
|
-
host = options.fetch("host", "
|
36
|
+
host = options.fetch("host", "127.0.0.1")
|
37
37
|
port = options.fetch("port", 3306).to_i
|
38
38
|
cid = options.fetch("category", 0)
|
39
39
|
table_prefix = options.fetch("prefix", "jos_")
|
@@ -12,10 +12,10 @@ module JekyllImport
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def self.specify_options(c)
|
15
|
-
c.option "file", "--file FILENAME",
|
16
|
-
c.option "time_format", "--time_format FORMAT",
|
17
|
-
c.option "extension", "--extension EXT",
|
18
|
-
c.option "layout", "--layout NAME",
|
15
|
+
c.option "file", "--file FILENAME", "Journal file. (default: '~/journal.txt')"
|
16
|
+
c.option "time_format", "--time_format FORMAT", "Time format of your journal. (default: '%Y-%m-%d %H:%M')"
|
17
|
+
c.option "extension", "--extension EXT", "Output extension. (default: 'md')"
|
18
|
+
c.option "layout", "--layout NAME", "Output post layout. (default: 'post')"
|
19
19
|
end
|
20
20
|
|
21
21
|
# Reads a jrnl file and creates a new post for each entry
|
@@ -28,7 +28,7 @@ module JekyllImport
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def self.specify_options(c)
|
31
|
-
c.option "marley_data_dir", "--marley_data_dir DIR", "The dir containing your marley data"
|
31
|
+
c.option "marley_data_dir", "--marley_data_dir DIR", "The dir containing your marley data."
|
32
32
|
end
|
33
33
|
|
34
34
|
def self.process(options)
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module JekyllImport
|
4
|
+
module Importers
|
5
|
+
class Medium < Importer
|
6
|
+
def self.specify_options(c)
|
7
|
+
c.option "username", "--username NAME", "Medium username"
|
8
|
+
c.option "canonical_link", "--canonical_link", "Copy original link as canonical_url to post (default: false)"
|
9
|
+
c.option "render_audio", "--render_audio", "Render <audio> element in posts for the enclosure URLs (default: false)"
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.validate(options)
|
13
|
+
abort "Missing mandatory option --username." if options["username"].nil?
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.require_deps
|
17
|
+
Importers::RSS.require_deps
|
18
|
+
end
|
19
|
+
|
20
|
+
# Medium posts and associated metadata are exported as an RSS Feed. Hence invoke our RSS Importer to create the
|
21
|
+
# Jekyll source directory.
|
22
|
+
#
|
23
|
+
# "Tags" attached to a Medium post are exported under the markup `<item><category>...</category></item>` in the
|
24
|
+
# export feed. Therefore, configure the RSS Importer to always look for tags in the `<category></category>` field
|
25
|
+
# of an RSS item.
|
26
|
+
def self.process(options)
|
27
|
+
Importers::RSS.process({
|
28
|
+
"source" => "https://medium.com/feed/@#{options.fetch("username")}",
|
29
|
+
"render_audio" => options.fetch("render_audio", false),
|
30
|
+
"canonical_link" => options.fetch("canonical_link", false),
|
31
|
+
"extract_tags" => "category",
|
32
|
+
})
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -14,7 +14,7 @@ module JekyllImport
|
|
14
14
|
COPY jekyll TO STDOUT WITH CSV HEADER;
|
15
15
|
ROLLBACK;
|
16
16
|
SQL
|
17
|
-
command = %(psql -h #{c[:host] || "
|
17
|
+
command = %(psql -h #{c[:host] || "127.0.0.1"} -c "#{sql.strip}" #{c[:database]} #{c[:username]} -o #{c[:filename] || "posts.csv"})
|
18
18
|
Jekyll.logger.info "Executing:", command
|
19
19
|
`#{command}`
|
20
20
|
CSV.process
|
@@ -40,7 +40,7 @@ module JekyllImport
|
|
40
40
|
c.option "dbname", "--dbname DB", "Database name"
|
41
41
|
c.option "user", "--user USER", "Database user name"
|
42
42
|
c.option "password", "--password PW", "Database user's password (default: '')"
|
43
|
-
c.option "host", "--host HOST",
|
43
|
+
c.option "host", "--host HOST", "Database host name (default: 'localhost')"
|
44
44
|
end
|
45
45
|
|
46
46
|
# This query will pull blog posts from all entries across all blogs. If
|
@@ -61,7 +61,7 @@ module JekyllImport
|
|
61
61
|
dbname = options.fetch("dbname")
|
62
62
|
user = options.fetch("user")
|
63
63
|
pass = options.fetch("password", "")
|
64
|
-
host = options.fetch("host", "
|
64
|
+
host = options.fetch("host", "127.0.0.1")
|
65
65
|
|
66
66
|
db = Sequel.mysql2(dbname, :user => user,
|
67
67
|
:password => pass,
|
@@ -32,17 +32,17 @@ module JekyllImport
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def self.specify_options(c)
|
35
|
-
c.option "
|
36
|
-
c.option "
|
37
|
-
c.option "
|
38
|
-
c.option "password", "--password PW", "Database user's password
|
39
|
-
c.option "host", "--host HOST",
|
40
|
-
c.option "port", "--port PORT", "Custom database port connect to (
|
41
|
-
c.option "blog_id", "--blog_id ID", "Specify a single Movable Type blog ID to import (default: all blogs)"
|
42
|
-
c.option "categories", "--categories", "
|
35
|
+
c.option "dbname", "--dbname DB", "Database name."
|
36
|
+
c.option "user", "--user USER", "Database user name."
|
37
|
+
c.option "engine", "--engine ENGINE", "Database engine ('mysql' or 'postgres'). (default: 'mysql')"
|
38
|
+
c.option "password", "--password PW", "Database user's password. (default: '')"
|
39
|
+
c.option "host", "--host HOST", "Database host name. (default: 'localhost')"
|
40
|
+
c.option "port", "--port PORT", "Custom database port connect to. (default: null)"
|
41
|
+
c.option "blog_id", "--blog_id ID", "Specify a single Movable Type blog ID to import. (default: null (all blogs))"
|
42
|
+
c.option "categories", "--categories", "When true, save post's categories in its YAML front matter. (default: true)"
|
43
43
|
c.option "src_encoding", "--src_encoding ENCODING", "Encoding of strings from database. (default: UTF-8)"
|
44
44
|
c.option "dest_encoding", "--dest_encoding ENCODING", "Encoding of output strings. (default: UTF-8)"
|
45
|
-
c.option "comments", "--comments", "
|
45
|
+
c.option "comments", "--comments", "When true, output comments in `_comments` directory. (default: false)"
|
46
46
|
end
|
47
47
|
|
48
48
|
# By default this migrator will include posts for all your MovableType blogs.
|
@@ -242,7 +242,7 @@ module JekyllImport
|
|
242
242
|
Sequel.sqlite(dbname)
|
243
243
|
when "mysql", "postgres"
|
244
244
|
db_connect_opts = {
|
245
|
-
:host => options.fetch("host", "
|
245
|
+
:host => options.fetch("host", "127.0.0.1"),
|
246
246
|
:user => options.fetch("user"),
|
247
247
|
:password => options.fetch("password", ""),
|
248
248
|
}
|
@@ -12,9 +12,9 @@ module JekyllImport
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def self.specify_options(c)
|
15
|
-
c.option "source",
|
16
|
-
c.option "layout",
|
17
|
-
c.option "avoid_liquid", "--avoid_liquid
|
15
|
+
c.option "source", "--source NAME", "The PluXml data directory to import."
|
16
|
+
c.option "layout", "--layout NAME", "The layout to apply. (default: 'post')"
|
17
|
+
c.option "avoid_liquid", "--avoid_liquid", "Will add `render_with_liquid: false` in front matter. (default: false)"
|
18
18
|
end
|
19
19
|
|
20
20
|
def self.validate(options)
|
@@ -14,19 +14,19 @@ module JekyllImport
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def self.specify_options(c)
|
17
|
-
c.option "dbname", "--dbname DB", "Database name
|
18
|
-
c.option "
|
19
|
-
c.option "
|
20
|
-
c.option "
|
21
|
-
c.option "host", "--host HOST", "Database host name (default: 'localhost')"
|
22
|
-
c.option "port", "--port PORT", "Database port number (default: '3306')"
|
23
|
-
c.option "clean_entities", "--clean_entities", "Whether to clean entities (default: true)"
|
24
|
-
c.option "comments", "--comments", "Whether to import comments (default: true)"
|
25
|
-
c.option "categories", "--categories", "Whether to import categories (default: true)"
|
26
|
-
c.option "tags", "--tags", "Whether to import tags (default: true)"
|
17
|
+
c.option "dbname", "--dbname DB", "Database name."
|
18
|
+
c.option "user", "--user USER", "Database user name."
|
19
|
+
c.option "password", "--password PW", "Database user's password."
|
20
|
+
c.option "socket", "--socket SOCKET", "Database socket. (default: null)"
|
21
|
+
c.option "host", "--host HOST", "Database host name. (default: 'localhost')"
|
22
|
+
c.option "port", "--port PORT", "Database port number. (default: '3306')"
|
23
|
+
c.option "clean_entities", "--clean_entities", "Whether to clean entities. (default: true)"
|
24
|
+
c.option "comments", "--comments", "Whether to import comments. (default: true)"
|
25
|
+
c.option "categories", "--categories", "Whether to import categories. (default: true)"
|
26
|
+
c.option "tags", "--tags", "Whether to import tags. (default: true)"
|
27
27
|
|
28
28
|
c.option "status", "--status STATUS,STATUS2", Array,
|
29
|
-
"Array of allowed statuses (
|
29
|
+
"Array of allowed statuses (either ['PUBLISHED'] or ['DRAFT']). (default: ['PUBLISHED'])"
|
30
30
|
end
|
31
31
|
|
32
32
|
# Main migrator function. Call this to perform the migration.
|
@@ -64,7 +64,7 @@ module JekyllImport
|
|
64
64
|
options = {
|
65
65
|
:user => opts.fetch("user", ""),
|
66
66
|
:pass => opts.fetch("password", ""),
|
67
|
-
:host => opts.fetch("host", "
|
67
|
+
:host => opts.fetch("host", "127.0.0.1"),
|
68
68
|
:port => opts.fetch("port", "3306"),
|
69
69
|
:socket => opts.fetch("socket", nil),
|
70
70
|
:dbname => opts.fetch("dbname", ""),
|
@@ -4,12 +4,16 @@ module JekyllImport
|
|
4
4
|
module Importers
|
5
5
|
class RSS < Importer
|
6
6
|
def self.specify_options(c)
|
7
|
-
c.option "source",
|
8
|
-
c.option "tag",
|
7
|
+
c.option "source", "--source NAME", "The RSS file or URL to import."
|
8
|
+
c.option "tag", "--tag NAME", "Add a specific tag to all posts."
|
9
|
+
c.option "extract_tags", "--extract_tags KEY", "Copies tags from the given subfield on the RSS `<item>` to front matter. (default: null)"
|
10
|
+
c.option "render_audio", "--render_audio", "Render `<audio>` element in posts for the enclosure URLs. (default: false)"
|
11
|
+
c.option "canonical_link", "--canonical_link", "Add original link as `canonical_url` to post front matter. (default: false)"
|
9
12
|
end
|
10
13
|
|
11
14
|
def self.validate(options)
|
12
15
|
abort "Missing mandatory option --source." if options["source"].nil?
|
16
|
+
abort "Provide either --tag or --extract_tags option." if options["extract_tags"] && options["tag"]
|
13
17
|
end
|
14
18
|
|
15
19
|
def self.require_deps
|
@@ -30,49 +34,82 @@ module JekyllImport
|
|
30
34
|
# Returns nothing.
|
31
35
|
def self.process(options)
|
32
36
|
source = options.fetch("source")
|
33
|
-
frontmatter = options.fetch("frontmatter", [])
|
34
|
-
body = options.fetch("body", ["description"])
|
35
37
|
|
36
38
|
content = ""
|
37
|
-
open(source) { |s| content = s.read }
|
39
|
+
URI.open(source) { |s| content = s.read }
|
38
40
|
rss = ::RSS::Parser.parse(content, false)
|
39
41
|
|
40
42
|
raise "There doesn't appear to be any RSS items at the source (#{source}) provided." unless rss
|
41
43
|
|
42
44
|
rss.items.each do |item|
|
43
|
-
|
44
|
-
|
45
|
-
|
45
|
+
write_rss_item(item, options)
|
46
|
+
end
|
47
|
+
end
|
46
48
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
49
|
+
def self.write_rss_item(item, options)
|
50
|
+
frontmatter = options.fetch("frontmatter", [])
|
51
|
+
body = options.fetch("body", ["description"])
|
52
|
+
render_audio = options.fetch("render_audio", false)
|
51
53
|
|
52
|
-
|
54
|
+
formatted_date = item.date.strftime("%Y-%m-%d")
|
55
|
+
post_name = Jekyll::Utils.slugify(item.title, :mode => "latin")
|
56
|
+
name = "#{formatted_date}-#{post_name}"
|
57
|
+
audio = render_audio && item.enclosure.url
|
58
|
+
canonical_link = options.fetch("canonical_link", false)
|
53
59
|
|
54
|
-
|
55
|
-
|
56
|
-
|
60
|
+
header = {
|
61
|
+
"layout" => "post",
|
62
|
+
"title" => item.title,
|
63
|
+
"canonical_url" => (canonical_link ? item.link : nil),
|
64
|
+
"tag" => get_tags(item, options),
|
65
|
+
}.compact
|
57
66
|
|
58
|
-
|
67
|
+
frontmatter.each do |value|
|
68
|
+
header[value] = item.send(value)
|
69
|
+
end
|
59
70
|
|
60
|
-
|
61
|
-
output << item.send(row).to_s
|
62
|
-
end
|
71
|
+
output = +""
|
63
72
|
|
64
|
-
|
65
|
-
output
|
73
|
+
body.each do |row|
|
74
|
+
output << item.send(row).to_s
|
75
|
+
end
|
76
|
+
|
77
|
+
output.strip!
|
78
|
+
output = item.content_encoded if output.empty?
|
79
|
+
|
80
|
+
FileUtils.mkdir_p("_posts")
|
66
81
|
|
67
|
-
|
82
|
+
File.open("_posts/#{name}.html", "w") do |f|
|
83
|
+
f.puts header.to_yaml
|
84
|
+
f.puts "---\n\n"
|
68
85
|
|
69
|
-
|
70
|
-
f.puts
|
71
|
-
|
72
|
-
|
86
|
+
if audio
|
87
|
+
f.puts <<~HTML
|
88
|
+
<audio controls="">
|
89
|
+
<source src="#{audio}" type="audio/mpeg">
|
90
|
+
Your browser does not support the audio element.
|
91
|
+
</audio>
|
92
|
+
HTML
|
73
93
|
end
|
94
|
+
|
95
|
+
f.puts output
|
74
96
|
end
|
75
97
|
end
|
98
|
+
|
99
|
+
def self.get_tags(item, options)
|
100
|
+
explicit_tag = options["tag"]
|
101
|
+
return explicit_tag unless explicit_tag.nil? || explicit_tag.empty?
|
102
|
+
|
103
|
+
tags_reference = options["extract_tags"]
|
104
|
+
return unless tags_reference
|
105
|
+
|
106
|
+
tags_from_feed = item.instance_variable_get("@#{tags_reference}")
|
107
|
+
return unless tags_from_feed.is_a?(Array)
|
108
|
+
|
109
|
+
tags = tags_from_feed.map { |feed_tag| feed_tag.content.downcase }
|
110
|
+
tags.empty? ? nil : tags.tap(&:uniq!)
|
111
|
+
end
|
112
|
+
private_class_method :get_tags
|
76
113
|
end
|
77
114
|
end
|
78
115
|
end
|