mirror of
https://github.com/Mistake35/Cedar-Django.git
synced 2026-07-17 16:11:14 +10:00
Finished the merge, Disabling comments, Community bans.
This commit is contained in:
+146
-79
@@ -1,67 +1,74 @@
|
||||
"""
|
||||
Django settings for closedverse project.
|
||||
|
||||
Generated by 'django-admin startproject' using Django 1.10.7.
|
||||
Generated by 'django-admin startproject' using Django 2.2.13.
|
||||
|
||||
For more information on this file, see
|
||||
https://docs.djangoproject.com/en/1.10/topics/settings/
|
||||
https://docs.djangoproject.com/en/2.2/topics/settings/
|
||||
|
||||
For the full list of settings and their values, see
|
||||
https://docs.djangoproject.com/en/1.10/ref/settings/
|
||||
https://docs.djangoproject.com/en/2.2/ref/settings/
|
||||
"""
|
||||
# Django Settings
|
||||
|
||||
import os
|
||||
|
||||
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = False
|
||||
PROD = False
|
||||
|
||||
# Quick-start development settings - unsuitable for production
|
||||
# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/
|
||||
# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/
|
||||
|
||||
# SECURITY WARNING: keep the secret key used in production secret! (If you want a website that can generate key https://miniwebtool.com/django-secret-key-generator/ goto here.)
|
||||
SECRET_KEY = ''
|
||||
|
||||
# Change the ALLOWED_HOSTS to your liking.
|
||||
# SECURITY WARNING: don't run with debug turned on in production!
|
||||
DEBUG = False
|
||||
|
||||
ALLOWED_HOSTS = [
|
||||
'domain.com'
|
||||
# This is just a default value for testing
|
||||
# Do not include 127.0.0.1 or localhost
|
||||
# in production for security reasons.
|
||||
ALLOWED_HOSTS = [
|
||||
'127.0.0.1',
|
||||
]
|
||||
|
||||
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
|
||||
|
||||
STATIC_URL = '/s/'
|
||||
MEDIA_URL = '/i/'
|
||||
CLOSEDVERSE_PROD = True
|
||||
IMAGE_DELETE_SETTING = 2
|
||||
|
||||
# Application definition
|
||||
|
||||
INSTALLED_APPS = [
|
||||
'admin_interface',
|
||||
'colorfield',
|
||||
'django.contrib.admin',
|
||||
'django.contrib.auth',
|
||||
'django.contrib.contenttypes',
|
||||
'django.contrib.sessions',
|
||||
'django.contrib.messages',
|
||||
'django.contrib.staticfiles',
|
||||
'markdown_deux',
|
||||
'markdown_deux',
|
||||
'closedverse_main',
|
||||
'ban',
|
||||
'maintenance',
|
||||
]
|
||||
X_FRAME_OPTIONS='SAMEORIGIN'
|
||||
|
||||
MIDDLEWARE = [
|
||||
'django.middleware.security.SecurityMiddleware',
|
||||
'django.contrib.sessions.middleware.SessionMiddleware',
|
||||
# use this middleware if you need x-forwarded-for support
|
||||
#'xff.middleware.XForwardedForMiddleware',
|
||||
'django.middleware.common.CommonMiddleware',
|
||||
'django.middleware.csrf.CsrfViewMiddleware',
|
||||
'django.contrib.auth.middleware.AuthenticationMiddleware',
|
||||
'django.contrib.messages.middleware.MessageMiddleware',
|
||||
'django.middleware.clickjacking.XFrameOptionsMiddleware',
|
||||
|
||||
#'ban.middleware.BanManagement',
|
||||
'closedverse_main.middleware.ClosedMiddleware',
|
||||
'whitenoise.middleware.WhiteNoiseMiddleware'
|
||||
#'maintenance.middleware.MaintenanceManagement',
|
||||
]
|
||||
if not DEBUG:
|
||||
MIDDLEWARE += ['whitenoise.middleware.WhiteNoiseMiddleware']
|
||||
|
||||
ROOT_URLCONF = 'closedverse.urls'
|
||||
|
||||
@@ -76,6 +83,7 @@ TEMPLATES = [
|
||||
'django.template.context_processors.request',
|
||||
'django.contrib.auth.context_processors.auth',
|
||||
'django.contrib.messages.context_processors.messages',
|
||||
'closedverse_main.context_processors.brand_name_universal',
|
||||
],
|
||||
},
|
||||
},
|
||||
@@ -85,17 +93,41 @@ WSGI_APPLICATION = 'closedverse.wsgi.application'
|
||||
|
||||
|
||||
# Database
|
||||
# https://docs.djangoproject.com/en/1.10/ref/settings/#databases
|
||||
# https://docs.djangoproject.com/en/2.2/ref/settings/#databases
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.sqlite3',
|
||||
'NAME': BASE_DIR + '/sql.sqlite3',
|
||||
'NAME': os.path.join(BASE_DIR, 'sql.sqlite3'),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
"""
|
||||
# log errors.
|
||||
LOGGING = {
|
||||
'version': 1,
|
||||
'disable_existing_loggers': False,
|
||||
'handlers': {
|
||||
'file': {
|
||||
'level': 'ERROR',
|
||||
'class': 'logging.FileHandler',
|
||||
'filename': 'logs/errors.log',
|
||||
},
|
||||
},
|
||||
'loggers': {
|
||||
'django': {
|
||||
'handlers': ['file'],
|
||||
'level': 'ERROR',
|
||||
'propagate': True,
|
||||
},
|
||||
},
|
||||
}
|
||||
"""
|
||||
|
||||
|
||||
# Password validation
|
||||
# https://docs.djangoproject.com/en/1.10/ref/settings/#auth-password-validators
|
||||
# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators
|
||||
|
||||
AUTH_PASSWORD_VALIDATORS = [
|
||||
{
|
||||
@@ -114,67 +146,95 @@ AUTH_PASSWORD_VALIDATORS = [
|
||||
|
||||
|
||||
# Internationalization
|
||||
# https://docs.djangoproject.com/en/1.10/topics/i18n/
|
||||
|
||||
TIME_ZONE = 'PST8PDT'
|
||||
# https://docs.djangoproject.com/en/2.2/topics/i18n/
|
||||
|
||||
LANGUAGE_CODE = 'en-us'
|
||||
|
||||
USE_I18N = True
|
||||
# replace with your own timezone
|
||||
TIME_ZONE = 'PST8PDT'
|
||||
|
||||
USE_L10N = True
|
||||
# Disable internationalization because Closedverse doesn't use it
|
||||
USE_I18N = False
|
||||
|
||||
USE_L10N = False
|
||||
|
||||
USE_TZ = True
|
||||
|
||||
# You can use Mailtrap to get the email system working. Mailtrap is free and will work well for what you'll be doing with this.
|
||||
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
|
||||
EMAIL_HOST = 'send.smtp.mailtrap.io'
|
||||
EMAIL_HOST_USER = 'api'
|
||||
EMAIL_HOST_PASSWORD = ''
|
||||
EMAIL_PORT = ''
|
||||
EMAIL_USE_TLS = True
|
||||
DEFAULT_FROM_EMAIL = 'noreply@domain'
|
||||
YOUR_DOMAIN = 'yoursite.com'
|
||||
|
||||
# Static files (CSS, JavaScript, Images)
|
||||
# https://docs.djangoproject.com/en/2.2/howto/static-files/
|
||||
|
||||
#STATIC_URL = '/static/'
|
||||
if not DEBUG:
|
||||
# without this, this will not serve static for admin (and other apps potentially)
|
||||
WHITENOISE_USE_FINDERS = True
|
||||
STATICFILES_STORAGE = 'whitenoise.storage.CompressedStaticFilesStorage'
|
||||
STATIC_ROOT = os.path.join(BASE_DIR, 'static/')
|
||||
else:
|
||||
# Define static files in the base directory
|
||||
STATICFILES_DIRS = [
|
||||
os.path.join(BASE_DIR, 'static/'),
|
||||
]
|
||||
|
||||
# Closedverse models and routes for Django
|
||||
AUTH_USER_MODEL = 'closedverse_main.User'
|
||||
CSRF_FAILURE_VIEW = 'closedverse_main.views.csrf_fail'
|
||||
LOGIN_URL = '/login/'
|
||||
LOGIN_REDIRECT_URL = '/login/'
|
||||
|
||||
# Static files (CSS, JavaScript, Images)
|
||||
# https://docs.djangoproject.com/en/1.10/howto/static-files/
|
||||
STATICFILES_DIRS = [
|
||||
os.path.join(BASE_DIR, 'static/')
|
||||
]
|
||||
STATIC_URL = '/s/'
|
||||
STATIC_ROOT = os.path.join(BASE_DIR, 's/')
|
||||
STATICFILES_STORAGE = 'whitenoise.storage.CompressedStaticFilesStorage'
|
||||
|
||||
# Media root
|
||||
# This MUST end with a trailing slash and there must be an 'rm' folder in it
|
||||
# User-uploaded media paths for Closedverse
|
||||
#MEDIA_URL = '/media/'
|
||||
# Must end with a trailing slash
|
||||
MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')
|
||||
# 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 = '/i/'
|
||||
|
||||
# Cedar Three settings
|
||||
# reCAPTCHA v2 keys, None for no reCAPTCHA
|
||||
recaptcha_pub = ''
|
||||
recaptcha_priv = ''
|
||||
# Settings for markdown_deux, a module
|
||||
# that Closedverse uses in user messages
|
||||
MARKDOWN_DEUX_STYLES = {
|
||||
'default': {
|
||||
'extras': {
|
||||
'code-friendly': None,
|
||||
},
|
||||
'safe_mode': 'escape',
|
||||
},
|
||||
}
|
||||
|
||||
# NNID forbidden list. None for no passing.
|
||||
nnid_forbiddens = BASE_DIR + '/forbidden.json'
|
||||
# Initialize version and Git URL
|
||||
CLOSEDVERSE_GIT_VERSION = 'unknown'
|
||||
CLOSEDVERSE_GIT_URL = ''
|
||||
CLOSEDVERSE_GIT_HAS_CHANGES = False
|
||||
|
||||
# Memo title and message on communities list
|
||||
# I got rid of this setting because it was annoying i guess, edit the HTML to change it. -seedur
|
||||
# Only set git version/URL if .git folder exists
|
||||
if os.path.isdir(os.path.join(BASE_DIR, '.git')):
|
||||
# Get version from Git. This is shown in the layout
|
||||
git_process = os.popen('git rev-parse HEAD', 'r')
|
||||
CLOSEDVERSE_GIT_VERSION = git_process.read()[:-1]
|
||||
|
||||
# Client key to use for iphub.email, because we're using that
|
||||
# None for no IP checking (recommended since this is so slow)
|
||||
# if this command returns a non-zero exit code, then
|
||||
# there have been some changes so let's indicate that
|
||||
if os.system('git diff-index --quiet HEAD --'):
|
||||
CLOSEDVERSE_GIT_HAS_CHANGES = True
|
||||
|
||||
git_process = os.popen('git remote get-url origin', 'r')
|
||||
CLOSEDVERSE_GIT_URL = git_process.read()[:-1]
|
||||
|
||||
try:
|
||||
git_url_without_ext = CLOSEDVERSE_GIT_URL.split('.git')[0]
|
||||
except IndexError:
|
||||
pass
|
||||
else:
|
||||
CLOSEDVERSE_GIT_URL = git_url_without_ext + '/commit/' + CLOSEDVERSE_GIT_VERSION
|
||||
|
||||
# Google reCAPTCHA (v2) settings
|
||||
# This feature won't work if these fields are not populated.
|
||||
RECAPTCHA_PUBLIC_KEY = None
|
||||
RECAPTCHA_PRIVATE_KEY = None
|
||||
|
||||
# Key for IPHub service for Closedverse, which detects proxies.
|
||||
IPHUB_KEY = ""
|
||||
|
||||
# If IP can be checked, then use this to disallow any proxies
|
||||
disallow_proxy = False
|
||||
# If this is set to True, then users will receive an error
|
||||
# upon trying to sign up for the site behind a proxy.
|
||||
# Uses IPHub service and requires an API key defined above.
|
||||
DISALLOW_PROXY = False
|
||||
|
||||
# Setting this to True forces every user to log in/
|
||||
# sign up for the site to view any content.
|
||||
@@ -191,15 +251,10 @@ LOGIN_EXEMPT_URLS = {
|
||||
r'^help/login$',
|
||||
}
|
||||
|
||||
# MD
|
||||
MARKDOWN_DEUX_STYLES = {
|
||||
"default": {
|
||||
"extras": {
|
||||
"code-friendly": None,
|
||||
},
|
||||
"safe_mode": "escape",
|
||||
},
|
||||
}
|
||||
# Action to perform on images belonging to posts/
|
||||
# comments when they are deleted
|
||||
# 0: keep, 1: move to 'rm' folder, 2: delete
|
||||
IMAGE_DELETE_SETTING = 2
|
||||
|
||||
# allow sign ups.
|
||||
allow_signups = True
|
||||
@@ -226,20 +281,32 @@ max_banner_size = 1
|
||||
minimum_password_length = 7
|
||||
|
||||
# The hard limit for uploading, Will cause an error if this is exceeded. This is set to 15MB by default (15728640)
|
||||
DATA_UPLOAD_MAX_MEMORY_SIZE = 15728640
|
||||
DATA_UPLOAD_MAX_MEMORY_SIZE = 52428800
|
||||
|
||||
# Set the default theme here! Set this to None to use the normal Closedverse theme.
|
||||
# TODO, make this work for users who aren't logged in.
|
||||
# Example: site_wide_theme_hex = "#ff4159"
|
||||
# The site wide global theme cannot be deactivated by your users.
|
||||
site_wide_theme_hex = 'ff4159'
|
||||
|
||||
# The location to redirect to if a user's status is set to 2 (Redirect) (rickroll)
|
||||
inactive_redirect = "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
|
||||
|
||||
# Option to delete image if it's local
|
||||
# 0 - keep, 1 - move to 'rm' folder, 2 - DELETE
|
||||
IMAGE_DELETE_SETTING = 0
|
||||
image_delete_opt = 0
|
||||
|
||||
# age (minimal 13 due to C.O.P.P.A)
|
||||
age_allowed = "13"
|
||||
|
||||
# brand name currently being implemented throughout templates
|
||||
brand_name = "Cedar"
|
||||
|
||||
# This option enables some production-specific pages
|
||||
# and routines, such as HTTPS scheme redirection and
|
||||
# proxy detection via IPHub.
|
||||
CLOSEDVERSE_PROD = True
|
||||
|
||||
XFF_TRUSTED_PROXY_DEPTH = 1
|
||||
XFF_STRICT = True
|
||||
XFF_NO_SPOOFING = True
|
||||
XFF_ALWAYS_PROXY = True
|
||||
XFF_HEADER_REQUIRED = True
|
||||
|
||||
# uncomment this if you want miis to be retrieved on the server
|
||||
#mii_endpoint = '/origin?a='
|
||||
|
||||
+25
-16
@@ -1,30 +1,39 @@
|
||||
"""closedverse URL Configuration
|
||||
|
||||
The `urlpatterns` list routes URLs to views. For more information please see:
|
||||
https://docs.djangoproject.com/en/1.10/topics/http/urls/
|
||||
https://docs.djangoproject.com/en/2.2/topics/http/urls/
|
||||
Examples:
|
||||
Function views
|
||||
1. Add an import: from my_app import views
|
||||
2. Add a URL to urlpatterns: url(r'^$', views.home, name='home')
|
||||
2. Add a URL to urlpatterns: path('', views.home, name='home')
|
||||
Class-based views
|
||||
1. Add an import: from other_app.views import Home
|
||||
2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home')
|
||||
2. Add a URL to urlpatterns: path('', Home.as_view(), name='home')
|
||||
Including another URLconf
|
||||
1. Import the include() function: from django.conf.urls import url, include
|
||||
2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls'))
|
||||
1. Import the include() function: from django.urls import include, path
|
||||
2. Add a URL to urlpatterns: path('blog/', include('blog.urls'))
|
||||
"""
|
||||
from django.conf.urls import url, include
|
||||
|
||||
from django.contrib import admin
|
||||
from .settings import INSTALLED_APPS, MEDIA_ROOT, MEDIA_URL
|
||||
from django.conf.urls.static import static
|
||||
from django.urls import include, path, re_path
|
||||
from django.views.static import serve
|
||||
|
||||
#from closedverse_main import urls
|
||||
from closedverse.settings import STATIC_URL
|
||||
|
||||
# determine static root for admin app
|
||||
#admin_root = admin.__file__.replace('__init__.py', 'static/admin')
|
||||
# Set internal server error handler
|
||||
handler500 = 'closedverse_main.views.server_err'
|
||||
urlpatterns = [
|
||||
url(r'^admin/', admin.site.urls),
|
||||
url(r'^', include('closedverse_main.urls'))
|
||||
path('admin/', admin.site.urls),
|
||||
# edit - the below snippet and admin_root variable are only for if you don't want to use whitenoise
|
||||
# translation: i made all of this before realizing whitenoise could serve it lmao
|
||||
|
||||
# serve static for admin, in production? since admin is the only app now
|
||||
# accomodations might be needed for other apps (e.g silk?)
|
||||
# also the slice is meant to normalize e.g static_url being '/s/' to just 's/', etc. (is this necessary? prob not)
|
||||
#re_path(r'^'+STATIC_URL[1:]+'admin/(?P<path>.*)$', serve, {'document_root': admin_root}),
|
||||
|
||||
# URLs for Closedverse
|
||||
path('', include('closedverse_main.urls'))
|
||||
]
|
||||
|
||||
if 'silk' in INSTALLED_APPS:
|
||||
urlpatterns += [url(r'^silk/', include('silk.urls', namespace='silk'))]
|
||||
|
||||
urlpatterns += static(MEDIA_URL, document_root=MEDIA_ROOT)
|
||||
|
||||
+2
-2
@@ -4,13 +4,13 @@ WSGI config for closedverse 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.10/howto/deployment/wsgi/
|
||||
https://docs.djangoproject.com/en/2.2/howto/deployment/wsgi/
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
from django.core.wsgi import get_wsgi_application
|
||||
|
||||
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "closedverse.settings")
|
||||
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'closedverse.settings')
|
||||
|
||||
application = get_wsgi_application()
|
||||
|
||||
Reference in New Issue
Block a user