Snipt: Glitch Edition
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

73 rindas
2.4KB

  1. import os
  2. from django.conf.urls import include, url
  3. from django.contrib import admin
  4. from django.contrib.auth.views import login
  5. from django.http import HttpResponseRedirect
  6. from django.views.generic import TemplateView
  7. from django.views.static import serve
  8. from snipts.api import (
  9. PublicSniptResource,
  10. PublicUserResource,
  11. PrivateSniptResource,
  12. PrivateFavoriteResource,
  13. PrivateUserProfileResource,
  14. PrivateUserResource,
  15. PublicTagResource,
  16. )
  17. # from snipts.views import search
  18. from tastypie.api import Api
  19. from views import homepage, lexers, login_redirect, tags, user_api_key
  20. public_api = Api(api_name="public")
  21. public_api.register(PublicSniptResource())
  22. public_api.register(PublicTagResource())
  23. public_api.register(PublicUserResource())
  24. private_api = Api(api_name="private")
  25. private_api.register(PrivateSniptResource())
  26. private_api.register(PrivateUserResource())
  27. private_api.register(PrivateFavoriteResource())
  28. private_api.register(PrivateUserProfileResource())
  29. urlpatterns = []
  30. if os.environ.get("DISABLE_SIGNUP") == "true":
  31. urlpatterns += [
  32. url(r"^register/?$", lambda x: HttpResponseRedirect("/404/")),
  33. url(r"^signup/?$", lambda x: HttpResponseRedirect("/404/")),
  34. ]
  35. else:
  36. urlpatterns += [url(r"^signup/?$", lambda x: HttpResponseRedirect("/register/"))]
  37. urlpatterns += [
  38. url(r"^$", homepage),
  39. url(r"", include("registration.backends.simple.urls")),
  40. url(r"^login/?$", login, name="login"),
  41. url(r"^login-redirect/$", login_redirect),
  42. url(r"^admin/", include(admin.site.urls)),
  43. url(r"^404/$", TemplateView.as_view(template_name="404.html")),
  44. url(r"^500/$", TemplateView.as_view(template_name="500.html")),
  45. url(r"^robots.txt$", TemplateView.as_view(template_name="robots.txt")),
  46. url(r"^tags/$", tags),
  47. url(r"^account/", include("accounts.urls")),
  48. url(r"^api/public/lexer/$", lexers),
  49. url(r"^api/private/key/$", user_api_key),
  50. url(r"^api/", include(public_api.urls)),
  51. url(r"^api/", include(private_api.urls)),
  52. # url(r"^search/$", search),
  53. url(r"^", include("teams.urls")),
  54. url(r"^", include("snipts.urls")),
  55. url(
  56. r"^(?P<path>favicon\.ico)$",
  57. serve,
  58. {"document_root": os.path.join(os.path.dirname(__file__), "static/img")},
  59. ),
  60. url(
  61. r"^static/(?P<path>.*)$",
  62. serve,
  63. {"document_root": os.path.join(os.path.dirname(__file__), "media")},
  64. ),
  65. ]