Permalink
Browse files

added pygmentize, quote detail/list, refactored settings a bit, add r…

…equirements app, and general push towards 0.2
  • Loading branch information...
1 parent f2c5e25 commit 7ef5c790c44b854d1007fc7e14dc38a461dda7ea @montylounge committed Sep 2, 2009
View
@@ -1,7 +1,7 @@
from django.db.models import signals
from django_proxy.signals import proxy_save, proxy_delete
from basic.blog.models import Post
-from basic.people.models import Quote
+from quoteme.models import Quote
from basic.bookmarks.models import Bookmark
signals.post_save.connect(proxy_save, Post, True)
@@ -1,20 +0,0 @@
-from django.conf import settings
-from django.http import *
-from django.views.debug import technical_500_response
-import sys
-
-class UserBasedExceptionMiddleware(object):
- '''
- Displays Django debugging messaage based on active user's session.
-
- Requirement:
- Active user's' session must be an authenticated superuser, or make sure active
- user's IP address is in INTERNAL_IPs for the error message to display. Otherwise
- user will receive the configured server response, which is normally a "friendly"
- 500 server error page.
-
- Source: http://ericholscher.com/blog/2008/nov/15/debugging-django-production-environments/
- '''
- def process_exception(self, request, exception):
- if request.user.is_superuser or request.META.get('REMOTE_ADDR') in settings.INTERNAL_IPS:
- return technical_500_response(request, *sys.exc_info())
View
@@ -24,24 +24,24 @@ def post_result_item(post):
'url': settings.SITE_URL + post.get_absolute_url(),
'text': post.body,
}
-
+
def springsteen_results(request):
'''
- Creates the django-springsteen compliant JSON results for only for findjango
+ Creates the django-springsteen compliant JSON results for only for findjango
integration.
-
+
Results:
Published Post objects.
'''
results = [ post_result_item(item) for item in Post.objects.published()[:50] ]
response_dict = { 'total_results': Post.objects.published().count(), 'results': results, }
return HttpResponse(simplejson.dumps(response_dict), mimetype='application/javascript')
-
-
+
+
def server_error(request, template_name='500.html'):
'''Handles displaying 500 server error page along with application MEDIA.'''
-
+
t = loader.get_template(template_name)
return http.HttpResponseServerError(t.render(Context({
"MEDIA_URL": settings.MEDIA_URL,
@@ -51,35 +51,35 @@ def server_error(request, template_name='500.html'):
def springsteen_firehose(request):
'''Generates django-springsteen compliant JSON results of proxy models for findjango integration.'''
-
+
def result_item(proxy):
'''Generates the item result object.'''
-
+
if proxy.content_type.name == 'bookmark':
url = proxy.content_object.get_absolute_url()
else:
url = settings.SITE_URL + proxy.content_object.get_absolute_url()
-
+
return {
'title': proxy.title,
'url': url,
'text': proxy.description,
}
-
+
posts = Proxy.objects.published()[:50].order_by('-pub_date')
results = [ result_item(item) for item in posts ]
response_dict = { 'total_results': Proxy.objects.published().count(), 'results': results, }
return HttpResponse(simplejson.dumps(response_dict), mimetype='application/javascript')
-
+
def springsteen_category(request, slug):
'''
- Creates the django-springsteen compliant JSON results for only for findjango
+ Creates the django-springsteen compliant JSON results for only for findjango
integration.
-
+
Results:
Published Post objects by category.
'''
-
+
category = get_object_or_404(Category, slug__iexact=slug)
posts = category.post_set.published()[:50]
results = [ post_result_item(item) for item in posts ]
@@ -91,17 +91,17 @@ def springsteen_category(request, slug):
def home_list(request, page=0, template_name='proxy/proxy_list.html', **kwargs):
'''
Homepage.
-
+
Template: ``proxy/proxy_list.html``
Context:
object_list
Aggregated list of Proxy instances (post, quote, bookmark).
-
+
'''
-
- posts = Proxy.objects.published().order_by('-pub_date')
+
+ posts = Proxy.objects.published().order_by('-pub_date')
pagesize = Settings.get_current().page_size or 20
-
+
return list_detail.object_list(
request,
queryset = posts,
@@ -110,8 +110,40 @@ def home_list(request, page=0, template_name='proxy/proxy_list.html', **kwargs):
template_name = template_name,
**kwargs
)
-
-
+
+
+def quote_list(request, template_name='quotes/quote_list.html', **kwargs):
+ '''
+ A basic cxample of overriding a reusable apps view to customize.
+
+ Displays quote list view. No paging added, but can be on your own.
+ '''
+
+ from quoteme.views import quote_list
+ favorite_jazz_album = getattr(settings, 'FAVORITE_JAZZ_ALBUM', 'Money Jungle')
+ extra = {
+ 'favorite_jazz_album': favorite_jazz_album,
+ }
+
+ return quote_list(request, template_name=template_name, extra_context=extra, **kwargs)
+
+
+def quote_detail(request, template_name='quotes/quote_detail.html', **kwargs):
+ '''
+ A basic cxample of overriding a reusable apps view to customize.
+
+ Displays quote detail view.
+ '''
+
+ from quoteme.views import quote_detail
+ favorite_food = getattr(settings, 'FAVORITE_FOOD', 'Pizza')
+ extra = {
+ 'favorite_food': favorite_food,
+ }
+
+ return quote_detail(request, template_name=template_name, extra_context=extra, **kwargs)
+
+
@check_honeypot
def contact_form(request, form_class=ContactForm,
template_name='contact_form/contact_form.html'):
@@ -1 +1 @@
-[{"pk": 1, "model": "flatblocks.flatblock", "fields": {"content": "Powered by <a href=\"http://bitbucket.org/montylounge/django-mingus/\" title=\"Mingus blog engine\">Mingus</a> a <a href=\"http://djangoproject.com\" title=\"Django - web framework for perfectionists with deadlines.\">Django</a> project. You're enjoying the Basic theme.", "header": "", "slug": "footer"}}, {"pk": 1, "model": "blog.category", "fields": {"slug": "django", "title": "Django"}}, {"pk": 1, "model": "blog.post", "fields": {"body": "Welcome to django-mingus powered blog engine.", "status": 2, "allow_comments": true, "author": null, "markup": "markdown", "tease": "Hello world.", "modified": "2009-08-23 23:51:31", "publish": "2009-08-23 23:49:32", "created": "2009-08-23 23:51:31", "body_markup": "<p>Welcome to django-mingus powered blog engine.\n</p>", "categories": [1], "title": "Welcome to Mingus", "slug": "welcome-mingus", "tags": "django, django-mingus, blog"}}, {"pk": 1, "model": "blog.settings", "fields": {"meta_description": "A blog engine powered by Mingus, a Django project.", "rss_url": "http://127.0.0.1:8000/feeds/latest/", "about": "This is a little bit about myself for the right hand rail.", "meta_keywords": "Blog, blog engine, Django, django-mingus.", "site_name": "example.com", "copyright": "Acme LLC.", "twitter_url": "http://twitter.com/YOURUSERNAME", "ping_google": true, "site": 1, "author_name": "Jane Shmoe", "page_size": 20, "disqus_shortname": "", "email_subscribe_url": ""}}, {"pk": 1, "model": "blog.blogroll", "fields": {"url": "http://blog.montylounge.com/", "sort_order": 0, "name": "Montylounge"}}, {"pk": 1, "model": "elsewhere.socialnetworkprofile", "fields": {"url": "http://github.com/montylounge", "category": 1, "sort_order": 0, "name": "Github", "description": ""}}, {"pk": 1, "model": "elsewhere.category", "fields": {"sort_order": 0, "title": "Development"}}, {"pk": 1, "model": "tagging.tag", "fields": {"name": "blog"}}, {"pk": 2, "model": "tagging.tag", "fields": {"name": "django"}}, {"pk": 3, "model": "tagging.tag", "fields": {"name": "django-mingus"}}, {"pk": 1, "model": "tagging.taggeditem", "fields": {"tag": 1, "object_id": 1, "content_type": 15}}, {"pk": 2, "model": "tagging.taggeditem", "fields": {"tag": 2, "object_id": 1, "content_type": 15}}, {"pk": 3, "model": "tagging.taggeditem", "fields": {"tag": 3, "object_id": 1, "content_type": 15}}, {"pk": 1, "model": "navbar.navbarentry", "fields": {"name": "about", "parent": null, "title": "about", "url": "/about/", "user_type": "E", "groups": [], "path_type": "A", "order": 0}}, {"pk": 2, "model": "navbar.navbarentry", "fields": {"name": "contact", "parent": null, "title": "contact", "url": "/contact/", "user_type": "E", "groups": [], "path_type": "A", "order": 1}}, {"pk": 1, "model": "flatpages.flatpage", "fields": {"registration_required": false, "title": "About", "url": "/about/", "template_name": "", "sites": [1], "content": "A little about yourself here.", "enable_comments": false}}]
+[{"pk": 1, "model": "flatblocks.flatblock", "fields": {"content": "Powered by <a href=\"http://github.com/montylounge/django-mingus/tree/master\" title=\"Django-Mingus blog engine\">Django-Mingus</a> a <a href=\"http://djangoproject.com\" title=\"Django - web framework for perfectionists with deadlines.\">Django</a> project. You're enjoying the Basic theme.", "header": "", "slug": "footer"}}, {"pk": 1, "model": "blog.category", "fields": {"slug": "django", "title": "Django"}}, {"pk": 1, "model": "blog.post", "fields": {"body": "Welcome to django-mingus powered blog engine.", "status": 2, "allow_comments": true, "author": null, "markup": "markdown", "tease": "Hello world.", "modified": "2009-08-23 23:51:31", "publish": "2009-08-23 23:49:32", "created": "2009-08-23 23:51:31", "body_markup": "<p>Welcome to django-mingus powered blog engine.\n</p>", "categories": [1], "title": "Welcome to Mingus", "slug": "welcome-mingus", "tags": "django, django-mingus, blog"}}, {"pk": 1, "model": "blog.settings", "fields": {"meta_description": "A blog engine powered by Mingus, a Django project.", "rss_url": "http://127.0.0.1:8000/feeds/latest/", "about": "This is a little bit about myself for the right hand rail.", "meta_keywords": "Blog, blog engine, Django, django-mingus.", "site_name": "example.com", "copyright": "Acme LLC.", "twitter_url": "http://twitter.com/YOURUSERNAME", "ping_google": true, "site": 1, "author_name": "Jane Shmoe", "page_size": 20, "disqus_shortname": "", "email_subscribe_url": ""}}, {"pk": 1, "model": "blog.blogroll", "fields": {"url": "http://blog.montylounge.com/", "sort_order": 0, "name": "Montylounge"}}, {"pk": 1, "model": "elsewhere.socialnetworkprofile", "fields": {"url": "http://github.com/montylounge", "category": 1, "sort_order": 0, "name": "Github", "description": ""}}, {"pk": 1, "model": "elsewhere.category", "fields": {"sort_order": 0, "title": "Development"}}, {"pk": 1, "model": "tagging.tag", "fields": {"name": "blog"}}, {"pk": 2, "model": "tagging.tag", "fields": {"name": "django"}}, {"pk": 3, "model": "tagging.tag", "fields": {"name": "django-mingus"}}, {"pk": 1, "model": "tagging.taggeditem", "fields": {"tag": 1, "object_id": 1, "content_type": 15}}, {"pk": 2, "model": "tagging.taggeditem", "fields": {"tag": 2, "object_id": 1, "content_type": 15}}, {"pk": 3, "model": "tagging.taggeditem", "fields": {"tag": 3, "object_id": 1, "content_type": 15}}, {"pk": 1, "model": "navbar.navbarentry", "fields": {"name": "about", "parent": null, "title": "about", "url": "/about/", "user_type": "E", "groups": [], "path_type": "A", "order": 0}}, {"pk": 2, "model": "navbar.navbarentry", "fields": {"name": "contact", "parent": null, "title": "contact", "url": "/contact/", "user_type": "E", "groups": [], "path_type": "A", "order": 1}}, {"pk": 1, "model": "flatpages.flatpage", "fields": {"registration_required": false, "title": "About", "url": "/about/", "template_name": "", "sites": [1], "content": "A little about yourself here.", "enable_comments": false}}]
@@ -0,0 +1,62 @@
+.highlight .hll { background-color: #ffffcc }
+.highlight { background: #f0f0f0; }
+.highlight .c { color: #60a0b0; font-style: italic } /* Comment */
+.highlight .err { border: 1px solid #FF0000 } /* Error */
+.highlight .k { color: #007020; font-weight: bold } /* Keyword */
+.highlight .o { color: #666666 } /* Operator */
+.highlight .cm { color: #60a0b0; font-style: italic } /* Comment.Multiline */
+.highlight .cp { color: #007020 } /* Comment.Preproc */
+.highlight .c1 { color: #60a0b0; font-style: italic } /* Comment.Single */
+.highlight .cs { color: #60a0b0; background-color: #fff0f0 } /* Comment.Special */
+.highlight .gd { color: #A00000 } /* Generic.Deleted */
+.highlight .ge { font-style: italic } /* Generic.Emph */
+.highlight .gr { color: #FF0000 } /* Generic.Error */
+.highlight .gh { color: #000080; font-weight: bold } /* Generic.Heading */
+.highlight .gi { color: #00A000 } /* Generic.Inserted */
+.highlight .go { color: #808080 } /* Generic.Output */
+.highlight .gp { color: #c65d09; font-weight: bold } /* Generic.Prompt */
+.highlight .gs { font-weight: bold } /* Generic.Strong */
+.highlight .gu { color: #800080; font-weight: bold } /* Generic.Subheading */
+.highlight .gt { color: #0040D0 } /* Generic.Traceback */
+.highlight .kc { color: #007020; font-weight: bold } /* Keyword.Constant */
+.highlight .kd { color: #007020; font-weight: bold } /* Keyword.Declaration */
+.highlight .kn { color: #007020; font-weight: bold } /* Keyword.Namespace */
+.highlight .kp { color: #007020 } /* Keyword.Pseudo */
+.highlight .kr { color: #007020; font-weight: bold } /* Keyword.Reserved */
+.highlight .kt { color: #902000 } /* Keyword.Type */
+.highlight .m { color: #40a070 } /* Literal.Number */
+.highlight .s { color: #4070a0 } /* Literal.String */
+.highlight .na { color: #4070a0 } /* Name.Attribute */
+.highlight .nb { color: #007020 } /* Name.Builtin */
+.highlight .nc { color: #0e84b5; font-weight: bold } /* Name.Class */
+.highlight .no { color: #60add5 } /* Name.Constant */
+.highlight .nd { color: #555555; font-weight: bold } /* Name.Decorator */
+.highlight .ni { color: #d55537; font-weight: bold } /* Name.Entity */
+.highlight .ne { color: #007020 } /* Name.Exception */
+.highlight .nf { color: #06287e } /* Name.Function */
+.highlight .nl { color: #002070; font-weight: bold } /* Name.Label */
+.highlight .nn { color: #0e84b5; font-weight: bold } /* Name.Namespace */
+.highlight .nt { color: #062873; font-weight: bold } /* Name.Tag */
+.highlight .nv { color: #bb60d5 } /* Name.Variable */
+.highlight .ow { color: #007020; font-weight: bold } /* Operator.Word */
+.highlight .w { color: #bbbbbb } /* Text.Whitespace */
+.highlight .mf { color: #40a070 } /* Literal.Number.Float */
+.highlight .mh { color: #40a070 } /* Literal.Number.Hex */
+.highlight .mi { color: #40a070 } /* Literal.Number.Integer */
+.highlight .mo { color: #40a070 } /* Literal.Number.Oct */
+.highlight .sb { color: #4070a0 } /* Literal.String.Backtick */
+.highlight .sc { color: #4070a0 } /* Literal.String.Char */
+.highlight .sd { color: #4070a0; font-style: italic } /* Literal.String.Doc */
+.highlight .s2 { color: #4070a0 } /* Literal.String.Double */
+.highlight .se { color: #4070a0; font-weight: bold } /* Literal.String.Escape */
+.highlight .sh { color: #4070a0 } /* Literal.String.Heredoc */
+.highlight .si { color: #70a0d0; font-style: italic } /* Literal.String.Interpol */
+.highlight .sx { color: #c65d09 } /* Literal.String.Other */
+.highlight .sr { color: #235388 } /* Literal.String.Regex */
+.highlight .s1 { color: #4070a0 } /* Literal.String.Single */
+.highlight .ss { color: #517918 } /* Literal.String.Symbol */
+.highlight .bp { color: #007020 } /* Name.Builtin.Pseudo */
+.highlight .vc { color: #bb60d5 } /* Name.Variable.Class */
+.highlight .vg { color: #bb60d5 } /* Name.Variable.Global */
+.highlight .vi { color: #bb60d5 } /* Name.Variable.Instance */
+.highlight .il { color: #40a070 } /* Literal.Number.Integer.Long */
@@ -4,6 +4,7 @@ python-dateutil==1.4.1
django==1.1
django-debug-toolbar==0.7
django-tagging==0.3
+Pygments==1.0
-e git+git://github.com/django-extensions/django-extensions.git#egg=django_extensions
-e svn+http://svn.aeracode.org/svn/south/trunk#egg=south
@@ -26,3 +27,5 @@ django-tagging==0.3
-e hg+https://bitbucket.org/ubernostrum/django-contact-form/#egg=contact_form
-e git+git://github.com/sunlightlabs/django-honeypot.git#egg=honeypot
-e git+git://github.com/montylounge/django-sugar.git#egg=sugar
+-e git+git://github.com/chrisdrackett/python-textile.git#egg=textile
+-e git+git://github.com/montylounge/django-quoteme.git#egg=quoteme
View
@@ -7,7 +7,7 @@
MEDIA_URL = '/media/'
STATIC_ROOT = join(MEDIA_ROOT, 'static')
STATIC_URL = '/media/static/'
-ADMIN_MEDIA_PREFIX = '/admin_media/'
+ADMIN_MEDIA_PREFIX = '/admin_media/'
SITE_ID=1
ROOT_URLCONF = 'mingus.urls'
@@ -21,7 +21,7 @@
)
TEMPLATE_DIRS = (
- [os.path.join(PROJECT_ROOT, "templates")]
+ [os.path.join(PROJECT_ROOT, "templates")]
)
MIDDLEWARE_CLASSES = (
@@ -30,7 +30,7 @@
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.doc.XViewMiddleware',
'django.contrib.redirects.middleware.RedirectFallbackMiddleware',
-'mingus.core.middleware.UserBasedExceptionMiddleware',
+'sugar.middleware.debugging.UserBasedExceptionMiddleware',
'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
'djangodblog.DBLogMiddleware',
'debug_toolbar.middleware.DebugToolbarMiddleware',
@@ -55,18 +55,15 @@
'django.contrib.sitemaps',
'django.contrib.flatpages',
'django.contrib.redirects',
-
+
'django_extensions',
'tagging',
'djangodblog',
'disqus',
'basic.inlines',
'basic.blog',
'basic.bookmarks',
- 'basic.events',
'basic.media',
- 'basic.people',
- 'basic.places',
'oembed',
'flatblocks',
'south',
@@ -84,6 +81,7 @@
'contact_form',
'honeypot',
'sugar',
+ 'quoteme',
)
try:
Oops, something went wrong.

0 comments on commit 7ef5c79

Please sign in to comment.