Lexers
parent
93858732ae
commit
731685ef5f
|
@ -206,6 +206,9 @@ if not DEBUG:
|
||||||
SESSION_COOKIE_SECURE = True
|
SESSION_COOKIE_SECURE = True
|
||||||
CSRF_COOKIE_SECURE = True
|
CSRF_COOKIE_SECURE = True
|
||||||
|
|
||||||
|
# Messages
|
||||||
|
MESSAGE_STORAGE = 'django.contrib.messages.storage.cookie.CookieStorage'
|
||||||
|
|
||||||
# User absolute URLs
|
# User absolute URLs
|
||||||
ABSOLUTE_URL_OVERRIDES = {
|
ABSOLUTE_URL_OVERRIDES = {
|
||||||
'auth.user': lambda u: "/%s/" % u.username,
|
'auth.user': lambda u: "/%s/" % u.username,
|
||||||
|
|
|
@ -2,9 +2,9 @@ from django import template
|
||||||
|
|
||||||
from templatetag_sugar.register import tag
|
from templatetag_sugar.register import tag
|
||||||
from templatetag_sugar.parser import Variable, Constant
|
from templatetag_sugar.parser import Variable, Constant
|
||||||
from pygments.lexers import get_all_lexers
|
|
||||||
|
|
||||||
from snipts.models import Favorite, Snipt
|
from snipts.models import Favorite, Snipt
|
||||||
|
from snipts.utils import get_lexers_list
|
||||||
|
|
||||||
import hashlib
|
import hashlib
|
||||||
|
|
||||||
|
@ -44,13 +44,7 @@ def snipts_count_for_user(context):
|
||||||
|
|
||||||
@tag(register, [Constant('as'), Variable()])
|
@tag(register, [Constant('as'), Variable()])
|
||||||
def get_lexers(context, asvar):
|
def get_lexers(context, asvar):
|
||||||
|
context[asvar] = get_lexers_list()
|
||||||
lexers = list(get_all_lexers())
|
|
||||||
lexers.append(('Markdown', ('markdown',),))
|
|
||||||
lexers = sorted(lexers)
|
|
||||||
|
|
||||||
context[asvar] = lexers
|
|
||||||
|
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
from django.contrib.auth import authenticate, login
|
from django.contrib.auth import authenticate, login
|
||||||
from django.template.defaultfilters import slugify
|
from django.template.defaultfilters import slugify
|
||||||
from registration.signals import user_registered
|
from registration.signals import user_registered
|
||||||
|
from pygments.lexers import get_all_lexers
|
||||||
|
|
||||||
|
|
||||||
def slugify_uniquely(value, model, slugfield="slug"):
|
def slugify_uniquely(value, model, slugfield="slug"):
|
||||||
|
@ -22,5 +23,10 @@ def activate_user(user, request, **kwargs):
|
||||||
password=request.POST['password1'])
|
password=request.POST['password1'])
|
||||||
login(request, user)
|
login(request, user)
|
||||||
|
|
||||||
|
def get_lexers_list():
|
||||||
|
lexers = list(get_all_lexers())
|
||||||
|
lexers.append(('Markdown', ('markdown',),))
|
||||||
|
lexers = sorted(lexers)
|
||||||
|
return lexers
|
||||||
|
|
||||||
user_registered.connect(activate_user)
|
user_registered.connect(activate_user)
|
||||||
|
|
|
@ -203,3 +203,4 @@ def search(request, template='search/search.html', load_all=True, form_class=Mod
|
||||||
context.update(extra_context)
|
context.update(extra_context)
|
||||||
|
|
||||||
return render_to_response(template, context, context_instance=context_class(request))
|
return render_to_response(template, context, context_instance=context_class(request))
|
||||||
|
|
||||||
|
|
6
urls.py
6
urls.py
|
@ -1,11 +1,11 @@
|
||||||
|
from django.conf.urls.defaults import include, patterns, url
|
||||||
from django.views.generic.simple import direct_to_template
|
from django.views.generic.simple import direct_to_template
|
||||||
from registration.forms import RegistrationFormUniqueEmail
|
from registration.forms import RegistrationFormUniqueEmail
|
||||||
from django.http import HttpResponseRedirect
|
from django.http import HttpResponseRedirect
|
||||||
from django.conf.urls.defaults import *
|
|
||||||
from django.contrib import admin
|
from django.contrib import admin
|
||||||
from snipts.views import search
|
from snipts.views import search
|
||||||
from django.db.models import Q
|
|
||||||
from tastypie.api import Api
|
from tastypie.api import Api
|
||||||
|
from views import lexers
|
||||||
from snipts.api import *
|
from snipts.api import *
|
||||||
|
|
||||||
import admin as custom_admin
|
import admin as custom_admin
|
||||||
|
@ -32,6 +32,8 @@ urlpatterns = patterns('',
|
||||||
url(r'^404/$', direct_to_template, {'template': '404.html'}),
|
url(r'^404/$', direct_to_template, {'template': '404.html'}),
|
||||||
url(r'^500/$', direct_to_template, {'template': '500.html'}),
|
url(r'^500/$', direct_to_template, {'template': '500.html'}),
|
||||||
|
|
||||||
|
url(r'^api/public/lexers/$', lexers),
|
||||||
|
|
||||||
url(r'^api/', include(public_api.urls)),
|
url(r'^api/', include(public_api.urls)),
|
||||||
url(r'^api/', include(private_api.urls)),
|
url(r'^api/', include(private_api.urls)),
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue