2019-08-20 18:04:10 +02:00
|
|
|
from flask import Flask, g
|
2018-02-23 23:34:06 +01:00
|
|
|
from flask_sqlalchemy import SQLAlchemy
|
|
|
|
from flask_migrate import Migrate
|
|
|
|
from flask_login import LoginManager
|
2020-07-21 21:06:00 +02:00
|
|
|
from flask_mail import Mail
|
2018-02-23 23:34:06 +01:00
|
|
|
from config import Config
|
2019-08-20 18:04:10 +02:00
|
|
|
import time
|
2020-07-22 10:44:56 +02:00
|
|
|
import slugify
|
2019-08-20 18:04:10 +02:00
|
|
|
|
2018-02-23 23:34:06 +01:00
|
|
|
app = Flask(__name__)
|
|
|
|
app.config.from_object(Config)
|
2019-09-05 23:42:47 +02:00
|
|
|
|
2019-12-04 12:22:16 +01:00
|
|
|
# Check security of secret
|
|
|
|
if Config.SECRET_KEY == "a-random-secret-key":
|
|
|
|
raise Exception("Please use a strong secret key!")
|
|
|
|
|
2018-02-23 23:34:06 +01:00
|
|
|
db = SQLAlchemy(app)
|
|
|
|
migrate = Migrate(app, db)
|
2020-07-21 21:06:00 +02:00
|
|
|
mail = Mail(app)
|
2019-02-02 17:34:41 +01:00
|
|
|
|
2019-12-03 20:32:01 +01:00
|
|
|
login = LoginManager(app)
|
|
|
|
login.login_view = 'login'
|
|
|
|
login.login_message = "Veuillez vous authentifier avant de continuer."
|
|
|
|
|
2019-09-05 23:42:47 +02:00
|
|
|
from app.utils.converters import *
|
|
|
|
app.url_map.converters['forum'] = ForumConverter
|
2020-07-16 23:58:21 +02:00
|
|
|
app.url_map.converters['topicpage'] = TopicPageConverter
|
2019-12-03 20:32:01 +01:00
|
|
|
|
2019-08-20 18:04:10 +02:00
|
|
|
@app.before_request
|
|
|
|
def request_time():
|
|
|
|
g.request_start_time = time.time()
|
|
|
|
g.request_time = lambda: "%.5fs" % (time.time() - g.request_start_time)
|
|
|
|
|
2019-12-04 01:16:16 +01:00
|
|
|
|
|
|
|
from app.processors.menu import menu_processor
|
|
|
|
from app.processors.utilities import utilities_processor
|
2019-08-20 18:04:10 +02:00
|
|
|
|
2019-06-06 01:06:46 +02:00
|
|
|
from app import models # IDK why this is here, but it works
|
2019-08-21 16:50:23 +02:00
|
|
|
from app.models.comment import Comment
|
|
|
|
from app.models.thread import Thread
|
|
|
|
from app.models.forum import Forum
|
2019-09-05 21:37:55 +02:00
|
|
|
from app.models.topic import Topic
|
2019-09-01 12:30:41 +02:00
|
|
|
from app.models.notification import Notification
|
2019-09-05 23:42:47 +02:00
|
|
|
|
2019-11-28 14:14:35 +01:00
|
|
|
from app.routes import index, search, users, tools # To load routes at initialization
|
2019-09-01 12:30:41 +02:00
|
|
|
from app.routes.account import login, account, notification
|
2019-09-02 21:35:16 +02:00
|
|
|
from app.routes.admin import index, groups, account, trophies, forums
|
2019-12-03 20:32:01 +01:00
|
|
|
from app.routes.forum import index, topic
|
2019-09-05 23:42:47 +02:00
|
|
|
|
2019-06-06 01:06:46 +02:00
|
|
|
from app.utils import pluralize # To use pluralize into the templates
|
2019-09-09 08:03:23 +02:00
|
|
|
from app.utils import date
|
2019-06-11 00:15:23 +02:00
|
|
|
from app.utils import is_title
|
2020-07-22 10:44:56 +02:00
|
|
|
|
|
|
|
# Add slugify into the available functions in every template
|
|
|
|
app.jinja_env.globals.update(
|
|
|
|
slugify=slugify.slugify
|
|
|
|
)
|