feat: add settings page with monaco editor and fix webdav prop for directories
Add a new SettingsView at /settings.html with a sidebar navigation for profile, notifications, and privacy sections. The settings page includes a Monaco code editor for profile description editing. Also fix the WebDAV propfind handler to only include contenttype and getcontentlength properties for files, preventing errors when these properties are requested on directories.
This commit is contained in:
@@ -42,6 +42,7 @@ from snek.view.terminal import TerminalSocketView, TerminalView
|
||||
from snek.view.upload import UploadView
|
||||
from snek.view.web import WebView
|
||||
from snek.webdav import WebdavApplication
|
||||
from snek.view.settings import SettingsView
|
||||
|
||||
SESSION_KEY = b"c79a0c5fda4b424189c427d28c9f7c34"
|
||||
|
||||
@@ -137,6 +138,7 @@ class Application(BaseApplication):
|
||||
self.router.add_view("/docs.html", DocsHTMLView)
|
||||
self.router.add_view("/docs.md", DocsMDView)
|
||||
self.router.add_view("/status.json", StatusView)
|
||||
self.router.add_view("/settings.html", SettingsView)
|
||||
self.router.add_view("/web.html", WebView)
|
||||
self.router.add_view("/login.html", LoginView)
|
||||
self.router.add_view("/login.json", LoginView)
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
{% extends "app.html" %}
|
||||
|
||||
{% block sidebar %}
|
||||
|
||||
{% include "sidebar_settings.html" %}
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block head %}
|
||||
<link href="https://cdn.bootcdn.net/ajax/libs/monaco-editor/0.20.0/min/vs/editor/editor.main.min.css" rel="stylesheet">
|
||||
|
||||
<script src="https://cdn.bootcdn.net/ajax/libs/monaco-editor/0.20.0/min/vs/loader.min.js"></script>
|
||||
|
||||
{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
|
||||
<h1>Setting page</h1>
|
||||
|
||||
<div id="profile_description"></div>
|
||||
|
||||
|
||||
|
||||
<script type="module">
|
||||
|
||||
require.config({ paths: { 'vs': 'https://cdn.bootcdn.net/ajax/libs/monaco-editor/0.20.0/min/vs' } });
|
||||
|
||||
require(['vs/editor/editor.main'], function () {
|
||||
var editor = monaco.editor.create(document.getElementById('profile_description'), {
|
||||
value: phpCode,
|
||||
language: 'php'
|
||||
});
|
||||
})
|
||||
</script>
|
||||
|
||||
{% endblock main %}
|
||||
@@ -0,0 +1,14 @@
|
||||
<style>
|
||||
.channel-list-item-highlight {
|
||||
/* xxx */
|
||||
}
|
||||
</style>
|
||||
<aside class="sidebar" id="channelSidebar">
|
||||
<h2>Settings</h2>
|
||||
<ul>
|
||||
<li><a class="no-select" href="/settings.html">Profile</a></li>
|
||||
<li><a class="no-select" href="/settings-notifications.html">Notifications</a></li>
|
||||
<li><a class="no-select" href="/settings-privacy.html">Privacy</a></li>
|
||||
</ul>
|
||||
|
||||
</aside>
|
||||
@@ -0,0 +1,8 @@
|
||||
from snek.system.view import BaseView
|
||||
|
||||
class SettingsView(BaseView):
|
||||
|
||||
login_required = True
|
||||
|
||||
async def get(self):
|
||||
return await self.render_template('settings.html')
|
||||
+3
-2
@@ -219,8 +219,9 @@ class WebdavApplication(aiohttp.web.Application):
|
||||
etree.SubElement(prop, "{DAV:}displayname").text = full_path.name
|
||||
etree.SubElement(prop, "{DAV:}lockdiscovery")
|
||||
mimetype, _ = mimetypes.guess_type(full_path.name)
|
||||
etree.SubElement(prop, "{DAV:}contenttype").text = mimetype
|
||||
etree.SubElement(prop, "{DAV:}getcontentlength").text = str(
|
||||
if full_path.is_file():
|
||||
etree.SubElement(prop, "{DAV:}contenttype").text = mimetype
|
||||
etree.SubElement(prop, "{DAV:}getcontentlength").text = str(
|
||||
full_path.stat().st_size
|
||||
if full_path.is_file()
|
||||
else self.get_directory_size(full_path)
|
||||
|
||||
Reference in New Issue
Block a user