Remove inlined JS
parent
b843b29975
commit
2fb85e138e
|
@ -36,6 +36,18 @@ try:
|
||||||
except FileNotFoundError:
|
except FileNotFoundError:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
# Force reloading cache when the JS is changed
|
||||||
|
JS_HASH = "none"
|
||||||
|
try:
|
||||||
|
# To keep things simple, we keep a single hash for the 2 files
|
||||||
|
js_data_common = (ROOT_DIR / "app" / "static" / "common-admin.js").read_bytes()
|
||||||
|
js_data_new = (ROOT_DIR / "app" / "static" / "new.js").read_bytes()
|
||||||
|
JS_HASH = hashlib.md5(
|
||||||
|
js_data_common + js_data_new, usedforsecurity=False
|
||||||
|
).hexdigest()
|
||||||
|
except FileNotFoundError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
VERSION = f"2.0.0+{VERSION_COMMIT}"
|
VERSION = f"2.0.0+{VERSION_COMMIT}"
|
||||||
USER_AGENT = f"microblogpub/{VERSION}"
|
USER_AGENT = f"microblogpub/{VERSION}"
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
document.addEventListener('DOMContentLoaded', (ev) => {
|
||||||
|
// Add confirm to "delete" button next to outbox objects
|
||||||
|
var forms = document.getElementsByClassName("object-delete-form")
|
||||||
|
for (var i = 0; i < forms.length; i++) {
|
||||||
|
forms[i].addEventListener('submit', (ev) => {
|
||||||
|
return confirm('Do you really want to delete this object?');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
|
@ -418,3 +418,4 @@ _templates.env.filters["pluralize"] = _pluralize
|
||||||
_templates.env.filters["parse_datetime"] = _parse_datetime
|
_templates.env.filters["parse_datetime"] = _parse_datetime
|
||||||
_templates.env.filters["poll_item_pct"] = _poll_item_pct
|
_templates.env.filters["poll_item_pct"] = _poll_item_pct
|
||||||
_templates.env.filters["privacy_replace_url"] = privacy_replace.replace_url
|
_templates.env.filters["privacy_replace_url"] = privacy_replace.replace_url
|
||||||
|
_templates.env.globals["JS_HASH"] = config.JS_HASH
|
||||||
|
|
|
@ -90,5 +90,5 @@
|
||||||
</p>
|
</p>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
<script src="/static/new.js"></script>
|
<script src="/static/new.js?v={{ JS_HASH }}"></script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -54,5 +54,8 @@
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</footer>
|
</footer>
|
||||||
|
{% if is_admin %}
|
||||||
|
<script src="/static/common-admin.js?v={{ JS_HASH }}"></script>
|
||||||
|
{% endif %}
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -97,7 +97,7 @@
|
||||||
{% endmacro %}
|
{% endmacro %}
|
||||||
|
|
||||||
{% macro admin_delete_button(ap_object_id) %}
|
{% macro admin_delete_button(ap_object_id) %}
|
||||||
<form action="{{ request.url_for("admin_actions_delete") }}" method="POST" onsubmit="return confirm('Do you really want to delete this object?');">
|
<form action="{{ request.url_for("admin_actions_delete") }}" class="object-delete-form" method="POST">
|
||||||
{{ embed_csrf_token() }}
|
{{ embed_csrf_token() }}
|
||||||
{{ embed_redirect_url() }}
|
{{ embed_redirect_url() }}
|
||||||
<input type="hidden" name="ap_object_id" value="{{ ap_object_id }}">
|
<input type="hidden" name="ap_object_id" value="{{ ap_object_id }}">
|
||||||
|
|
Loading…
Reference in New Issue