Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: getnikola/nikola
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 0a4b06e39341
Choose a base ref
...
head repository: getnikola/nikola
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: f59f07bedcf4
Choose a head ref
  • 3 commits
  • 2 files changed
  • 1 contributor

Commits on Jul 11, 2015

  1. Avoiding creating new_site directory too early (otherwise conf.py wil…

    …l be called conf.py.import_wordpress-xxx)
    felixfontein committed Jul 11, 2015
    Copy the full SHA
    5c13c3e View commit details
  2. Allowing to hide installation notes.

    Not showing 'assuming --user' message when output_dir is forced.
    felixfontein committed Jul 11, 2015
    Copy the full SHA
    03a54d5 View commit details
  3. Copy the full SHA
    f59f07b View commit details
Showing with 25 additions and 21 deletions.
  1. +12 −10 nikola/plugins/command/import_wordpress.py
  2. +13 −11 nikola/plugins/command/plugin.py
22 changes: 12 additions & 10 deletions nikola/plugins/command/import_wordpress.py
Original file line number Diff line number Diff line change
@@ -57,14 +57,16 @@
LOGGER = utils.get_logger('import_wordpress', utils.STDERR_HANDLER)


def install_plugin(site, plugin_name, output_dir=None):
def install_plugin(site, plugin_name, output_dir=None, show_install_notes=False):
LOGGER.notice("Installing plugin '{0}'".format(plugin_name))
plugin_installer = plugin.CommandPlugin()
plugin_installer.set_site(site)
options = {}
for option in plugin_installer.cmd_options:
options[option['name']] = option['default']
options['install'] = plugin_name
options['output_dir'] = output_dir
options['show_install_notes'] = show_install_notes
if not plugin_installer.execute(options=options):
return False
site.plugin_manager.collectPlugins()
@@ -245,15 +247,6 @@ def _read_options(self, options, args):
LOGGER.error("Please note that the WordPress post compiler is licensed under the GPL v2.")
return False

if self.use_wordpress_compiler:
if self.install_wordpress_compiler:
if not install_plugin(self.site, 'wordpress_compiler', output_dir=os.path.join(self.output_folder, 'plugins')):
return False
else:
LOGGER.warn("Make sure to install the WordPress page compiler via")
LOGGER.warn(" nikola plugin -i wordpress_compiler")
LOGGER.warn("in your imported blog's folder ({0}), if you haven't installed it system-wide or user-wide. Otherwise, your newly imported blog won't compile.".format(self.output_folder))

return True

def _prepare(self, channel):
@@ -340,6 +333,15 @@ def show_info_about_mising_module(modulename):
self.write_configuration(self.get_configuration_output_path(),
rendered_template)

if self.use_wordpress_compiler:
if self.install_wordpress_compiler:
if not install_plugin(self.site, 'wordpress_compiler', output_dir=os.path.join(self.output_folder, 'plugins')):
return False
else:
LOGGER.warn("Make sure to install the WordPress page compiler via")
LOGGER.warn(" nikola plugin -i wordpress_compiler")
LOGGER.warn("in your imported blog's folder ({0}), if you haven't installed it system-wide or user-wide. Otherwise, your newly imported blog won't compile.".format(self.output_folder))

@classmethod
def read_xml_file(cls, filename):
xml = []
24 changes: 13 additions & 11 deletions nikola/plugins/command/plugin.py
Original file line number Diff line number Diff line change
@@ -119,6 +119,7 @@ def _execute(self, options, args):
upgrade = options.get('upgrade')
list_available = options.get('list')
list_installed = options.get('list_installed')
show_install_notes = options.get('show_install_notes', True)
command_count = [bool(x) for x in (
install,
uninstall,
@@ -129,16 +130,17 @@ def _execute(self, options, args):
print(self.help())
return

if not self.site.configured and not user_mode and install:
LOGGER.notice('No site found, assuming --user')
user_mode = True

if user_mode:
self.output_dir = os.path.expanduser('~/.nikola/plugins')
else:
self.output_dir = 'plugins'
if options.get('output_dir') is not None:
self.output_dir = options.get('output_dir')
else:
if not self.site.configured and not user_mode and install:
LOGGER.notice('No site found, assuming --user')
user_mode = True

if user_mode:
self.output_dir = os.path.expanduser('~/.nikola/plugins')
else:
self.output_dir = 'plugins'

if list_available:
return self.list_available(url)
@@ -149,7 +151,7 @@ def _execute(self, options, args):
elif uninstall:
return self.do_uninstall(uninstall)
elif install:
return self.do_install(url, install)
return self.do_install(url, install, show_install_notes)

def list_available(self, url):
data = self.get_json(url)
@@ -203,7 +205,7 @@ def do_upgrade(self, url):
self.do_install(url, name)
return True

def do_install(self, url, name):
def do_install(self, url, name, show_install_notes=True):
data = self.get_json(url)
if name in data:
utils.makedirs(self.output_dir)
@@ -260,7 +262,7 @@ def do_install(self, url, name):
print('You have to install those yourself or through a package '
'manager.')
confpypath = os.path.join(dest_path, 'conf.py.sample')
if os.path.exists(confpypath):
if os.path.exists(confpypath) and show_install_notes:
LOGGER.notice('This plugin has a sample config file. Integrate it with yours in order to make this plugin work!')
print('Contents of the conf.py.sample file:\n')
with io.open(confpypath, 'r', encoding='utf-8') as fh: