Skip to content

Commit

Permalink
Merge branch 'master' of github.com:hasgeek/baseframe into filter-cle…
Browse files Browse the repository at this point in the history
…anurl
  • Loading branch information
iambibhas committed Aug 25, 2020
2 parents 2d20465 + 66d1f1c commit 85c22df
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions baseframe/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
from flask_babelhg import Babel, Domain, ctx_has_locale
from speaklater import is_lazy_string

from babel import Locale
from flask_caching import Cache
from furl import furl
from pytz import UTC, timezone
Expand Down Expand Up @@ -111,6 +112,8 @@ def default(self, o):
return o.zone
if isinstance(o, (date, datetime, time)):
return o.isoformat()
if isinstance(o, Locale):
return str(o)
if isinstance(o, abc.Mapping):
return dict(o)
if isinstance(o, furl):
Expand Down
7 changes: 7 additions & 0 deletions baseframe/filters.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -*- coding: utf-8 -*-

from __future__ import unicode_literals
from six.moves.urllib.parse import urlsplit, urlunsplit
import six

from datetime import datetime, timedelta
Expand Down Expand Up @@ -293,3 +294,9 @@ def cleanurl_filter(url):
url = furl(url)
url.path.normalize()
return furl().set(netloc=url.netloc, path=url.path).url.lstrip('//').rstrip('/')


@baseframe.app_template_filter('make_relative_url')
def make_relative_url(url):
"""Filter to discard scheme and netloc from a URL, used to undo _external=True"""
return urlunsplit(urlsplit(url)._replace(scheme='', netloc=''))
2 changes: 1 addition & 1 deletion baseframe/templates/baseframe/mui/components.html.jinja2
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{%- macro faicon(icon, icon_size='body', baseline=true, css_class='') -%}
{% assets "fa5-sprite" %}<svg class="fa5-icon {%- if icon_size %} fa5-icon--{{icon_size}} {%- endif -%} {%- if baseline %} fa5--align-baseline {%- endif -%} {%- if css_class %} {{ css_class }} {%- endif -%}" aria-hidden="true" role="img"><use xlink:href="{{ ASSET_URL }}#{{icon}}"></use></svg>{% endassets %}
{% assets "fa5-sprite" %}<svg class="fa5-icon {%- if icon_size %} fa5-icon--{{icon_size}} {%- endif -%} {%- if baseline %} fa5--align-baseline {%- endif -%} {%- if css_class %} {{ css_class }} {%- endif -%}" aria-hidden="true" role="img"><use xlink:href="{{ ASSET_URL|make_relative_url }}#{{icon}}"></use></svg>{% endassets %}
{%- endmacro %}

{%- macro alertbox(category, message="") %}
Expand Down

0 comments on commit 85c22df

Please sign in to comment.