mirror of
https://github.com/kxgx/2.13-Ink-screen-clock.git
synced 2026-03-15 07:03:16 +08:00
Add files via upload
This commit is contained in:
9
webui/default.min.css
vendored
Normal file
9
webui/default.min.css
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
/*!
|
||||
Theme: Default
|
||||
Description: Original highlight.js style
|
||||
Author: (c) Ivan Sagalaev <maniac@softwaremaniacs.org>
|
||||
Maintainer: @highlightjs/core-team
|
||||
Website: https://highlightjs.org/
|
||||
License: see project LICENSE
|
||||
Touched: 2021
|
||||
*/pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{background:#f3f3f3;color:#444}.hljs-comment{color:#697070}.hljs-punctuation,.hljs-tag{color:#444a}.hljs-tag .hljs-attr,.hljs-tag .hljs-name{color:#444}.hljs-attribute,.hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-name,.hljs-selector-tag{font-weight:700}.hljs-deletion,.hljs-number,.hljs-quote,.hljs-selector-class,.hljs-selector-id,.hljs-string,.hljs-template-tag,.hljs-type{color:#800}.hljs-section,.hljs-title{color:#800;font-weight:700}.hljs-link,.hljs-operator,.hljs-regexp,.hljs-selector-attr,.hljs-selector-pseudo,.hljs-symbol,.hljs-template-variable,.hljs-variable{color:#ab5656}.hljs-literal{color:#695}.hljs-addition,.hljs-built_in,.hljs-bullet,.hljs-code{color:#397300}.hljs-meta{color:#1f7199}.hljs-meta .hljs-string{color:#38a}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:700}
|
||||
1213
webui/highlight.min.js
vendored
Normal file
1213
webui/highlight.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
40
webui/index.html
Normal file
40
webui/index.html
Normal file
@@ -0,0 +1,40 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/ace-editor@1.4.12/css/ace.min.css">
|
||||
<script src="https://cdn.jsdelivr.net/npm/ace-editor@1.4.12/js/ace.min.js"></script>
|
||||
<meta charset="UTF-8">
|
||||
<title>编辑 main.py</title>
|
||||
<style>
|
||||
#editor {
|
||||
width: 100%;
|
||||
height: 500px;
|
||||
font-family: monospace;
|
||||
font-size: 16px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>编辑 main.py</h1>
|
||||
<form action="/save.py" method="post">
|
||||
<div id="editor"><?php echo file_get_contents('/root/2.13-Ink-screen-clock/bin/main.py'); ?></div>
|
||||
<input type="hidden" name="content" id="hidden-content">
|
||||
<br>
|
||||
<input type="submit" value="保存">
|
||||
</form>
|
||||
<script>
|
||||
// 初始化 Ace Editor
|
||||
var editor = ace.edit("editor");
|
||||
editor.setTheme("ace/theme/monokai");
|
||||
editor.getSession().setMode("ace/mode/python");
|
||||
editor.setValue(<?php echo json_encode(file_get_contents($filePath)); ?>);
|
||||
|
||||
// 在表单提交前将编辑器内容赋值给隐藏的textarea
|
||||
document.querySelector('form').addEventListener('submit', function() {
|
||||
document.getElementById('hidden-content').value = editor.getValue();
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
23
webui/save.py
Normal file
23
webui/save.py
Normal file
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env python3
|
||||
import os
|
||||
import sys
|
||||
|
||||
# 设置文件路径
|
||||
file_path = '/root/2.13-Ink-screen-clock/bin/main.py'
|
||||
|
||||
# 读取POST数据
|
||||
content_length = int(os.environ.get('CONTENT_LENGTH', 0))
|
||||
content = sys.stdin.read(content_length)
|
||||
|
||||
# 保存文件
|
||||
try:
|
||||
with open(file_path, 'w') as file:
|
||||
file.write(content)
|
||||
response = "<h1>文件保存成功!</h1>"
|
||||
except Exception as e:
|
||||
response = "<h1>文件保存失败:{}</h1>".format(e)
|
||||
|
||||
# 返回响应
|
||||
print("Content-Type: text/html")
|
||||
print()
|
||||
print(response)
|
||||
Reference in New Issue
Block a user