From 2e9fd9c6b93a77dcf5caa42a4d71b9da2021693f Mon Sep 17 00:00:00 2001 From: Tom Christie Date: Fri, 28 Jan 2011 09:14:04 +0000 Subject: [PATCH] Minor fixups on pygments example --- .hgignore | 3 +++ examples/initial_data.json | 20 -------------------- examples/pygments_api/views.py | 6 +++--- examples/settings.py | 2 +- examples/urls.py | 2 +- 5 files changed, 8 insertions(+), 25 deletions(-) delete mode 100644 examples/initial_data.json diff --git a/.hgignore b/.hgignore index 0676dcf70..3b9fa9fd3 100644 --- a/.hgignore +++ b/.hgignore @@ -2,9 +2,12 @@ syntax: glob *.pyc *.db +*~ env docs-build html +examples/media/pygments/* +examples/media/objectstore/* .project .pydevproject .settings diff --git a/examples/initial_data.json b/examples/initial_data.json deleted file mode 100644 index 62103cf97..000000000 --- a/examples/initial_data.json +++ /dev/null @@ -1,20 +0,0 @@ -[ - { - "pk": 1, - "model": "auth.user", - "fields": { - "username": "admin", - "first_name": "", - "last_name": "", - "is_active": true, - "is_superuser": true, - "is_staff": true, - "last_login": "2010-01-01 00:00:00", - "groups": [], - "user_permissions": [], - "password": "sha1$6cbce$e4e808893d586a3301ac3c14da6c84855999f1d8", - "email": "test@example.com", - "date_joined": "2010-01-01 00:00:00" - } - } -] \ No newline at end of file diff --git a/examples/pygments_api/views.py b/examples/pygments_api/views.py index 01f1b4b64..02f541f3a 100644 --- a/examples/pygments_api/views.py +++ b/examples/pygments_api/views.py @@ -38,15 +38,15 @@ class PygmentsRoot(Resource): if not os.path.exists(pathname): # We only need to generate the file if it doesn't already exist. - title = content['title'] if content['title'] else None + options = {'title': content['title']} if content['title'] else {} linenos = 'table' if content['linenos'] else False lexer = get_lexer_by_name(content['lexer']) - formatter = HtmlFormatter(style=content['style'], linenos=linenos, full=True, title=title) + formatter = HtmlFormatter(style=content['style'], linenos=linenos, full=True, **options) with open(pathname, 'w') as outfile: highlight(content['code'], lexer, formatter, outfile) - return Response(status.HTTP_303_SEE_OTHER, headers={'Location': self.reverse(PygmentsInstance, unique_id)}) + return Response(status.HTTP_201_CREATED, headers={'Location': self.reverse(PygmentsInstance, unique_id)}) class PygmentsInstance(Resource): diff --git a/examples/settings.py b/examples/settings.py index ea97d1924..0ae3bf562 100644 --- a/examples/settings.py +++ b/examples/settings.py @@ -48,7 +48,7 @@ USE_L10N = True # Absolute filesystem path to the directory that will hold user-uploaded files. # Example: "/home/media/media.lawrence.com/" -MEDIA_ROOT = '/Users/tomchristie/' +MEDIA_ROOT = 'media/' # URL that handles the media served from MEDIA_ROOT. Make sure to use a # trailing slash if there is a path component (optional in other cases). diff --git a/examples/urls.py b/examples/urls.py index 5e308f00b..b1dec13d5 100644 --- a/examples/urls.py +++ b/examples/urls.py @@ -4,7 +4,7 @@ from django.contrib import admin admin.autodiscover() urlpatterns = patterns('', - (r'pygments-example/', include('pygments_api.urls')), + (r'^pygments-example/', include('pygments_api.urls')), (r'^blog-post-example/', include('blogpost.urls')), (r'^object-store-example/', include('objectstore.urls')), (r'^accounts/login/$', 'django.contrib.auth.views.login'),