ikiwiki: Initialize shortcuts during post-init setup

In CI tests, when running 'run --list-dependencies', init for ikiwiki fails with
the following error. Fix that.

Exception while running init for <module 'plinth.modules.ikiwiki' from '/builds//freedombox/plinth/modules/ikiwiki/__init__.py'>: Action must exist in action directory.
Traceback (most recent call last):
  File "/builds//freedombox/plinth/app.py", line 536, in _initialize_module
    module.app = app_class()
  File "/builds//freedombox/plinth/modules/ikiwiki/__init__.py", line 61, in __init__
    self.refresh_sites()
  File "/builds//freedombox/plinth/modules/ikiwiki/__init__.py", line 102, in refresh_sites
    sites = actions.run('ikiwiki', ['get-sites']).split('\n')
  File "/builds//freedombox/plinth/actions.py", line 95, in run
    return _run(action, options, input, run_in_background, False)
  File "/builds//freedombox/plinth/actions.py", line 147, in _run
    raise ValueError('Action must exist in action directory.')
ValueError: Action must exist in action directory.

Tests:

- Shortcuts for ikiwiki show up properly on the front page after FreedomBox
daemon is restarted.

- Salsa CI no longer show the above error during --list-dependencies.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa 2022-01-11 14:51:24 -08:00 committed by James Valleroy
parent 6199718a19
commit a7f3677c0e
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808

View File

@ -58,8 +58,6 @@ class IkiwikiApp(app_module.App):
'ikiwiki:index', parent_url_name='apps')
self.add(menu_item)
self.refresh_sites()
packages = Packages('packages-ikiwiki', [
'ikiwiki', 'libdigest-sha-perl', 'libxml-writer-perl',
'xapian-omega', 'libsearch-xapian-perl', 'libimage-magick-perl'
@ -83,6 +81,10 @@ class IkiwikiApp(app_module.App):
**manifest.backup)
self.add(backup_restore)
def post_init(self):
"""Perform post initialization operations."""
self.refresh_sites()
def add_shortcut(self, site, title):
"""Add an ikiwiki shortcut to frontpage."""
shortcut = frontpage.Shortcut('shortcut-ikiwiki-' + site, title,