diff options
Diffstat (limited to 'src/hydrilla/proxy/web_ui')
7 files changed, 57 insertions, 10 deletions
diff --git a/src/hydrilla/proxy/web_ui/items.py b/src/hydrilla/proxy/web_ui/items.py index 808fb6d..d0f0f2e 100644 --- a/src/hydrilla/proxy/web_ui/items.py +++ b/src/hydrilla/proxy/web_ui/items.py @@ -390,8 +390,8 @@ def show_required_mapping( return flask.redirect(url) -@bp.route('/package/viewpayload/<string:item_version_id>/<string:pattern>/<string:lib_identifier>') -def show_payload(item_version_id: str, pattern: str, lib_identifier: str) \ +@bp.route('/package/viewlibrary/<string:item_version_id>/<string:pattern>/<string:lib_identifier>') +def show_package_library(item_version_id: str, pattern: str, lib_identifier: str) \ -> werkzeug.Response: state = _app.get_haketilo_state() @@ -406,10 +406,35 @@ def show_payload(item_version_id: str, pattern: str, lib_identifier: str) \ item_version_id = resource_ver_ref.id ) except st.MissingItemError: - resource_ref = \ - state.resource_store().get_by_identifier(lib_identifier) + resource_ref = state.resource_store().get_by_identifier( + lib_identifier + ) url = flask.url_for('.show_library', item_id=resource_ref.id) except st.MissingItemError: flask.abort(404) return flask.redirect(url) + +@bp.route('/package/viewbypayload/<string:payload_id>/<string:package_identifier>') +def show_payload_package(payload_id: str, package_identifier: str) \ + -> werkzeug.Response: + state = _app.get_haketilo_state() + + try: + ref = state.payload_store().get(payload_id) + + try: + mapping_ver_ref = ref.get_display_info().mapping_info.ref + url = flask.url_for( + '.show_package_version', + item_version_id = mapping_ver_ref.id + ) + except st.MissingItemError: + mapping_ref = state.mapping_store().get_by_identifier( + package_identifier + ) + url = flask.url_for('.show_package', item_id=mapping_ref.id) + except st.MissingItemError: + flask.abort(404) + + return flask.redirect(url) diff --git a/src/hydrilla/proxy/web_ui/items_import.py b/src/hydrilla/proxy/web_ui/items_import.py index a5b5f18..f94768f 100644 --- a/src/hydrilla/proxy/web_ui/items_import.py +++ b/src/hydrilla/proxy/web_ui/items_import.py @@ -51,7 +51,13 @@ bp = flask.Blueprint('import', __package__) @bp.route('/import', methods=['GET']) def items_import(errors: t.Mapping[str, bool] = {}) -> werkzeug.Response: - html = flask.render_template('import.html.jinja', **errors) + pattern = flask.request.args.get('pattern') + if pattern is None: + extra_args = {} + else: + extra_args = {'pattern': normalize_pattern(pattern)} + + html = flask.render_template('import.html.jinja', **errors, **extra_args) return flask.make_response(html, 200) def items_import_from_file() -> werkzeug.Response: @@ -172,7 +178,6 @@ def item_import_ad_hoc() -> werkzeug.Response: try: builder_args = ['-s', str(source_dir), '-d', str(malcontent_dir)] build.perform(builder_args, standalone_mode=False) - build.perform(['-s', str(source_dir), '-d', '/tmp/haketilodebug'], standalone_mode=False) _app.get_haketilo_state().import_items(malcontent_dir) except: import traceback diff --git a/src/hydrilla/proxy/web_ui/rules.py b/src/hydrilla/proxy/web_ui/rules.py index 56753a3..606d33f 100644 --- a/src/hydrilla/proxy/web_ui/rules.py +++ b/src/hydrilla/proxy/web_ui/rules.py @@ -107,3 +107,16 @@ def alter_rule(rule_id: str) -> werkzeug.Response: flask.abort(404) return flask.redirect(flask.url_for('.show_rule', rule_id=rule_id)) + +@bp.route('/rules/viewbypattern') +def show_pattern_rule() -> werkzeug.Response: + pattern = flask.request.args['pattern'] + + try: + store = _app.get_haketilo_state().rule_store() + rule_ref = store.get_by_pattern(pattern) + except st.MissingItemError: + html = flask.render_template('rules/add.html.jinja', pattern=pattern) + return flask.make_response(html, 200) + + return flask.redirect(flask.url_for('.show_rule', rule_id=rule_ref.id)) diff --git a/src/hydrilla/proxy/web_ui/templates/import.html.jinja b/src/hydrilla/proxy/web_ui/templates/import.html.jinja index 6ec9947..7f3be50 100644 --- a/src/hydrilla/proxy/web_ui/templates/import.html.jinja +++ b/src/hydrilla/proxy/web_ui/templates/import.html.jinja @@ -103,7 +103,7 @@ code in a proprietary work, I am not going to enforce this in court. {% if invalid_ad_hoc_patterns is defined %} {{ error_note(_('web_ui.err.invalid_ad_hoc_patterns')) }} {% endif %} - {{ form_field('patterns', height=3) }} + {{ form_field('patterns', height=3, initial_value=pattern|default(none)) }} {{ label(_('web_ui.import.script_text_field_label'), 'script_text') }} {{ form_field('script_text', required=false, height=15) }} diff --git a/src/hydrilla/proxy/web_ui/templates/index.html.jinja b/src/hydrilla/proxy/web_ui/templates/index.html.jinja index 2b49361..ff74369 100644 --- a/src/hydrilla/proxy/web_ui/templates/index.html.jinja +++ b/src/hydrilla/proxy/web_ui/templates/index.html.jinja @@ -299,4 +299,8 @@ code in a proprietary work, I am not going to enforce this in court. {{ _('web_ui.home.payloadon_popup_no') }} {% endif %} {% endcall %} + + <p> + {{ _('web_ui.home.popup_can_be_opened_by') }} + </p> {% endblock main %} diff --git a/src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja b/src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja index fe816ab..386c0c8 100644 --- a/src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja +++ b/src/hydrilla/proxy/web_ui/templates/items/package_viewversion.html.jinja @@ -75,7 +75,7 @@ code in a proprietary work, I am not going to enforce this in court. {% set encoded = patterns[0]|urlencode|replace('/', '%2F') %} {% set url = url_for( - '.show_payload', + '.show_package_library', item_version_id = version_display_info.ref.id, pattern = encoded, lib_identifier = lib_identifier diff --git a/src/hydrilla/proxy/web_ui/templates/rules/add.html.jinja b/src/hydrilla/proxy/web_ui/templates/rules/add.html.jinja index 6d21ccd..9e4b869 100644 --- a/src/hydrilla/proxy/web_ui/templates/rules/add.html.jinja +++ b/src/hydrilla/proxy/web_ui/templates/rules/add.html.jinja @@ -24,14 +24,14 @@ code in a proprietary work, I am not going to enforce this in court. {% block main %} <h3>{{ _('web_ui.rules.add.heading') }}</h3> - <form method="POST"> + <form method="POST" action="{{ url_for('.add_rule') }}"> {{ label(_('web_ui.rules.add.pattern_field_label'), 'pattern') }} {% if rule_pattern_invalid is defined %} {{ error_note(_('web_ui.err.rule_pattern_invalid')) }} {% endif %} - {{ form_field('pattern') }} + {{ form_field('pattern', initial_value=pattern|default(none)) }} {{ label(_('web_ui.rules.add.block_or_allow_label'), 'allow') }} |