Mercurial > libervia-web
view libervia/pages/lists/_browser/__init__.py @ 1457:792a2e902ee9
server: fix inverse URL redirection for root path + allow multiple inverse redirections:
- inverse redirection is now working for root path
- a list can now be used in `url_redirections_dict`: the first item only will be used for
redirection, but all items will be used for inverse redirection.
e.g.: if in `url_redirections_dict` we have `"/": ["/u/some_user/blog",
"/blog/view/some_user_jid@example.org"]`, root will redirect to "/u/some_user/blog", but
both "/u/some_user/blog" and "/blog/view/some_user_jid@example.org" will have an inverse
redirection to the root path
fix 395
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 29 Sep 2021 17:39:06 +0200 |
parents | 72f9639594b2 |
children | 106bae41f5c8 |
line wrap: on
line source
from browser import DOMNode, document, aio from javascript import JSON from aio_bridge import Bridge, BridgeException import dialog bridge = Bridge() async def on_delete(evt): evt.stopPropagation() evt.preventDefault() target = evt.currentTarget item_elt = DOMNode(target.closest('.item')) item_elt.classList.add("selected_for_deletion") item = JSON.parse(item_elt.dataset.item) confirmed = await dialog.Confirm( f"List {item['name']!r} will be deleted, are you sure?", ok_label="delete", ).ashow() if not confirmed: item_elt.classList.remove("selected_for_deletion") return try: await bridge.interestRetract("", item['id']) except BridgeException as e: dialog.notification.show( f"Can't remove list {item['name']!r} from personal interests: {e}", "error" ) else: print(f"{item['name']!r} removed successfuly from list of interests") item_elt.classList.add("state_deleted") item_elt.bind("transitionend", lambda evt: item_elt.remove()) if item.get("creator", False): try: await bridge.psNodeDelete( item['service'], item['node'], ) except BridgeException as e: dialog.notification.show( f"Error while deleting {item['name']!r}: {e}", "error" ) else: dialog.notification.show(f"{item['name']!r} has been deleted") for elt in document.select('.action_delete'): elt.bind("click", lambda evt: aio.run(on_delete(evt)))