jekyll-import 0.18.1 → 0.19.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/lib/jekyll-import/importers/dotclear.rb +124 -0
 - data/lib/jekyll-import/importers/roller.rb +1 -1
 - data/lib/jekyll-import/importers/rss.rb +7 -6
 - data/lib/jekyll-import/importers/s9y_database.rb +1 -1
 - data/lib/jekyll-import/importers/wordpress.rb +1 -1
 - data/lib/jekyll-import/version.rb +1 -1
 - metadata +3 -2
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA256:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 5e0c80e9a51361d575c8282c0dd6f813d24cf36423fcbe891a4dcda8c2410003
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: 8067c22cc55a955283967999590cecc4ea5f6fd212005b62919d811cb76bcc9b
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: 9ea2f084457d3192cece261e1e98511e4cf0219e62afb5d3c2b50f8c957e76fe82f85ae9b5c55beebf4c8b6c15f8acbd17da00dca245253af5ddc3a9a84888b7
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: f5abebbb51120ba3877075eaf82f4a02c07e3253011b75c996e3f1c9aa5ab9533e66775f5041702bda739513ad1e5fa600775c5e3b7e60d452422edc85507aec
         
     | 
| 
         @@ -0,0 +1,124 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            # frozen_string_literal: true
         
     | 
| 
      
 2 
     | 
    
         
            +
             
     | 
| 
      
 3 
     | 
    
         
            +
            # Tested with dotClear 2.1.5
         
     | 
| 
      
 4 
     | 
    
         
            +
            module JekyllImport
         
     | 
| 
      
 5 
     | 
    
         
            +
              module Importers
         
     | 
| 
      
 6 
     | 
    
         
            +
                class Dotclear < Importer
         
     | 
| 
      
 7 
     | 
    
         
            +
                  def self.specify_options(c)
         
     | 
| 
      
 8 
     | 
    
         
            +
                    c.option "datafile", "--datafile PATH", "dotClear export file"
         
     | 
| 
      
 9 
     | 
    
         
            +
                    c.option "mediafolder", "--mediafolder PATH", "dotClear media export folder (media.zip inflated)"
         
     | 
| 
      
 10 
     | 
    
         
            +
                  end
         
     | 
| 
      
 11 
     | 
    
         
            +
             
     | 
| 
      
 12 
     | 
    
         
            +
                  def self.require_deps
         
     | 
| 
      
 13 
     | 
    
         
            +
                    JekyllImport.require_with_fallback(%w(
         
     | 
| 
      
 14 
     | 
    
         
            +
                      rubygems
         
     | 
| 
      
 15 
     | 
    
         
            +
                      fileutils
         
     | 
| 
      
 16 
     | 
    
         
            +
                      safe_yaml
         
     | 
| 
      
 17 
     | 
    
         
            +
                      date
         
     | 
| 
      
 18 
     | 
    
         
            +
                      active_support
         
     | 
| 
      
 19 
     | 
    
         
            +
                      active_support/core_ext/string/inflections
         
     | 
| 
      
 20 
     | 
    
         
            +
                      csv
         
     | 
| 
      
 21 
     | 
    
         
            +
                      pp
         
     | 
| 
      
 22 
     | 
    
         
            +
                    ))
         
     | 
| 
      
 23 
     | 
    
         
            +
                  end
         
     | 
| 
      
 24 
     | 
    
         
            +
             
     | 
| 
      
 25 
     | 
    
         
            +
                  def self.validate(opts)
         
     | 
| 
      
 26 
     | 
    
         
            +
                    abort "Specify a data file !" if opts["datafile"].nil? || opts["datafile"].empty?
         
     | 
| 
      
 27 
     | 
    
         
            +
                    abort "Specify a media folder !" if opts["mediafolder"].nil? || opts["mediafolder"].empty?
         
     | 
| 
      
 28 
     | 
    
         
            +
                  end
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                  def self.extract_headers_section(str)
         
     | 
| 
      
 31 
     | 
    
         
            +
                    str[1..-2].split(" ")[1].split(",")
         
     | 
| 
      
 32 
     | 
    
         
            +
                  end
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                  def self.extract_data_section(str)
         
     | 
| 
      
 35 
     | 
    
         
            +
                    str.gsub(%r!^"!, "").gsub(%r!"$!, "").split('","')
         
     | 
| 
      
 36 
     | 
    
         
            +
                  end
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
                  def self.process(opts)
         
     | 
| 
      
 39 
     | 
    
         
            +
                    options = {
         
     | 
| 
      
 40 
     | 
    
         
            +
                      :datafile    => opts.fetch("datafile", ""),
         
     | 
| 
      
 41 
     | 
    
         
            +
                      :mediafolder => opts.fetch("mediafolder", ""),
         
     | 
| 
      
 42 
     | 
    
         
            +
                    }
         
     | 
| 
      
 43 
     | 
    
         
            +
             
     | 
| 
      
 44 
     | 
    
         
            +
                    FileUtils.mkdir_p("_posts")
         
     | 
| 
      
 45 
     | 
    
         
            +
                    FileUtils.mkdir_p("_drafts")
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
                    type_data = ""
         
     | 
| 
      
 48 
     | 
    
         
            +
                    headers = {}
         
     | 
| 
      
 49 
     | 
    
         
            +
                    posts_and_drafts = {}
         
     | 
| 
      
 50 
     | 
    
         
            +
                    keywords = {}
         
     | 
| 
      
 51 
     | 
    
         
            +
             
     | 
| 
      
 52 
     | 
    
         
            +
                    File.readlines(options[:datafile]).each do |lineraw|
         
     | 
| 
      
 53 
     | 
    
         
            +
                      line = lineraw.strip.gsub(%r!\n$!, "")
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
                      next if line.empty?
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
                      if line.start_with?("[") # post | media \ meta | comment...
         
     | 
| 
      
 58 
     | 
    
         
            +
                        type_data = line.split(" ").first[1..-1]
         
     | 
| 
      
 59 
     | 
    
         
            +
                        headers[type_data] = extract_headers_section(line)
         
     | 
| 
      
 60 
     | 
    
         
            +
                        next
         
     | 
| 
      
 61 
     | 
    
         
            +
                      end
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
                      elts = extract_data_section(line)
         
     | 
| 
      
 64 
     | 
    
         
            +
             
     | 
| 
      
 65 
     | 
    
         
            +
                      if type_data == "post"
         
     | 
| 
      
 66 
     | 
    
         
            +
                        draft = (elts[headers[type_data].index("post_status")] != "1")
         
     | 
| 
      
 67 
     | 
    
         
            +
             
     | 
| 
      
 68 
     | 
    
         
            +
                        date_str = elts[headers[type_data].index("post_creadt")]
         
     | 
| 
      
 69 
     | 
    
         
            +
                        date_blank = (date_str.nil? || date_str.empty?)
         
     | 
| 
      
 70 
     | 
    
         
            +
                        date_str_formatted = date_blank ? Date.today : Date.parse(date_str).strftime("%Y-%m-%d")
         
     | 
| 
      
 71 
     | 
    
         
            +
                        title_param = elts[headers[type_data].index("post_title")].to_s.parameterize
         
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
      
 73 
     | 
    
         
            +
                        content = elts[headers[type_data].index("post_content_xhtml")].to_s
         
     | 
| 
      
 74 
     | 
    
         
            +
                        content = content.gsub('\"', '"').gsub('\n', "\n").gsub("/public/", "/assets/images/")
         
     | 
| 
      
 75 
     | 
    
         
            +
             
     | 
| 
      
 76 
     | 
    
         
            +
                        filepath = File.join(Dir.pwd, (draft ? "_drafts" : "_posts"), "#{date_str_formatted}-#{title_param}.html")
         
     | 
| 
      
 77 
     | 
    
         
            +
             
     | 
| 
      
 78 
     | 
    
         
            +
                        entire_content_file = <<~POST_FILE
         
     | 
| 
      
 79 
     | 
    
         
            +
                          ---
         
     | 
| 
      
 80 
     | 
    
         
            +
                          layout: post
         
     | 
| 
      
 81 
     | 
    
         
            +
                          title: "#{elts[headers[type_data].index("post_title")]}"
         
     | 
| 
      
 82 
     | 
    
         
            +
                          date: #{elts[headers[type_data].index("post_creadt")]} +0100
         
     | 
| 
      
 83 
     | 
    
         
            +
                          tags: ABC
         
     | 
| 
      
 84 
     | 
    
         
            +
                          ---
         
     | 
| 
      
 85 
     | 
    
         
            +
             
     | 
| 
      
 86 
     | 
    
         
            +
                          #{content}
         
     | 
| 
      
 87 
     | 
    
         
            +
                        POST_FILE
         
     | 
| 
      
 88 
     | 
    
         
            +
             
     | 
| 
      
 89 
     | 
    
         
            +
                        posts_and_drafts[elts[headers[type_data].index("post_id")]] = { :path => filepath, :content => entire_content_file }
         
     | 
| 
      
 90 
     | 
    
         
            +
                      elsif type_data == "media"
         
     | 
| 
      
 91 
     | 
    
         
            +
                        elts[headers[type_data].index("media_title")]
         
     | 
| 
      
 92 
     | 
    
         
            +
                        mediafilepath = elts[headers[type_data].index("media_file")]
         
     | 
| 
      
 93 
     | 
    
         
            +
             
     | 
| 
      
 94 
     | 
    
         
            +
                        src_path = File.join(options[:mediafolder], mediafilepath)
         
     | 
| 
      
 95 
     | 
    
         
            +
                        dst_path = File.join(Dir.pwd, "assets", "images", mediafilepath.to_s)
         
     | 
| 
      
 96 
     | 
    
         
            +
             
     | 
| 
      
 97 
     | 
    
         
            +
                        FileUtils.mkdir_p(File.dirname(dst_path))
         
     | 
| 
      
 98 
     | 
    
         
            +
                        FileUtils.cp(src_path, dst_path)
         
     | 
| 
      
 99 
     | 
    
         
            +
                      elsif type_data == "meta"
         
     | 
| 
      
 100 
     | 
    
         
            +
                        keywords[elts[headers[type_data].index("post_id")]] ||= []
         
     | 
| 
      
 101 
     | 
    
         
            +
                        keywords[elts[headers[type_data].index("post_id")]] << elts[headers[type_data].index("meta_id")]
         
     | 
| 
      
 102 
     | 
    
         
            +
                      elsif type_data == "link"
         
     | 
| 
      
 103 
     | 
    
         
            +
             
     | 
| 
      
 104 
     | 
    
         
            +
                      elsif type_data == "setting"
         
     | 
| 
      
 105 
     | 
    
         
            +
             
     | 
| 
      
 106 
     | 
    
         
            +
                      elsif type_data == "comment"
         
     | 
| 
      
 107 
     | 
    
         
            +
             
     | 
| 
      
 108 
     | 
    
         
            +
                      end
         
     | 
| 
      
 109 
     | 
    
         
            +
                    end
         
     | 
| 
      
 110 
     | 
    
         
            +
             
     | 
| 
      
 111 
     | 
    
         
            +
                    # POST-process : Change media path in posts and drafts
         
     | 
| 
      
 112 
     | 
    
         
            +
                    posts_and_drafts.each do |post_id, hsh|
         
     | 
| 
      
 113 
     | 
    
         
            +
                      keywords_str = keywords[post_id].to_a.join(", ")
         
     | 
| 
      
 114 
     | 
    
         
            +
                      content_file = hsh[:content]
         
     | 
| 
      
 115 
     | 
    
         
            +
                      content_file = content_file.gsub("tags: ABC", "tags: [#{keywords_str}]")
         
     | 
| 
      
 116 
     | 
    
         
            +
             
     | 
| 
      
 117 
     | 
    
         
            +
                      File.open(hsh[:path], "wb") do |f|
         
     | 
| 
      
 118 
     | 
    
         
            +
                        f.write(content_file)
         
     | 
| 
      
 119 
     | 
    
         
            +
                      end
         
     | 
| 
      
 120 
     | 
    
         
            +
                    end
         
     | 
| 
      
 121 
     | 
    
         
            +
                  end
         
     | 
| 
      
 122 
     | 
    
         
            +
                end
         
     | 
| 
      
 123 
     | 
    
         
            +
              end
         
     | 
| 
      
 124 
     | 
    
         
            +
            end
         
     | 
| 
         @@ -80,7 +80,7 @@ module JekyllImport 
     | 
|
| 
       80 
80 
     | 
    
         
             
                      begin
         
     | 
| 
       81 
81 
     | 
    
         
             
                        require "htmlentities"
         
     | 
| 
       82 
82 
     | 
    
         
             
                      rescue LoadError
         
     | 
| 
       83 
     | 
    
         
            -
                         
     | 
| 
      
 83 
     | 
    
         
            +
                        warn "Could not require 'htmlentities', so the :clean_entities option is now disabled."
         
     | 
| 
       84 
84 
     | 
    
         
             
                        options[:clean_entities] = false
         
     | 
| 
       85 
85 
     | 
    
         
             
                      end
         
     | 
| 
       86 
86 
     | 
    
         
             
                    end
         
     | 
| 
         @@ -41,9 +41,7 @@ module JekyllImport 
     | 
|
| 
       41 
41 
     | 
    
         | 
| 
       42 
42 
     | 
    
         
             
                    rss.items.each do |item|
         
     | 
| 
       43 
43 
     | 
    
         
             
                      formatted_date = item.date.strftime("%Y-%m-%d")
         
     | 
| 
       44 
     | 
    
         
            -
                      post_name = item.title 
     | 
| 
       45 
     | 
    
         
            -
                        i.downcase if i != ""
         
     | 
| 
       46 
     | 
    
         
            -
                      end.compact.join("-")
         
     | 
| 
      
 44 
     | 
    
         
            +
                      post_name = Jekyll::Utils.slugify(item.title, :mode => "latin")
         
     | 
| 
       47 
45 
     | 
    
         
             
                      name = "#{formatted_date}-#{post_name}"
         
     | 
| 
       48 
46 
     | 
    
         | 
| 
       49 
47 
     | 
    
         
             
                      header = {
         
     | 
| 
         @@ -51,18 +49,21 @@ module JekyllImport 
     | 
|
| 
       51 
49 
     | 
    
         
             
                        "title"  => item.title,
         
     | 
| 
       52 
50 
     | 
    
         
             
                      }
         
     | 
| 
       53 
51 
     | 
    
         | 
| 
       54 
     | 
    
         
            -
                      header["tag"] = options["tag"] unless options. 
     | 
| 
      
 52 
     | 
    
         
            +
                      header["tag"] = options["tag"] unless options["tag"].nil? || options["tag"].empty?
         
     | 
| 
       55 
53 
     | 
    
         | 
| 
       56 
54 
     | 
    
         
             
                      frontmatter.each do |value|
         
     | 
| 
       57 
55 
     | 
    
         
             
                        header[value] = item.send(value)
         
     | 
| 
       58 
56 
     | 
    
         
             
                      end
         
     | 
| 
       59 
57 
     | 
    
         | 
| 
       60 
     | 
    
         
            -
                      output = ""
         
     | 
| 
      
 58 
     | 
    
         
            +
                      output = +""
         
     | 
| 
       61 
59 
     | 
    
         | 
| 
       62 
60 
     | 
    
         
             
                      body.each do |row|
         
     | 
| 
       63 
     | 
    
         
            -
                        output  
     | 
| 
      
 61 
     | 
    
         
            +
                        output << item.send(row).to_s
         
     | 
| 
       64 
62 
     | 
    
         
             
                      end
         
     | 
| 
       65 
63 
     | 
    
         | 
| 
      
 64 
     | 
    
         
            +
                      output.strip!
         
     | 
| 
      
 65 
     | 
    
         
            +
                      output = item.content_encoded if output.empty?
         
     | 
| 
      
 66 
     | 
    
         
            +
             
     | 
| 
       66 
67 
     | 
    
         
             
                      FileUtils.mkdir_p("_posts")
         
     | 
| 
       67 
68 
     | 
    
         | 
| 
       68 
69 
     | 
    
         
             
                      File.open("_posts/#{name}.html", "w") do |f|
         
     | 
| 
         @@ -207,7 +207,7 @@ module JekyllImport 
     | 
|
| 
       207 
207 
     | 
    
         
             
                    require gem_name
         
     | 
| 
       208 
208 
     | 
    
         
             
                    true
         
     | 
| 
       209 
209 
     | 
    
         
             
                  rescue LoadError
         
     | 
| 
       210 
     | 
    
         
            -
                     
     | 
| 
      
 210 
     | 
    
         
            +
                    warn "Could not require '#{gem_name}', so the :#{option_name} option is now disabled."
         
     | 
| 
       211 
211 
     | 
    
         
             
                    true
         
     | 
| 
       212 
212 
     | 
    
         
             
                  end
         
     | 
| 
       213 
213 
     | 
    
         | 
| 
         @@ -101,7 +101,7 @@ module JekyllImport 
     | 
|
| 
       101 
101 
     | 
    
         
             
                      begin
         
     | 
| 
       102 
102 
     | 
    
         
             
                        require "htmlentities"
         
     | 
| 
       103 
103 
     | 
    
         
             
                      rescue LoadError
         
     | 
| 
       104 
     | 
    
         
            -
                         
     | 
| 
      
 104 
     | 
    
         
            +
                        warn "Could not require 'htmlentities', so the " \
         
     | 
| 
       105 
105 
     | 
    
         
             
                                    ":clean_entities option is now disabled."
         
     | 
| 
       106 
106 
     | 
    
         
             
                        options[:clean_entities] = false
         
     | 
| 
       107 
107 
     | 
    
         
             
                      end
         
     | 
    
        metadata
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            --- !ruby/object:Gem::Specification
         
     | 
| 
       2 
2 
     | 
    
         
             
            name: jekyll-import
         
     | 
| 
       3 
3 
     | 
    
         
             
            version: !ruby/object:Gem::Version
         
     | 
| 
       4 
     | 
    
         
            -
              version: 0. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.19.0
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
7 
     | 
    
         
             
            - Tom Preston-Werner
         
     | 
| 
         @@ -10,7 +10,7 @@ authors: 
     | 
|
| 
       10 
10 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       11 
11 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       12 
12 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       13 
     | 
    
         
            -
            date: 2019- 
     | 
| 
      
 13 
     | 
    
         
            +
            date: 2019-06-24 00:00:00.000000000 Z
         
     | 
| 
       14 
14 
     | 
    
         
             
            dependencies:
         
     | 
| 
       15 
15 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       16 
16 
     | 
    
         
             
              name: fastercsv
         
     | 
| 
         @@ -370,6 +370,7 @@ files: 
     | 
|
| 
       370 
370 
     | 
    
         
             
            - lib/jekyll-import/importers/behance.rb
         
     | 
| 
       371 
371 
     | 
    
         
             
            - lib/jekyll-import/importers/blogger.rb
         
     | 
| 
       372 
372 
     | 
    
         
             
            - lib/jekyll-import/importers/csv.rb
         
     | 
| 
      
 373 
     | 
    
         
            +
            - lib/jekyll-import/importers/dotclear.rb
         
     | 
| 
       373 
374 
     | 
    
         
             
            - lib/jekyll-import/importers/drupal6.rb
         
     | 
| 
       374 
375 
     | 
    
         
             
            - lib/jekyll-import/importers/drupal7.rb
         
     | 
| 
       375 
376 
     | 
    
         
             
            - lib/jekyll-import/importers/drupal_common.rb
         
     |