Changed server.
This commit is contained in:
parent
821db3cb1a
commit
3623286a9d
@ -65,6 +65,13 @@ class Application(BaseApplication):
|
|||||||
self.setup_router()
|
self.setup_router()
|
||||||
self.db.query("PRAGMA journal_mode=WAL")
|
self.db.query("PRAGMA journal_mode=WAL")
|
||||||
self.db.query("PRAGMA syncnorm=off")
|
self.db.query("PRAGMA syncnorm=off")
|
||||||
|
if not self.db["user"].has_index("username"):
|
||||||
|
self.db["user"].create_index("username", unique=True)
|
||||||
|
if not self.db["channel_member"].has_index(["channel_uid","user_uid"]):
|
||||||
|
self.db["channel_member"].create_index(["channel_uid","user_uid"])
|
||||||
|
if not self.db["channel_message"].has_index(["channel_uid","user_uid"]):
|
||||||
|
self.db["channel_message"].create_index(["channel_uid","user_uid"])
|
||||||
|
|
||||||
self.cache = Cache(self)
|
self.cache = Cache(self)
|
||||||
self.services = get_services(app=self)
|
self.services = get_services(app=self)
|
||||||
self.mappers = get_mappers(app=self)
|
self.mappers = get_mappers(app=self)
|
||||||
|
@ -111,6 +111,21 @@ a {
|
|||||||
height: 200px;
|
height: 200px;
|
||||||
background: #1a1a1a;
|
background: #1a1a1a;
|
||||||
}
|
}
|
||||||
|
.container {
|
||||||
|
flex: 1;
|
||||||
|
padding: 10px;
|
||||||
|
ul {
|
||||||
|
list-style: none;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
a {
|
||||||
|
font-size: 20px;
|
||||||
|
color: #f05a28;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
.chat-messages::-webkit-scrollbar {
|
.chat-messages::-webkit-scrollbar {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
"description": "Danger noodle",
|
"description": "Danger noodle",
|
||||||
"display": "standalone",
|
"display": "standalone",
|
||||||
"orientation": "portrait",
|
"orientation": "portrait",
|
||||||
"scope": "/web.html",
|
"scope": "/",
|
||||||
"theme_color": "#000000",
|
"theme_color": "#000000",
|
||||||
"background_color": "#000000",
|
"background_color": "#000000",
|
||||||
"related_applications": [],
|
"related_applications": [],
|
||||||
|
@ -74,10 +74,6 @@ def set_link_target_blank(text):
|
|||||||
element.attrs['rel'] = 'noopener noreferrer'
|
element.attrs['rel'] = 'noopener noreferrer'
|
||||||
element.attrs['referrerpolicy'] = 'no-referrer'
|
element.attrs['referrerpolicy'] = 'no-referrer'
|
||||||
element.attrs['href'] = element.attrs['href'].strip(".")
|
element.attrs['href'] = element.attrs['href'].strip(".")
|
||||||
#if element.attrs['href'].startswith("https://www.you") and "?v=" in element.attrs["href"]:
|
|
||||||
# video_name = element.attrs["href"].split("?v=")[1].split("&")[0]
|
|
||||||
# embed_template = f'<iframe width="560" height="315" src="https://www.youtube.com/embed/{video_name}" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>'
|
|
||||||
# element.replace_with(BeautifulSoup(embed_template, 'html.parser'))
|
|
||||||
|
|
||||||
return str(soup)
|
return str(soup)
|
||||||
|
|
||||||
@ -93,7 +89,7 @@ def embed_youtube(text):
|
|||||||
def embed_image(text):
|
def embed_image(text):
|
||||||
soup = BeautifulSoup(text, 'html.parser')
|
soup = BeautifulSoup(text, 'html.parser')
|
||||||
for element in soup.find_all("a"):
|
for element in soup.find_all("a"):
|
||||||
for extension in [".png", ".jpeg", ".gif", ".webp", ".svg", ".bmp", ".tiff", ".ico", ".heif"]:
|
for extension in [".png", ".jpg", ".jpeg", ".gif", ".webp", ".svg", ".bmp", ".tiff", ".ico", ".heif"]:
|
||||||
if extension in element.attrs['href'].lower():
|
if extension in element.attrs['href'].lower():
|
||||||
embed_template = f'<img src="{element.attrs["href"]}" title="{element.attrs["href"]}" alt="{element.attrs["href"]}" />'
|
embed_template = f'<img src="{element.attrs["href"]}" title="{element.attrs["href"]}" alt="{element.attrs["href"]}" />'
|
||||||
element.replace_with(BeautifulSoup(embed_template, 'html.parser'))
|
element.replace_with(BeautifulSoup(embed_template, 'html.parser'))
|
||||||
|
@ -34,7 +34,7 @@
|
|||||||
<main>
|
<main>
|
||||||
{% block sidebar %}
|
{% block sidebar %}
|
||||||
<aside class="sidebar">
|
<aside class="sidebar">
|
||||||
<h2 class="no-select">Chat Rooms</h2>
|
<h2 class="no-select">Channels</h2>
|
||||||
<ul>
|
<ul>
|
||||||
{% for channel in channels %}
|
{% for channel in channels %}
|
||||||
<li><a class="no-select" href="/channel/{{channel['uid']}}.html">{{channel['name']}}</a></li>
|
<li><a class="no-select" href="/channel/{{channel['uid']}}.html">{{channel['name']}}</a></li>
|
||||||
|
@ -2,25 +2,27 @@
|
|||||||
|
|
||||||
{% block title %}Search{% endblock %}
|
{% block title %}Search{% endblock %}
|
||||||
|
|
||||||
{% block main %}
|
{% block main %}
|
||||||
|
|
||||||
<section class="chat-area">
|
<section class="chat-area">
|
||||||
<div class="chat-header"><h2>Search user</h2></div>
|
<div class="chat-header">
|
||||||
<div class="chat-messages">
|
<h2>Search user</h2>
|
||||||
|
</div>
|
||||||
|
<div class="container">
|
||||||
<form method="get" action="/search-user.html">
|
<form method="get" action="/search-user.html">
|
||||||
<input type="text" placeholder="Username" name="query" value="{{query}}" REQUIRED></input>
|
<input type="text" placeholder="Username" name="query" value="{{query}}" REQUIRED></input>
|
||||||
<fancy-button size="auto" text="Search" url="submit"></fancy-button>
|
<fancy-button size="auto" text="Search" url="submit"></fancy-button>
|
||||||
</form>
|
</form>
|
||||||
<ul>
|
<ul>
|
||||||
{% for user in users %}
|
{% for user in users %}
|
||||||
<li>
|
<li>
|
||||||
<a href="/channel/{{user.uid.value}}.html">{{user.username.value}}</a>
|
<a href="/channel/{{user.uid.value}}.html">{{user.username.value}}</a>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
{% endfor %}
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
|
{% endfor %}
|
||||||
</div>
|
</ul>
|
||||||
</section>
|
|
||||||
{% endblock %}
|
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
{% endblock %}
|
@ -109,6 +109,24 @@ class RPCView(BaseView):
|
|||||||
lowercase = query.lower()
|
lowercase = query.lower()
|
||||||
if any(keyword in lowercase for keyword in ["drop", "alter", "update", "delete", "replace", "insert", "truncate"]) and 'select' not in lowercase:
|
if any(keyword in lowercase for keyword in ["drop", "alter", "update", "delete", "replace", "insert", "truncate"]) and 'select' not in lowercase:
|
||||||
raise Exception("Not allowed")
|
raise Exception("Not allowed")
|
||||||
|
records = [dict(record) async for record in self.services.channel.query(args[0])]
|
||||||
|
for record in records:
|
||||||
|
try:
|
||||||
|
del record['email']
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
del record["password"]
|
||||||
|
except KeyError:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
del record['message']
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
try:
|
||||||
|
del record['html']
|
||||||
|
except:
|
||||||
|
pass
|
||||||
return [dict(record) async for record in self.services.channel.query(args[0])]
|
return [dict(record) async for record in self.services.channel.query(args[0])]
|
||||||
|
|
||||||
async def __call__(self, data):
|
async def __call__(self, data):
|
||||||
|
Loading…
Reference in New Issue
Block a user