From 3064efeeb19a1bdede26e3c0f9a18a902a4ceeab Mon Sep 17 00:00:00 2001 From: ienev Date: Fri, 2 Jun 2017 09:03:09 +0300 Subject: [PATCH 1/2] add-port-option-for-joomla-importers * Add option to specify the MySQL port for the Joomla importers * Use Ruby 1.9 hash syntax * Update the Joomla importers documentation --- docs/_importers/joomla.md | 5 +++-- docs/_importers/joomla3.md | 4 +++- lib/jekyll-import/importers/joomla.rb | 8 +++++--- lib/jekyll-import/importers/joomla3.rb | 8 +++++--- 4 files changed, 16 insertions(+), 9 deletions(-) diff --git a/docs/_importers/joomla.md b/docs/_importers/joomla.md index 987425e8..69ddd3c1 100644 --- a/docs/_importers/joomla.md +++ b/docs/_importers/joomla.md @@ -16,11 +16,12 @@ $ ruby -rubygems -e 'require "jekyll-import"; "user" => "myuser", "password" => "mypassword", "host" => "myhost", + "port" => "port", "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"`, `port` defaults to `"3306"`, `section` +defaults to `"1"` and `prefix` defaults to `"jos_"`. diff --git a/docs/_importers/joomla3.md b/docs/_importers/joomla3.md index 0cc440df..0956d74e 100644 --- a/docs/_importers/joomla3.md +++ b/docs/_importers/joomla3.md @@ -16,13 +16,15 @@ $ ruby -rubygems -e 'require "jekyll-import"; "user" => "myuser", "password" => "mypassword", "host" => "myhost", + "port" => "port", "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"`, `port` 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. diff --git a/lib/jekyll-import/importers/joomla.rb b/lib/jekyll-import/importers/joomla.rb index 8ea1de2e..9c70b0ee 100644 --- a/lib/jekyll-import/importers/joomla.rb +++ b/lib/jekyll-import/importers/joomla.rb @@ -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 @@ -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') 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") diff --git a/lib/jekyll-import/importers/joomla3.rb b/lib/jekyll-import/importers/joomla3.rb index 23c16079..3d780609 100644 --- a/lib/jekyll-import/importers/joomla3.rb +++ b/lib/jekyll-import/importers/joomla3.rb @@ -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 @@ -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') 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") From 400c9a12317cdde77cddde40df0ecee47779010a Mon Sep 17 00:00:00 2001 From: ienev Date: Sun, 4 Jun 2017 14:26:00 +0300 Subject: [PATCH 2/2] Port is an integer --- docs/_importers/joomla.md | 4 ++-- docs/_importers/joomla3.md | 4 ++-- lib/jekyll-import/importers/joomla.rb | 2 +- lib/jekyll-import/importers/joomla3.rb | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/docs/_importers/joomla.md b/docs/_importers/joomla.md index 69ddd3c1..5edb81b4 100644 --- a/docs/_importers/joomla.md +++ b/docs/_importers/joomla.md @@ -16,12 +16,12 @@ $ ruby -rubygems -e 'require "jekyll-import"; "user" => "myuser", "password" => "mypassword", "host" => "myhost", - "port" => "port", + "port" => portnumber, "section" => "thesection", "prefix" => "mytableprefix" })' {% endhighlight %} The only required fields are `dbname` and `user`. `password` defaults to `""`, -`host` defaults to `"localhost"`, `port` defaults to `"3306"`, `section` +`host` defaults to `"localhost"`, `portnumber` defaults to `3306`, `section` defaults to `"1"` and `prefix` defaults to `"jos_"`. diff --git a/docs/_importers/joomla3.md b/docs/_importers/joomla3.md index 0956d74e..d1bc447c 100644 --- a/docs/_importers/joomla3.md +++ b/docs/_importers/joomla3.md @@ -16,14 +16,14 @@ $ ruby -rubygems -e 'require "jekyll-import"; "user" => "myuser", "password" => "mypassword", "host" => "myhost", - "port" => "port", + "port" => portnumber, "category" => category, "prefix" => "mytableprefix" })' {% endhighlight %} The only required fields are `dbname`, `prefix` and `user`. `password` defaults to `""`, -`host` defaults to `"localhost"`, `port` defaults to `"3306"` and `prefix` defaults to +`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 diff --git a/lib/jekyll-import/importers/joomla.rb b/lib/jekyll-import/importers/joomla.rb index 9c70b0ee..53ac8ec3 100644 --- a/lib/jekyll-import/importers/joomla.rb +++ b/lib/jekyll-import/importers/joomla.rb @@ -34,7 +34,7 @@ def self.process(options) user = options.fetch('user') pass = options.fetch('password', '') host = options.fetch('host', 'localhost') - port = options.fetch('port', '3306') + port = options.fetch('port', 3306).to_i section = options.fetch('section', '1') table_prefix = options.fetch('prefix', 'jos_') diff --git a/lib/jekyll-import/importers/joomla3.rb b/lib/jekyll-import/importers/joomla3.rb index 3d780609..23e35e54 100644 --- a/lib/jekyll-import/importers/joomla3.rb +++ b/lib/jekyll-import/importers/joomla3.rb @@ -34,7 +34,7 @@ def self.process(options) user = options.fetch('user') pass = options.fetch('password', '') host = options.fetch('host', 'localhost') - port = options.fetch('port', '3306') + port = options.fetch('port', 3306).to_i cid = options.fetch('category', 0) table_prefix = options.fetch('prefix', 'jos_')