Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ViUR3 #15

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,21 @@ indent_size = 2

[*.md]
trim_trailing_whitespace = false

[{*.pyw,*.py}]
# Codestyle
ij_python_align_multiline_imports = true
ij_python_blank_lines_after_imports = 1
ij_python_blank_lines_after_local_imports = 0
ij_python_from_import_new_line_after_left_parenthesis = false
ij_python_from_import_new_line_before_right_parenthesis = false
ij_python_from_import_parentheses_force_if_multiline = false
ij_python_from_import_trailing_comma_if_multiline = false
ij_python_from_import_wrapping = 1
# Optimize Imports
ij_python_optimize_imports_always_split_from_imports = false
ij_python_optimize_imports_case_insensitive_order = false
ij_python_optimize_imports_join_from_imports_with_same_source = true
ij_python_optimize_imports_sort_by_type_first = true
ij_python_optimize_imports_sort_imports = true
ij_python_optimize_imports_sort_names_in_from_imports = true
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.html linguist-language=Jinja2
18 changes: 2 additions & 16 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,8 @@

.idea

deploy/pyodide
deploy/vi

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you remove these?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is standard gitignore file in viur base. The VI is served by the viur-cli.

node_modules

/login
/acc
/acc.txt

/appengine-db
/database
/storage

Thumbs.db
[Dd]esktop.ini
$RECYCLE.BIN/
.DS_Store
._*
.Trashes
.Trash-*
storage
9 changes: 0 additions & 9 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,9 +0,0 @@
[submodule "vi"]
path = vi
url = [email protected]:viur-framework/vi.git
[submodule "deploy/server"]
path = deploy/server
url = [email protected]:viur-framework/server.git
[submodule "sources/less/ignite"]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is ignite no longer a submdule?

path = sources/less/ignite
url = [email protected]:viur-framework/ignite.git
827 changes: 159 additions & 668 deletions LICENSE

Large diffs are not rendered by default.

18 changes: 18 additions & 0 deletions Pipfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

#[[source]]
#url = "https://test.pypi.org/simple/"
#verify_ssl = true
#name = "testpypi"

[packages]
viur-core = "*"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we please use a specific version?


[dev-packages]
viur-cli = "*"

[requires]
python_version = "3.9"
843 changes: 843 additions & 0 deletions Pipfile.lock

Large diffs are not rendered by default.

26 changes: 26 additions & 0 deletions deploy/.gcloudignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# This file specifies files that are *not* uploaded to Google Cloud Platform
# using gcloud. It follows the same syntax as .gitignore, with the addition of
# "#!include" directives (which insert the entries of the given .gitignore-style
# file at that point).
#
# For more information, run:
# $ gcloud topic gcloudignore
#
.gcloudignore
# If you would like to upload your .git directory, .gitignore file or files
# from your .gitignore file, remove the corresponding line
# below:
.git
.gitignore

# Python pycache:
__pycache__/
# Ignored by the build system
/setup.cfg

node_modules/
/viur/docs/
/viur/CHANGELOG.md
/viur/LICENSE
/viur/README.md
/viur/.readthedocs.yml
Comment on lines +22 to +26
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These shouldn't be necessary, if we load the core from pip

57 changes: 34 additions & 23 deletions deploy/app.yaml
Original file line number Diff line number Diff line change
@@ -1,37 +1,48 @@
#application: ignite-docs
#version: 1
runtime: python27
api_version: 1
threadsafe: False
runtime: python39

# (1) Under some circumstances, you need to set a higher instance_class,
# like F2 or F4. Unfortunately, this will increase App Engine cost,
# see https://cloud.google.com/appengine/pricing.
instance_class: F1
default_expiration: "30s"

# (2) To get more memory and concurrent requests, a separate gunicorn is run.
entrypoint: gunicorn -b :$PORT -w 1 --threads 2 --disable-redirect-access-to-syslog main:app

# (3) Limited scaling is default, to keep frontend instance hours low.
# Please change these values on your demands.
automatic_scaling:
max_concurrent_requests: 2
max_instances: 1
max_idle_instances: 1

handlers:
# (4) For a local Pyodide installation, activate below and run get-pyodide.py from project root.
# Leave the comments to use the CDN-version of Pyodide, which also runs very well.
#- url: /pyodide/(.*\.(wasm|data))$
# static_files: pyodide/\1
# upload: pyodide/.*\.(wasm|data)$
# mime_type: application/wasm
#- url: /pyodide
# static_dir: pyodide

# (5) Activate this when vi_plugins should be used
#- url: /vi_plugins/s
# static_dir: vi_plugins

- url: /vi/s
static_dir: vi
- url: /static
static_dir: static
application_readable: true
- url: /resources
static_dir: server/resources
- url: /_tasks
script: ignite-docs.application
- url: /admin/user/getAuthMethod
script: ignite-docs.application
- url: /admin/.*
script: ignite-docs.application
- url: /vi.*
script: ignite-docs.application
static_dir: viur/core/resources
- url: /favicon.ico
static_files: static/meta/favicon.ico
upload: favicon.ico
- url: /.*
script: ignite-docs.application

libraries:
- name: jinja2
version: latest
- url: /robots.txt
static_files: static/meta/robots.txt
upload: robots.txt

inbound_services:
- warmup

builtins:
- deferred: on
2 changes: 1 addition & 1 deletion deploy/cron.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cron:
- description: Task trigger
url: /_tasks
url: /_tasks/cron
schedule: every 4 hours
10 changes: 8 additions & 2 deletions deploy/emails/user_password_recovery.email
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Subject: Reset Password
Reset Password
{% extends "viur_mail_default.html" %}

{% block title %}
Expand All @@ -10,6 +10,12 @@ Subject: Reset Password
Hello user,
<br><br>

open this link to confirm the password reset process: <a href="{{ getHostUrl() }}/user/auth_userpassword/pwrecover?authtoken={{ skel.skey }}">{{ getHostUrl() }}/user/auth_userpassword/pwrecover?authtoken={{ skel.skey }}</a>
open this link to confirm the password reset process:
<a href="{{ getHostUrl() }}/user/auth_userpassword/pwrecover?recoveryKey={{ skel["recoveryKey"] }}">
{{ getHostUrl() }}/user/auth_userpassword/pwrecover?recoveryKey={{ skel["recoveryKey"] }}
</a>

or enter the following verification code manually:
<pre>{{ skel["recoveryKey"] }}</pre>
</div>
{% endblock %}
3 changes: 1 addition & 2 deletions deploy/emails/viur_mail_dummy.email
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@

Subject: ViMail Dummy
ViMail Subject (always first line)
{% extends "viur_mail_default.html" %}

{% block title %}
Expand Down
11 changes: 11 additions & 0 deletions deploy/html/editform/editform_bone_bone.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<input
class="switch-input ignt-input--boolean ignt-input--{{ boneName }}
{{ "is-required" if boneParams.required }}
{{ "is-readonly" if boneParams.readOnly }}
{{ "is-invalid" if boneErrors else "is-valid" }}"
name="{{ boneName }}"
value="{{ boneValue or "" }}"
{{ "required" if boneParams.required }}
{{ "readonly" if boneParams.readOnly }}
{% if boneErrors %} aria-invalid="true" {% endif %}
>
17 changes: 17 additions & 0 deletions deploy/html/editform/editform_bone_bool.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<div class="switch ignt-switch">
<input
class="switch-input ignt-input--boolean ignt-input--{{ boneName }}
{{ "is-required" if boneParams.required }}
{{ "is-readonly" if boneParams.readOnly }}
{{ "is-invalid" if boneErrors else "is-valid" }}"
id="ignt-id-{{ boneName }}"
type="checkbox"
name="{{ boneName }}"
value="True"
{{ "checked" if boneValue }}
{{ "required" if boneParams.required }}
{{ "readonly" if boneParams.readOnly }}
{% if boneErrors %} aria-invalid="true" {% endif %}
>
<label class="switch-label" for="ignt-id-{{ boneName }}"></label>
</div>
25 changes: 25 additions & 0 deletions deploy/html/editform/editform_bone_captcha.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<div class="hidden2formfield">
<script src="https://www.google.com/recaptcha/api.js?render={{ boneValue }}"></script>
<input type="hidden" class="recaptcha" name="g-recaptcha-response"
data-sitekey="{{ boneValue }}"
data-action="{{ boneParams["action"]|default("form") }}">
</div>

<script>
(function () {
function fetchToken(input) {
grecaptcha.ready(function () {
const {sitekey, action} = input.dataset;
grecaptcha.execute(sitekey, {action})
.then(token => {
input.value = token;
// A reCAPTCHA token expires after two minutes,
// refresh it 10 seconds before.
setTimeout(fetchToken, (2 * 60 - 10) * 1000, input);
});
});
}

document.querySelectorAll('.recaptcha').forEach(fetchToken);
})();
</script>
14 changes: 14 additions & 0 deletions deploy/html/editform/editform_bone_color.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<input
class="input ignt-input ignt-input--color ignt-input--{{ boneName }}
{{ "is-required" if boneParams.required }}
{{ "is-readonly" if boneParams.readOnly }}
{{ "is-invalid" if boneErrors else "is-valid" }}"
name="{{ boneName }}"
type="color"
title="{{ boneParams.tooltip or boneParams.descr or boneName }}"
id="ignt-id-{{ boneName }}"
value="{{ boneValue|default("", true) }}"
{{ "readonly" if boneParams.readOnly }}
{{ "required" if boneParams.required }}
{% if boneErrors %} aria-invalid="true" {% endif %}
>
21 changes: 21 additions & 0 deletions deploy/html/editform/editform_bone_date.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<div
id="ignt-id-{{ boneName }}"
class="input-group">
{% if boneParams.date and boneParams.time %}
{# Current Webbrowsers dont support a datetime input yet so we'll split it up until they do #}
<input type="date" class="input ignt-input ignt-input--date" value="{% if boneValue %}{{ boneValue.strftime("%Y-%m-%d") }}{% endif %}"
name="{{ boneName }}-date" {% if boneParams.readOnly %}disabled="disabled"{% endif %}>
<input type="time" class="input ignt-input ignt-input--time" value="{% if boneValue %}{{ boneValue.strftime("%H:%M:%S") }}{% endif %}"
name="{{ boneName }}-time" {% if boneParams.readOnly %}disabled="disabled"{% endif %}>
<input type="hidden" value="{% if boneValue %}{{ boneValue.strftime("%Y-%M-%d") }}{% endif %}"
name="{{ boneName }}" class="js-viur-bones-date-doubleinput">
{% elif boneParams.date %}
<input type="date" class="input ignt-input ignt-input--date" value="{% if boneValue %}{{ boneValue.strftime("%Y-%m-%d") }}{% endif %}"
name="{{ boneName }}" {% if boneParams.readOnly %}disabled="disabled"{% endif %}>
{% elif boneParams.time %}
<input type="time" class="input ignt-input ignt-input--time" value="{% if boneValue %}{{ boneValue.strftime("%H:%M:%S") }}{% endif %}"
name="{{ boneName }}-time" {% if boneParams.readOnly %}disabled="disabled"{% endif %}>
{% else %}
<!-- You messed up this datebone somehow -->
{% endif %}
</div>
4 changes: 4 additions & 0 deletions deploy/html/editform/editform_bone_hidden.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{% if boneValue and (boneParams["type"] == "relational" or boneParams["type"].startswith("relational.")) %}
{% set boneValue = boneValue["dest"]["key"] %}
{% endif %}
<input type="hidden" name="{{ boneName }}" value="{{ boneValue or "" }}">
28 changes: 28 additions & 0 deletions deploy/html/editform/editform_bone_numeric.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{%- if boneParams.precision < 0 -%}
{# if precision is < 0, we only allow powers of 10 to be selected by forcing the last n digits to be allways
zero (ie. ..., 0, 10, 20, ... or ..., 0, 100, 200, ...). We ensure that the last digits of our min/max value
matches that alley by foring the last n digits to be 0. Otherwise we might end up in shifted alleys
( ..., -4, 6, 16, ... or the like) #}
{%- set min = (boneParams.min|string)[:-(boneParams.precision|abs)]+"0"*(boneParams.precision|abs) -%}
{%- set max = (boneParams.max|string)[:-(boneParams.precision|abs)]+"0"*(boneParams.precision|abs) -%}
{%- else -%}
{% set min = boneParams.min -%}
{% set max = boneParams.max -%}
{%- endif -%}

<input
class="input ignt-input ignt-input-numeric ignt-input--{{ boneName }}
{{ "is-required" if boneParams.required }}
{{ "is-readonly" if boneParams.readOnly }}
{{ "is-invalid" if boneErrors else "is-valid" }}"
value="{{ boneValue|default("", true) }}"
name="{{ boneName }}"
type="number"
title="{{ boneParams.tooltip or boneParams.descr or boneName }}"
id="ignt-id-{{boneName}}"
{% if min %} min="{{ min }}" {% endif %}
{% if max %} max="{{ max }}" {% endif %}
{{ "readonly" if boneParams.readOnly }}
{{ "required" if boneParams.required }}
{% if boneErrors %} aria-invalid="true" {% endif %}
>
14 changes: 14 additions & 0 deletions deploy/html/editform/editform_bone_password.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<input
class="input ignt-input ignt-input--password ignt-ignt--{{ boneName }}
{{ "is-required" if boneParams.required }}
{{ "is-readonly" if boneParams.readOnly }}
{{ "is-invalid" if boneErrors else "is-valid" }}"
name="{{ boneName }}"
type="password"
title="{{ boneParams.tooltip or boneParams.descr or boneName }}"
id="ignt-id-{{ boneName }}"
value="{{ boneValue|default("", true) }}"
{{ "required" if boneParams.required }}
{{ "readonly" if boneParams.readOnly }}
{% if boneErrors %} aria-invalid="true" {% endif %}
>
8 changes: 8 additions & 0 deletions deploy/html/editform/editform_bone_record.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{{ renderEditForm(
skel={
"structure": boneParams.using,
"value": boneValue or {},
"errors": boneErrors
},
prefix=boneName
) }}
34 changes: 34 additions & 0 deletions deploy/html/editform/editform_bone_relational.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<select
id="ignt-id-{{ boneName }}"
name="{{ boneName }}"
class="select ignt-select ignt-select--{{ boneName }}
{{ "is-required" if boneParams.required }}
{{ "is-readonly" if boneParams.readOnly }}
{{ "is-invalid" if boneWasInvalid else "is-valid" }}"
{{'readonly' if boneParams.readOnly}}
{{'required' if boneParams.required}}
>
{% set ns = namespace(cursor="") %}
{% for i in range(0, 1000, 100) %}
{% if ns.cursor == "" %}
{% set skellist = getList(boneParams.module, limit=100) %}
{% set ns.cursor = skellist.getCursor() %}
{% elif ns.cursor != none %}
{% set skellist = getList(boneParams.module, cursor=ns.cursor, limit=100) %}
{% set ns.cursor = skellist.getCursor() %}
{% else %}
{% set skellist = [] %}
{% endif %}
{% for entry in skellist %}
{% if loop.first %}
<option value="" {{ "selected" if not boneValue }} {{ "disabled" if boneParams.required}} hidden>
-
</option>
{% endif %}
<option value="{{ entry["key"] }}" {{ "selected" if boneValue and entry["key"] == boneValue["dest"]["key"] }}>
{{ entry["name"] }}
</option>
{% endfor %}
{% endfor %}

</select>
Loading