Skip to content

Commit

Permalink
Add option to specify the MySQL port for the Joomla importers (#310)
Browse files Browse the repository at this point in the history
Merge pull request 310
  • Loading branch information
ienev authored and jekyllbot committed Jun 20, 2017
1 parent ce38e10 commit 142f1b5
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 9 deletions.
5 changes: 3 additions & 2 deletions docs/_importers/joomla.md
Expand Up @@ -16,11 +16,12 @@ $ ruby -rubygems -e 'require "jekyll-import";
"user" => "myuser",
"password" => "mypassword",
"host" => "myhost",
"port" => portnumber,
"section" => "thesection",
"prefix" => "mytableprefix"
})'
{% endhighlight %}

The only required fields are `dbname` and `user`. `password` defaults to `""`,
`host` defaults to `"localhost"`, and `section` defaults to `"1"` and `prefix`
defaults to `"jos_"`.
`host` defaults to `"localhost"`, `portnumber` defaults to `3306`, `section`
defaults to `"1"` and `prefix` defaults to `"jos_"`.
4 changes: 3 additions & 1 deletion docs/_importers/joomla3.md
Expand Up @@ -16,13 +16,15 @@ $ ruby -rubygems -e 'require "jekyll-import";
"user" => "myuser",
"password" => "mypassword",
"host" => "myhost",
"port" => portnumber,
"category" => category,
"prefix" => "mytableprefix"
})'
{% endhighlight %}

The only required fields are `dbname`, `prefix` and `user`. `password` defaults to `""`,
and `host` defaults to `"localhost"`.
`host` defaults to `"localhost"`, `portnumber` defaults to `3306` and `prefix` defaults to
`"jos_"`.

If the `category` numerical field is not filled, all articles will be imported, except the ones that are
uncategorized.
8 changes: 5 additions & 3 deletions lib/jekyll-import/importers/joomla.rb
Expand Up @@ -14,6 +14,7 @@ def self.specify_options(c)
c.option 'user', '--user', 'Database user name'
c.option 'password', '--password', "Database user's password (default: '')"
c.option 'host', '--host', 'Database host name'
c.option 'port', '--port', 'Database port'
c.option 'section', '--section', 'Table prefix name'
c.option 'prefix', '--prefix', 'Table prefix name'
end
Expand All @@ -32,11 +33,12 @@ def self.process(options)
dbname = options.fetch('dbname')
user = options.fetch('user')
pass = options.fetch('password', '')
host = options.fetch('host', "localhost")
host = options.fetch('host', 'localhost')
port = options.fetch('port', 3306).to_i
section = options.fetch('section', '1')
table_prefix = options.fetch('prefix', "jos_")
table_prefix = options.fetch('prefix', 'jos_')

db = Sequel.mysql2(dbname, :user => user, :password => pass, :host => host, :encoding => 'utf8')
db = Sequel.mysql2(dbname, user: user, password: pass, host: host, port: port, encoding: 'utf8')

FileUtils.mkdir_p("_posts")

Expand Down
8 changes: 5 additions & 3 deletions lib/jekyll-import/importers/joomla3.rb
Expand Up @@ -14,6 +14,7 @@ def self.specify_options(c)
c.option 'user', '--user', 'Database user name'
c.option 'password', '--password', "Database user's password (default: '')"
c.option 'host', '--host', 'Database host name'
c.option 'port', '--port', 'Database port'
c.option 'category', '--category', 'ID of the category'
c.option 'prefix', '--prefix', 'Table prefix name'
end
Expand All @@ -32,11 +33,12 @@ def self.process(options)
dbname = options.fetch('dbname')
user = options.fetch('user')
pass = options.fetch('password', '')
host = options.fetch('host', "localhost")
host = options.fetch('host', 'localhost')
port = options.fetch('port', 3306).to_i
cid = options.fetch('category', 0)
table_prefix = options.fetch('prefix', "jos_")
table_prefix = options.fetch('prefix', 'jos_')

db = Sequel.mysql2(dbname, :user => user, :password => pass, :host => host, :encoding => 'utf8')
db = Sequel.mysql2(dbname, user: user, password: pass, host: host, port: port, encoding: 'utf8')

FileUtils.mkdir_p("_posts")

Expand Down

0 comments on commit 142f1b5

Please sign in to comment.