From e44e8fb84d27d82d113737eca77b341777bd8043 Mon Sep 17 00:00:00 2001 From: Nick Sergeant Date: Sun, 4 Mar 2012 15:58:00 -0500 Subject: [PATCH] Lol --- .hgignore | 1 - media/images/snipt-tags-icon.png | Bin 0 -> 1159 bytes media/images/tags-icon.png | Bin 0 -> 1164 bytes snipt.css | 4026 ----------------- .../0002_auto__add_field_snipt_tags.py | 75 + ...ld_snipt_tags__add_field_snipt_old_tags.py | 103 + .../0007_auto__del_field_snipt_old_tags.py | 96 + snipts/templates/snipts/tags-public.html | 10 + snipts/templates/snipts/tags-user.html | 10 + utils/templatetags/__init__.py | 0 utils/templatetags/verbatim.py | 44 + 11 files changed, 338 insertions(+), 4027 deletions(-) create mode 100644 media/images/snipt-tags-icon.png create mode 100644 media/images/tags-icon.png delete mode 100644 snipt.css create mode 100644 snipts/migrations/0002_auto__add_field_snipt_tags.py create mode 100644 snipts/migrations/0006_auto__del_field_snipt_tags__add_field_snipt_old_tags.py create mode 100644 snipts/migrations/0007_auto__del_field_snipt_old_tags.py create mode 100644 snipts/templates/snipts/tags-public.html create mode 100644 snipts/templates/snipts/tags-user.html create mode 100644 utils/templatetags/__init__.py create mode 100644 utils/templatetags/verbatim.py diff --git a/.hgignore b/.hgignore index 67313ab..4872b47 100644 --- a/.hgignore +++ b/.hgignore @@ -2,4 +2,3 @@ media/cache media/css/style.css media/js/script.js -tags diff --git a/media/images/snipt-tags-icon.png b/media/images/snipt-tags-icon.png new file mode 100644 index 0000000000000000000000000000000000000000..ff1932d630a93b7449f758f3332c1b1d6725827c GIT binary patch literal 1159 zcmeAS@N?(olHy`uVBq!ia0vp^JV4CH!3HFy_x^nYq$EpRBT9nv(@M${i&7aJQ}UBi z6+Ckj(^G>|6H_V+Po~;1Ffc1+hD4M^`1)8S=jZArg4F0$^BXQ!4Z zB&DWj=GiK}-@RW+Av48RDcsc8z_-9TH6zobswg$M$}c3jDm&RSMakYy!KT6rXh3di zNuokUZcbjYRfVk**jy_h8zii+qySb@l5ML5aa4qFfP!;=QL2Keo`G(%fti7VnW3Jc zv5C34xsHO7fuVuEfswwUk*=Y+m9dePfq?=PC;@FNN=dT{a&d#&1?1T(Wt5Z@Sn2DR zmzV368|&p4rRy77T3Uk4Ff!5ws?aU2%qvN((9J7WhMC}!TAW;zSx}OhpQivaF)=B> zw8T~k=u(Imatq+b<`qMO2^e7d6^RA}m|mCsATTyCgZF_RLl@OtZ!KCq%Ix3G+B~*Wu2&j&+PHW{7*NWlaiK_{Vs}eqoS&V+6k|^Q=d` znVFf4FScz~(0s-m^t$1OWJfr&XglLkIfk2;9BSA*_A`Bq-N2jC70x8;&Tur2>1I;E zXP(9%Yy$Qv( literal 0 HcmV?d00001 diff --git a/media/images/tags-icon.png b/media/images/tags-icon.png new file mode 100644 index 0000000000000000000000000000000000000000..510067e97a9afedae33d59563e83a54833e431b1 GIT binary patch literal 1164 zcmeAS@N?(olHy`uVBq!ia0vp^JV4CH!3HFy_x^nYq$EpRBT9nv(@M${i&7aJQ}UBi z6+Ckj(^G>|6H_V+Po~;1Ffc1+hD4M^`1)8S=jZArg4F0$^BXQ!4Z zB&DWj=GiK}-@RW+Av48RDcsc8z_-9TH6zobswg$M$}c3jDm&RSMakYy!KT6rXh3di zNuokUZcbjYRfVk**jy_h8zii+qySb@l5ML5aa4qFfP!;=QL2Keo`G(%fti7VnW3Jc zv5C34xsHO7fuVuEfswwUk*=Y+m9dePfq?=PC;@FNN=dT{a&d#&1?1T(Wt5Z@Sn2DR zmzV368|&p4rRy77T3Uk4Ff!5ws?aU2%qvN((9J7WhMC}!TAW;zSx}OhpQivaF)=B> zw8T~k=u(Imatq+b<`qMO2^e7d6^RACs$`PS0`sDLqk^sM>jWPX9E{kBO^0Q zHxpN5m|mCsATTy$@#v|;(ZC3iW(Sce|JW`W$acsx zi#}%--OskkRidEz@`nH>tvdcCEFU!NxQ_hmNzAry$hpaPM2|(}H)HI_K2DE6j73Qe zKP(iFD)3n>Ym^BP_?39EWs$@>##JwQXQ}ZVRXETw??=NtarU6C4tF?0{z%=eWng4u YF#MHz_} +

Popular public tags

+ + diff --git a/snipts/templates/snipts/tags-user.html b/snipts/templates/snipts/tags-user.html new file mode 100644 index 0000000..588c6ac --- /dev/null +++ b/snipts/templates/snipts/tags-user.html @@ -0,0 +1,10 @@ +
+

{{ user.username }}'s tags

+ +
diff --git a/utils/templatetags/__init__.py b/utils/templatetags/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/utils/templatetags/verbatim.py b/utils/templatetags/verbatim.py new file mode 100644 index 0000000..a956607 --- /dev/null +++ b/utils/templatetags/verbatim.py @@ -0,0 +1,44 @@ +""" +jQuery templates use constructs like: + + {{if condition}} print something{{/if}} + +This, of course, completely screws up Django templates, +because Django thinks {{ and }} mean something. + +Wrap {% verbatim %} and {% endverbatim %} around those +blocks of jQuery templates and this will try its best +to output the contents with no changes. +""" + +from django import template + +register = template.Library() + + +class VerbatimNode(template.Node): + + def __init__(self, text): + self.text = text + + def render(self, context): + return self.text + + +@register.tag +def verbatim(parser, token): + text = [] + while 1: + token = parser.tokens.pop(0) + if token.contents == 'endverbatim': + break + if token.token_type == template.TOKEN_VAR: + text.append('{{') + elif token.token_type == template.TOKEN_BLOCK: + text.append('{%') + text.append(token.contents) + if token.token_type == template.TOKEN_VAR: + text.append('}}') + elif token.token_type == template.TOKEN_BLOCK: + text.append('%}') + return VerbatimNode(''.join(text))