heck
This commit is contained in:
parent
5efee0ffd2
commit
c2796a5075
15
http_server/izzylib/http_server/activitypub.py
Normal file
15
http_server/izzylib/http_server/activitypub.py
Normal file
|
@ -0,0 +1,15 @@
|
|||
from . import view
|
||||
|
||||
|
||||
class ActivityPub:
|
||||
def __init__(self, app):
|
||||
self.app = app
|
||||
self.cfg = app.cfg
|
||||
|
||||
|
||||
def setup_views(self):
|
||||
self.app.add_class_route(view.Actor)
|
||||
self.app.add_class_route(view.Nodeinfo)
|
||||
self.app.add_class_route(view.Webfinger)
|
||||
self.app.add_class_route(view.WkHostMeta)
|
||||
self.app.add_class_route(view.WkNodeinfo)
|
|
@ -30,7 +30,7 @@ class GenericError:
|
|||
traceback.print_exc()
|
||||
|
||||
try:
|
||||
return response.error(msg, status)
|
||||
return response.error(msg, status, pprint=True)
|
||||
|
||||
except Exception as e:
|
||||
traceback.print_exc()
|
||||
|
|
|
@ -43,6 +43,7 @@ input:not([type='checkbox']), select, textarea {
|
|||
background-color: var(--background);
|
||||
border: 1px solid var(--background);
|
||||
box-shadow: 0 2px 2px 0 var(--shadow-color);
|
||||
padding: 5px;
|
||||
}
|
||||
|
||||
input:hover, select:hover, textarea:hover {
|
||||
|
@ -195,9 +196,9 @@ details:focus, summary:focus {
|
|||
|
||||
#content-body .title {
|
||||
text-align: center;
|
||||
font-size: 1.5em;
|
||||
font-size: 2em;
|
||||
font-weight: bold;
|
||||
color: var(--primary)
|
||||
color: var(--primary);
|
||||
}
|
||||
|
||||
#footer {
|
||||
|
@ -226,32 +227,16 @@ details:focus, summary:focus {
|
|||
white-space: nowrap;
|
||||
}
|
||||
|
||||
{% for name in cssfiles %}
|
||||
{% include 'style/' + name + '.css' %}
|
||||
{% endfor %}
|
||||
|
||||
|
||||
/* responsive design */
|
||||
@media (max-width: 810px) {
|
||||
body {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#body {
|
||||
width: auto;
|
||||
}
|
||||
#logreg input, textarea {
|
||||
display: block;
|
||||
margin: 8px auto;
|
||||
}
|
||||
|
||||
@media (max-width: 610px) {
|
||||
.settings .grid-container {
|
||||
grid-template-columns: auto;
|
||||
}
|
||||
|
||||
.settings .label {
|
||||
text-align: center;
|
||||
}
|
||||
#logreg textarea, input:not([type='submit']) {
|
||||
width: 50%;
|
||||
}
|
||||
|
||||
|
||||
/* Main menu */
|
||||
#btn {
|
||||
cursor: pointer;
|
||||
|
@ -277,7 +262,7 @@ details:focus, summary:focus {
|
|||
position: fixed;
|
||||
z-index: 5;
|
||||
top: 12px;
|
||||
{% if menu_left %}right: calc(100% - 250px + 12px){% else %}right: 12px;{% endif %};
|
||||
{% if menu_left %}right: calc(100% - 250px + 12px){% else %}right: 12px{% endif %};
|
||||
background-color: {{primary.darken(75)}};
|
||||
color: {{background}};
|
||||
}
|
||||
|
@ -397,6 +382,37 @@ details:focus, summary:focus {
|
|||
}
|
||||
|
||||
|
||||
{% for name in cssfiles %}
|
||||
{% include 'style/' + name + '.css' %}
|
||||
{% endfor %}
|
||||
|
||||
|
||||
/* responsive design */
|
||||
@media (max-width: 810px) {
|
||||
body {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
#body {
|
||||
width: auto;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 610px) {
|
||||
.settings .grid-container {
|
||||
grid-template-columns: auto;
|
||||
}
|
||||
|
||||
.settings .label {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
#logreg textarea, input:not([type='submit']) {
|
||||
width: calc(100% - 16px);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* scrollbar */
|
||||
body {scrollbar-width: 15px; scrollbar-color: var(--primary) {{background.darken(10)}};}
|
||||
::-webkit-scrollbar {width: 15px;}
|
||||
|
|
|
@ -2,10 +2,10 @@
|
|||
%html
|
||||
%head
|
||||
%title << {{cfg.name}}: {{page}}
|
||||
%link rel='stylesheet' type='text/css' href='/framework/style.css'
|
||||
%link rel='manifest' href='/framework/manifest.json'
|
||||
%meta charset='UTF-8'
|
||||
%meta name='viewport' content='width=device-width, initial-scale=1'
|
||||
%link(rel='stylesheet' type='text/css' href='/framework/style.css')
|
||||
%link(rel='manifest' href='/framework/manifest.json')
|
||||
%meta(charset='UTF-8')
|
||||
%meta(name='viewport' content='width=device-width, initial-scale=1')
|
||||
-block head
|
||||
|
||||
%body
|
||||
|
@ -13,10 +13,10 @@
|
|||
#header.flex-container
|
||||
-if menu_left
|
||||
#btn.section
|
||||
.page-title.section -> %a.title href='/' << {{cfg.name}}
|
||||
.page-title.section -> %a.title(href='/') << {{cfg.name}}
|
||||
|
||||
-else
|
||||
.page-title.section -> %a.title href='/' << {{cfg.name}}
|
||||
.page-title.section -> %a.title(href='/') << {{cfg.name}}
|
||||
#btn.section
|
||||
|
||||
-if message
|
||||
|
@ -34,9 +34,9 @@
|
|||
-else:
|
||||
-for label, path_data in cfg.menu.items()
|
||||
-if path_data[1] == 1000 and request.user_level == 0:
|
||||
.item -> %a href='{{path_data[0]}}' << {{label}}
|
||||
.item -> %a(href='{{path_data[0]}}') << {{label}}
|
||||
-elif request.user_level >= path_data[1]
|
||||
.item -> %a href='{{path_data[0]}}' << {{label}}
|
||||
.item -> %a(href='{{path_data[0]}}') << {{label}}
|
||||
|
||||
#content-body.section
|
||||
-block content
|
||||
|
@ -45,6 +45,6 @@
|
|||
.avatar
|
||||
.user
|
||||
.source
|
||||
%a href='{{cfg.git_repo}}' target='_new' << {{cfg.name}}/{{cfg.version}}
|
||||
%a(href='{{cfg.git_repo}}' target='_new') << {{cfg.name}}/{{cfg.version}}
|
||||
|
||||
%script type='application/javascript' src='/framework/static/menu.js'
|
||||
%script(type='application/javascript' src='/framework/static/menu.js')
|
||||
|
|
|
@ -1 +1 @@
|
|||
.item => %a(href='/') << Home
|
||||
.item -> %a(href='/') << Home
|
||||
|
|
|
@ -6,7 +6,7 @@ from .misc import Headers
|
|||
|
||||
|
||||
class Request(sanic.request.Request):
|
||||
def __init__(self, url_bytes, headers, version, method, transport, app, **kwargs):
|
||||
def __init__(self, url_bytes, headers, version, method, transport, app):
|
||||
super().__init__(url_bytes, headers, version, method, transport, app)
|
||||
|
||||
self.Headers = Headers(headers)
|
||||
|
|
|
@ -5,6 +5,7 @@ from izzylib import DotDict, izzylog
|
|||
from izzylib.template import Color
|
||||
from sanic.compat import Header
|
||||
from sanic.cookies import CookieJar
|
||||
from sanic.response import text as Raw
|
||||
|
||||
|
||||
class Response:
|
||||
|
@ -171,6 +172,7 @@ class Response:
|
|||
|
||||
def error(self, message, status=500, **kwargs):
|
||||
if self.request and 'json' in self.request.headers.get('accept', ''):
|
||||
kwargs.pop('pprint', None)
|
||||
return self.json({f'error {status}': message}, status=status, **kwargs)
|
||||
|
||||
return self.template('error.haml', {'error_message': message}, status=status, **kwargs)
|
||||
|
@ -224,7 +226,7 @@ class Response:
|
|||
def get_response(self, *args, **kwargs):
|
||||
self.set_data(*args, **kwargs)
|
||||
|
||||
response = sanic.response.HTTPResponse(self.body, self.status, self.headers, self.content_type)
|
||||
response = sanic.response.raw(self.body, self.status, self.headers, self.content_type)
|
||||
response._cookies = self.cookies
|
||||
|
||||
return response
|
||||
|
|
|
@ -62,7 +62,8 @@ class Style(View):
|
|||
paths = ['/framework/style.css']
|
||||
|
||||
async def get(self, request, response):
|
||||
return response.template('base.css', content_type='text/css')
|
||||
resp = response.template('base.css', content_type='text/css')
|
||||
return resp
|
||||
|
||||
|
||||
### ActivityPub Views ###
|
||||
|
|
|
@ -2,5 +2,5 @@
|
|||
from .generic import SqlColumn, CustomRows, SqlSession, SqlDatabase, Tables, OperationalError, ProgrammingError
|
||||
from .sqlite_server import SqliteClient, SqliteColumn, SqliteServer, SqliteSession
|
||||
|
||||
from .database import Database, Session
|
||||
from .queries import Column, Insert, Select, Table, Tables, Update
|
||||
#from .database import Database, Session
|
||||
#from .queries import Column, Insert, Select, Table, Tables, Update
|
||||
|
|
|
@ -46,10 +46,7 @@ class SqlDatabase:
|
|||
engine_string = dbtype + '://'
|
||||
|
||||
if dbtype == 'sqlite':
|
||||
try:
|
||||
database = kwargs['name']
|
||||
except KeyError:
|
||||
database = kwargs['database']
|
||||
|
||||
if nfs_check(database):
|
||||
izzylog.error('Database file is on an NFS share which does not support locking. Any writes to the database will fail')
|
||||
|
|
|
@ -129,6 +129,10 @@ class Template(Environment):
|
|||
except TypeError:
|
||||
context = self.func_context(context, {})
|
||||
|
||||
if context == None:
|
||||
izzylog.warning('Template context was set to "None"')
|
||||
context = {}
|
||||
|
||||
result = self.get_template(tplfile).render(context)
|
||||
|
||||
if pprint and any(map(tplfile.endswith, ['haml', 'html', 'xml'])):
|
||||
|
|
Loading…
Reference in a new issue