mirror of
https://github.com/encode/django-rest-framework.git
synced 2024-11-22 17:47:04 +03:00
Minor fixups on pygments example
This commit is contained in:
parent
8e8547ff9a
commit
2e9fd9c6b9
|
@ -2,9 +2,12 @@ syntax: glob
|
||||||
|
|
||||||
*.pyc
|
*.pyc
|
||||||
*.db
|
*.db
|
||||||
|
*~
|
||||||
env
|
env
|
||||||
docs-build
|
docs-build
|
||||||
html
|
html
|
||||||
|
examples/media/pygments/*
|
||||||
|
examples/media/objectstore/*
|
||||||
.project
|
.project
|
||||||
.pydevproject
|
.pydevproject
|
||||||
.settings
|
.settings
|
||||||
|
|
|
@ -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"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
]
|
|
|
@ -38,15 +38,15 @@ class PygmentsRoot(Resource):
|
||||||
|
|
||||||
if not os.path.exists(pathname):
|
if not os.path.exists(pathname):
|
||||||
# We only need to generate the file if it doesn't already exist.
|
# 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
|
linenos = 'table' if content['linenos'] else False
|
||||||
lexer = get_lexer_by_name(content['lexer'])
|
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:
|
with open(pathname, 'w') as outfile:
|
||||||
highlight(content['code'], lexer, formatter, 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):
|
class PygmentsInstance(Resource):
|
||||||
|
|
|
@ -48,7 +48,7 @@ USE_L10N = True
|
||||||
|
|
||||||
# Absolute filesystem path to the directory that will hold user-uploaded files.
|
# Absolute filesystem path to the directory that will hold user-uploaded files.
|
||||||
# Example: "/home/media/media.lawrence.com/"
|
# 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
|
# 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).
|
# trailing slash if there is a path component (optional in other cases).
|
||||||
|
|
|
@ -4,7 +4,7 @@ from django.contrib import admin
|
||||||
admin.autodiscover()
|
admin.autodiscover()
|
||||||
|
|
||||||
urlpatterns = patterns('',
|
urlpatterns = patterns('',
|
||||||
(r'pygments-example/', include('pygments_api.urls')),
|
(r'^pygments-example/', include('pygments_api.urls')),
|
||||||
(r'^blog-post-example/', include('blogpost.urls')),
|
(r'^blog-post-example/', include('blogpost.urls')),
|
||||||
(r'^object-store-example/', include('objectstore.urls')),
|
(r'^object-store-example/', include('objectstore.urls')),
|
||||||
(r'^accounts/login/$', 'django.contrib.auth.views.login'),
|
(r'^accounts/login/$', 'django.contrib.auth.views.login'),
|
||||||
|
|
Loading…
Reference in New Issue
Block a user