mirror of
https://github.com/DarrenOfficial/dpaste.git
synced 2024-11-23 11:56:36 +11:00
More project restructuring to make the project look more like a Django 1.5 project.
This commit is contained in:
parent
ee0fc79a3e
commit
d539631da7
11 changed files with 44 additions and 74 deletions
7
.gitignore
vendored
7
.gitignore
vendored
|
@ -1,7 +1,2 @@
|
|||
*~
|
||||
*.pyc
|
||||
docs/_build/*
|
||||
uploads
|
||||
dpaste/conf/local/*.py
|
||||
dev.db
|
||||
dpaste/settings_local.py
|
||||
dpaste.egg-info
|
||||
|
|
|
@ -1,40 +0,0 @@
|
|||
#!/usr/bin/env python
|
||||
import os
|
||||
import sys
|
||||
from django import get_version
|
||||
from django.core.management import execute_from_command_line, LaxOptionParser
|
||||
from django.core.management.base import BaseCommand
|
||||
|
||||
# Work out the project module name and root directory, assuming that this file
|
||||
# is located at [project]/bin/manage.py
|
||||
PROJECT_DIR, PROJECT_MODULE_NAME = os.path.split(
|
||||
os.path.dirname(os.path.dirname(os.path.realpath(__file__))))
|
||||
|
||||
# Check that the project module can be imported.
|
||||
try:
|
||||
__import__(PROJECT_MODULE_NAME)
|
||||
except ImportError:
|
||||
# Couldn't import the project, place it on the Python path and try again.
|
||||
sys.path.append(PROJECT_DIR)
|
||||
try:
|
||||
__import__(PROJECT_MODULE_NAME)
|
||||
except ImportError:
|
||||
sys.stderr.write("Error: Can't import the \"%s\" project module." %
|
||||
PROJECT_MODULE_NAME)
|
||||
sys.exit(1)
|
||||
|
||||
def has_settings_option():
|
||||
parser = LaxOptionParser(usage="%prog subcommand [options] [args]",
|
||||
version=get_version(),
|
||||
option_list=BaseCommand.option_list)
|
||||
try:
|
||||
options = parser.parse_args(sys.argv[:])[0]
|
||||
except:
|
||||
return False # Ignore any option errors at this point.
|
||||
return bool(options.settings)
|
||||
|
||||
if not has_settings_option() and not 'DJANGO_SETTINGS_MODULE' in os.environ:
|
||||
settings_module = '%s.conf.local.settings' % PROJECT_MODULE_NAME
|
||||
os.environ['DJANGO_SETTINGS_MODULE'] = settings_module
|
||||
|
||||
execute_from_command_line()
|
|
@ -1,17 +0,0 @@
|
|||
from django.conf.urls.defaults import *
|
||||
from django.conf import settings
|
||||
from django.contrib import admin
|
||||
from piston.resource import Resource
|
||||
from dpaste.handlers import SnippetHandler
|
||||
|
||||
admin.autodiscover()
|
||||
snippet_resource = Resource(handler=SnippetHandler)
|
||||
|
||||
urlpatterns = patterns('',
|
||||
url(r'^about/$', 'django.views.generic.simple.direct_to_template', {'template': 'about.html'}, name='about'),
|
||||
url(r'^admin/', include(admin.site.urls)),
|
||||
|
||||
url(r'^api/(?P<secret_id>[^/]+)/$', snippet_resource),
|
||||
url(r'^api/$', snippet_resource),
|
||||
(r'^', include('dpaste.urls')),
|
||||
)
|
|
@ -68,7 +68,7 @@ ADMIN_MEDIA_PREFIX = '/static/admin/'
|
|||
|
||||
MEDIA_ROOT = os.path.join(VAR_ROOT, 'uploads')
|
||||
|
||||
ROOT_URLCONF = 'dpaste.conf.urls'
|
||||
ROOT_URLCONF = 'dpaste.urls'
|
||||
|
||||
LOGIN_URL = '/accounts/login/'
|
||||
LOGOUT_URL = '/accounts/logout/'
|
||||
|
@ -104,7 +104,6 @@ INSTALLED_APPS = (
|
|||
'mptt',
|
||||
'south',
|
||||
'gunicorn',
|
||||
|
||||
'dpaste',
|
||||
)
|
||||
|
0
dpaste/static/.gitignore
vendored
0
dpaste/static/.gitignore
vendored
2
dpaste/static/raven-0.4.min.js
vendored
2
dpaste/static/raven-0.4.min.js
vendored
File diff suppressed because one or more lines are too long
|
@ -34,11 +34,6 @@
|
|||
|
||||
{% block script_footer %}
|
||||
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
|
||||
<script type="text/javascript" src="{{ STATIC_URL }}raven-0.4.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
Raven.config('http://0afbf6df0a9749f9985059ed6c527b19@ohnoez.mahner.org/2');
|
||||
window.onerror = Raven.process;
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
</body>
|
||||
|
|
|
@ -1,8 +1,33 @@
|
|||
from django.conf.urls.defaults import patterns, url
|
||||
from django.conf.urls.defaults import *
|
||||
from django.conf import settings
|
||||
from django.contrib import admin
|
||||
from piston.resource import Resource
|
||||
from dpaste.handlers import SnippetHandler
|
||||
|
||||
admin.autodiscover()
|
||||
|
||||
urlpatterns = patterns('dpaste.views',
|
||||
snippet_resource = Resource(handler=SnippetHandler)
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Generic
|
||||
# -----------------------------------------------------------------------------
|
||||
urlpatterns = patterns('',
|
||||
url(r'^about/$', 'django.views.generic.simple.direct_to_template', {'template': 'about.html'}, name='about'),
|
||||
url(r'^admin/', include(admin.site.urls)),
|
||||
)
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# API
|
||||
# -----------------------------------------------------------------------------
|
||||
urlpatterns += patterns('',
|
||||
url(r'^api/(?P<secret_id>[^/]+)/$', snippet_resource),
|
||||
url(r'^api/$', snippet_resource),
|
||||
)
|
||||
|
||||
# -----------------------------------------------------------------------------
|
||||
# Dpaste
|
||||
# -----------------------------------------------------------------------------
|
||||
urlpatterns += patterns('dpaste.views',
|
||||
url(r'^$', 'snippet_new', name='snippet_new'),
|
||||
url(r'^guess/$', 'guess_lexer', name='snippet_guess_lexer'),
|
||||
url(r'^diff/$', 'snippet_diff', name='snippet_diff'),
|
||||
|
|
15
manage.py
Executable file
15
manage.py
Executable file
|
@ -0,0 +1,15 @@
|
|||
#!/usr/bin/env python
|
||||
import os
|
||||
import sys
|
||||
|
||||
if __name__ == "__main__":
|
||||
# If a 'settings_local' file is present, use it
|
||||
try:
|
||||
from dpaste import settings_local
|
||||
settings_module = "dpaste.settings_local"
|
||||
except ImportError:
|
||||
settings_module = "dpaste.settings"
|
||||
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", settings_module)
|
||||
from django.core.management import execute_from_command_line
|
||||
execute_from_command_line(sys.argv)
|
Loading…
Reference in a new issue