Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

initial import from anime

  • Loading branch information...
commit 9e189cb74b8900abcebf758018886061e08edcca 0 parents
@carljm carljm authored
27 LICENSE
@@ -0,0 +1,27 @@
+Copyright (c) 2010, Eldarion, Inc.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without modification,
+are permitted provided that the following conditions are met:
+
+ * Redistributions of source code must retain the above copyright notice,
+ this list of conditions and the following disclaimer.
+
+ * Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ * Neither the name of Eldarion, Inc. nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1  MANIFEST.in
@@ -0,0 +1 @@
+include README.rst
5 README.rst
@@ -0,0 +1,5 @@
+============
+boxes README
+============
+
+An app for including boxes of admin-controllable content in templates.
0  boxes/__init__.py
No changes.
6 boxes/admin.py
@@ -0,0 +1,6 @@
+from django.contrib import admin
+
+from boxes.models import Box
+
+
+admin.site.register(Box)
16 boxes/fixture_gen.py
@@ -0,0 +1,16 @@
+from django.conf import settings
+
+from fixture_generator import fixture_generator
+
+from boxes.models import Box
+
+
+@fixture_generator(Box)
+def initial_data():
+ Box.objects.create(label="home_sidebar_title", content="Welcome to our Alpha v1")
+ Box.objects.create(label="home_sidebar_content", content="admin conrolled message/html here. (note to self: add twitter and moro links here)")
+ Box.objects.create(label="ad_300", content="""
+ <a href="#">
+ <img src="%(STATIC_URL)simg/a/ads/ani-ad-main.jpg" alt="Ad" />
+ </a>""" % {"STATIC_URL": settings.STATIC_URL}
+ )
9 boxes/models.py
@@ -0,0 +1,9 @@
+from django.db import models
+
+
+class Box(models.Model):
+ label = models.CharField(max_length=100, db_index=True)
+ content = models.TextField()
+
+ def __unicode__(self):
+ return self.label
0  boxes/templatetags/__init__.py
No changes.
25 boxes/templatetags/boxes_tags.py
@@ -0,0 +1,25 @@
+import textile
+
+from django import template
+from django.template.loader import render_to_string
+from django.utils.safestring import mark_safe
+
+from templatetag_sugar.register import tag
+from templatetag_sugar.parser import Name, Variable, Constant, Optional, Model
+
+from boxes.models import Box
+from anime.utils import sanitize_html
+
+
+register = template.Library()
+
+@tag(register, [Variable(), Optional([Variable()])])
+def box(context, label, plain_html=False):
+ try:
+ box = Box.objects.get(label=label)
+ except Box.DoesNotExist:
+ return ""
+ content = box.content.strip()
+ if plain_html:
+ return content
+ return textile.textile(sanitize_html(content))
1  requirements.txt
@@ -0,0 +1 @@
+django-app-test-runner
26 setup.py
@@ -0,0 +1,26 @@
+from distutils.core import setup
+
+
+setup(
+ name = "boxes",
+ version = "0.1.dev1",
+ author = "Eldarion",
+ author_email = "development@eldarion.com",
+ description = "a reusable Django content-boxes application",
+ long_description = open("README.rst").read(),
+ license = "BSD",
+ url = "http://github.com/eldarion/boxes",
+ packages = [
+ "boxes",
+ "boxes.templatetags",
+ ],
+ classifiers = [
+ "Development Status :: 3 - Alpha",
+ "Environment :: Web Environment",
+ "Intended Audience :: Developers",
+ "License :: OSI Approved :: BSD License",
+ "Operating System :: OS Independent",
+ "Programming Language :: Python",
+ "Framework :: Django",
+ ]
+)
Please sign in to comment.
Something went wrong with that request. Please try again.