Skip to content

Commit

Permalink
1
Browse files Browse the repository at this point in the history
  • Loading branch information
SunWuyuan committed Nov 19, 2023
1 parent 1bed767 commit 9c363fb
Show file tree
Hide file tree
Showing 3 changed files with 265 additions and 24 deletions.
60 changes: 37 additions & 23 deletions build/ejs/python/python_edit.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,15 @@
<title>Python编程 - <%= process.env.siteneme %>
</title>
<link rel="shortcut icon" href='<%= process.env.staticurl %>/img/siteicon.png'>
<link rel="stylesheet" href="<%= process.env.staticurl %>/pythonstatic/bootstrap/css/bootstrap.min.css" />
<link rel="stylesheet" href="<%= process.env.staticurl %>/layui/css/layui.css">
<link rel="stylesheet" href="<%= process.env.staticurl %>/pythonstatic/css/CodeMirror.css" />
<link rel="stylesheet" href='<%= process.env.staticurl %>/pythonstatic/css/style.css' />
<link rel="stylesheet" href="<%= process.env.staticurl %>/pythonstatic/css/solarized.css" />
<link rel="stylesheet" href="<%= process.env.staticurl %>/layui/css/layui.css">
<link type="text/css" rel="stylesheet" href="<%= process.env.staticurl %>/pythonstatic/showWorks.css" />
<% include ../linkfile.ejs %>
<%- process.env.includecode %></head>
<%- process.env.includecode %><link
rel="stylesheet"
data-name="vs/editor/editor.main"
href="<%= process.env.staticurl %>/vs/editor/editor.main.css"
/></head>

<body class="mdui-theme-accent-blue">
<script>
Expand Down Expand Up @@ -111,16 +112,18 @@
style="border-radius: 10px;">关闭</button>
</div>
</div>
<div class="layui-fluid" style="padding: 0;">
<div class="mdui-fluid" style="padding: 0;">
<!-- 编程区 -->
<div class="layui-row">
<div class="layui-col-md8 layui-col-sm12 layui-col-xs12" style="padding: 0; background-color: aqua;"

<div class="mdui-row mdui-row-gapless">
<div class="mdui-col-xs-12 mdui-col-sm-8" style="padding: 0;"
id='python_edit_box'>
<div class="python-editor-code">
<textarea id="code_textarea"></textarea>
<div class="python-editor-code"><div id="container" style="height:calc(93vh); border: 1px solid grey"></div>

</div>
</div>
<div style="display: flex; position: absolute; top:8px; right:0; z-index: 99999;">
<!-- 运行结果区 -->
<div class=" mdui-col-xs-12 mdui-col-sm-4"><div style="display: flex; position: absolute; top:8px; right:0; z-index: 99999;">
<div style="margin:auto 10px;">
<button class="mdui-btn mdui-btn-raised mdui-ripple mdui-color-theme-accent" id="run-code" onclick="run_it()"
style="border-radius: 10px;">运行</button>
Expand All @@ -129,28 +132,27 @@
<button class="mdui-btn mdui-btn-raised mdui-ripple mdui-color-red-accent" onclick="run_clear()"
style="border-radius: 10px;">清除</button>
</div>
<div style="margin:auto 10px auto 0;">
<!-- <div style="margin:auto 10px auto 0;">
<button class="mdui-btn mdui-btn-raised mdui-ripple mdui-color-cyan-700" onclick="all_Screen(this)"
style="border-radius: 10px;">全屏运行</button>
</div>
</div>-->
</div>
<!-- 运行结果区 -->
<div id='main_edit_box'>
<div class="layui-col-md4 layui-col-sm12 layui-col-xs12" style="padding: 0;">
<div class="layui-row">
<div class="layui-col-md12 layui-col-sm6 layui-col-xs12" style="padding: 0;">
<div class="" style="padding: 0;">
<div class="">
<div class="" style="padding: 0;">
<div id="canvas_box"
style="height:calc(50vh); background:url(/*<%= process.env.staticurl %>/pythonstatic/img/welcome_python_editor.png*/) no-repeat center;background-size: contain;background-size:auto 100%;">
style="height:calc(50vh);background:url(/*<%= process.env.staticurl %>/pythonstatic/img/welcome_python_editor.png*/) no-repeat center;background-size: contain;background-size:auto 100%;">
<div id="mycanvas"></div>
</div>
</div>
<div class="layui-col-md12 layui-col-sm6 layui-col-xs12"
style="padding: 0; margin:0;background-color: rgba(0, 0, 0, 0);height:calc(50vh - 52px);">
<textarea id="output" style="height: 100%;width: 100%;" disabled>终端打印输出区</textarea>
<div class=""
style="padding: 0!important ; margin:0;background-color: rgb(0, 0, 0);height:calc(50vh - 50px);">
<textarea id="output" class="mdui-text-color-theme-text" style="padding: 0!important ;border: 0px!important ;height: 100%;width: 100%;" disabled>终端打印输出区</textarea>
</div>
</div>
</div>
</div>
</div></div>
</div>
</div>

Expand Down Expand Up @@ -204,8 +206,20 @@
</div>
</div>




<script>
</script>
<script src="<%= process.env.staticurl %>/vs/loader.js"></script>
<script src="<%= process.env.staticurl %>/vs/editor/editor.main.nls.js"></script>
<script src="<%= process.env.staticurl %>/vs/editor/editor.main.js"></script>




<script type="text/javascript" src="<%= process.env.staticurl %>/js/jquery.min.js"></script>
<script type="text/javascript" src="<%= process.env.staticurl %>/pythonstatic/CodeMirror.js"></script>
<script type="text/javascript" src="<%= process.env.staticurl %>/pythonstatic/js/file-saver.js"></script>
<script type="text/javascript" src="<%= process.env.staticurl %>/pythonstatic/skulpt.min.js"></script>
<script type="text/javascript" src="<%= process.env.staticurl %>/pythonstatic/skulpt-stdlib.js"></script>
Expand Down
224 changes: 224 additions & 0 deletions build/ejs/python/python_edit_old.ejs
Original file line number Diff line number Diff line change
@@ -0,0 +1,224 @@
<!DOCTYPE html>
<html>

<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Python编程 - <%= process.env.siteneme %>
</title>
<link rel="shortcut icon" href='<%= process.env.staticurl %>/img/siteicon.png'>
<link rel="stylesheet" href="<%= process.env.staticurl %>/pythonstatic/bootstrap/css/bootstrap.min.css" />
<link rel="stylesheet" href="<%= process.env.staticurl %>/layui/css/layui.css">
<link rel="stylesheet" href="<%= process.env.staticurl %>/pythonstatic/css/CodeMirror.css" />
<link rel="stylesheet" href='<%= process.env.staticurl %>/pythonstatic/css/style.css' />
<link rel="stylesheet" href="<%= process.env.staticurl %>/pythonstatic/css/solarized.css" />
<link type="text/css" rel="stylesheet" href="<%= process.env.staticurl %>/pythonstatic/showWorks.css" />
<% include ../linkfile.ejs %>
<%- process.env.includecode %></head>

<body class="mdui-theme-accent-blue">
<script>
if (localStorage.darkTheme)
document.body.classList.add("mdui-theme-layout-dark");
document.getElementById("switch-theme").addEventListener(
"click",
() => document.body.classList.toggle("mdui-theme-layout-dark") ?
(localStorage.darkTheme = true) :
(delete localStorage.darkTheme)
);
</script>

<div>
<div class="mdui-toolbar">
<a class="mdui-btn mdui-btn-icon" id="toggle" href="/"><i class="mdui-icon material-icons">home</i></a>
<a href="/"><span class="mdui-typo-title">
<%= process.env.siteneme %> Python编辑器
</span></a>
<div class="mdui-toolbar-spacer"></div>
<a href="javascript:;" onclick="javascript:location.reload();" class="mdui-btn mdui-btn-icon mdui-ripple"><i
class="mdui-icon material-icons">refresh</i></a>
<% if (login==false) { %>
<a href="/user/login" class="mdui-btn mdui-ripple" style="border-radius: 12px;">登录/注册</a>
<% } else { %>
<button class="mdui-btn mdui-btn-icon mdui-ripple" mdui-dialog="{target: '#user'}"><i
class="mdui-icon material-icons">account_circle</i></button>
<% } %>
</div>
<div class="mdui-tab">
<a class="mdui-ripple " style="border-radius: 20px;" mdui-dialog="{target: '#file'}"><i
class="mdui-icon material-icons">insert_drive_file</i>文件</a>

<div id="save_work">
<% if (login) { %>
<a class="mdui-ripple" onclick="save_work()" style="border-radius: 20px;"><i
class="mdui-icon material-icons">cloud_upload</i>保存到云端</a>
<% } else { %>
<% } %>
</div> <a class="mdui-ripple" id="revise_work" onclick="revise_work()" style="border-radius: 20px;"><i
class="mdui-icon material-icons">call_split</i>改编此作品</a>

<div style="margin: auto 0;" mdui-dialog="{target: '#info'}">
<a class="mdui-ripple" style="border-radius: 20px;">
<i class="mdui-icon material-icons">info</i>
<span>项目信息</span>
</a>
</div>

<div class="mdui-toolbar-spacer"></div>
<a class="mdui-ripple" onclick="open_YX()" style="border-radius: 20px;"><i
class="mdui-icon material-icons">thumb_up</i>优秀作品</a>
<% if (login) { %>
<a class="mdui-ripple" onclick="open_MY()" style="border-radius: 20px;"><i
class="mdui-icon material-icons">inbox</i>我的作品</a>
<% } else { %>
<% } %>
<% if (login==false) { %>
<a class="mdui-ripple" href="/user/login" style="border-radius: 20px;">
<i class="mdui-icon material-icons">account_circle</i>登录|注册 </a>
<% } else { %>
<a class="mdui-ripple" mdui-dialog="{target: '#user'}" style="border-radius: 20px;">
<i class="mdui-icon material-icons">account_circle</i>
登录为
<%= nickname %>
</a>
<% } %>
</div>
</div>
<div class="mdui-dialog" id="user" style="border-radius: 20px;">
<div class="mdui-dialog-title">登录为 <%= nickname %>
</div>
<div class="mdui-dialog-content"> 选择操作前请保存作品</div>
<div class="mdui-dialog-actions">
<div class="mdui-tab">
<a href="/my/scratch" class="mdui-ripple" style="border-radius: 20px;">
<i class="mdui-icon material-icons">insert_drive_file</i>
<label>Scratch作品</label>
</a>
<a href="/my/python" class="mdui-ripple" style="border-radius: 20px;">
<i class="mdui-icon material-icons">insert_drive_file</i>
<label>Python作品</label>
</a>
<a href="/my/info" class="mdui-ripple" style="border-radius: 20px;">
<i class="mdui-icon material-icons">remove_red_eye</i>
<label>个人信息</label>
</a>
<a href="/user/logout" class="mdui-ripple" style="border-radius: 20px;">
<i class="mdui-icon material-icons">close</i>
<label>退出</label>
</a>
</div>
<button class="mdui-btn mdui-ripple mdui-text-color-theme-text" mdui-dialog-close
style="border-radius: 10px;">关闭</button>
</div>
</div>
<div class="layui-fluid" style="padding: 0;">
<!-- 编程区 -->
<div class="layui-row">
<div class="layui-col-md8 layui-col-sm12 layui-col-xs12" style="padding: 0; background-color: aqua;"
id='python_edit_box'>
<div class="python-editor-code">
<textarea id="code_textarea"></textarea>
</div>
</div>
<div style="display: flex; position: absolute; top:8px; right:0; z-index: 99999;">
<div style="margin:auto 10px;">
<button class="mdui-btn mdui-btn-raised mdui-ripple mdui-color-theme-accent" id="run-code" onclick="run_it()"
style="border-radius: 10px;">运行</button>
</div>
<div style="margin:auto 10px auto 0;">
<button class="mdui-btn mdui-btn-raised mdui-ripple mdui-color-red-accent" onclick="run_clear()"
style="border-radius: 10px;">清除</button>
</div>
<div style="margin:auto 10px auto 0;">
<button class="mdui-btn mdui-btn-raised mdui-ripple mdui-color-cyan-700" onclick="all_Screen(this)"
style="border-radius: 10px;">全屏运行</button>
</div>
</div>
<!-- 运行结果区 -->
<div id='main_edit_box'>
<div class="layui-col-md4 layui-col-sm12 layui-col-xs12" style="padding: 0;">
<div class="layui-row">
<div class="layui-col-md12 layui-col-sm6 layui-col-xs12" style="padding: 0;">
<div id="canvas_box"
style="height:calc(50vh); background:url(/*<%= process.env.staticurl %>/pythonstatic/img/welcome_python_editor.png*/) no-repeat center;background-size: contain;background-size:auto 100%;">
<div id="mycanvas"></div>
</div>
</div>
<div class="layui-col-md12 layui-col-sm6 layui-col-xs12"
style="padding: 0; margin:0;background-color: rgba(0, 0, 0, 0);height:calc(50vh - 52px);">
<textarea id="output" style="height: 100%;width: 100%;" disabled>终端打印输出区</textarea>
</div>
</div>
</div>
</div>
</div>
</div>






<div class="mdui-dialog" id="info" style="border-radius: 20px;">
<div class="mdui-dialog-title">项目信息
</div>
<div class="mdui-dialog-content">修改内容请手动保存到云端
<br/>
分享
<label class="mdui-switch">
<input type="checkbox" id="publish-work-box" onclick="publish_work()"/>
<i class="mdui-switch-icon"></i>
</label>
<div class="mdui-textfield">
<input class="mdui-textfield-input" type="text" placeholder="请输入作品名称" maxlength="20" id='work_title_input'
autocomplete="off" onkeypress="work_title_changed()" />
</div>
<div class="mdui-textfield">
<textarea class="mdui-textfield-input" rows="4" placeholder="简介" maxlength="1000" id='work_info_input'
onkeypress="work_title_changed()"></textarea>
</div>
</div>
<div class="mdui-dialog-actions">

<button class="mdui-btn mdui-ripple mdui-text-color-theme-text" mdui-dialog-close
style="border-radius: 10px;">关闭</button>
</div>
</div>

<div class="mdui-dialog" id="file" style="border-radius: 20px;">
<div class="mdui-dialog-title">文件操作
</div>
<div class="mdui-dialog-content"> 选择操作前请保存作品</div>
<div class="mdui-dialog-actions">
<div class="mdui-tab">
<a class="mdui-ripple " onclick="new_file()" style="border-radius: 20px;"><i
class="mdui-icon material-icons">add</i>新建一个作品</a>
<a class="mdui-ripple" onclick="open_file()" style="border-radius: 20px;"><i
class="mdui-icon material-icons">file_upload</i>从电脑中上传</a> <input type="file" id="files"
style="display: none">
<a class="mdui-ripple" onclick="save_file()" style="border-radius: 20px;"><i
class="mdui-icon material-icons">cloud_download</i>保存到电脑</a>
</div>
<button class="mdui-btn mdui-ripple mdui-text-color-theme-text" mdui-dialog-close
style="border-radius: 10px;">关闭</button>
</div>
</div>

<script type="text/javascript" src="<%= process.env.staticurl %>/js/jquery.min.js"></script>
<script type="text/javascript" src="<%= process.env.staticurl %>/pythonstatic/CodeMirror.js"></script>
<script type="text/javascript" src="<%= process.env.staticurl %>/pythonstatic/js/file-saver.js"></script>
<script type="text/javascript" src="<%= process.env.staticurl %>/pythonstatic/skulpt.min.js"></script>
<script type="text/javascript" src="<%= process.env.staticurl %>/pythonstatic/skulpt-stdlib.js"></script>
<script type="text/javascript" src="<%= process.env.staticurl %>/pythonstatic/mode/python.js"></script>
<script type="text/javascript" src="<%= process.env.staticurl %>/pythonstatic/js/show-hint.js"></script>
<script type="text/javascript" src="<%= process.env.staticurl %>/layui/layui.all.js"></script>
<script type="text/javascript" src="<%= process.env.staticurl %>/pythonstatic/public.js"></script>
<script type="text/javascript">
var isLogin = `<%= login %>`;
var _userid = `<%= userid %>`;
</script>
<script type="text/javascript" src="<%= process.env.staticurl %>/pythonstatic/python_edit.js"></script>
</body>

</html>
<script>qiniuurl = '<%= process.env.qiniuurl %>'</script>
5 changes: 4 additions & 1 deletion server/router_python.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,10 @@ router.post('/play/favo', function (req, res) {
router.get('/edit', function (req, res) {
res.render('ejs/python/python_edit.ejs');
})

//python兼容编辑器
router.get('/old', function (req, res) {
res.render('ejs/python/python_edit_old.ejs');
})
// 从数据库获取作品
router.post('/getWork', function (req, res) {
var projectid = 0;
Expand Down

0 comments on commit 9c363fb

Please sign in to comment.