archive
/
static-share
Archived
1
Fork 0

init basic project

This commit is contained in:
Jake Howard 2016-09-05 08:36:06 +01:00
commit d6f337c274
Signed by: jake
GPG Key ID: 57AFB45680EDD477
36 changed files with 506 additions and 0 deletions

3
.babelrc Normal file
View File

@ -0,0 +1,3 @@
{
"presets": ["es2015"]
}

3
.buildpacks Normal file
View File

@ -0,0 +1,3 @@
https://github.com/heroku/heroku-buildpack-nodejs
https://github.com/romeovs/heroku-buildpack-npm-build
https://github.com/heroku/heroku-buildpack-python

9
.eslintrc Normal file
View File

@ -0,0 +1,9 @@
{
"extends": "./node_modules/eslint-config/.eslintrc",
"rules": {
"no-unused-vars": [2, {"vars": "all", "args": "none"}]
},
"globals": {
"$": true
}
}

64
.gitignore vendored Normal file
View File

@ -0,0 +1,64 @@
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
# C extensions
*.so
# Distribution / packaging
.Python
env/
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
*.egg-info/
.installed.cfg
*.egg
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
coverage/
.tox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*,cover
# Translations
*.mo
*.pot
# Django stuff:
*.log
collected-static/
# Sphinx documentation
docs/_build/
# PyBuilder
target/
node_modules/
media/
database.db

1
.nvmrc Normal file
View File

@ -0,0 +1 @@
5.11.1

1
.python-version Normal file
View File

@ -0,0 +1 @@
3.4.2

1
Procfile Normal file
View File

@ -0,0 +1 @@
web: waitress-serve --port $PORT project.wsgi:application

0
README.md Normal file
View File

29
build Executable file
View File

@ -0,0 +1,29 @@
#!/bin/bash
if [ -z "$NVM_DIR" ]
then
NVM_DIR="$HOME/.nvm"
fi
. $NVM_DIR/nvm.sh
nvm install
nvm use
set -e
if hash pyenv 2>/dev/null;
then
echo "using pyenv wrapper"
pyenv install --skip-existing
pyenv exec pyvenv env
else
echo "using pyvenv (Built in python)"
pyvenv env
fi
env/bin/pip install -r requirements.txt
npm install
npm run build
env/bin/python manage.py collectstatic --noinput

22
circle.yml Normal file
View File

@ -0,0 +1,22 @@
machine:
python:
version: 3.4.2
node:
version: 5.11.1
environment:
DEBUG: true
DATABASE_URL: postgres://localhost/static-share
EMAIL_BACKEND: django.core.mail.backends.console.EmailBackend
SECRET_KEY: 123
IN_TEST: true
dependencies:
pre:
- ./build
cache_directories:
- env
- node_modules
test:
override:
- ./runtests

View File

@ -0,0 +1,4 @@
DEBUG=true
DATABASE_URL=sqlite://./database.db
EMAIL_BACKEND=django.core.mail.backends.console.EmailBackend
SECRET_KEY=%*v!183hd8(4j)hg6ylyor34iq_um^&k!0pk_1efn_$j76=so2

View File

@ -0,0 +1 @@
web: manage.py runserver 0.0.0.0:$PORT

10
manage.py Executable file
View File

@ -0,0 +1,10 @@
#!/usr/bin/env python
import os
import sys
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings")
from django.core.management import execute_from_command_line
execute_from_command_line(sys.argv)

43
package.json Normal file
View File

@ -0,0 +1,43 @@
{
"name": "share-static",
"version": "0.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "npm run lint",
"lint": "eslint 'static/src/js/'",
"create-build-dirs": "mkdir -p static/build/js static/build/css static/build/fonts static/build/img",
"build-scss": "bash scripts/build-scss.sh",
"build-js": "bash scripts/build-js.sh",
"build-fonts": "cp -R node_modules/bootstrap-sass/assets/fonts/bootstrap/* static/build/fonts/ && cp -R node_modules/font-awesome/fonts static/build",
"build": "npm run create-build-dirs && npm run build-scss && npm run build-js && npm run build-fonts"
},
"repository": {
"type": "git",
"url": "git+https://github.com/RealOrangeOne/static-share.git"
},
"author": "TheOrangeOne",
"license": "ISC",
"bugs": {
"url": "https://github.com/RealOrangeOne/static-share/issues"
},
"homepage": "https://github.com/RealOrangeOne/static-share#readme",
"dependencies": {
"bootstrap-sass": "=3.3.7",
"font-awesome": "=4.6.3",
"jquery": "=2.1.4"
},
"devDependencies": {
"autoprefixer": "=6.3.7",
"babel-preset-es2015": "=6.9.0",
"babelify": "=7.3.0",
"browserify": "=13.1.0",
"clean-css": "=3.4.19",
"eslint": "=1.5.0",
"eslint-config": "git://github.com/dabapps/eslint-config.git",
"node-sass": "=3.8.0",
"postcss-cli": "=2.5.2",
"sass-lint": "=1.8.2",
"uglify-js": "=2.7.0"
}
}

0
project/__init__.py Normal file
View File

View File

7
project/files/admin.py Normal file
View File

@ -0,0 +1,7 @@
from django.contrib import admin
from .models import SharedFile
@admin.register(SharedFile)
class SharedFileAdmin(admin.ModelAdmin):
pass

View File

3
project/files/tests.py Normal file
View File

@ -0,0 +1,3 @@
from django.test import TestCase
# Create your tests here.

3
project/files/views.py Normal file
View File

@ -0,0 +1,3 @@
from django.shortcuts import render
# Create your views here.

View File

8
project/pages/tests.py Normal file
View File

@ -0,0 +1,8 @@
from django.core.urlresolvers import reverse
from django.test import TestCase
class IndexPageTestCase(TestCase):
def test_accessable(self):
response = self.client.get(reverse("pages:index"))
self.assertEqual(response.status_code, 200)

6
project/pages/urls.py Normal file
View File

@ -0,0 +1,6 @@
from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^$', views.IndexView.as_view(), name="index")
]

5
project/pages/views.py Normal file
View File

@ -0,0 +1,5 @@
from django.views.generic import TemplateView
class IndexView(TemplateView):
template_name = 'index.html'

156
project/settings.py Normal file
View File

@ -0,0 +1,156 @@
import dj_database_url
import os
import logging
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = os.environ['SECRET_KEY']
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = os.environ.get('DEBUG', True)
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = (
'flat',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'project.files',
'project.pages'
)
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
'django.middleware.security.SecurityMiddleware'
)
ROOT_URLCONF = 'project.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages'
],
},
},
]
WSGI_APPLICATION = 'project.wsgi.application'
if 'OPBEAT_SECRET_TOKEN' in os.environ and 'IN_TEST' not in os.environ:
OPBEAT = {
'ORGANIZATION_ID': os.environ['OPBEAT_ORGANIZATION_ID'],
'APP_ID': os.environ['OPBEAT_APP_ID'],
'SECRET_TOKEN': os.environ['OPBEAT_SECRET_TOKEN'],
}
MIDDLEWARE_CLASSES = (
'opbeat.contrib.django.middleware.OpbeatAPMMiddleware',
) + MIDDLEWARE_CLASSES
INSTALLED_APPS = (
"opbeat.contrib.django",
) + INSTALLED_APPS
# Database
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases
DATABASES = {
'default': dj_database_url.config(default=os.environ['DATABASE_URL'])
}
EMAIL_BACKEND = os.environ['EMAIL_BACKEND']
LANGUAGE_CODE = 'en-gb'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
LOGGING = {
'version': 1,
'disable_existing_loggers': True,
'filters': {
'request_id': {
'()': 'log_request_id.filters.RequestIDFilter'
}
},
'formatters': {
'standard': {
'format': 'at=%(levelname)s request_id=%(request_id)s logger=%(name)s %(message)s',
},
},
'handlers': {
'console': {
'level': 'DEBUG',
'class': 'logging.StreamHandler',
'formatter': 'standard',
'filters': ['request_id'],
},
},
'root': {
'handlers': ['console'],
'level': 'INFO',
},
'loggers': {
'django.request': {
'handlers': ['console'],
'level': 'ERROR',
'propagate': False,
},
'log_request_id.middleware': {
'level': 'INFO',
'propagate': True,
},
'project': {
'level': 'DEBUG',
'propagate': True,
},
}
}
if 'IN_TEST' in os.environ:
logging.disable(logging.ERROR)
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'collected-static')
STATICFILES_STORAGE = 'whitenoise.django.GzipManifestStaticFilesStorage'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static', 'build'),
)
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'

12
project/urls.py Normal file
View File

@ -0,0 +1,12 @@
from django.conf.urls import include, url
from django.contrib import admin
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
url(r'', include("project.pages.urls", namespace="pages"))
]
urlpatterns += staticfiles_urlpatterns()

15
project/wsgi.py Normal file
View File

@ -0,0 +1,15 @@
"""
WSGI config for twm project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/
"""
import os
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "project.settings")
from django.core.wsgi import get_wsgi_application
from whitenoise.django import DjangoWhiteNoise
application = get_wsgi_application()
application = DjangoWhiteNoise(application)

11
requirements.txt Normal file
View File

@ -0,0 +1,11 @@
coverage==3.7.1
dj-database-url==0.4.1
django==1.8.13
django-shortuuidfield==0.1.3
django-flat-theme==1.1.3
django-log-request-id==1.1.0
flake8==2.5.4
opbeat==3.3.4
psycopg2==2.6.1
waitress==0.9.0
whitenoise==3.2.0

16
runtests Executable file
View File

@ -0,0 +1,16 @@
#!/usr/bin/env bash
set -e
TEST_ARGS=$@
export PATH=env/bin:${PATH}
export IN_TEST=true
coverage run --source=project --omit='*/wsgi.py,*/settings.py,*/migrations/*.py,*__init__*,*/tests.py' manage.py test $TEST_ARGS
flake8 project --ignore=E128,E501 --exclude="migrations,*/wsgi.py"
coverage report
coverage html
npm test

21
scripts/build-js.sh Normal file
View File

@ -0,0 +1,21 @@
#!/usr/bin/env bash
set -e
if [ "$NODE_ENV" = "production" ]
then
echo ">>> WARNING: Building in Production Mode!"
fi
uglifyjs node_modules/jquery/dist/jquery.js --compress --screw-ie8 --define --stats --keep-fnames -o static/build/js/jquery.js
echo ">> Building Application JS..."
browserify -t [ babelify ] static/src/js/app.js -o static/build/js/app.js
if [ "$NODE_ENV" = "production" ]
then
echo ">> Compressing Application..."
uglifyjs static/build/js/app.js --compress --screw-ie8 --define --stats --keep-fnames -o static/build/js/app.js
fi
echo "> JS Built!"

20
scripts/build-scss.sh Normal file
View File

@ -0,0 +1,20 @@
#!/usr/bin/env bash
set -e
if [ "$NODE_ENV" = "production" ]
then
echo ">>> WARNING: Building in Production Mode!"
fi
echo ">> Building SCSS..."
node-sass static/src/scss/index.scss static/build/css/index.css --source-map-embed
echo ">> Post-Processing..."
postcss -u autoprefixer -o static/build/css/index.css static/build/css/index.css
if [ "$NODE_ENV" = "production" ]
then
echo ">> Compressing CSS..."
cleancss -d --s0 -o static/build/css/index.css static/build/css/index.css
fi

1
static/src/js/app.js Normal file
View File

@ -0,0 +1 @@
import 'bootstrap-sass/assets/javascripts/bootstrap.js';

View File

@ -0,0 +1,9 @@
@import "variables"; // Import variables before anything else
$icon-font-path: "../fonts/";
@import "node_modules/bootstrap-sass/assets/stylesheets/_bootstrap";
$fa-font-path: $icon-font-path;
@import "node_modules/font-awesome/scss/font-awesome";
@import url("https://fonts.googleapis.com/css?family=Roboto:400,700,300,300italic,400italic,700italic");

View File

@ -0,0 +1 @@
$font-family-base: "Roboto", "Helvetica Neue", Arial, sans-serif;

14
templates/base.html Normal file
View File

@ -0,0 +1,14 @@
{% load staticfiles %}
<html>
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
<title>{% block title %}{% endblock %} | StaticShare</title>
<link rel="stylesheet" type="text/css" href="{% static 'css/index.css' %}" />
<script src="{% static 'js/jquery.js' %}"></script>
</head>
<body>
{% block content %}{% endblock %}
<script src="{% static 'js/app.js' %}"></script>
</body>
</html>

7
templates/index.html Normal file
View File

@ -0,0 +1,7 @@
{% extends 'base.html' %}
{% block title %}Homepage{% endblock %}
{% block content %}
<h1>Index</h1>
{% endblock %}