Skip to content

Commit d85dcdb

Browse files
committed
replaced missing JavaScript on Playground Packages page to restore functionality of GitHub and PyPI buttons that was inadvertently removed in the last version; when docx template file is used with fields, a shallow copy rather than a deep copy is made to facilitate driving the interview logic from the DOCX file; support for dark mode screenshots in the Examples area of the Playground
1 parent ee5ee12 commit d85dcdb

File tree

253 files changed

+93
-42
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

253 files changed

+93
-42
lines changed

CHANGELOG.md

+10-3

docassemble_base/docassemble/base/parse.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -7507,7 +7507,10 @@ def prepare_attachment(self, attachment, the_user_dict):
75077507
if isinstance(item, dict):
75087508
new_field_data.update(item)
75097509
the_field_data = new_field_data
7510-
result['field_data'] = copy.deepcopy(pickleable_objects(the_user_dict))
7510+
# result['field_data'] = copy.copy(pickleable_objects(the_user_dict))
7511+
result['field_data'] = {}
7512+
for var_name, var_value in pickleable_objects(the_user_dict).items():
7513+
result['field_data'][var_name] = var_value
75117514
self.interview.populate_non_pickleable(result['field_data'])
75127515
if 'alpha' not in result['field_data']:
75137516
raise DAError("problem with field data")

docassemble_webapp/docassemble/webapp/server.py

+21-14
Original file line numberDiff line numberDiff line change
@@ -2606,7 +2606,7 @@ def standard_html_start(interview_language=DEFAULT_LANGUAGE, debug=False, bootst
26062606
bootstrap_part = '\n <link href="' + url_for('static', filename='bootstrap/css/bootstrap.min.css', v=da_version, _external=external) + '" rel="stylesheet">'
26072607
else:
26082608
bootstrap_part = '\n <link href="' + bootstrap_theme + '" rel="stylesheet">'
2609-
if session.get('color_scheme', 'light') == 'dark':
2609+
if session.get('color_scheme', 0):
26102610
color_scheme_part = ' data-bs-theme="dark"'
26112611
else:
26122612
color_scheme_part = ''
@@ -6593,14 +6593,20 @@ def test_embed():
65936593
return response
65946594

65956595

6596+
@app.route("/dark_mode", methods=['GET'])
6597+
def force_dark_mode():
6598+
session['color_scheme'] = 2
6599+
return ('', 200)
6600+
6601+
65966602
@app.route("/color_scheme", methods=['PATCH'])
65976603
@csrf.exempt
65986604
def change_color_scheme():
65996605
patch_data = request.form.copy()
6600-
if 'scheme' in patch_data and patch_data['scheme'] in ('light', 'dark'):
6601-
session['color_scheme'] = patch_data['scheme']
6602-
return jsonify({'scheme': patch_data['scheme']})
6603-
return ('{"scheme": "light"}', 200)
6606+
if 'scheme' in patch_data and patch_data['scheme'] in ('0', '1', '2'):
6607+
session['color_scheme'] = int(patch_data['scheme'])
6608+
return jsonify({'scheme': session['color_scheme']})
6609+
return ('{"scheme": 0}', 200)
66046610

66056611

66066612
@app.route("/launch", methods=['GET'])
@@ -8765,18 +8771,18 @@ def index(action_argument=None, refer=None):
87658771
location_bar = url_for('index', **index_params)
87668772
index_params_external = copy.copy(index_params)
87678773
index_params_external['_external'] = True
8768-
if daconfig.get("auto color scheme", True) and not is_js:
8774+
if session.get('color_scheme', 0) < 2 and daconfig.get("auto color scheme", True) and not is_js:
87698775
color_scheme = """\
8770-
var daCurrentColorScheme = """ + json.dumps(session.get('color_scheme', 'light')) + """
8776+
var daCurrentColorScheme = """ + str(session.get('color_scheme', 0)) + """;
87718777
var daDesiredColorScheme;
87728778
if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
8773-
daDesiredColorScheme = "dark"
8779+
daDesiredColorScheme = 1;
87748780
}
87758781
else {
8776-
daDesiredColorScheme = "light";
8782+
daDesiredColorScheme = 0;
87778783
}
87788784
if (daCurrentColorScheme != daDesiredColorScheme){
8779-
document.documentElement.setAttribute('data-bs-theme', daDesiredColorScheme);
8785+
document.documentElement.setAttribute('data-bs-theme', daDesiredColorScheme ? 'dark': 'light');
87808786
$.ajax({
87818787
type: "PATCH",
87828788
url: """ + json.dumps(url_for('change_color_scheme')) + """,
@@ -13548,7 +13554,7 @@ def user_designator(the_user):
1354813554

1354913555
def in_debug():
1355013556
return DEBUG
13551-
return {'word': docassemble.base.functions.word, 'in_debug': in_debug, 'user_designator': user_designator, 'get_part': get_part, 'current_language': lang, 'color_scheme': session.get('color_scheme', 'light')}
13557+
return {'word': docassemble.base.functions.word, 'in_debug': in_debug, 'user_designator': user_designator, 'get_part': get_part, 'current_language': lang, 'color_scheme': session.get('color_scheme', 0)}
1355213558

1355313559

1355413560
@app.route('/speakfile', methods=['GET'])
@@ -21312,7 +21318,7 @@ def playground_packages():
2131221318
extra_command = " scrollBottom();"
2131321319
else:
2131421320
extra_command = ""
21315-
extra_command += upload_js() + """
21321+
extra_command += indent_by(upload_js(), 2) + """\
2131621322
$("#daCancelPyPI").click(function(event){
2131721323
var daWhichButton = this;
2131821324
$("#pypi_message_div").hide();
@@ -21487,7 +21493,7 @@ def playground_packages():
2148721493
$("#readme").val(daCm.state.doc.toString());
2148821494
$("#form").trigger("reinitialize.areYouSure");
2148921495
return true;
21490-
});
21496+
});""" + extra_command + """
2149121497
});
2149221498
</script>"""
2149321499
if github_use_ssh:
@@ -22692,6 +22698,7 @@ def playground_page():
2269222698
$("#da-example-source-after").html(info['after_html']);
2269322699
$("#da-example-image-link").attr("href", info['interview']);
2269422700
$("#da-example-image").attr("src", info['image']);
22701+
$("#da-example-image-dark").attr("srcset", info['image'].replace('/examples/', '/examplesdark/'));
2269522702
if (info['documentation'] != null){
2269622703
$("#da-example-documentation-link").attr("href", info['documentation']);
2269722704
$("#da-example-documentation-link").removeClass("da-example-hidden");
@@ -31646,7 +31653,7 @@ def define_examples():
3164631653
return
3164731654
example_html.append(' </div>')
3164831655
example_html.append(' <div class="col-md-4 da-example-source-col"><h5 class="mb-1">' + word('Source') + '<a href="#" tabindex="0" class="dabadge btn btn-success da-example-copy">' + word("Insert") + '</a></h5><div id="da-example-source-before" class="dainvisible"></div><div id="da-example-source"></div><div id="da-example-source-after" class="dainvisible"></div><div><a tabindex="0" class="da-example-hider" id="da-show-full-example">' + word("Show context of example") + '</a><a tabindex="0" class="da-example-hider dainvisible" id="da-hide-full-example">' + word("Hide context of example") + '</a></div></div>')
31649-
example_html.append(' <div class="col-md-6"><h5 class="mb-1">' + word("Preview") + '<a href="#" target="_blank" class="dabadge btn btn-primary da-example-documentation da-example-hidden" id="da-example-documentation-link">' + word("View documentation") + '</a></h5><a href="#" target="_blank" id="da-example-image-link"><img title=' + json.dumps(word("Click to try this interview")) + ' class="da-example-screenshot" id="da-example-image"></a></div>')
31656+
example_html.append(' <div class="col-md-6"><h5 class="mb-1">' + word("Preview") + '<a href="#" target="_blank" class="dabadge btn btn-primary da-example-documentation da-example-hidden" id="da-example-documentation-link">' + word("View documentation") + '</a></h5><a href="#" target="_blank" id="da-example-image-link"><picture><source media="(prefers-color-scheme: dark)" id="da-example-image-dark" /><img title=' + json.dumps(word("Click to try this interview")) + ' class="da-example-screenshot" id="da-example-image" /></picture></a></div>')
3165031657
pg_ex['encoded_data_dict'] = safeid(json.dumps(data_dict))
3165131658
pg_ex['encoded_example_html'] = Markup("\n".join(example_html))
3165231659

docassemble_webapp/docassemble/webapp/static/app/app.css

+5
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,11 @@ img.da-example-screenshot {
505505
background-color: white;
506506
}
507507

508+
[data-bs-theme=dark] img.da-example-screenshot {
509+
border-color: #333333;
510+
background-color: #212529;
511+
}
512+
508513
.da-example-link {
509514
cursor: pointer;
510515
}

docassemble_webapp/docassemble/webapp/static/app/app.min.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docassemble_webapp/docassemble/webapp/static/app/bundle.css

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docassemble_webapp/docassemble/webapp/templates/base_templates/base.html

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<!DOCTYPE html>
2-
<html lang="{{ current_language }}"{% if color_scheme == 'dark' %} data-bs-theme="dark"{% endif%}>
2+
<html lang="{{ current_language }}"{% if color_scheme %} data-bs-theme="dark"{% endif%}>
33
<head>
44
<meta charset="utf-8">
55
<meta name="apple-mobile-web-app-capable" content="yes">
@@ -180,17 +180,17 @@
180180

181181
<script src="{{ url_for('static', filename='app/adminbundle.js', v=config['DA_VERSION']) }}"></script>
182182
<script>
183-
{%- if config['AUTO_COLOR_SCHEME'] %}
184-
var daCurrentColorScheme = "{{ color_scheme }}";
183+
{%- if config['AUTO_COLOR_SCHEME'] and color_scheme < 2 %}
184+
var daCurrentColorScheme = {{ color_scheme }};
185185
var daDesiredColorScheme;
186186
if (window.matchMedia('(prefers-color-scheme: dark)').matches) {
187-
daDesiredColorScheme = "dark"
187+
daDesiredColorScheme = 1;
188188
}
189189
else {
190-
daDesiredColorScheme = "light";
190+
daDesiredColorScheme = 0;
191191
}
192192
if (daCurrentColorScheme != daDesiredColorScheme){
193-
document.documentElement.setAttribute('data-bs-theme', daDesiredColorScheme);
193+
document.documentElement.setAttribute('data-bs-theme', daDesiredColorScheme ? 'dark' : 'light');
194194
$.ajax({
195195
type: "PATCH",
196196
url: "{{ url_for('change_color_scheme') }}",

docassemble_webapp/setup.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def read(fname):
7373
"contourpy==1.2.1",
7474
"convertapi==1.8.0",
7575
"crayons==0.4.0",
76-
"cryptography==43.0.0",
76+
"cryptography==43.0.1",
7777
"cssselect2==0.7.0",
7878
"cycler==0.12.1",
7979
"defusedxml==0.7.1",
@@ -319,5 +319,5 @@ def read(fname):
319319
namespace_packages=['docassemble'],
320320
install_requires=install_requires,
321321
zip_safe=False,
322-
package_data={'docassemble.webapp': ['alembic.ini', os.path.join('alembic', '*'), os.path.join('alembic', 'versions', '*'), os.path.join('data', '*.*'), os.path.join('data', 'static', '*.*'), os.path.join('data', 'static', 'favicon', '*.*'), os.path.join('data', 'questions', '*.*'), os.path.join('templates', 'base_templates', '*.html'), os.path.join('templates', 'flask_user', '*.html'), os.path.join('templates', 'flask_user', 'emails', '*.*'), os.path.join('templates', 'pages', '*.html'), os.path.join('templates', 'pages', '*.xml'), os.path.join('templates', 'pages', '*.js'), os.path.join('templates', 'users', '*.html'), os.path.join('static', 'app', '*.*'), os.path.join('static', 'sounds', '*.*'), os.path.join('static', 'examples', '*.*'), os.path.join('static', 'fontawesome', 'js', '*.*'), os.path.join('static', 'office', '*.*'), os.path.join('static', 'bootstrap-fileinput', 'img', '*'), os.path.join('static', 'img', '*'), os.path.join('static', 'bootstrap-fileinput', 'themes', 'fas', '*'), os.path.join('static', 'bootstrap-fileinput', 'js', 'locales', '*'), os.path.join('static', 'bootstrap-fileinput', 'js', 'plugins', '*'), os.path.join('static', 'bootstrap-slider', 'dist', '*.js'), os.path.join('static', 'bootstrap-slider', 'dist', 'css', '*.css'), os.path.join('static', 'bootstrap-fileinput', 'css', '*.css'), os.path.join('static', 'bootstrap-fileinput', 'js', '*.js'), os.path.join('static', 'bootstrap-fileinput', 'themes', 'fa', '*.js'), os.path.join('static', 'bootstrap-fileinput', 'themes', 'fas', '*.js'), os.path.join('static', 'bootstrap-combobox', 'css', '*.css'), os.path.join('static', 'bootstrap-combobox', 'js', '*.js'), os.path.join('static', 'bootstrap-fileinput', '*.md'), os.path.join('static', 'bootstrap', 'js', '*.*'), os.path.join('static', 'bootstrap', 'css', '*.*'), os.path.join('static', 'labelauty', 'source', '*.*'), os.path.join('static', 'areyousure', '*.js'), os.path.join('static', 'popper', '*.*'), os.path.join('static', 'popper', 'umd', '*.*'), os.path.join('static', 'popper', 'esm', '*.*'), os.path.join('static', '*.html')]}
322+
package_data={'docassemble.webapp': ['alembic.ini', os.path.join('alembic', '*'), os.path.join('alembic', 'versions', '*'), os.path.join('data', '*.*'), os.path.join('data', 'static', '*.*'), os.path.join('data', 'static', 'favicon', '*.*'), os.path.join('data', 'questions', '*.*'), os.path.join('templates', 'base_templates', '*.html'), os.path.join('templates', 'flask_user', '*.html'), os.path.join('templates', 'flask_user', 'emails', '*.*'), os.path.join('templates', 'pages', '*.html'), os.path.join('templates', 'pages', '*.xml'), os.path.join('templates', 'pages', '*.js'), os.path.join('templates', 'users', '*.html'), os.path.join('static', 'app', '*.*'), os.path.join('static', 'sounds', '*.*'), os.path.join('static', 'examples', '*.*'), os.path.join('static', 'examplesdark', '*.*'), os.path.join('static', 'fontawesome', 'js', '*.*'), os.path.join('static', 'office', '*.*'), os.path.join('static', 'bootstrap-fileinput', 'img', '*'), os.path.join('static', 'img', '*'), os.path.join('static', 'bootstrap-fileinput', 'themes', 'fas', '*'), os.path.join('static', 'bootstrap-fileinput', 'js', 'locales', '*'), os.path.join('static', 'bootstrap-fileinput', 'js', 'plugins', '*'), os.path.join('static', 'bootstrap-slider', 'dist', '*.js'), os.path.join('static', 'bootstrap-slider', 'dist', 'css', '*.css'), os.path.join('static', 'bootstrap-fileinput', 'css', '*.css'), os.path.join('static', 'bootstrap-fileinput', 'js', '*.js'), os.path.join('static', 'bootstrap-fileinput', 'themes', 'fa', '*.js'), os.path.join('static', 'bootstrap-fileinput', 'themes', 'fas', '*.js'), os.path.join('static', 'bootstrap-combobox', 'css', '*.css'), os.path.join('static', 'bootstrap-combobox', 'js', '*.js'), os.path.join('static', 'bootstrap-fileinput', '*.md'), os.path.join('static', 'bootstrap', 'js', '*.*'), os.path.join('static', 'bootstrap', 'css', '*.*'), os.path.join('static', 'labelauty', 'source', '*.*'), os.path.join('static', 'areyousure', '*.js'), os.path.join('static', 'popper', '*.*'), os.path.join('static', 'popper', 'umd', '*.*'), os.path.join('static', 'popper', 'esm', '*.*'), os.path.join('static', '*.html')]}
323323
)

0 commit comments

Comments
 (0)