Horrible things for nice storage
parent
477cf2f1bb
commit
18b47de71f
|
@ -3,7 +3,7 @@ boto
|
|||
Django
|
||||
django-annoying
|
||||
django-bcrypt
|
||||
django-css
|
||||
django-compressor
|
||||
django-grappelli
|
||||
django-pagination
|
||||
django-postmark
|
||||
|
|
|
@ -515,3 +515,7 @@ article.snipt {
|
|||
.hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
body {
|
||||
background: blue;
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ import os
|
|||
|
||||
DEBUG = True
|
||||
TEMPLATE_DEBUG = DEBUG
|
||||
BASE_PATH = os.path.dirname(__file__)
|
||||
|
||||
ADMINS = (
|
||||
('Nick Sergeant', 'nick@snipt.net'),
|
||||
|
@ -49,20 +50,22 @@ USE_L10N = True
|
|||
|
||||
# Absolute filesystem path to the directory that will hold user-uploaded files.
|
||||
# Example: "/home/media/media.lawrence.com/media/"
|
||||
MEDIA_ROOT = '/Users/Nick/Code/snipt/snipt/media/'
|
||||
MEDIA_ROOT = ''
|
||||
|
||||
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
|
||||
# trailing slash.
|
||||
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
|
||||
MEDIA_URL = '/media/'
|
||||
MEDIA_URL = ''
|
||||
|
||||
# Absolute path to the directory static files should be collected to.
|
||||
# Don't put anything in this directory yourself; store your static files
|
||||
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
|
||||
# Example: "/home/media/media.lawrence.com/static/"
|
||||
STATIC_ROOT = '/Users/Nick/Code/snipt/snipt/static/'
|
||||
STATICFILES_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
|
||||
STATIC_ROOT = os.path.join(BASE_PATH, 'static')
|
||||
STATICFILES_STORAGE = 'snipt.storage.CachedS3BotoStorage'
|
||||
STATIC_URL = 'https://dn2p0mzo970os.cloudfront.net/'
|
||||
|
||||
# S3 Settings
|
||||
AWS_ACCESS_KEY_ID = 'AKIAJTFDHBCXHJLXINKQ'
|
||||
AWS_SECRET_ACCESS_KEY = 'olt18bexb9Yoxb0GmKEKwLwG385/zSYvCz1KRVTo'
|
||||
AWS_STORAGE_BUCKET_NAME = 'snipt'
|
||||
|
@ -74,7 +77,7 @@ ADMIN_MEDIA_PREFIX = STATIC_URL + 'grappelli/'
|
|||
|
||||
# Additional locations of static files
|
||||
STATICFILES_DIRS = (
|
||||
'/Users/Nick/Code/snipt/snipt/media',
|
||||
os.path.join(BASE_PATH, 'media'),
|
||||
)
|
||||
|
||||
# List of finder classes that know how to find static files in
|
||||
|
@ -82,7 +85,7 @@ STATICFILES_DIRS = (
|
|||
STATICFILES_FINDERS = (
|
||||
'django.contrib.staticfiles.finders.FileSystemFinder',
|
||||
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
|
||||
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
|
||||
'compressor.finders.CompressorFinder',
|
||||
)
|
||||
|
||||
# Make this unique, and don't share it with anybody.
|
||||
|
@ -94,12 +97,21 @@ TEMPLATE_LOADERS = (
|
|||
'django.template.loaders.app_directories.Loader',
|
||||
# 'django.template.loaders.eggs.Loader',
|
||||
)
|
||||
TEMPLATE_CONTEXT_PROCESSORS = (
|
||||
'django.core.context_processors.auth',
|
||||
'django.core.context_processors.debug',
|
||||
'django.core.context_processors.i18n',
|
||||
'django.core.context_processors.media',
|
||||
'django.core.context_processors.request',
|
||||
'django.core.context_processors.static',
|
||||
)
|
||||
|
||||
MIDDLEWARE_CLASSES = (
|
||||
'snipt.middleware.www.WWWMiddleware',
|
||||
'django.middleware.cache.CacheMiddleware',
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
'django.middleware.csrf.CsrfResponseMiddleware',
|
||||
'django.middleware.csrf.CsrfViewMiddleware',
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
|
@ -169,20 +181,18 @@ GRAPPELLI_ADMIN_TITLE = '<a href="/">Snipt</a>'
|
|||
# Virtualenv
|
||||
VIRTUALENV_PATH = '/Users/Nick/.virtualenvs/snipt/lib/python2.7/site-packages/'
|
||||
|
||||
# Compressor
|
||||
COMPRESS_ENABLED = True
|
||||
COMPRESS_OUTPUT_DIR = 'cache'
|
||||
COMPRESS_ROOT = STATIC_ROOT
|
||||
COMPRESS_URL = STATIC_URL
|
||||
COMPRESS_STORAGE = STATICFILES_STORAGE
|
||||
|
||||
# Account settings
|
||||
LOGIN_REDIRECT_URL = '/'
|
||||
LOGIN_URL = '/login/'
|
||||
LOGOUT_URL = '/logout/'
|
||||
|
||||
# CSS compression
|
||||
COMPRESS_OUTPUT_DIR = 'cache'
|
||||
COMPILER_FORMATS = {
|
||||
'.less': {
|
||||
'binary_path':'lessc',
|
||||
'arguments': '*.less *.css'
|
||||
},
|
||||
}
|
||||
|
||||
# User absolute URLs
|
||||
ABSOLUTE_URL_OVERRIDES = {
|
||||
'auth.user': lambda u: "/%s/" % u.username,
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
from django.core.files.storage import get_storage_class
|
||||
from storages.backends.s3boto import S3BotoStorage
|
||||
|
||||
class CachedS3BotoStorage(S3BotoStorage):
|
||||
"""
|
||||
S3 storage backend that saves the files locally, too.
|
||||
"""
|
||||
def __init__(self, *args, **kwargs):
|
||||
super(CachedS3BotoStorage, self).__init__(*args, **kwargs)
|
||||
self.local_storage = get_storage_class(
|
||||
"compressor.storage.CompressorFileStorage")()
|
||||
|
||||
def save(self, name, content):
|
||||
name = super(CachedS3BotoStorage, self).save(name, content)
|
||||
self.local_storage._save(name, content)
|
||||
return name
|
||||
|
||||
def path(self, name):
|
||||
return self.local_storage.path(name)
|
|
@ -1,32 +1,24 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en" class="{% block html-class %}{% endblock %}">
|
||||
<head>
|
||||
|
||||
{% load compress %}
|
||||
|
||||
<title>{% block page-title %}Snipt{% endblock %}</title>
|
||||
<meta charset="utf-8" />
|
||||
<meta name="description" content="Long-term memory for coders. Share and store code snippets." />
|
||||
|
||||
{% load compress %}
|
||||
|
||||
{% compress css %}
|
||||
<link rel="stylesheet" href="/media/css/reset.css" />
|
||||
<link rel="stylesheet" href="/media/css/themes.css" />
|
||||
{% if not debug %}
|
||||
<link rel="stylesheet" href="/media/css/style.less" />
|
||||
{% endif %}
|
||||
<link rel="stylesheet" href="{{ STATIC_URL }}css/reset.css" />
|
||||
<link rel="stylesheet" href="{{ STATIC_URL }}css/themes.css" />
|
||||
<link rel="stylesheet" href="{{ STATIC_URL }}css/style.less" />
|
||||
{% endcompress %}
|
||||
{% if debug %}
|
||||
<link rel="stylesheet/less" href="/media/css/style.less" />
|
||||
{% endif %}
|
||||
|
||||
{% compress js %}
|
||||
<script type="text/javascript" src="/media/js/jquery.js"></script>
|
||||
<script type="text/javascript" src="/media/js/jquery.infieldlabel.js"></script>
|
||||
<script type="text/javascript" src="/media/js/jquery.hotkeys.js"></script>
|
||||
<script type="text/javascript" src="/media/js/coffee-script.js"></script>
|
||||
<script type="text/coffeescript" src="/media/js/script.coffee"></script>
|
||||
{% if debug %}
|
||||
<script type="text/javascript" src="/media/js/less.js"></script>
|
||||
{% endif %}
|
||||
<script type="text/javascript" src="{{ STATIC_URL }}js/jquery.js"></script>
|
||||
<script type="text/javascript" src="{{ STATIC_URL }}js/jquery.infieldlabel.js"></script>
|
||||
<script type="text/javascript" src="{{ STATIC_URL }}js/jquery.hotkeys.js"></script>
|
||||
<script type="text/javascript" src="{{ STATIC_URL }}js/coffee-script.js"></script>
|
||||
<script type="text/coffeescript" src="{{ STATIC_URL }}js/script.coffee"></script>
|
||||
{% endcompress %}
|
||||
|
||||
<!--[if IE]>
|
||||
|
|
Loading…
Reference in New Issue