Compare commits

..

1 Commits

Author SHA1 Message Date
Nick Klockenga
b7715d3b43
Update link and clone repo to seedsigner from kdmukai 2023-08-02 23:40:40 -04:00
6 changed files with 35 additions and 267 deletions

View File

@ -29,4 +29,4 @@ see: [SettingsQR Specification](docs/settingsqr_specification.md)
---
#### Attribution
*This repo started as a fork from [@davidshimjs](https://github.com/davidshimjs)'s [qrcodejs](https://github.com/davidshimjs/qrcodejs) but I have since detached my fork as I changed the repo structure and am unlikely to have any PRs from or to the original. @davidshimjs's original [LICENSE](LICENSE) remains as-is from the original repo.*
*This repo started as a fork from [@davidshimjs](https://github.com/davidshimjs)'s [qrcodejs](https://github.com/davidshimjs/qrcodejs) but I have since detached my fork as I changed the repo structure and am unlikely to have any PRs from or to the original. @davidshimjs's original [LICENSE](LICENSE) remains as-is from the original repo.*

View File

@ -7,17 +7,17 @@ The SettingsQR Generator pulls the `SettingsDefinition` class from the main Seed
## Set up a local copy of this repo
To make deeper changes to the SettingsQR Generator, you'll want to clone the repo with the `--recursive` option so that it includes the nested SeedSigner core repo as well:
```bash
git clone --recursive https://github.com/seedsigner/seedsigner-settings-generator.git
git clone --recursive https://github.com/kdmukai/seedsigner-settings-generator.git
```
<details>
<summary>Note: If you don't include `--recursive`...</summary>
You'll need to make two follow-up calls:
```bash
git submodule init
git submodule update --remote
```
```bash
git submodule init
git submodule update --remote
```
</details>
You should now have a complete copy of this repo AND the SeedSigner repo in your `src/` subdir.
@ -29,11 +29,6 @@ We rely on a python script that uses a Jinja2 template to generate the static `i
pip install -r requirements.txt
```
We also need the main SeedSigner code installed in our virtualenv:
```bash
pip install -e src/seedsigner
```
## Updating changes from `SettingsDefinition` in the SeedSigner repo
Any time a change is made in `SettingsDefinition` in SeedSigner, you'll need to regenerate the SettingsQR Generator's `index.html` in order to see the latest settings options changes.
@ -46,11 +41,16 @@ Change the `url` and `branch` as needed:
```
[submodule "src/seedsigner"]
path = src/seedsigner
url = https://github.com/my_user/seedsigner.git
branch = my_branch
url = https://github.com/kdmukai/seedsigner.git
branch = settings_definition
```
The `generate.sh` script in the next step will automatically update the submodule to your specified fork and branch.
Once your changes are made, you need to tell `git` to pull the new repo or branch:
```
git submodule update --remote
```
And then any time there are further changes in the `SettingsDefinition` in your target fork/branch, you'll need to repeat the above `update` call to pull in those changes.
## Generate updated `index.html`
@ -60,7 +60,7 @@ cd src
./generate.sh
```
The script runs `src/parse_settings_json.py` which extracts SeedSigner's `SettingsDefinition`. That is then used to generate the final static `index.html` that gets written to the `docs/` dir.
The script tells `SettingsDefinition` to extract itself to json and then calls the `src/parse_settings_json.py` python script to read the settings in and generate the final static `index.html` that gets written to the `docs/` dir.
*Note: Why are the static web files in the `docs/` subdir (a better place would be something like a `www/` subdir)? A limitation in Github Pages only lets us host the static website from either the repo root or from a hard-coded `docs/` subdir.*

View File

@ -146,42 +146,11 @@
</td>
</tr>
<tr>
<td class="label">
Language
</td>
<td>
<select name="lang" id="lang" class="form-select" onchange="buildConfig();" autocomplete="off">
<option value="en" selected>English</option>
<option value="ca" >Català</option>
<option value="de" >Deutsch</option>
<option value="es" >Español</option>
<option value="fr" >Français</option>
<option value="it" >Italiano</option>
<option value="nl" >Nederlands</option>
<option value="zh_Hans_CN" >(beta) 简体中文 (Chinese Simplified)</option>
<option value="ja" >(beta) 日本語 (Japanese)</option>
</select>
</td>
<tr>
<td class="label">
Persistent settings
<div class="help_text">Store Settings on SD card</div>
<div class="help_text">Store Settings on SD card.</div>
</td>
<td>
@ -310,11 +279,9 @@
<label for="scripts_nat"><input type="checkbox" name="scripts" id="scripts_nat" value="nat" checked onchange="buildConfig();" autocomplete="off">&nbsp;Native Segwit</label><br/>
<label for="scripts_nes"><input type="checkbox" name="scripts" id="scripts_nes" value="nes" checked onchange="buildConfig();" autocomplete="off">&nbsp;Nested Segwit</label><br/>
<label for="scripts_nes"><input type="checkbox" name="scripts" id="scripts_nes" value="nes" checked onchange="buildConfig();" autocomplete="off">&nbsp;Nested Segwit (legacy)</label><br/>
<label for="scripts_leg"><input type="checkbox" name="scripts" id="scripts_leg" value="leg" onchange="buildConfig();" autocomplete="off">&nbsp;Legacy</label><br/>
<label for="scripts_tr"><input type="checkbox" name="scripts" id="scripts_tr" value="tr" checked onchange="buildConfig();" autocomplete="off">&nbsp;Taproot</label><br/>
<label for="scripts_tr"><input type="checkbox" name="scripts" id="scripts_tr" value="tr" onchange="buildConfig();" autocomplete="off">&nbsp;Taproot</label><br/>
<label for="scripts_cus"><input type="checkbox" name="scripts" id="scripts_cus" value="cus" onchange="buildConfig();" autocomplete="off">&nbsp;Custom Derivation</label><br/>
@ -362,11 +329,11 @@
<select name="camera" id="camera" class="form-select" onchange="buildConfig();" autocomplete="off">
<option value="0" ></option>
<option value="0" selected></option>
<option value="90" >90°</option>
<option value="180" selected>180°</option>
<option value="180" >180°</option>
<option value="270" >270°</option>
@ -376,7 +343,7 @@
<tr>
<td class="label">
Compact SeedQR
CompactSeedQR
</td>
<td>
@ -400,53 +367,6 @@
</td>
<tr>
<td class="label">
Electrum seeds
<div class="help_text">Native Segwit only</div>
</td>
<td>
<div class="form-check form-switch">
<input type="checkbox" name="electrum" id="" class="form-check-input" value="E" onchange="buildConfig();" autocomplete="off">
</div>
</td>
<tr>
<td class="label">
MicroSD toast timer
</td>
<td>
<select name="microsd_toast_timer" id="microsd_toast_timer" class="form-select" onchange="buildConfig();" autocomplete="off">
<option value="D" >Disabled</option>
<option value="E" selected>5 seconds</option>
<option value="inf" >Until SD removed</option>
</select>
</td>
<tr>
<td class="label">
Message signing
</td>
<td>
<div class="form-check form-switch">
<input type="checkbox" name="message_signing" id="" class="form-check-input" value="E" onchange="buildConfig();" autocomplete="off">
</div>
</td>
<tr>
<td class="label">
Show privacy warnings
@ -473,19 +393,6 @@
</td>
<tr>
<td class="label">
Show QR brightness tips
</td>
<td>
<div class="form-check form-switch">
<input type="checkbox" name="qr_brightness_tips" id="" class="form-check-input" value="E" onchange="buildConfig();" checked autocomplete="off">
</div>
</td>
<tr>
<td class="label">
Show partner logos
@ -499,38 +406,6 @@
</td>
<tr>
<td class="label">
Display type
</td>
<td>
<select name="disp_conf" id="disp_conf" class="form-select" onchange="buildConfig();" autocomplete="off">
<option value="st7789_240x240" selected>st7789 240x240</option>
<option value="st7789_320x240" >st7789 320x240</option>
<option value="ili9341_320x240" >ili9341 320x240 (beta)</option>
</select>
</td>
<tr>
<td class="label">
Invert colors
</td>
<td>
<div class="form-check form-switch">
<input type="checkbox" name="rgb_inv" id="" class="form-check-input" value="E" onchange="buildConfig();" autocomplete="off">
</div>
</td>
</table>
<br/>
@ -555,13 +430,6 @@
settings.push(`lang=${$("#lang").val()}`);
// TODO: multiselect types can't be blank
if ($("input[name='persistent']:checked").length > 0) {
settings.push(`persistent=${$("input[name='persistent']:checked").map(function () {return this.value;}).get().join()}`);
}
@ -573,8 +441,6 @@
// TODO: multiselect types can't be blank
if ($("input[name='coords']:checked").length > 0) {
@ -583,29 +449,21 @@
// TODO: multiselect types can't be blank
settings.push(`denom=${$("#denom").val()}`);
// TODO: multiselect types can't be blank
settings.push(`network=${$("#network").val()}`);
// TODO: multiselect types can't be blank
settings.push(`qr_density=${$("#qr_density").val()}`);
// TODO: multiselect types can't be blank
if ($("input[name='xpub_export']:checked").length > 0) {
@ -619,8 +477,6 @@
// TODO: multiselect types can't be blank
if ($("input[name='sigs']:checked").length > 0) {
@ -629,8 +485,6 @@
// TODO: multiselect types can't be blank
if ($("input[name='scripts']:checked").length > 0) {
@ -639,8 +493,6 @@
// TODO: multiselect types can't be blank
if ($("input[name='xpub_details']:checked").length > 0) {
@ -654,22 +506,16 @@
// TODO: multiselect types can't be blank
settings.push(`passphrase=${$("#passphrase").val()}`);
// TODO: multiselect types can't be blank
settings.push(`camera=${$("#camera").val()}`);
// TODO: multiselect types can't be blank
if ($("input[name='compact_seedqr']:checked").length > 0) {
@ -683,8 +529,6 @@
// TODO: multiselect types can't be blank
if ($("input[name='bip85']:checked").length > 0) {
@ -698,45 +542,6 @@
// TODO: multiselect types can't be blank
if ($("input[name='electrum']:checked").length > 0) {
settings.push(`electrum=${$("input[name='electrum']:checked").map(function () {return this.value;}).get().join()}`);
}
if ($("input[name='electrum']:not(:checked)").length > 0) {
// Set "D" for disabled
settings.push(`electrum=D`);
}
// TODO: multiselect types can't be blank
settings.push(`microsd_toast_timer=${$("#microsd_toast_timer").val()}`);
// TODO: multiselect types can't be blank
if ($("input[name='message_signing']:checked").length > 0) {
settings.push(`message_signing=${$("input[name='message_signing']:checked").map(function () {return this.value;}).get().join()}`);
}
if ($("input[name='message_signing']:not(:checked)").length > 0) {
// Set "D" for disabled
settings.push(`message_signing=D`);
}
// TODO: multiselect types can't be blank
if ($("input[name='priv_warn']:checked").length > 0) {
@ -750,8 +555,6 @@
// TODO: multiselect types can't be blank
if ($("input[name='dire_warn']:checked").length > 0) {
@ -765,23 +568,6 @@
// TODO: multiselect types can't be blank
if ($("input[name='qr_brightness_tips']:checked").length > 0) {
settings.push(`qr_brightness_tips=${$("input[name='qr_brightness_tips']:checked").map(function () {return this.value;}).get().join()}`);
}
if ($("input[name='qr_brightness_tips']:not(:checked)").length > 0) {
// Set "D" for disabled
settings.push(`qr_brightness_tips=D`);
}
// TODO: multiselect types can't be blank
if ($("input[name='partners']:checked").length > 0) {
@ -795,30 +581,6 @@
// TODO: multiselect types can't be blank
settings.push(`disp_conf=${$("#disp_conf").val()}`);
// TODO: multiselect types can't be blank
if ($("input[name='rgb_inv']:checked").length > 0) {
settings.push(`rgb_inv=${$("input[name='rgb_inv']:checked").map(function () {return this.value;}).get().join()}`);
}
if ($("input[name='rgb_inv']:not(:checked)").length > 0) {
// Set "D" for disabled
settings.push(`rgb_inv=D`);
}
// TODO: multiselect types can't be blank
var config = settings.join(" ");

View File

@ -1,9 +1,12 @@
#!/bin/bash
# pull the latest from our target SeedSigner fork/branch
git submodule update --remote --recursive
git submodule update --remote
# Extract SeedSigner's `SettingsDefinition` and generate the static index.html
python3 extract_settings.py
# generate the settings_definition.json from SettingsDefinition in SeedSigner
python3 seedsigner/src/seedsigner/models/settings_definition.py
# parse the json and generate the static index.html
python3 parse_settings_json.py
mv index.html ../docs/.

View File

@ -1,23 +1,24 @@
import json
from jinja2 import Template
from seedsigner.models.settings import SettingsDefinition
print("Generating static index.html")
# Extract the SettingsDefinition from the SeedSigner source
settings_definition_dict = SettingsDefinition.to_dict()
# Load the settings_definition.json
with open("settings_definition.json", 'r') as json_file:
settings_json = json.load(json_file)
# Load the Jinja2 template
with open("index.jinja", 'r') as template_file:
template = Template(template_file.read())
# Prep the template data from settings_json
template_data = {
"settings_entries": [],
}
for entry in settings_definition_dict.get("settings_entries"):
for entry in settings_json.get("settings_entries"):
print(entry["attr_name"])
if entry["visibility"] == "hidden":
print(f"""Skipping hidden setting '{entry["attr_name"]}'""")
@ -26,6 +27,8 @@ for entry in settings_definition_dict.get("settings_entries"):
entry["attr_name"] = entry["abbreviated_name"]
template_data["settings_entries"].append(entry)
# Render the final static index.html
final_html = template.render(template_data)
with open("index.html", 'w') as html_file:

@ -1 +1 @@
Subproject commit 3455aa4958e5c1f9027d287cde821596d43b9cae
Subproject commit 8017f11e95ca0162bbda25c34f596eda8f5911eb