From 4ff472ee2b7bb87f0aa804586b69ca129f359ce1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Ku=C5=BE=C3=ADlek?= Date: Tue, 3 Mar 2020 11:54:08 +0100 Subject: [PATCH] Configs for deployment, the css --- yadc/__init__.py | 43 ++++++++++++++++++++++++++----------------- yadc/config.def.py | 14 ++++++++++++++ yadc/static/all.css | 1 + 3 files changed, 41 insertions(+), 17 deletions(-) create mode 100644 yadc/config.def.py create mode 100644 yadc/static/all.css diff --git a/yadc/__init__.py b/yadc/__init__.py index 39466a4..8acf90d 100644 --- a/yadc/__init__.py +++ b/yadc/__init__.py @@ -1,4 +1,5 @@ import os +import shutil from flask import Flask from flask_sqlalchemy import SQLAlchemy @@ -19,26 +20,34 @@ assets = AssetsEnvironment() def create_app(): - app = Flask(__name__) - app.config.from_mapping( - SECRET_KEY='dev', - #SQLALCHEMY_DATABASE_URI='sqlite:///{}'.format(os.path.join(app.instance_path, 'yadc.db')), - SQLALCHEMY_DATABASE_URI='postgresql://{}:{}@{}:{}/{}'.format('yadc', 'omegalul', 'localhost', 5432, 'yadc'), - MAX_CONTENT_LENGTH=10*1024*1024, - POST_LIST_THUMB_HEIGHT=200, - POST_UPLOADS=os.path.join(app.instance_path, 'post'), - INSTANCE_NAME='Darkne.su', - POSTS_PER_PAGE=8, - MANAGE_USERS_PER_PAGE=2, - MANAGE_POSTS_PER_PAGE=2, - - ALLOW_REGISTER=False, - - SQLALCHEMY_ECHO=True, - ) + app = Flask(__name__, instance_relative_config=True) + app.config.from_pyfile('config.py') + app.config.from_mapping(POST_UPLOADS=os.path.join(app.instance_path, 'post'), SQLALCHEMY_TRACK_MODIFICATIONS=False) + # app.config.from_mapping( + # SECRET_KEY='dev', + # #SQLALCHEMY_DATABASE_URI='sqlite:///{}'.format(os.path.join(app.instance_path, 'yadc.db')), + # SQLALCHEMY_DATABASE_URI='postgresql://{}:{}@{}:{}/{}'.format('yadc', 'omegalul', 'localhost', 5432, 'yadc'), + # MAX_CONTENT_LENGTH=10*1024*1024, + # POST_LIST_THUMB_HEIGHT=200, + # POST_UPLOADS=os.path.join(app.instance_path, 'post'), + # INSTANCE_NAME='Darkne.su', + # POSTS_PER_PAGE=8, + # MANAGE_USERS_PER_PAGE=2, + # MANAGE_POSTS_PER_PAGE=2, + + # ALLOW_REGISTER=False, + + # SQLALCHEMY_ECHO=True, + # ) try: os.makedirs(app.instance_path) + + # os.makedirs(app.config.get('POST_UPLOADS')) + for d in ['img', 'jpeg', 'sample', 'thumb']: + os.makedirs(os.path.join(app.config.get('POST_UPLOADS'), d)) + + # shutil.copyfile(os.path.join(app.root_path, 'config.def.py'), os.path.join(app.instance_path, 'config.py')) except OSError: pass diff --git a/yadc/config.def.py b/yadc/config.def.py new file mode 100644 index 0000000..ba7897d --- /dev/null +++ b/yadc/config.def.py @@ -0,0 +1,14 @@ +INSTANCE_NAME = 'Darkne.su' + +ALLOW_REGISTER = False + +SECRET_KEY = '' +# SQLALCHEMY_ECHO = True +SQLALCHEMY_DATABASE_URI = 'postgresql://{}:{}@{}:{}/{}'.format('yadc', 'password', 'localhost', 5432, 'yadc') + +MAX_CONTENT_LENGTH = 10*1024*1024 + +POST_LIST_THUMB_HEIGHT = 200 +POSTS_PER_PAGE = 8 +MANAGE_USERS_PER_PAGE = 8 +MANAGE_POSTS_PER_PAGE = 8 \ No newline at end of file diff --git a/yadc/static/all.css b/yadc/static/all.css new file mode 100644 index 0000000..8bf9758 --- /dev/null +++ b/yadc/static/all.css @@ -0,0 +1 @@ +*{box-sizing:border-box}body{margin:0;font-family:Verdana,Geneva,Tahoma,sans-serif;background-color:#222;color:#fff}a{color:#bbb;text-decoration:none}a:hover{color:#909090;text-decoration:none}header{display:flex;align-items:baseline;padding:0 10px;background-color:#222}header>a.logo{font-size:2em;margin:6px}@media(max-width:559px){header{position:relative}}header>nav{flex-grow:1;display:flex}header>nav>._overlay{display:none}@media(max-width:559px){header>nav{display:none}header>nav._drop{display:flex;flex-flow:column nowrap;position:absolute;margin:0;top:100%;left:0;right:0;z-index:10;background-color:#111d}header>nav>a,header>nav a#user-menu,header>nav .user_dropdown>a{padding:12px;padding-left:24px}header>nav>a:hover,header>nav>a:active,header>nav a#user-menu:hover,header>nav a#user-menu:active,header>nav .user_dropdown>a:hover,header>nav .user_dropdown>a:active{background-color:#333}header>nav .user::before{content:"";display:block;border-top:1px solid grey;margin:2px 12px}header>nav .user #user-menu{display:block}header>nav .user .user_dropdown{display:flex;flex-flow:column nowrap}header>nav>._overlay{display:block;position:fixed;width:100%;height:100%;z-index:-1;background-color:#0006}html.oh{overflow:hidden}}@media(min-width:560px){header>nav{margin:0 5px;align-items:center}header>nav>*{margin:0 5px;padding:6px 0}header>nav>.user{padding:0;margin-left:auto;margin-right:0;position:relative}header>nav>.user #user-menu{display:block;padding:6px 10px}header>nav>.user .user_dropdown{display:none}header>nav>.user .user_dropdown a{padding:10px}header>nav>.user .user_dropdown a:hover{background-color:#333}header>nav>.user:hover>.user_dropdown{display:flex;flex-flow:column nowrap;position:absolute;margin:0;top:100%;right:0;z-index:10;background-color:#111d}}header>#nav-menu{display:none}@media(max-width:559px){header>#nav-menu{display:block;margin:5px;margin-left:auto;padding:0 2px;align-self:center;font-size:2em;cursor:pointer}}.flash_msgs{display:flex;flex-flow:column-reverse nowrap;position:fixed;z-index:20;bottom:0;right:0;margin:0;padding:10px;font-size:.9em;pointer-events:none}.flash_msgs>li{width:250px;padding:10px;background-color:#000c;overflow:hidden;opacity:0;animation:fade 7s normal}.flash_msgs>li:not(:first-child){margin-bottom:10px}@keyframes fade{0%,100%{opacity:0}20%,80%{opacity:1}}.main_wrap{margin:0 auto;max-width:1300px;padding:8px;padding-top:0;padding-bottom:0}.main_wrap h3{margin:0;margin-bottom:10px;font-size:1.3em}.main_wrap .important_subwrap{display:flex;overflow:visible}@media(max-width:899px){.main_wrap .important_subwrap{flex-flow:column nowrap}}@media(min-width:900px){.main_wrap .important_subwrap{flex-flow:row nowrap}}.main_wrap .important_subwrap>section.side_panel{flex-shrink:0;padding:10px}@media(min-width:900px){.main_wrap .important_subwrap>section.side_panel{width:18rem;height:0}}.main_wrap .important_subwrap>section.side_panel article{margin-bottom:10px}.main_wrap .important_subwrap>section.side_panel article.tags .searchbox{width:calc(18rem - 50px);position:relative}.main_wrap .important_subwrap>section.side_panel article.tags .searchbox input[name=tagsearch]{width:100%}.main_wrap .important_subwrap>section.side_panel article.tags .searchbox>.search_dropdown{display:flex;flex-flow:column nowrap;align-items:start;width:100%;position:absolute;z-index:10;overflow:auto;background-color:#2d2d2de0}.main_wrap .important_subwrap>section.side_panel article.tags .tag_container>a,.main_wrap .important_subwrap>section.side_panel article.tags .search_dropdown>a{margin:2px 2px;padding:.35em .6em;border-radius:4px;background-color:#121212ff;cursor:pointer}.main_wrap .important_subwrap>section.side_panel article.tags .tag_container>a>*,.main_wrap .important_subwrap>section.side_panel article.tags .search_dropdown>a>*{pointer-events:none}.main_wrap .important_subwrap>section.side_panel article.tags .tag_container>a>.fa-tag,.main_wrap .important_subwrap>section.side_panel article.tags .search_dropdown>a>.fa-tag{font-size:.9em;margin-right:2px}.main_wrap .important_subwrap>section.side_panel article.tags .tag_container>a>.count,.main_wrap .important_subwrap>section.side_panel article.tags .search_dropdown>a>.count{font-size:.8em}.main_wrap .important_subwrap>section.side_panel article.tags .tag_container>a:not(:hover)>span.close,.main_wrap .important_subwrap>section.side_panel article.tags .search_dropdown>a:not(:hover)>span.close{display:none}.main_wrap .important_subwrap>section.side_panel article.tags .tag_container>a:not(:hover)>span.plus,.main_wrap .important_subwrap>section.side_panel article.tags .search_dropdown>a:not(:hover)>span.plus{display:none}.main_wrap .important_subwrap>section.side_panel article.tags .tag_container>a:hover>span.count,.main_wrap .important_subwrap>section.side_panel article.tags .search_dropdown>a:hover>span.count{display:none}.main_wrap .important_subwrap>section.side_panel article.tags .tag_container>a.tagselected,.main_wrap .important_subwrap>section.side_panel article.tags .search_dropdown>a.tagselected{background-color:#400808ff}.main_wrap .important_subwrap>section.side_panel article.tags .tag_container>a.tag_hide,.main_wrap .important_subwrap>section.side_panel article.tags .search_dropdown>a.tag_hide{display:none}.main_wrap .important_subwrap>section.side_panel article.tags .tag_container{display:flex}@media(max-width:899px){.main_wrap .important_subwrap>section.side_panel article.tags .tag_container{flex-flow:row wrap}}@media(min-width:900px){.main_wrap .important_subwrap>section.side_panel article.tags .tag_container{flex-flow:column nowrap;align-items:start}}.main_wrap .important_subwrap>section.side_panel article.post_desc{display:flex;flex-flow:column nowrap;font-size:.9em}.main_wrap .important_subwrap>section.side_panel article.post_desc>img{display:block;max-width:128px}@media(min-width:900px){.main_wrap .important_subwrap>section:not(.side_panel){width:100%}}.main_wrap section.post_list{overflow:hidden}@media(max-width:559px){.main_wrap section.post_list{margin-left:-8px;margin-right:-8px}}.main_wrap section.post_list .posts{display:flex;flex-flow:row wrap}@media(max-width:899px){.main_wrap section.post_list .posts{margin-left:-8px;margin-right:-8px}}.main_wrap section.post_list .posts::after{content:"";flex:10000 0 350px}.main_wrap section.post_list .posts>figure{position:relative;margin:8px}.main_wrap section.post_list .posts>figure img{display:block;width:100%;height:100%;transition:.2s ease}.main_wrap section.post_list .posts>figure:hover img{opacity:.7}@media(min-width:900px){.main_wrap section.post_single{padding:8px}}@media(max-width:899px){.main_wrap section.post_single{order:-1;margin-bottom:8px}}@media(max-width:559px){.main_wrap section.post_single{margin-left:-8px;margin-right:-8px}}.main_wrap section.post_single img{display:block;max-width:100%}.main_wrap section.comments{padding:10px}@media(min-width:900px){.main_wrap section.comments{margin-left:18rem}}.main_wrap section.comments>.comment_container{padding:0 10px;max-width:500px}.main_wrap section.comments>.comment_container article{overflow:hidden;margin-bottom:1em}.main_wrap section.comments>.comment_container h4{margin:0;margin-bottom:.5em}.main_wrap section.comments>.comment_container p,.main_wrap section.comments>.comment_container textarea{margin:0}.main_wrap section.comments>.comment_container p.deleted,.main_wrap section.comments>.comment_container textarea.deleted{color:red}.main_wrap section.comments>.comment_container .head{display:flex;justify-content:space-between}.main_wrap section.comments>.form>form{margin-left:10px;max-width:500px}.main_wrap section.comments>.form>form input:required{box-shadow:none}.main_wrap section.comments>.form>form textarea{width:100%;background:#444a;border:none;color:inherit;font:inherit}.main_wrap section.management_table table{margin:0 auto}.main_wrap section.management_table tr th{background-color:#606060}.main_wrap section.management_table tr:nth-child(even){background-color:#303030}.main_wrap section.management_table tr th,.main_wrap section.management_table tr td{padding:6px 10px}.main_wrap section.management_table tr:not(.edit) td>.edit{display:none}.main_wrap section.management_table tr.edit td>.show{display:none}.main_wrap section.management_table tr input[type=submit]{display:none}.main_wrap section.management_table tr .fa{padding:4px 4px;align-self:center;font-size:1.5em;cursor:pointer}.main_wrap form.editingable:not(.time-to-edit) .edit{display:none}.main_wrap form.editingable.time-to-edit .notedit{display:none}.main_wrap form.editingable input[type=text],.main_wrap form.editingable textarea{resize:vertical;width:100%}.main_wrap form.editingable input[type=text].edit,.edit .main_wrap form.editingable input[type=text],.main_wrap form.editingable textarea.edit,.edit .main_wrap form.editingable textarea{background:#444a;border:none;color:inherit;font:inherit}.main_wrap form input{margin:5px 0}.main_wrap .pagin{margin:10px 0;display:flex;flex-flow:row nowrap;justify-content:center}.main_wrap .pagin>a{display:block;background-color:#0005;padding:8px 12px;margin:0 2px}footer{padding:10px;text-align:center} \ No newline at end of file