aboutsummaryrefslogtreecommitdiffstats
path: root/sneak_peek_tag
diff options
context:
space:
mode:
authorTeddy Wing2014-04-20 00:20:55 -0400
committerTeddy Wing2014-04-20 00:20:55 -0400
commit75fa16196e8b304d4c35581850bba8311f5dd1ed (patch)
tree6c12966fb26b2a508b700cefd1670a964a1e078b /sneak_peek_tag
parent97f1a5787085bd52bcea28edf10204bd9c2d43d2 (diff)
downloaddjango-sneak-peek-75fa16196e8b304d4c35581850bba8311f5dd1ed.tar.bz2
Add sneak_peek app
Includes: * Template tag * Static resources
Diffstat (limited to 'sneak_peek_tag')
-rw-r--r--sneak_peek_tag/__init__.py0
-rw-r--r--sneak_peek_tag/static/sneak_peek_tag/css/sneak-peek.css18
-rwxr-xr-xsneak_peek_tag/static/sneak_peek_tag/images/sneak-peek-border-image.pngbin0 -> 991 bytes
-rw-r--r--sneak_peek_tag/templatetags/__init__.py0
-rw-r--r--sneak_peek_tag/templatetags/sneak_peek.py36
5 files changed, 54 insertions, 0 deletions
diff --git a/sneak_peek_tag/__init__.py b/sneak_peek_tag/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/sneak_peek_tag/__init__.py
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
--- /dev/null
+++ b/sneak_peek_tag/static/sneak_peek_tag/images/sneak-peek-border-image.png
Binary files differ
diff --git a/sneak_peek_tag/templatetags/__init__.py b/sneak_peek_tag/templatetags/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/sneak_peek_tag/templatetags/__init__.py
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 = """<div class="sneak-peek %s">
+ %s
+ </div>""" % (self.style, content)
+ return wrapped_hidden_feature
+ else:
+ return ''