Skip to content

Commit bceac69

Browse files
committed
first release
0 parents  commit bceac69

38 files changed

+11750
-0
lines changed

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/.idea/
2+
/db.sqlite3
3+
/config/settings/local.py
4+
node_modules/
5+
static_compiled/
6+
/static_root/

Dockerfile

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
# Please remember to rename django_heroku to your project directory name
2+
FROM python:3.6-stretch
3+
4+
WORKDIR /app
5+
6+
ENV PYTHONUNBUFFERED=1 \
7+
PYTHONPATH=/app \
8+
DJANGO_SETTINGS_MODULE=config.settings.production \
9+
PORT=8000 \
10+
WEB_CONCURRENCY=3
11+
12+
EXPOSE 8000
13+
14+
# Install operating system dependencies.
15+
RUN apt-get update -y && \
16+
apt-get install -y apt-transport-https rsync gettext libgettextpo-dev && \
17+
curl -sL https://deb.nodesource.com/setup_8.x | bash - && \
18+
apt-get install -y nodejs &&\
19+
rm -rf /var/lib/apt/lists/*
20+
21+
# start to compile front-end stuff
22+
WORKDIR django_heroku/static_src
23+
24+
# Install front-end dependencies.
25+
COPY ./django_heroku/static_src/package.json ./django_heroku/static_src/package-lock.json ./
26+
RUN npm install
27+
28+
# Compile static files
29+
COPY ./django_heroku/static_src/ ./
30+
RUN npm run build:prod
31+
32+
# Install Gunicorn.
33+
RUN pip install "gunicorn>=19.8,<19.9"
34+
35+
# start to install backend-end stuff
36+
WORKDIR /app
37+
38+
# Install Python requirements.
39+
COPY requirements.txt .
40+
RUN pip install -r requirements.txt
41+
42+
# Copy application code.
43+
COPY . .
44+
45+
# Install assets
46+
RUN python manage.py collectstatic --noinput --clear
47+
48+
# Run application
49+
CMD gunicorn config.wsgi:application
50+

config/__init__.py

Whitespace-only changes.

config/settings/__init__.py

Whitespace-only changes.

config/settings/base.py

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
import environ
2+
import os
3+
4+
BASE_DIR = environ.Path(__file__) - 3
5+
PROJECT_DIR = BASE_DIR.path('django_heroku')
6+
7+
8+
# Application definition
9+
10+
INSTALLED_APPS = [
11+
'django.contrib.admin',
12+
'django.contrib.auth',
13+
'django.contrib.contenttypes',
14+
'django.contrib.sessions',
15+
'django.contrib.messages',
16+
'django.contrib.staticfiles',
17+
]
18+
19+
MIDDLEWARE = [
20+
'django.middleware.security.SecurityMiddleware',
21+
'whitenoise.middleware.WhiteNoiseMiddleware',
22+
'django.contrib.sessions.middleware.SessionMiddleware',
23+
'django.middleware.common.CommonMiddleware',
24+
'django.middleware.csrf.CsrfViewMiddleware',
25+
'django.contrib.auth.middleware.AuthenticationMiddleware',
26+
'django.contrib.messages.middleware.MessageMiddleware',
27+
'django.middleware.clickjacking.XFrameOptionsMiddleware',
28+
]
29+
30+
ROOT_URLCONF = 'config.urls'
31+
32+
TEMPLATES = [
33+
{
34+
'BACKEND': 'django.template.backends.django.DjangoTemplates',
35+
'DIRS': [
36+
os.path.join(PROJECT_DIR, 'templates'),
37+
],
38+
'APP_DIRS': True,
39+
'OPTIONS': {
40+
'context_processors': [
41+
'django.template.context_processors.debug',
42+
'django.template.context_processors.request',
43+
'django.contrib.auth.context_processors.auth',
44+
'django.contrib.messages.context_processors.messages',
45+
],
46+
},
47+
},
48+
]
49+
50+
WSGI_APPLICATION = 'config.wsgi.application'
51+
52+
53+
# Database
54+
# https://docs.djangoproject.com/en/1.11/ref/settings/#databases
55+
56+
DATABASES = {
57+
'default': {
58+
'ENGINE': 'django.db.backends.sqlite3',
59+
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
60+
}
61+
}
62+
63+
64+
# Internationalization
65+
# https://docs.djangoproject.com/en/1.11/topics/i18n/
66+
67+
LANGUAGE_CODE = 'en-us'
68+
69+
TIME_ZONE = 'UTC'
70+
71+
USE_I18N = True
72+
73+
USE_L10N = True
74+
75+
USE_TZ = True
76+
77+
78+
# Static files (CSS, JavaScript, Images)
79+
# https://docs.djangoproject.com/en/1.11/howto/static-files/
80+
81+
STATICFILES_FINDERS = [
82+
'django.contrib.staticfiles.finders.FileSystemFinder',
83+
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
84+
]
85+
86+
STATICFILES_DIRS = [
87+
os.path.join(PROJECT_DIR, 'static_compiled'),
88+
]
89+
90+
STATIC_ROOT = os.path.join(BASE_DIR, 'static_root')
91+
STATIC_URL = '/static/'
92+
93+
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
94+
MEDIA_URL = '/media/'

config/settings/dev.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
from __future__ import absolute_import, unicode_literals
2+
3+
from .base import *
4+
5+
# SECURITY WARNING: don't run with debug turned on in production!
6+
DEBUG = True
7+
8+
# SECURITY WARNING: keep the secret key used in production secret!
9+
SECRET_KEY = '5+f#!xn=hj^u#=cr9@pz@@5cf7bqf0ymy=8uyfpx_zvxpght3='
10+
11+
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
12+
13+
ALLOWED_HOSTS = ['*']
14+
15+
try:
16+
from .local import *
17+
except ImportError:
18+
pass

config/settings/production.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
from __future__ import absolute_import, unicode_literals
2+
3+
from .base import *
4+
5+
env = os.environ.copy()
6+
7+
import dj_database_url
8+
9+
DEBUG = False
10+
11+
SECRET_KEY = os.environ.get('SECRET_KEY', default='5+f#!xn=hj^u#=cr9@pz@@5cf7bqf0ymy=8uyfpx_zvxpght3=')
12+
13+
STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
14+
15+
ALLOWED_HOSTS = ['*']
16+
17+
if "DATABASE_URL" in env:
18+
DATABASES['default'] = dj_database_url.config(conn_max_age=600, ssl_require=True)
19+
20+
try:
21+
from .local import *
22+
except ImportError:
23+
pass

config/urls.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
"""django_heroku URL Configuration
2+
3+
The `urlpatterns` list routes URLs to views. For more information please see:
4+
https://docs.djangoproject.com/en/2.2/topics/http/urls/
5+
Examples:
6+
Function views
7+
1. Add an import: from my_app import views
8+
2. Add a URL to urlpatterns: path('', views.home, name='home')
9+
Class-based views
10+
1. Add an import: from other_app.views import Home
11+
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
12+
Including another URLconf
13+
1. Import the include() function: from django.urls import include, path
14+
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
15+
"""
16+
from django.contrib import admin
17+
from django.urls import path
18+
19+
urlpatterns = [
20+
path('admin/', admin.site.urls),
21+
]

config/wsgi.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import os
2+
import sys
3+
4+
from django.core.wsgi import get_wsgi_application
5+
6+
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "config.settings.production")
7+
8+
application = get_wsgi_application()

django_heroku/__init__.py

Whitespace-only changes.

django_heroku/static_src/.babelrc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
presets: [
3+
[ 'env', { modules: false } ],
4+
'react'
5+
]
6+
}

django_heroku/static_src/.eslintrc

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"commonjs": true,
5+
"es6": true
6+
},
7+
"extends": "eslint:recommended",
8+
"parserOptions": {
9+
"ecmaFeatures": {
10+
"jsx": true
11+
},
12+
"sourceType": "module"
13+
},
14+
"plugins": [
15+
"react"
16+
],
17+
"rules": {
18+
"indent": [
19+
"error",
20+
4
21+
],
22+
"linebreak-style": [
23+
"error",
24+
"unix"
25+
],
26+
"quotes": [
27+
"error",
28+
"single"
29+
],
30+
"jsx-quotes": [
31+
"error",
32+
"prefer-double"
33+
],
34+
"semi": [
35+
"error",
36+
"always"
37+
],
38+
"react/jsx-uses-react": 2,
39+
"react/jsx-uses-vars": 2,
40+
"react/react-in-jsx-scope": 2
41+
}
42+
}
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#########################
2+
## Sass Lint File
3+
#########################
4+
# For details on the rules see https://github.com/sasstools/sass-lint/tree/master/docs/rules
5+
# Linter Options
6+
options:
7+
# Don't merge default rules
8+
# merge-default-rules: false
9+
# Set the formatter to 'html'
10+
# formatter: html
11+
# Output file instead of logging results
12+
# output-file: 'linters/sass-lint.html'
13+
# File Options
14+
files:
15+
ignore:
16+
- 'sass/vendor/**/*.*'
17+
# include:
18+
# - 'src/src/_source/sass/**/*.s+(a|c)ss'
19+
# Rule Configuration
20+
rules:
21+
bem-depth:
22+
- 1
23+
- max-depth: 2
24+
extends-before-mixins: 2
25+
extends-before-declarations: 2
26+
placeholder-in-extend: 2
27+
empty-line-between-blocks:
28+
- 2
29+
- include: true
30+
- allow-single-line-rulesets: true
31+
mixins-before-declarations:
32+
- 2
33+
- exclude:
34+
- media-query
35+
no-warn: 0
36+
no-debug: 0
37+
indentation:
38+
- 1
39+
- size: 4
40+
variable-for-property:
41+
- 0
42+
no-css-comments: 0
43+
class-name-format:
44+
- 1
45+
- convention: hyphenatedbem
46+
force-pseudo-nesting: 0
47+
nesting-depth: 0
48+
force-attribute-nesting: 0
49+
force-element-nesting: 1
50+
no-qualifying-elements: 0
51+
leading-zero:
52+
- 1
53+
- include: true
54+
no-vendor-prefixes:
55+
- 1
56+
mixin-name-format:
57+
- 1
58+
- convention: hyphenatedlowercase
59+
no-color-keywords: 0
60+
no-color-literals: 0
61+
property-sort-order:
62+
- 0
63+
-
64+
order: recess
65+
empty-args:
66+
- 1
67+
-
68+
include: true

0 commit comments

Comments
 (0)