Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to specify the MySQL port for the Joomla importers #310

Merged
merged 2 commits into from Jun 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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