reworked username preloading due to import coupling

This commit is contained in:
Kevin Froman 2021-01-19 05:36:09 +00:00
parent cb17270512
commit 4b7b408d60
7 changed files with 35 additions and 35 deletions

View File

@ -4,11 +4,12 @@ Setup config from onboarding choices
""" """
from pathlib import Path from pathlib import Path
from typing import Union from typing import Union
from threading import Thread
from time import sleep
from filepaths import onboarding_mark_file
from onionrtypes import JSONSerializable from onionrtypes import JSONSerializable
from onionrtypes import OnboardingConfig from onionrtypes import OnboardingConfig
from onionrplugins import onionrevents
import config import config
""" """
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
@ -69,4 +70,4 @@ def set_config_from_onboarding(config_settings: OnboardingConfig):
get(config_settings, 'plainContrib')) get(config_settings, 'plainContrib'))
config.set('onboarding.done', True, savefile=True) config.set('onboarding.done', True, savefile=True)
onionrevents.event("onboard", config_settings)

View File

@ -16,18 +16,18 @@ import onionrcrypto
from onionrcrypto import getourkeypair from onionrcrypto import getourkeypair
from etc.onionrvalues import DATABASE_LOCK_TIMEOUT from etc.onionrvalues import DATABASE_LOCK_TIMEOUT
""" """
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details. GNU General Public License for more details.
You should have received a copy of the GNU General Public License You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. along with this program. If not, see <https://www.gnu.org/licenses/>.
""" """

View File

@ -1,5 +1,5 @@
{ {
"name" : "usernames", "name" : "usernames",
"version" : "0.0.0", "version" : "0.0.1",
"author" : "onionr" "author" : "onionr"
} }

View File

@ -6,8 +6,13 @@ Preset Onionr usernames
import locale import locale
locale.setlocale(locale.LC_ALL, '') locale.setlocale(locale.LC_ALL, '')
from utils import identifyhome import os
import sys
sys.path.insert(0, os.path.dirname(os.path.realpath(__file__)))
import logger
from onionrusers import contactmanager from onionrusers import contactmanager
from utils import identifyhome
import config
""" """
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by it under the terms of the GNU General Public License as published by
@ -24,13 +29,19 @@ along with this program. If not, see <https://www.gnu.org/licenses/>.
""" """
plugin_name = 'usernames' plugin_name = 'usernames'
PLUGIN_VERSION = '0.0.1'
def on_onboard(api, data=None): def on_init(api, data = None):
username_file = identifyhome.identify_home() + f'plugins/{plugin_name}/usernames.dat' config.reload()
if config.get('onboarding.done', True):
return
username_file = identifyhome.identify_home() + 'plugins/usernames/usernames.dat'
with open(username_file, 'r') as usernames: with open(username_file, 'r') as usernames:
username_and_keys = usernames.readlines() username_and_keys = usernames.readlines()
logger.info("Setting preset usernames", terminal=True)
for entry in username_and_keys: for entry in username_and_keys:
username, key = entry.split(',') username, key = entry.split(',')
username = username.strip() username = username.strip()
@ -40,5 +51,3 @@ def on_onboard(api, data=None):
user = contactmanager.ContactManager(key, saveUser=True) user = contactmanager.ContactManager(key, saveUser=True)
user.set_info('name', username) user.set_info('name', username)

View File

@ -1 +1,3 @@
Kevin Froman,GM3E4VCUNLF5F7Y64STD2HEURG45U3NYPLBZBT3Z6YWOALJHZPPQ Kevin Froman,GM3E4VCUNLF5F7Y64STD2HEURG45U3NYPLBZBT3Z6YWOALJHZPPQ
Supernova,OXDRJS7YC7GQCQX7AAAJWN7LFI34AB2BE4VBYGEEUWGB3TSDB5FQ
Cartr,DWQ4CGQGUAVBTXZKFABS63W6KK4JSXK6HTEOXDATOADJNBE4C62A

View File

@ -203,7 +203,7 @@
<div class="step-content has-text-justified"> <div class="step-content has-text-justified">
<div class="box"> <div class="box">
<div class="columns"> <div class="columns">
<div class="column is-3"> <div class="column is-4">
<div class="box"> <div class="box">
<nav class="level"> <nav class="level">
<div class="level-left"> <div class="level-left">
@ -214,7 +214,7 @@
</nav> </nav>
</div> </div>
</div> </div>
<div class="column is-3"> <div class="column is-4">
<div class="box"> <div class="box">
<nav class="level"> <nav class="level">
<div class="level-left"> <div class="level-left">
@ -225,7 +225,7 @@
</nav> </nav>
</div> </div>
</div> </div>
<div class="column is-3"> <div class="column is-4">
<div class="box"> <div class="box">
<nav class="level"> <nav class="level">
<div class="level-left"> <div class="level-left">
@ -236,17 +236,6 @@
</nav> </nav>
</div> </div>
</div> </div>
<div class="column is-3">
<div class="box">
<nav class="level">
<div class="level-left">
<div class="level-item">
<i class="icon fas fa-id-card" for="usernames"></i> <input type="checkbox" name="usernames" checked> <label for="usernames">Preloaded Usernames</label>
</div>
</div>
</nav>
</div>
</div>
</div> </div>
</div> </div>
</div> </div>

View File

@ -52,13 +52,12 @@ document.getElementById('onboardingForm').onsubmit = function(e){
submitInfo.networkContrib = getCheckValue('networkContribution') submitInfo.networkContrib = getCheckValue('networkContribution')
submitInfo.plainContrib = getCheckValue('networkContributionPlain') submitInfo.plainContrib = getCheckValue('networkContributionPlain')
submitInfo.donate = getCheckValue('donate') submitInfo.donate = getCheckValue('donate')
//submitInfo.deterministic = getCheckValue('useDeterministic')
submitInfo.mail = getCheckValue('useMail') submitInfo.mail = getCheckValue('useMail')
submitInfo.circles = getCheckValue('useCircles') submitInfo.circles = getCheckValue('useCircles')
submitInfo.useDark = getCheckValue('useDarkTheme') submitInfo.useDark = getCheckValue('useDarkTheme')
submitInfo.preloadUsernames = getCheckValue('usernames')
submitInfo.optimize = getCheckValue('optimize') submitInfo.optimize = getCheckValue('optimize')
if (submitInfo.donate){ if (submitInfo.donate){
openDonateModal(submitInfo) openDonateModal(submitInfo)
return false return false