commit d6f337c2743e69931528796d9cae95687f6641b8 Author: TheOrangeOne Date: Mon Sep 5 08:36:06 2016 +0100 init basic project diff --git a/.babelrc b/.babelrc new file mode 100644 index 0000000..c13c5f6 --- /dev/null +++ b/.babelrc @@ -0,0 +1,3 @@ +{ + "presets": ["es2015"] +} diff --git a/.buildpacks b/.buildpacks new file mode 100644 index 0000000..014ce78 --- /dev/null +++ b/.buildpacks @@ -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 diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..16f0a2a --- /dev/null +++ b/.eslintrc @@ -0,0 +1,9 @@ +{ + "extends": "./node_modules/eslint-config/.eslintrc", + "rules": { + "no-unused-vars": [2, {"vars": "all", "args": "none"}] + }, + "globals": { + "$": true + } +} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9d20eb8 --- /dev/null +++ b/.gitignore @@ -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 diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 0000000..32447ce --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +5.11.1 diff --git a/.python-version b/.python-version new file mode 100644 index 0000000..4d9d11c --- /dev/null +++ b/.python-version @@ -0,0 +1 @@ +3.4.2 diff --git a/Procfile b/Procfile new file mode 100644 index 0000000..c90b8d4 --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +web: waitress-serve --port $PORT project.wsgi:application diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 diff --git a/build b/build new file mode 100755 index 0000000..39e7472 --- /dev/null +++ b/build @@ -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 diff --git a/circle.yml b/circle.yml new file mode 100644 index 0000000..8f116c5 --- /dev/null +++ b/circle.yml @@ -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 diff --git a/etc/environments/development/env b/etc/environments/development/env new file mode 100644 index 0000000..6dcac5c --- /dev/null +++ b/etc/environments/development/env @@ -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 diff --git a/etc/environments/development/procfile b/etc/environments/development/procfile new file mode 100644 index 0000000..e84b479 --- /dev/null +++ b/etc/environments/development/procfile @@ -0,0 +1 @@ +web: manage.py runserver 0.0.0.0:$PORT diff --git a/manage.py b/manage.py new file mode 100755 index 0000000..82cfa83 --- /dev/null +++ b/manage.py @@ -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) diff --git a/package.json b/package.json new file mode 100644 index 0000000..6a6f4a6 --- /dev/null +++ b/package.json @@ -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" + } +} diff --git a/project/__init__.py b/project/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/project/files/__init__.py b/project/files/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/project/files/admin.py b/project/files/admin.py new file mode 100644 index 0000000..8fe8086 --- /dev/null +++ b/project/files/admin.py @@ -0,0 +1,7 @@ +from django.contrib import admin +from .models import SharedFile + + +@admin.register(SharedFile) +class SharedFileAdmin(admin.ModelAdmin): + pass diff --git a/project/files/migrations/__init__.py b/project/files/migrations/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/project/files/tests.py b/project/files/tests.py new file mode 100644 index 0000000..7ce503c --- /dev/null +++ b/project/files/tests.py @@ -0,0 +1,3 @@ +from django.test import TestCase + +# Create your tests here. diff --git a/project/files/views.py b/project/files/views.py new file mode 100644 index 0000000..91ea44a --- /dev/null +++ b/project/files/views.py @@ -0,0 +1,3 @@ +from django.shortcuts import render + +# Create your views here. diff --git a/project/pages/__init__.py b/project/pages/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/project/pages/tests.py b/project/pages/tests.py new file mode 100644 index 0000000..03b7a34 --- /dev/null +++ b/project/pages/tests.py @@ -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) diff --git a/project/pages/urls.py b/project/pages/urls.py new file mode 100644 index 0000000..869e109 --- /dev/null +++ b/project/pages/urls.py @@ -0,0 +1,6 @@ +from django.conf.urls import url +from . import views + +urlpatterns = [ + url(r'^$', views.IndexView.as_view(), name="index") +] diff --git a/project/pages/views.py b/project/pages/views.py new file mode 100644 index 0000000..2844b2c --- /dev/null +++ b/project/pages/views.py @@ -0,0 +1,5 @@ +from django.views.generic import TemplateView + + +class IndexView(TemplateView): + template_name = 'index.html' diff --git a/project/settings.py b/project/settings.py new file mode 100644 index 0000000..3f1d21c --- /dev/null +++ b/project/settings.py @@ -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/' diff --git a/project/urls.py b/project/urls.py new file mode 100644 index 0000000..7af1769 --- /dev/null +++ b/project/urls.py @@ -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() diff --git a/project/wsgi.py b/project/wsgi.py new file mode 100644 index 0000000..89e8c99 --- /dev/null +++ b/project/wsgi.py @@ -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) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..e48a686 --- /dev/null +++ b/requirements.txt @@ -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 diff --git a/runtests b/runtests new file mode 100755 index 0000000..a8bb40c --- /dev/null +++ b/runtests @@ -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 diff --git a/scripts/build-js.sh b/scripts/build-js.sh new file mode 100644 index 0000000..d243e23 --- /dev/null +++ b/scripts/build-js.sh @@ -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!" diff --git a/scripts/build-scss.sh b/scripts/build-scss.sh new file mode 100644 index 0000000..30e2183 --- /dev/null +++ b/scripts/build-scss.sh @@ -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 diff --git a/static/src/js/app.js b/static/src/js/app.js new file mode 100644 index 0000000..0af6d63 --- /dev/null +++ b/static/src/js/app.js @@ -0,0 +1 @@ +import 'bootstrap-sass/assets/javascripts/bootstrap.js'; diff --git a/static/src/scss/index.scss b/static/src/scss/index.scss new file mode 100644 index 0000000..87c88d1 --- /dev/null +++ b/static/src/scss/index.scss @@ -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"); diff --git a/static/src/scss/variables.scss b/static/src/scss/variables.scss new file mode 100644 index 0000000..2cf0701 --- /dev/null +++ b/static/src/scss/variables.scss @@ -0,0 +1 @@ +$font-family-base: "Roboto", "Helvetica Neue", Arial, sans-serif; diff --git a/templates/base.html b/templates/base.html new file mode 100644 index 0000000..fd23355 --- /dev/null +++ b/templates/base.html @@ -0,0 +1,14 @@ +{% load staticfiles %} + + + + + {% block title %}{% endblock %} | StaticShare + + + + + {% block content %}{% endblock %} + + + diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..8d9b087 --- /dev/null +++ b/templates/index.html @@ -0,0 +1,7 @@ +{% extends 'base.html' %} + +{% block title %}Homepage{% endblock %} + +{% block content %} +

Index

+{% endblock %}