onboarding work

This commit is contained in:
Kevin Froman 2019-12-03 00:00:15 -06:00
parent 3816e64da7
commit 1eb47a4584
6 changed files with 29 additions and 29 deletions

View File

@ -1,13 +0,0 @@
name: Greetings
on: [pull_request, issues]
jobs:
greeting:
runs-on: ubuntu-latest
steps:
- uses: actions/first-interaction@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
issue-message: 'Message that will be displayed on users'' first issue'
pr-message: 'Hi, please make the PR at https://gitlab.com/beardog/Onionr'' first pr'

View File

@ -37,15 +37,21 @@ def set_config_from_onboarding(config_settings: OnboardingConfig):
network_security_level = 0
theme = "dark"
get = _get_val_or_none
if _get_val_or_none(config_settings, 'stateTarget') == True:
if get(config_settings, 'stateTarget') or not get(config_settings,
'networkContribution'):
config.set('general.security_level', 1)
if _get_val_or_none(config_settings, 'useDark') == False:
config.set('ui.theme', 'light')
config.set('ui.theme', 'light')
if get(config_settings, 'useDark'):
config.set('ui.theme', 'dark')
if not get(config_settings, 'useMail'):
config.set('plugins.disabled', ['pms'])
config.set('general.store_plaintext_blocks',
_get_val_or_none(config_settings, 'plainContrib'))
get(config_settings, 'plainContrib'))
config.set('onboarding.done', True, savefile=True)

View File

@ -18,10 +18,15 @@
along with this program. If not, see <https://www.gnu.org/licenses/>.
"""
import onionrplugins
import config
def load_plugin_blueprints(flaskapp, blueprint: str = 'flask_blueprint'):
"""Iterate enabled plugins and load any http endpoints they have"""
config.reload()
disabled = config.get('plugins.disabled')
for plugin in onionrplugins.get_enabled_plugins():
if plugin in disabled:
continue
plugin = onionrplugins.get_plugin(plugin)
try:
flaskapp.register_blueprint(getattr(plugin, blueprint))

View File

@ -30,7 +30,7 @@ _pluginsfolder = dataDir + 'plugins/'
_instances = dict()
config.reload()
def reload(onionr = None, stop_event = True):
def reload(stop_event = True):
'''
Reloads all the plugins
'''
@ -47,10 +47,10 @@ def reload(onionr = None, stop_event = True):
if stop_event is True:
for plugin in enabled_plugins:
stop(plugin, onionr)
stop(plugin)
for plugin in enabled_plugins:
start(plugin, onionr)
start(plugin)
return True
except:
@ -58,7 +58,7 @@ def reload(onionr = None, stop_event = True):
return False
def enable(name, onionr = None, start_event = True):
def enable(name, start_event = True):
'''
Enables a plugin
'''
@ -69,7 +69,7 @@ def enable(name, onionr = None, start_event = True):
enabled_plugins = get_enabled_plugins()
if not name in enabled_plugins:
try:
events.call(get_plugin(name), 'enable', onionr)
events.call(get_plugin(name), 'enable')
except ImportError as e: # Was getting import error on Gitlab CI test "data"
# NOTE: If you are experiencing issues with plugins not being enabled, it might be this resulting from an error in the module
# can happen inconsistently (especially between versions)
@ -92,7 +92,7 @@ def enable(name, onionr = None, start_event = True):
return False
def disable(name, onionr = None, stop_event = True):
def disable(name, stop_event = True):
'''
Disables a plugin
'''
@ -105,12 +105,12 @@ def disable(name, onionr = None, stop_event = True):
config.set('plugins.enabled', enabled_plugins, True)
if exists(name):
events.call(get_plugin(name), 'disable', onionr)
events.call(get_plugin(name), 'disable')
if stop_event is True:
stop(name)
def start(name, onionr = None):
def start(name):
'''
Starts the plugin
'''
@ -124,7 +124,7 @@ def start(name, onionr = None):
if plugin is None:
raise Exception('Failed to import module.')
else:
events.call(plugin, 'start', onionr)
events.call(plugin, 'start')
return plugin
except:
@ -134,7 +134,7 @@ def start(name, onionr = None):
return None
def stop(name, onionr = None):
def stop(name):
'''
Stops the plugin
'''
@ -148,7 +148,7 @@ def stop(name, onionr = None):
if plugin is None:
raise Exception('Failed to import module.')
else:
events.call(plugin, 'stop', onionr)
events.call(plugin, 'stop')
return plugin
except:

View File

@ -32,7 +32,9 @@ def __event_caller(event_name, data = {}):
DO NOT call this function, this is for threading code only.
Instead, call onionrevents.event
'''
disabled = config.get('plugins.disabled')
for plugin in plugins.get_enabled_plugins():
if plugin in disabled: continue
try:
call(plugins.get_plugin(plugin), event_name, data, get_pluginapi(data))
except ModuleNotFoundError as e:

View File

@ -76,6 +76,6 @@
},
"onboarding": {
"done": false
"done": true
}
}