Skip to content

Commit

Permalink
SVN was being a dick.
Browse files Browse the repository at this point in the history
  • Loading branch information
Clinton Ecker authored and Clinton Ecker committed Nov 15, 2009
0 parents commit 180c4f3
Show file tree
Hide file tree
Showing 18 changed files with 504 additions and 0 deletions.
3 changes: 3 additions & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
django-chunks was originally developed by Clint Ecker

Caching code suggested by Kevin Fricovsky (howiworkdaily.com)
27 changes: 27 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
Copyright (c) 2008, Clint Ecker
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 the <ORGANIZATION> 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.
58 changes: 58 additions & 0 deletions USAGE
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
Think of it as flatpages for small bits of reusable content you might want to
insert into your templates and manage from the admin interface.

This is really nothing more than a model and a template tag.

By adding `chunks` to your installed apps list in your Django project and
performing a `./manage.py syncdb`, you'll be able to add as many "keyed" bits
of content chunks to your site.

The idea here is that you can create a chunk of content, name it with a unique
key (for example: `home_page_left_bottom`) and then you can call this content
from a normal template.

Why would anyone want this?

It essentially allows someone to define "chunks" (I had wanted to call it
blocks, but that would be very confusing for obvious reasons) of content in
your template that can be directly edited from the awesome Django admin
interface. Throwing a rich text editor control on top of it make it even
easier.

Template tag usage:

{% load chunks %}
<html>
<head>
<title>Test</title>
</head>
<body>
<h1> Blah blah blah</h1>
<div id="sidebar">
...
</div>
<div id="left">
{% chunk "home_page_left" %}
</div>
<div id="right">
{% chunk "home_page_right" %}
</div>
</body>
</html>

This is really helpful in those cases where you want to use
`django.contrib.flatpages` but you need multiple content areas. I hope this
is helpful to people and I'll be making minor edits as I see them necessary.

Caching

If you want to cache the content of your chunks you can pass along a caching
time argument in your chunk tag. Example:

{% chunk "home_page_left" 3600 %}

The caching time is specified in seconds. For caching to work properly you
must configure a cache backend in your settings.py. See the Django
documentation for more information:

http://www.djangoproject.com/documentation/cache/
23 changes: 23 additions & 0 deletions chunks/.svn/all-wcprops
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
K 25
svn:wc:ra_dav:version-url
V 28
/svn/!svn/ver/7/trunk/chunks
END
admin.py
K 25
svn:wc:ra_dav:version-url
V 37
/svn/!svn/ver/7/trunk/chunks/admin.py
END
__init__.py
K 25
svn:wc:ra_dav:version-url
V 40
/svn/!svn/ver/5/trunk/chunks/__init__.py
END
models.py
K 25
svn:wc:ra_dav:version-url
V 38
/svn/!svn/ver/7/trunk/chunks/models.py
END
133 changes: 133 additions & 0 deletions chunks/.svn/entries
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
10

dir
7
https://django-chunks.googlecode.com/svn/trunk/chunks
https://django-chunks.googlecode.com/svn



2008-08-02T02:16:08.092826Z
7
clintecker














d8811138-1151-0410-9359-9732050ff79b

admin.py
file




2009-11-15T21:14:45.000000Z
2711c1332686f7431a0b478e39eb5f48
2008-08-02T02:16:08.092826Z
7
clintecker





















197

__init__.py
file




2009-11-15T21:14:45.000000Z
d41d8cd98f00b204e9800998ecf8427e
2008-08-02T01:24:52.110089Z
5
clintecker





















0

templatetags
dir

models.py
file




2009-11-15T21:14:45.000000Z
382745a7dd9525d3b8c3590d2dd28c93
2008-08-02T02:16:08.092826Z
7
clintecker





















454

Empty file.
8 changes: 8 additions & 0 deletions chunks/.svn/text-base/admin.py.svn-base
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from django.contrib import admin
from models import Chunk

class ChunkAdmin(admin.ModelAdmin):
list_display = ('key',)
search_fields = ('key', 'content')

admin.site.register(Chunk, ChunkAdmin)
14 changes: 14 additions & 0 deletions chunks/.svn/text-base/models.py.svn-base
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from django.db import models

class Chunk(models.Model):
"""
A Chunk is a piece of content associated
with a unique key that can be inserted into
any template with the use of a special template
tag
"""
key = models.CharField(help_text="A unique name for this chunk of content", blank=False, max_length=255, unique=True)
content = models.TextField(blank=True)

def __unicode__(self):
return u"%s" % (self.key,)
Empty file added chunks/__init__.py
Empty file.
8 changes: 8 additions & 0 deletions chunks/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
from django.contrib import admin
from models import Chunk

class ChunkAdmin(admin.ModelAdmin):
list_display = ('key',)
search_fields = ('key', 'content')

admin.site.register(Chunk, ChunkAdmin)
14 changes: 14 additions & 0 deletions chunks/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from django.db import models

class Chunk(models.Model):
"""
A Chunk is a piece of content associated
with a unique key that can be inserted into
any template with the use of a special template
tag
"""
key = models.CharField(help_text="A unique name for this chunk of content", blank=False, max_length=255, unique=True)
content = models.TextField(blank=True)

def __unicode__(self):
return u"%s" % (self.key,)
17 changes: 17 additions & 0 deletions chunks/templatetags/.svn/all-wcprops
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
K 25
svn:wc:ra_dav:version-url
V 41
/svn/!svn/ver/5/trunk/chunks/templatetags
END
chunks.py
K 25
svn:wc:ra_dav:version-url
V 51
/svn/!svn/ver/5/trunk/chunks/templatetags/chunks.py
END
__init__.py
K 25
svn:wc:ra_dav:version-url
V 53
/svn/!svn/ver/5/trunk/chunks/templatetags/__init__.py
END
Loading

0 comments on commit 180c4f3

Please sign in to comment.