From 75fa16196e8b304d4c35581850bba8311f5dd1ed Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Sun, 20 Apr 2014 00:20:55 -0400 Subject: Add sneak_peek app Includes: * Template tag * Static resources --- sneak_peek_tag/__init__.py | 0 .../static/sneak_peek_tag/css/sneak-peek.css | 18 +++++++++++ .../images/sneak-peek-border-image.png | Bin 0 -> 991 bytes sneak_peek_tag/templatetags/__init__.py | 0 sneak_peek_tag/templatetags/sneak_peek.py | 36 +++++++++++++++++++++ 5 files changed, 54 insertions(+) create mode 100644 sneak_peek_tag/__init__.py create mode 100644 sneak_peek_tag/static/sneak_peek_tag/css/sneak-peek.css create mode 100755 sneak_peek_tag/static/sneak_peek_tag/images/sneak-peek-border-image.png create mode 100644 sneak_peek_tag/templatetags/__init__.py create mode 100644 sneak_peek_tag/templatetags/sneak_peek.py (limited to 'sneak_peek_tag') diff --git a/sneak_peek_tag/__init__.py b/sneak_peek_tag/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/sneak_peek_tag/static/sneak_peek_tag/css/sneak-peek.css b/sneak_peek_tag/static/sneak_peek_tag/css/sneak-peek.css new file mode 100644 index 0000000..e5f9eb8 --- /dev/null +++ b/sneak_peek_tag/static/sneak_peek_tag/css/sneak-peek.css @@ -0,0 +1,18 @@ +/* 'Under construction' border around sneak peek features */¬ +.django-sneak-peek {¬ +▸ border-style: solid;¬ +▸ border-width: 10px;¬ +▸ -moz-border-image: url('../images/sneak-peek-border-image.png') 10 round;¬ +▸ -webkit-border-image: url('../images/sneak-peek-border-image.png') 10 round;¬ +▸ -o-border-image: url('../images/sneak-peek-border-image.png') 10 round;¬ +▸ border-image: url('../images/sneak-peek-border-image.png') 10 round;¬ +}¬ +¬ +.django-sneak-peek.outline {¬ +▸ border: none;¬ +▸ outline: 10px dashed #fbe500;¬ +}¬ +¬ +.django-sneak-peek.borderless {¬ +▸ border: none;¬ +}¬ diff --git a/sneak_peek_tag/static/sneak_peek_tag/images/sneak-peek-border-image.png b/sneak_peek_tag/static/sneak_peek_tag/images/sneak-peek-border-image.png new file mode 100755 index 0000000..8020abe Binary files /dev/null and b/sneak_peek_tag/static/sneak_peek_tag/images/sneak-peek-border-image.png differ diff --git a/sneak_peek_tag/templatetags/__init__.py b/sneak_peek_tag/templatetags/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/sneak_peek_tag/templatetags/sneak_peek.py b/sneak_peek_tag/templatetags/sneak_peek.py new file mode 100644 index 0000000..9a0faa4 --- /dev/null +++ b/sneak_peek_tag/templatetags/sneak_peek.py @@ -0,0 +1,36 @@ +from django.template import Library, Node + +register = Library() + +@register.tag(name="sneak_peek") +def sneak_peek(parser, token): + tag = None + style = 'default' + try: + tag, style = token.split_contents() + except ValueError: + pass + nodelist = parser.parse(('endsneak_peek',)) + parser.delete_first_token() + return SneakPeekWrapper(nodelist, style) + + +class SneakPeekWrapper(Node): + def __init__(self, nodelist, style): + self.nodelist = nodelist + self.style = style + + def render(self, context): + user = context['request'].user + + # TODO: update with permission check on user + user_is_blessed = True + + if user_is_blessed: + content = self.nodelist.render(context) + wrapped_hidden_feature = """