2014-08-20 18:28:25 +03:00
|
|
|
import os
|
|
|
|
import json
|
|
|
|
from urlparse import urlparse
|
2013-12-03 22:09:57 +02:00
|
|
|
|
2014-09-18 00:13:10 +03:00
|
|
|
|
|
|
|
def update(data):
|
|
|
|
conf = read()
|
|
|
|
conf.update(data)
|
|
|
|
save(data)
|
|
|
|
|
|
|
|
|
|
|
|
def read():
|
|
|
|
conf = dict()
|
|
|
|
|
|
|
|
try:
|
|
|
|
with open(os.path.join(APP_PATH, 'config.json')) as f:
|
|
|
|
conf = json.load(f)
|
|
|
|
except IOError:
|
|
|
|
pass
|
|
|
|
|
|
|
|
return conf
|
|
|
|
|
|
|
|
|
|
|
|
def save(conf):
|
|
|
|
with open(os.path.join(APP_PATH, 'config.json'), 'w') as f:
|
2014-09-19 00:44:01 +03:00
|
|
|
f.write(json.dumps(conf, sort_keys=True, indent=4, separators=(',', ': ')).strip() + '\n')
|
2014-09-18 00:13:10 +03:00
|
|
|
|
|
|
|
APP_PATH = os.path.abspath(os.path.dirname(__file__) + "/../..")
|
|
|
|
USER_HOME = os.path.abspath(os.path.expanduser("~"))
|
2014-09-02 17:29:04 +03:00
|
|
|
|
2014-08-20 18:28:25 +03:00
|
|
|
ENV = 'DEV'
|
2013-12-03 22:09:57 +02:00
|
|
|
|
2014-08-20 18:28:25 +03:00
|
|
|
DEBUG = True
|
|
|
|
ASSETS_DEBUG = True
|
2014-09-18 00:13:10 +03:00
|
|
|
SQLALCHEMY_ECHO = False
|
2014-08-30 18:06:12 +03:00
|
|
|
|
2014-09-04 05:29:47 +03:00
|
|
|
PORT = 5000
|
2014-09-18 00:13:10 +03:00
|
|
|
BASE_URL = 'http://localhost'
|
2014-09-04 05:29:47 +03:00
|
|
|
SITE_TITLE = "Realms"
|
2013-12-03 22:09:57 +02:00
|
|
|
|
2014-10-03 21:49:18 +03:00
|
|
|
# https://pythonhosted.org/Flask-SQLAlchemy/config.html#connection-uri-format
|
2014-09-02 17:29:04 +03:00
|
|
|
DB_URI = 'sqlite:///%s/wiki.db' % USER_HOME
|
2014-10-03 21:49:18 +03:00
|
|
|
# DB_URI = 'mysql://scott:tiger@localhost/mydatabase'
|
|
|
|
# DB_URI = 'postgresql://scott:tiger@localhost/mydatabase'
|
|
|
|
# DB_URI = 'oracle://scott:tiger@127.0.0.1:1521/sidname'
|
2014-08-30 18:06:12 +03:00
|
|
|
|
|
|
|
CACHE_TYPE = 'simple'
|
|
|
|
|
2014-09-18 00:13:10 +03:00
|
|
|
# Redis
|
|
|
|
#CACHE_TYPE = 'redis'
|
2014-08-30 18:06:12 +03:00
|
|
|
CACHE_REDIS_HOST = '127.0.0.1'
|
|
|
|
CACHE_REDIS_PORT = 6379
|
|
|
|
CACHE_REDIS_DB = '0'
|
2014-09-18 00:13:10 +03:00
|
|
|
|
|
|
|
# Memcached
|
|
|
|
#CACHE_TYPE = 'memcached'
|
|
|
|
CACHE_MEMCACHED_SERVERS = ['127.0.0.1:11211']
|
|
|
|
|
2014-09-04 05:29:47 +03:00
|
|
|
# Get ReCaptcha Keys for your domain here:
|
|
|
|
# https://www.google.com/recaptcha/admin#whyrecaptcha
|
2014-09-02 17:29:04 +03:00
|
|
|
RECAPTCHA_ENABLE = False
|
2014-08-30 18:06:12 +03:00
|
|
|
RECAPTCHA_USE_SSL = False
|
|
|
|
RECAPTCHA_PUBLIC_KEY = "6LfYbPkSAAAAAB4a2lG2Y_Yjik7MG9l4TDzyKUao"
|
|
|
|
RECAPTCHA_PRIVATE_KEY = "6LfYbPkSAAAAAG-KlkwjZ8JLWgwc9T0ytkN7lWRE"
|
|
|
|
RECAPTCHA_OPTIONS = {}
|
|
|
|
|
2014-09-18 00:13:10 +03:00
|
|
|
SECRET_KEY = 'CHANGE_ME'
|
2013-12-03 22:09:57 +02:00
|
|
|
|
2014-09-14 06:47:17 +03:00
|
|
|
# Path on file system where wiki data will reside
|
2014-09-10 00:01:00 +03:00
|
|
|
WIKI_PATH = os.path.join(APP_PATH, 'wiki')
|
2014-09-14 06:47:17 +03:00
|
|
|
|
|
|
|
# Name of page that will act as home
|
2014-08-20 18:28:25 +03:00
|
|
|
WIKI_HOME = 'home'
|
2014-09-14 06:47:17 +03:00
|
|
|
|
2014-08-20 18:28:25 +03:00
|
|
|
ALLOW_ANON = True
|
2014-09-14 06:47:17 +03:00
|
|
|
REGISTRATION_ENABLED = True
|
|
|
|
|
|
|
|
# Used by Flask-Login
|
2014-08-30 18:06:12 +03:00
|
|
|
LOGIN_DISABLED = ALLOW_ANON
|
2013-12-03 22:09:57 +02:00
|
|
|
|
2014-10-02 01:14:54 +03:00
|
|
|
# None, firepad, or togetherjs
|
|
|
|
COLLABORATION = 'togetherjs'
|
|
|
|
|
|
|
|
# Required for firepad
|
|
|
|
FIREBASE_HOSTNAME = None
|
|
|
|
|
2014-09-10 21:58:47 +03:00
|
|
|
# Page names that can't be modified
|
2014-09-14 06:47:17 +03:00
|
|
|
WIKI_LOCKED_PAGES = []
|
|
|
|
# Depreciated variable name
|
|
|
|
LOCKED = WIKI_LOCKED_PAGES
|
2014-09-10 21:58:47 +03:00
|
|
|
|
2013-12-03 22:09:57 +02:00
|
|
|
ROOT_ENDPOINT = 'wiki.page'
|
|
|
|
|
2014-09-29 23:22:20 +03:00
|
|
|
__env = {}
|
|
|
|
for k, v in os.environ.items():
|
|
|
|
if k.startswith('REALMS_'):
|
|
|
|
__env[k[7:]] = v
|
|
|
|
|
|
|
|
globals().update(__env)
|
|
|
|
|
2014-09-09 00:05:23 +03:00
|
|
|
try:
|
|
|
|
with open(os.path.join(APP_PATH, 'config.json')) as f:
|
|
|
|
__settings = json.load(f)
|
2014-09-14 06:47:17 +03:00
|
|
|
for k in ['APP_PATH', 'USER_HOME']:
|
|
|
|
if k in __settings:
|
|
|
|
del __settings[k]
|
2014-09-09 00:05:23 +03:00
|
|
|
globals().update(__settings)
|
|
|
|
except IOError:
|
|
|
|
pass
|
2014-08-20 18:28:25 +03:00
|
|
|
|
|
|
|
if BASE_URL.endswith('/'):
|
|
|
|
BASE_URL = BASE_URL[-1]
|
|
|
|
|
2014-08-30 18:06:12 +03:00
|
|
|
SQLALCHEMY_DATABASE_URI = DB_URI
|
|
|
|
|
2014-08-20 18:28:25 +03:00
|
|
|
_url = urlparse(BASE_URL)
|
|
|
|
RELATIVE_PATH = _url.path
|
|
|
|
|
|
|
|
if ENV != "DEV":
|
|
|
|
DEBUG = False
|
|
|
|
ASSETS_DEBUG = False
|
2014-09-02 17:29:04 +03:00
|
|
|
SQLALCHEMY_ECHO = False
|
2014-08-20 18:28:25 +03:00
|
|
|
|
|
|
|
MODULES = ['wiki', 'auth']
|