X-Git-Url: https://git.mar77i.info/?a=blobdiff_plain;f=hub%2Futils.py;h=ae448ed8fb499a14c3c9ea486fcc1e59252fbe42;hb=16c0b1e580f2c92baf6882ec4dfa655c267d23b9;hp=c9d955cfa107e1e6cc01f5d7a7ea1b3d1e9a23d1;hpb=c0e574584af0d45070e5fa81fcbcd1dccc2c5a42;p=hublib diff --git a/hub/utils.py b/hub/utils.py index c9d955c..ae448ed 100644 --- a/hub/utils.py +++ b/hub/utils.py @@ -1,11 +1,17 @@ -from base64 import urlsafe_b64encode -from hashlib import sha3_512 +from pathlib import Path +from jinja2_simple_tags import StandaloneTag -def scramble(secret, value): - h = sha3_512() - h.update(f"{secret}{value}".encode()) - return urlsafe_b64encode(h.digest()).rstrip(b"=").decode("ascii") + +class StaticTag(StandaloneTag): + tags = {"static"} + + def render(self, filename="/", hubapp=None): + if not hubapp: + hubapp = self.context["hubapp"] + elif isinstance(hubapp, str): + hubapp = self.context["hubapp"].app.hubapps[hubapp] + return hubapp.uri_from(Path(filename)) def get_redis_pass(redis_conf):