diff --git a/.gitignore b/.gitignore index a4179b2..3eee248 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,2 @@ -*~ -*.pyc -docs/_build/* -uploads -dpaste/conf/local/*.py -dev.db +dpaste/settings_local.py dpaste.egg-info diff --git a/dpaste/conf/__init__.py b/README.md similarity index 100% rename from dpaste/conf/__init__.py rename to README.md diff --git a/dpaste/bin/manage.py b/dpaste/bin/manage.py deleted file mode 100755 index fca5b86..0000000 --- a/dpaste/bin/manage.py +++ /dev/null @@ -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() diff --git a/dpaste/conf/urls.py b/dpaste/conf/urls.py deleted file mode 100644 index 22df1a1..0000000 --- a/dpaste/conf/urls.py +++ /dev/null @@ -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[^/]+)/$', snippet_resource), - url(r'^api/$', snippet_resource), - (r'^', include('dpaste.urls')), -) diff --git a/dpaste/conf/settings.py b/dpaste/settings.py similarity index 99% rename from dpaste/conf/settings.py rename to dpaste/settings.py index 7b88e74..127fd89 100644 --- a/dpaste/conf/settings.py +++ b/dpaste/settings.py @@ -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', ) diff --git a/dpaste/static/.gitignore b/dpaste/static/.gitignore deleted file mode 100644 index e69de29..0000000 diff --git a/dpaste/static/raven-0.4.min.js b/dpaste/static/raven-0.4.min.js deleted file mode 100644 index 60adf0a..0000000 --- a/dpaste/static/raven-0.4.min.js +++ /dev/null @@ -1,2 +0,0 @@ -/* Raven.js v0.4 | https://github.com/lincolnloop/raven-js/ */ -function parseUri(e){var d=parseUri.options,a=d.parser[d.strictMode?"strict":"loose"].exec(e),c={},b=14;while(b--){c[d.key[b]]=a[b]||""}c[d.q.name]={};c[d.key[12]].replace(d.q.parser,function(g,f,h){if(f){c[d.q.name][f]=h}});return c}parseUri.options={strictMode:false,key:["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"],q:{name:"queryKey",parser:/(?:^|&)([^&=]*)=?([^&]*)/g},parser:{strict:/^(?:([^:\/?#]+):)?(?:\/\/((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?))?((((?:[^?#\/]*\/)*)([^?#]*))(?:\?([^#]*))?(?:#(.*))?)/,loose:/^(?:(?![^:@]+:[^:@\/]*@)([^:\/?#.]+):)?(?:\/\/)?((?:(([^:@]*)(?::([^:@]*))?)?@)?([^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/}};(function(){var a=this;var d;d=a.Raven={};var b=d;d.VERSION="0.4";var c=a.jQuery||a.Zepto||a.ender;d.loaded=false;d.options={secretKey:undefined,publicKey:undefined,servers:[],projectId:1,logger:"javascript",site:undefined,signatureUrl:undefined,fetchHeaders:false,testMode:false};d.funcNameRE=/function\s*([\w\-$]+)?\s*\(/i;d.config=function(e){if(typeof(e)==="string"){if(e.indexOf("http")===0){e=d.parseDSN(e)}else{throw"Base64 encoded config is no longer supported - use DSN"}}c.each(e,function(f,g){b.options[f]=g})};d.parseDSN=function(f){var h=parseUri(f);var g=h.path.lastIndexOf("/");var e;var i;if(g===-1){e=h.path.substr(1);i=""}else{i=h.path.substr(1,g);e=h.path.substr(g+1)}return{servers:[h.protocol+"://"+h.host+":"+h.port+"/"+i+"api/"+e+"/store/"],publicKey:h.user,secretKey:h.password,projectId:e}};d.getHeaders=function(){var e={};if(b.options.fetchHeaders){e=c.ajax({type:"HEAD",url:a.location,async:false}).getAllResponseHeaders()}e.Referer=document.referrer;e["User-Agent"]=navigator.userAgent;return e};d.parseHeaders=function(e){var f={};c.each(e.split("\n"),function(h,k){var g=k.slice(0,k.indexOf(":")),j=k.slice(k.indexOf(":")+2);f[g]=j});return f};d.getSignature=function(e,f,g){if(b.options.signatureUrl){c.post(b.options.signatureUrl,{message:e,timestamp:f},function(h){g(h.signature)})}else{g()}};d.getAuthHeader=function(e,f){var g="Sentry sentry_version=2.0, ";g+="sentry_timestamp="+f+", ";g+="sentry_client=raven-js/"+b.VERSION;if(b.options.publicKey){g+=", sentry_key="+b.options.publicKey}if(e){g+=", sentry_signature="+e}return g};d.captureException=function(i){var h,f,g;if(i.line){h=i.line}else{if(i.lineNumber){h=i.lineNumber}}if(i.sourceURL){g=i.sourceURL}else{if(i.fileName){g=i.fileName}}if(i.arguments&&i.stack){f=this.chromeTraceback(i)}else{if(i.stack){if(i.stack.indexOf("@")==-1){f=this.chromeTraceback(i)}else{f=this.firefoxTraceback(i)}}else{f=[{filename:g,lineno:h}];f=f.concat(this.otherTraceback(arguments.callee))}}b.process(i,g,h,f)};d.captureMessage=function(e){b.process(e)};d.trimString=function(e){return e.replace(/^\s+|\s+$/g,"")};d.chromeTraceback=function(k){var l,i,g,j,h=[],f=k.stack.split("\n");c.each(f.slice(1),function(m,e){l=d.trimString(e).slice(3);if(l=="unknown source"){return}else{l=l.split(" ")}if(l.length>2){i=l[0];g=l.slice(1).join(" ");j="(unknown)"}else{if(l.length==2){i=l[0];g=l[1]}else{i="(unknown)";g=l[0]}}if(g&&g!="(unknown source)"){if(g.slice(0,1)=="("){g=g.slice(1,-1).split(":")}else{g=g.split(":")}j=g.slice(-2)[0];g=g.slice(0,-2).join(":")}h.push({"function":i,filename:g,lineno:j})});return h};d.firefoxTraceback=function(l){var m,j,i,g,k,h=[],f=l.stack.split("\n");c.each(f,function(n,e){if(e){m=e.split("@");if(m[0]){j=m[0].split("(");if(j[1]!=")"){i=j[1].slice(0,-1).split(",")}else{i=undefined}if(j[0]){j=j[0]}else{j="(unknown)"}}else{j="(unknown)"}g=m[1].split(":");k=g.slice(-1)[0];g=g.slice(0,-1).join(":");h.push({"function":j,filename:g,lineno:k,vars:{"arguments":i}})}});return h};d.otherTraceback=function(j){var i,h,f="",g=[],e=9;while(j&&g.length",g=[];c.each(f,function(k,j){if(j===undefined){g.push("undefined")}else{if(j===null){g.push("null")}else{if(j instanceof Array){g.push(e.stringifyArguments(j))}else{if(j.constructor){i=j.constructor.name||(e.funcNameRE.test(j.constructor.toString())?RegExp.$1||h:h);if(i=="String"){g.push('"'+j+'"')}else{if(i=="Number"||i=="Date"){g.push(j)}else{if(i=="Boolean"){g.push(j?"true":"false")}else{g.push(i)}}}}else{g.push(h)}}}}});return g};d.process=function(p,n,f,g,j){var l,o,h,i,k,e=a.location.origin+a.location.pathname,m=a.location.search.slice(1);if(typeof(p)==="object"){k=p.name;p=p.message}l=f?p+" at "+f:p;if(g){o={frames:g};n=n||g[0].filename}else{if(n){o={frames:[{filename:n,lineno:f}]}}}h={message:l,culprit:n,"sentry.interfaces.Stacktrace":o,"sentry.interfaces.Exception":{type:k,value:p},project:b.options.projectId,logger:b.options.logger,site:b.options.site};if(!b.options.testMode){h["sentry.interfaces.Http"]={url:e,querystring:m,headers:b.getHeaders()}}j=j||(new Date()).getTime();i=JSON.stringify(h);b.getSignature(i,j,function(q){var r=b.getAuthHeader(q,j);c.each(b.options.servers,function(s,t){c.ajax({type:"POST",url:t,data:i,headers:{"X-Sentry-Auth":r,Authentication:r}})})})}}).call(this); \ No newline at end of file diff --git a/dpaste/templates/base.html b/dpaste/templates/base.html index d5934ae..4e33b02 100644 --- a/dpaste/templates/base.html +++ b/dpaste/templates/base.html @@ -34,11 +34,6 @@ {% block script_footer %} - - {% endblock %} diff --git a/dpaste/urls.py b/dpaste/urls.py index 6e53d64..4a43484 100644 --- a/dpaste/urls.py +++ b/dpaste/urls.py @@ -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[^/]+)/$', 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'), diff --git a/manage.py b/manage.py new file mode 100755 index 0000000..bc248e2 --- /dev/null +++ b/manage.py @@ -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) diff --git a/requirements.pip b/requirements.txt similarity index 100% rename from requirements.pip rename to requirements.txt