onboarding work
This commit is contained in:
parent
3816e64da7
commit
1eb47a4584
@ -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'
|
|
@ -37,15 +37,21 @@ def set_config_from_onboarding(config_settings: OnboardingConfig):
|
|||||||
|
|
||||||
network_security_level = 0
|
network_security_level = 0
|
||||||
theme = "dark"
|
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)
|
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',
|
config.set('general.store_plaintext_blocks',
|
||||||
_get_val_or_none(config_settings, 'plainContrib'))
|
get(config_settings, 'plainContrib'))
|
||||||
|
|
||||||
|
|
||||||
config.set('onboarding.done', True, savefile=True)
|
config.set('onboarding.done', True, savefile=True)
|
||||||
|
@ -18,10 +18,15 @@
|
|||||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
"""
|
"""
|
||||||
import onionrplugins
|
import onionrplugins
|
||||||
|
import config
|
||||||
|
|
||||||
def load_plugin_blueprints(flaskapp, blueprint: str = 'flask_blueprint'):
|
def load_plugin_blueprints(flaskapp, blueprint: str = 'flask_blueprint'):
|
||||||
"""Iterate enabled plugins and load any http endpoints they have"""
|
"""Iterate enabled plugins and load any http endpoints they have"""
|
||||||
|
config.reload()
|
||||||
|
disabled = config.get('plugins.disabled')
|
||||||
for plugin in onionrplugins.get_enabled_plugins():
|
for plugin in onionrplugins.get_enabled_plugins():
|
||||||
|
if plugin in disabled:
|
||||||
|
continue
|
||||||
plugin = onionrplugins.get_plugin(plugin)
|
plugin = onionrplugins.get_plugin(plugin)
|
||||||
try:
|
try:
|
||||||
flaskapp.register_blueprint(getattr(plugin, blueprint))
|
flaskapp.register_blueprint(getattr(plugin, blueprint))
|
||||||
|
@ -30,7 +30,7 @@ _pluginsfolder = dataDir + 'plugins/'
|
|||||||
_instances = dict()
|
_instances = dict()
|
||||||
config.reload()
|
config.reload()
|
||||||
|
|
||||||
def reload(onionr = None, stop_event = True):
|
def reload(stop_event = True):
|
||||||
'''
|
'''
|
||||||
Reloads all the plugins
|
Reloads all the plugins
|
||||||
'''
|
'''
|
||||||
@ -47,10 +47,10 @@ def reload(onionr = None, stop_event = True):
|
|||||||
|
|
||||||
if stop_event is True:
|
if stop_event is True:
|
||||||
for plugin in enabled_plugins:
|
for plugin in enabled_plugins:
|
||||||
stop(plugin, onionr)
|
stop(plugin)
|
||||||
|
|
||||||
for plugin in enabled_plugins:
|
for plugin in enabled_plugins:
|
||||||
start(plugin, onionr)
|
start(plugin)
|
||||||
|
|
||||||
return True
|
return True
|
||||||
except:
|
except:
|
||||||
@ -58,7 +58,7 @@ def reload(onionr = None, stop_event = True):
|
|||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
def enable(name, onionr = None, start_event = True):
|
def enable(name, start_event = True):
|
||||||
'''
|
'''
|
||||||
Enables a plugin
|
Enables a plugin
|
||||||
'''
|
'''
|
||||||
@ -69,7 +69,7 @@ def enable(name, onionr = None, start_event = True):
|
|||||||
enabled_plugins = get_enabled_plugins()
|
enabled_plugins = get_enabled_plugins()
|
||||||
if not name in enabled_plugins:
|
if not name in enabled_plugins:
|
||||||
try:
|
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"
|
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
|
# 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)
|
# can happen inconsistently (especially between versions)
|
||||||
@ -92,7 +92,7 @@ def enable(name, onionr = None, start_event = True):
|
|||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
def disable(name, onionr = None, stop_event = True):
|
def disable(name, stop_event = True):
|
||||||
'''
|
'''
|
||||||
Disables a plugin
|
Disables a plugin
|
||||||
'''
|
'''
|
||||||
@ -105,12 +105,12 @@ def disable(name, onionr = None, stop_event = True):
|
|||||||
config.set('plugins.enabled', enabled_plugins, True)
|
config.set('plugins.enabled', enabled_plugins, True)
|
||||||
|
|
||||||
if exists(name):
|
if exists(name):
|
||||||
events.call(get_plugin(name), 'disable', onionr)
|
events.call(get_plugin(name), 'disable')
|
||||||
|
|
||||||
if stop_event is True:
|
if stop_event is True:
|
||||||
stop(name)
|
stop(name)
|
||||||
|
|
||||||
def start(name, onionr = None):
|
def start(name):
|
||||||
'''
|
'''
|
||||||
Starts the plugin
|
Starts the plugin
|
||||||
'''
|
'''
|
||||||
@ -124,7 +124,7 @@ def start(name, onionr = None):
|
|||||||
if plugin is None:
|
if plugin is None:
|
||||||
raise Exception('Failed to import module.')
|
raise Exception('Failed to import module.')
|
||||||
else:
|
else:
|
||||||
events.call(plugin, 'start', onionr)
|
events.call(plugin, 'start')
|
||||||
|
|
||||||
return plugin
|
return plugin
|
||||||
except:
|
except:
|
||||||
@ -134,7 +134,7 @@ def start(name, onionr = None):
|
|||||||
|
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def stop(name, onionr = None):
|
def stop(name):
|
||||||
'''
|
'''
|
||||||
Stops the plugin
|
Stops the plugin
|
||||||
'''
|
'''
|
||||||
@ -148,7 +148,7 @@ def stop(name, onionr = None):
|
|||||||
if plugin is None:
|
if plugin is None:
|
||||||
raise Exception('Failed to import module.')
|
raise Exception('Failed to import module.')
|
||||||
else:
|
else:
|
||||||
events.call(plugin, 'stop', onionr)
|
events.call(plugin, 'stop')
|
||||||
|
|
||||||
return plugin
|
return plugin
|
||||||
except:
|
except:
|
||||||
|
@ -32,7 +32,9 @@ def __event_caller(event_name, data = {}):
|
|||||||
DO NOT call this function, this is for threading code only.
|
DO NOT call this function, this is for threading code only.
|
||||||
Instead, call onionrevents.event
|
Instead, call onionrevents.event
|
||||||
'''
|
'''
|
||||||
|
disabled = config.get('plugins.disabled')
|
||||||
for plugin in plugins.get_enabled_plugins():
|
for plugin in plugins.get_enabled_plugins():
|
||||||
|
if plugin in disabled: continue
|
||||||
try:
|
try:
|
||||||
call(plugins.get_plugin(plugin), event_name, data, get_pluginapi(data))
|
call(plugins.get_plugin(plugin), event_name, data, get_pluginapi(data))
|
||||||
except ModuleNotFoundError as e:
|
except ModuleNotFoundError as e:
|
||||||
|
@ -76,6 +76,6 @@
|
|||||||
},
|
},
|
||||||
|
|
||||||
"onboarding": {
|
"onboarding": {
|
||||||
"done": false
|
"done": true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user