Browse Source

静态文件与模板文件

huwhois 1 year ago
parent
commit
35a073de1a

+ 0 - 94
public/html/color.html

@ -1,94 +0,0 @@
1
<!DOCTYPE html>
2
<html>
3
<head lang="en">
4
    <meta charset="UTF-8">
5
    <title></title>
6
    <style>
7
        *{
8
            margin: 0;
9
            padding: 0;
10
        }
11
        .box{
12
            margin: 40px auto;
13
            width: 60px;
14
            background-color: #f0ac6b;
15
        }
16
        .t1{
17
            margin: 40px auto;
18
            width: 0px;
19
            height: 0px;
20
            /*background-color: #f0ac6b;*/
21
            border-bottom: 40px solid red;
22
            border-right: 20px solid transparent;
23
            border-left: 20px solid transparent;
24
        }
25
        .t2{
26
            margin: 40px auto;
27
            width: 0px;
28
            height: 0px;
29
            /*background-color: #f0ac6b;*/
30
            border-bottom: 40px solid transparent;
31
            border-right: 40px solid red;
32
            /*border-left: 20px solid transparent;*/
33
        }
34
        .t3{
35
            margin: 40px auto;
36
            width: 0;
37
            height: 0;
38
            border-top: 40px solid red;
39
            border-right: 20px solid transparent;
40
            border-left: 20px solid transparent;
41
        }
42
        .t4{
43
            margin: 40px auto;
44
            width: 0;
45
            height: 0;
46
            border-top: 40px solid transparent;
47
            border-left: 40px solid red;
48
        }
49
        .t5{
50
            margin: 40px auto;
51
            width: 0;
52
            height: 0;
53
            border-top: 40px solid red;
54
            border-right: 40px solid transparent;
55
        }
56
        .t6{
57
            margin: 40px auto;
58
            width: 0px;
59
            height: 0px;
60
            border-left: 40px solid transparent;
61
            border-bottom: 40px solid red;
62
        }
63
        .t7{
64
            margin: 40px auto;
65
            width: 0;
66
            height: 0;
67
            border-left: 40px solid red;
68
            border-bottom: 20px solid transparent;
69
            border-top: 20px solid transparent;
70
        }
71
        .t8{
72
            margin: 40px auto;
73
            width: 0;
74
            height: 0;
75
            border-right: 40px solid red;
76
            border-bottom: 20px solid transparent;
77
            border-top: 20px solid transparent;
78
        }
79
    </style>
80
</head>
81
<body>
82
<div class="box">
83
    <div class="t1"></div>
84
    <div class="t3"></div>
85
    <div class="t2"></div>
86
    <div class="t4"></div>
87
    <div class="t5"></div>
88
    <div class="t6"></div>
89
    <div class="t7"></div>
90
    <div class="t8"></div>
91
</div>
92
93
</body>
94
</html>

+ 0 - 348
public/html/editor.html

@ -1,348 +0,0 @@
1
<!DOCTYPE html>
2
<html>
3
4
	<head>
5
		<meta charset="UTF-8">
6
		<title>markdown编辑器</title>
7
		<link href="/static/css/markdown.css" rel="stylesheet" />
8
		<script src="/static/js/jquery.min.js"></script>
9
		<script src="/static/js/ace.js"></script>
10
		<script src="/static/js/marked.js"></script>
11
		<script src="/static/js/showPanel.js"></script>
12
13
		<style type="text/css">
14
			* {
15
				margin: 0;
16
				padding: 0;
17
				outline: none;
18
				border-radius: 0;
19
			}
20
			
21
			html,
22
			body {
23
				width: 100%;
24
				height: 100%;
25
				font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
26
				background-color: #ebebeb;
27
			}
28
			
29
			#bar {
30
				height: 130px;
31
				width: 100%;
32
				color: #fff;
33
			}
34
			
35
			#bar #topbar {
36
				height: 40px;
37
				background-color: #337AB7;
38
				width: 100%;
39
				color: #fff;
40
				line-height: 50px;
41
			}
42
			
43
			#bar #czbar {
44
				height: 50px;
45
				background-color: #FFFFFF;
46
				width: 100%;
47
				color: #fff;
48
				line-height: 50px;
49
			}
50
			
51
			#bar #toolbar {
52
				height: 40px;
53
				background-color: #337AB7;
54
				width: 100%;
55
				color: #fff;
56
				line-height: 50px;
57
			}
58
			
59
			#container {
60
				overflow: auto;
61
				position: absolute;
62
				bottom: 0;
63
				left: 0;
64
				right: 0;
65
				top: 130px;
66
			}
67
			
68
			#editor-column,
69
			#preview-column {
70
				width: 49.5%;
71
				height: 100%;
72
				overflow: auto;
73
				position: relative;
74
				background-color: #F6F6F6;
75
			}
76
			
77
			.pull-left {
78
				float: left;
79
			}
80
			
81
			.pull-right {
82
				float: right;
83
			}
84
			
85
			#toolbar img {
86
				width: 25px;
87
				height: 25px;
88
				padding-top: 8px;
89
				padding-bottom: 7px;
90
				margin-left: 10px;
91
			}
92
			
93
			#toolbar img:hover {
94
				background: #EBEBEB;
95
				cursor: pointer;
96
			}
97
			
98
			#commit {
99
				color: #FFFFFF;
100
				padding: 5px 15px;
101
				background: #BE1A21;
102
				border: 0px none #FFECEC;
103
			}
104
			
105
			#commit:hover {
106
				cursor: pointer;
107
				background: #CB474D;
108
			}
109
			
110
			#dialog{
111
				position: fixed;
112
				height: 400px;
113
				width: 550px;
114
				background: #FFFFFF;
115
				z-index: 5;
116
				left: 30%;
117
				border: 1px solid gray;
118
				top: 25%;
119
				display: none;
120
			}
121
			
122
			#showImg{
123
				height: 160px;
124
				width: 160px;
125
				position: absolute;
126
				border: 0.5px solid gainsboro;
127
				bottom: 80px;
128
				left:35%;
129
			}
130
			
131
			#cancel{
132
				border: 0px none #FFECEC;
133
				background: #999999;
134
				color: #FFFFFF;
135
				padding: 5px 15px;
136
				position: absolute;
137
				top: 8px;
138
				right: 100px;
139
			}
140
			
141
			#cancel:hover{
142
				background: #AAAAAA;	
143
			}
144
			
145
			#insert{
146
				border: 0px none #FFECEC;
147
				background: #BE1A21;
148
				color: #FFFFFF;
149
				padding: 5px 15px;
150
				position: absolute;
151
				top: 8px;
152
				right: 30px;
153
			}
154
			
155
			#insert:hover{
156
				background: #CB474D;
157
			}
158
			
159
			#upload{
160
				border: 0px none #FFECEC;
161
				background: #999999;
162
				color: #FFFFFF;
163
				padding: 7px 30px;
164
				position: absolute;
165
				top: 67px;
166
				right: 40px;
167
			}
168
			
169
			#upload:hover{
170
				background: #AAAAAA;	
171
			}
172
			
173
			#filediv{
174
				width: 70%;
175
				height: 30px;
176
				top: 70px;
177
				left: 20px;
178
				position: absolute;
179
				
180
			}
181
			
182
			#file{
183
				width: 95%;
184
				height: 30px;
185
				position: relative;
186
				top: -27px;
187
				opacity: 0.000001;
188
				cursor: pointer;
189
			}
190
			
191
			
192
		</style>
193
		
194
		<script>
195
			$(function(){
196
				$('#dialog').hide();
197
			})
198
			
199
			
200
		</script>
201
	</head>
202
203
	<body>
204
		<div id='bar'>
205
			<div id="topbar">
206
			</div>
207
			<div id="czbar">
208
				<input style="font-size: 26px;width: 80%;padding-left: 10px;border: 0px none #FFFFFF;padding-top: 5px;" type="text" value="文章标题" placeholder="文章标题" />
209
				<select id="group">
210
					<option value="volvo">android</option>
211
					<option value="saab">算法</option>
212
					<option value="opel">java思想</option>
213
					<option value="audi">web</option>
214
				</select>
215
				<button id="commit">发表博客</button>
216
			</div>
217
			<div id="toolbar">
218
				<img src="/static/img/bold.png" id="bold" onclick="insertText('**这里填写要加粗的文字**')"/>
219
				<img src="/static/img/italic.png" id="italic" onclick="insertText('_这里填写要斜体的文字_')"/>
220
				<img src="/static/img/hyperlink.png" id="hyperlink" onclick="insertText('[这里写连接的描述](这里填写连接地址)')"/>
221
				<img src="/static/img/code.png" id="code" onclick="insertText('```\n这里插入代码\n```')"/>
222
				<img src="/static/img/image.png" id="image" onclick="showDialog()"/>
223
			</div>
224
225
		</div>
226
		<div id='container'>
227
			<div id='editor-column' class='pull-left'>
228
				<div id='panel-editor' style="height: 100%;">
229
					<!--编辑区-->
230
					<div class="editor-content" id="mdeditor" style="height: 100%;"></div>
231
232
				</div>
233
			</div>
234
			<div id='preview-column' class='pull-right'>
235
				<div id='panel-preview'>
236
					<!--显示区-->
237
					<div id="preview" class="markdown-body"></div>
238
239
				</div>
240
			</div>
241
			
242
			<div id="dialog">
243
				<div style="position: absolute;height: 40px;width: 100%;background: #FFFFFF;border-bottom: 1px solid gray;">
244
					<span style="position: absolute;left: 10px;top: 10px;color: gray;">插入图片</span>
245
					<img src="img/X.png" style="height: 25px;width: 25px;position: absolute;right: 10px;top: 10px;cursor: pointer;" onclick="f_cancel()"/>
246
				</div>
247
				
248
				<div>
249
					<div id="filediv">
250
						<span style="background: gray;color: #FFFFFF;padding: 6px 10px;">选择图片</span>
251
						<input type="text" id="fileName" style="height: 25px;width: 70%;"/>
252
						
253
						<input type="file" id="file" name="file" onchange="setFile()"/>
254
					</div>
255
					<button id="upload" onclick="uploadFile()">上传</button>
256
				</div>
257
				
258
				<img  id="showImg"/>
259
				
260
				<div style="position: absolute;bottom: 1px;width: 100%;height: 40px;border-top: 1px solid gray;">
261
					<button id="cancel" onclick="f_cancel()">取消</button>
262
					<button id="insert" onclick="insert()">插入</button>
263
				</div>
264
			</div>
265
			
266
			<script>
267
				var imgUrl='';//上传图片返回的url
268
			
269
				var acen_edit = ace.edit('mdeditor');//左侧编辑框
270
				acen_edit.setTheme('ace/theme/chrome');
271
				acen_edit.getSession().setMode('ace/mode/markdown');
272
				acen_edit.renderer.setShowPrintMargin(false);
273
				$("#mdeditor").keyup(function() {//给左侧编辑框添加事件,,当键盘抬起时,右侧实时显示左侧的md内容
274
					$("#preview").html(marked(acen_edit.getValue()));
275
				});
276
				
277
278
				function f_commit() {
279
					console.log($('#group').val());
280
				}
281
				//DownPanel是我自己写的一个提示,当鼠标移到该dom上,回显示相关提示
282
				$('#bold').DownPanel({
283
					render: '<span style="color:#ffffff;">加粗</span>',
284
					background: '#000000',
285
					top: ($('#bold').offset().top + 40),
286
					left: ($('#bold').offset().left)
287
				});
288
				$('#code').DownPanel({
289
					render: '<span style="color:#ffffff;">插入代码</span>',
290
					background: '#000000',
291
					top: ($('#code').offset().top + 40),
292
					left: ($('#code').offset().left)
293
				});
294
				$('#hyperlink').DownPanel({
295
					render: '<span style="color:#ffffff;">插入超链接</span>',
296
					background: '#000000',
297
					top: ($('#hyperlink').offset().top + 40),
298
					left: ($('#hyperlink').offset().left)
299
				});
300
				$('#image').DownPanel({
301
					render: '<span style="color:#ffffff;">插入图片</span>',
302
					background: '#000000',
303
					top: ($('#image').offset().top + 40),
304
					left: ($('#image').offset().left)
305
				});
306
				$('#italic').DownPanel({
307
					render: '<span style="color:#ffffff;">斜体</span>',
308
					background: '#000000',
309
					top: ($('#italic').offset().top + 40),
310
					left: ($('#italic').offset().left)
311
				});
312
				
313
				//左侧插入,用户插入一些特定方法
314
				function insertText(val) {
315
					acen_edit.insert(val); //光标位置插入
316
				}
317
				
318
				//选择图片后,用于显示图片路径
319
				function setFile(){
320
					$('#fileName').val($('#file').val());
321
				}
322
				
323
				//上传图片到服务器,返回图片地址
324
				function uploadFile(){
325
					imgUrl='https://ss0.bdstatic.com/5aV1bjqh_Q23odCf/static/superman/img/logo/logo_white.png';
326
					$('#showImg').attr('src','https://ss0.bdstatic.com/5aV1bjqh_Q23odCf/static/superman/img/logo/logo_white.png');
327
				}
328
				
329
				//插入图片弹窗取消
330
				function f_cancel(){
331
					$('#dialog').hide();
332
				}
333
				
334
				//插入图片
335
				function insert(){
336
					$('#dialog').hide();
337
					insertText('![这里写图片描述]('+imgUrl+')')
338
				}
339
				
340
				//显示弹窗
341
				function showDialog(){
342
					$('#dialog').show();
343
				}
344
				
345
			</script>
346
	</body>
347
348
</html>

+ 2 - 3
public/index.php

@ -10,7 +10,6 @@
10 10
// +----------------------------------------------------------------------
11 11
// | Author: huwhois <huwhois@163.com>
12 12
// +----------------------------------------------------------------------
13
namespace App;
14 13
if(version_compare(PHP_VERSION,'5.3.0','<'))  die('require PHP > 5.3.0 !');
15 14
16 15
// error_reporting(E_ALL || ~E_NOTICE);
@ -20,6 +19,6 @@ ini_set('max_execution_time', 0);
20 19
21 20
define("APP_PATH", __DIR__ . '/../application/');
22 21
define("DATA_PATH", __DIR__ . '/../data/');
23
define("ROOT_PATH", __DIR__  . '/');
22
define("ROOT_PATH", dirname(__DIR__, 1));
24 23
25
require(APP_PATH . 'start.php');
24
require(__DIR__ . '/../application/start.php');

+ 8 - 5
public/router.php

@ -1,9 +1,12 @@
1 1
<?php
2
$uri = urldecode(
3
    parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH)
4
);
2 5
3
if (is_file($_SERVER["DOCUMENT_ROOT"] . $_SERVER["SCRIPT_NAME"])) {
6
// 这个文件允许我们从内置 PHP web 服务器中模拟 Apache 的 "mod_rewrite" 功能.
7
// 而无需在此安装"真正的" web 服务器软件。
8
if ($uri !== '/' && file_exists(__DIR__.'/../public'.$uri)) {
4 9
    return false;
5
} else {
6
    $_SERVER["SCRIPT_FILENAME"] = __DIR__ . '/index.php';
7
8
    require __DIR__ . "/index.php";
9 10
}
11
12
require __DIR__ . "/index.php";

BIN
public/static/css/glyphicons-halflings-regular.ttf


BIN
public/static/css/glyphicons-halflings-regular.woff


BIN
public/static/css/glyphicons-halflings-regular.woff2


+ 3 - 3
public/static/css/index.css

@ -17,8 +17,8 @@ header span.logo {
17 17
}
18 18
19 19
header button {
20
    margin-left: 40px;
21
    /* opacity: 1; */
20
    margin-left: 16%;
21
  /* opacity: 1; */
22 22
}
23 23
24 24
header span img {
@ -92,4 +92,4 @@ article .content {
92 92
93 93
.modal-login {
94 94
    width: 400px;
95
}
95
}

+ 143 - 0
public/static/css/login.css

@ -0,0 +1,143 @@
1
@charset "utf-8";
2
* {
3
    margin: 0;
4
    padding: 0;
5
}
6
7
body {
8
    font: 12px/180% Arial, Helvetica, Verdana;
9
    color: #5a5a5a;
10
    margin: 0;
11
    background: #FFF;
12
}
13
14
/* body.login {
15
    background: url(../img/login_bgx.jpg);
16
} */
17
18
.login_m {
19
    width: 403px;
20
    /* height:375px;*/
21
    margin: 6% auto;
22
}
23
24
.login_logo {
25
    text-align: center;
26
    margin-bottom: 25px;
27
}
28
29
.login_boder {
30
    /* background: url(../images/login_m_bg.png) no-repeat; */
31
    /* height:430px ;*/
32
    overflow: hidden;
33
}
34
35
.login_padding {
36
    padding: 15px 47px 20px 47px;
37
}
38
39
.login_padding div {
40
    margin-top: 10px;
41
    margin-bottom: 5px;
42
}
43
44
.login_boder h2 {
45
    color: #4f5d80;
46
    text-transform: uppercase;
47
    font-size: 12px;
48
    font-weight: normal;
49
    margin-bottom: 9px;
50
}
51
52
.login_boder h2 a,
53
.login_boder h2 a:visited {
54
    text-decoration: none;
55
    color: #8c8e91;
56
}
57
58
.login_boder h2 a:hover {
59
    text-decoration: none;
60
    color: #206fd5;
61
}
62
63
.login_boder input.txt_input {
64
    width: 295px;
65
    height: 36px;
66
    border: 1px solid #cad2db;
67
    padding: 0 5px;
68
    -moz-border-radius: 5px;
69
    -webkit-border-radius: 5px;
70
    border-radius: 5px;
71
    line-height: 36px;
72
    margin-bottom: 10px;
73
    font-size: 14px;
74
    color: #717171;
75
    font-family: Arial;
76
}
77
78
.login_boder input.txt_input:focus {
79
    transition: border linear .2s, box-shadow linear .2s;
80
    -moz-transition: border linear .2s, -moz-box-shadow linear .2s;
81
    -webkit-transition: border linear .2s, -webkit-box-shadow linear .2s;
82
    outline: none;
83
    border-color: rgba(173, 173, 173.75);
84
    box-shadow: 0 0 8px rgba(173, 173, 173, .5);
85
    -moz-box-shadow: 0 0 8px rgba(173, 173, 173, .5);
86
    -webkit-box-shadow: 0 0 8px rgba(173, 173, 173, 3);
87
    border: 1px solid #6192c8;
88
}
89
90
.verify{
91
    height: 80px;
92
}
93
94
.verify_input {
95
    float: left;
96
    width: 160px;
97
    height: 36px;
98
    border: 1px solid #cad2db;
99
    margin-right: 10px;
100
    padding: 0 5px;
101
    -moz-border-radius: 5px;
102
    -webkit-border-radius: 5px;
103
    border-radius: 5px;
104
    line-height: 36px;
105
    /* margin-bottom: 10px; */
106
    font-size: 14px;
107
    color: #717171;
108
    font-family: Arial;
109
}
110
111
.button{
112
    height: 32px;
113
}
114
115
.sub_button {
116
    float: left;
117
    text-decoration: none;
118
    width: 100px;
119
    height: 30px;
120
    line-height: 30px;
121
    text-align: center;
122
    color: #FFF;
123
    font-size: 18px;
124
    font-weight: bold;
125
    background-color:#206fd5;
126
    opacity: 0.7;
127
    border: none;
128
    margin-left: 50%;
129
}
130
131
.login_padding span {
132
    color: red;
133
}
134
135
.login_padding label span {
136
    width: 260px;
137
    height: 12px;
138
    display: inline-block;
139
}
140
141
.copyrights {
142
    margin: 40px auto;
143
}

BIN
public/static/fonts/glyphicons-halflings-regular.ttf


BIN
public/static/fonts/glyphicons-halflings-regular.woff


BIN
public/static/fonts/glyphicons-halflings-regular.woff2


BIN
public/static/img/logo.png


BIN
public/static/img/logo.png~


public/html/index.html → view/index.bak.php


+ 216 - 0
view/index.php

@ -0,0 +1,216 @@
1
<html lang="zh-cn">
2
3
<head>
4
    <link rel="stylesheet" href="/static/css/bootstrap.min.css">
5
    <link rel="stylesheet" href="/static/css/index.css">
6
    <script src="/static/js/jquery.min.js"></script>
7
    <script src="/static/js/bootstrap.min.js"></script>
8
    <script src="/static/js/axios.min.js"></script>
9
    <!-- <script src="https://cdn.bootcss.com/axios/0.17.1/axios.min.js"></script> -->
10
    <!-- <link href="/static/css/markdown.css" rel="stylesheet" /> -->
11
    <script src="/static/ace/ace.js"></script>
12
    <script src="/static/ace/mode-markdown.js"></script>
13
    <script src="/static/ace/theme-chrome.js"></script>
14
    <!-- <script src="/static/js/marked.js"></script> -->
15
    <!-- <script src="/static/js/showPanel.js"></script> -->
16
    <!-- <link rel="stylesheet" href="/static/codemirror-5.31.0/lib/codemirror.css"/> -->
17
    <!-- <script src="/static/codemirror-5.31.0/lib/codemirror.js"></script> -->
18
    <!--引入css文件,用以支持主题-->
19
    <!-- <link rel="stylesheet" href="/static/codemirror-5.31.0/theme/solarized.css"/> -->
20
    <!-- <script src="/static/codemirror-5.31.0/mode/markdown/markdown.js"></script> -->
21
22
    <link rel="stylesheet" href="/static/highlight/styles/solarized-light.css">
23
    <script src="/static/highlight/highlight.pack.js"></script>
24
    <title>MarkDown-Wiki:
25
        <?php echo $doc;?>
26
    </title>
27
</head>
28
29
<body>
30
    <header>
31
        <span class="logo">
32
            <a href="/index">HUWIKI</a>
33
        </span>
34
        <!-- Button trigger modal -->
35
        <button type="button" class="btn btn-primary btn-lg" data-toggle="modal" onclick="edit()">
36
            <span class="glyphicon glyphicon-pencil" aria-hidden="true"></span> 编辑
37
        </button>
38
        <button type="button" class="btn btn-primary btn-lg" onclick="logout()">
39
            <span class="glyphicon glyphicon-log-out" aria-hidden="true"></span> 退出
40
        </button>
41
        <button type="button" class="btn btn-primary btn-lg" onclick="window.location.href='/userlist'">
42
            <span class="glyphicon glyphicon-user" aria-hidden="true"></span> 用户管理
43
        </button>
44
    </header>
45
    <aside>
46
        <div class="nav" style="z-index: 99;">
47
            <span>位置: <a href="/index">index</a></span>
48
            <?php
49
                $dir_name = pathinfo($doc, PATHINFO_DIRNAME);
50
                $nav = explode('/',$dir_name);
51
                $temp = "/index/";
52
                foreach ($nav as $val) {
53
                    if ($val=='.' || $val == '..') {
54
                        continue;
55
                    } else {
56
            ?>
57
            <span> / <a href="<?php echo $temp.$val.'/index.md';?>">
58
                    <?php echo $val;?>
59
                </a></span>
60
            <?php
61
                    }
62
                    $temp .= $val ."/";
63
                }
64
            ?>
65
        </div>
66
        <div class="toc">
67
            <?php echo $toc;?>
68
        </div>
69
    </aside>
70
    <!--article标签中就是我们编写的文本内容-->
71
    <article>
72
        <div class="top">
73
74
        </div>
75
        <div class="content">
76
            <?php
77
                if ($is_file_exists) {
78
                    echo $content;
79
                } else {
80
            ?>
81
            <div class="is_file_exists">
82
                <span>文档不存在, 点击<a href='javascript:void(0213123);' onclick='edit()'>新建文档</a></span>
83
            </div>
84
            <?php
85
                }
86
            ?>
87
        </div>
88
    </article>
89
90
    <!-- 编辑 Modal  -->
91
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
92
        <div class="modal-dialog" role="document">
93
            <div class="modal-content modal-edit">
94
                <div class="modal-header">
95
                    <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span
96
                            aria-hidden="true">&times;</span></button>
97
                    <h4 class="modal-title" id="myModalLabel">编辑</h4>
98
                </div>
99
                <div class="modal-body">
100
                    <div class="editor-content" id="mdeditor" style="height: 70%;"><?php echo $text;?></div>
101
                    <!-- <textarea class="form-control" rows="20" style="resize:vertical" id="mdeditor" name="mdeditor"><?php echo $text;?></textarea> -->
102
                    <!-- begin code -->
103
                    <!-- <textarea class="form-control" id="mdeditor" name="mdeditor"><?php echo $text;?></textarea> -->
104
                    <!-- end code-->
105
                </div>
106
                <div class="modal-footer">
107
                    <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
108
                    <button type="button" class="btn btn-primary" onclick="save('<?php echo $doc;?>')">Save
109
                        changes</button>
110
                </div>
111
            </div>
112
        </div>
113
    </div>
114
115
    <script>
116
        $(document).ready(function () {
117
            // 表格加上边框
118
            $("table").addClass('table table-bordered');
119
            
120
            if (storage.getItem("headerColor")) {
121
                var color = storage.getItem("headerColor");
122
123
                $("header").css('background-color', color);
124
            }
125
        });
126
127
        //修改header background-color
128
        function changeColor(obj) {
129
            // console.log($(obj).data("status"));
130
            var status = $(obj).data("status");
131
            if (status == 0) {
132
                $(".select_header_color").css("display", "block");
133
                $(obj).data("status", 1);
134
            } else {
135
                $(".select_header_color").css("display", "none");
136
                $(obj).data("status", 0);
137
            }
138
        }
139
        function doChange(color) {
140
            // console.log(color);
141
            // var color = $(obj).val();
142
            storage.setItem("headerColor", color);
143
            $("header").css("background-color", color);
144
        }
145
146
        // 代码高亮
147
        document.addEventListener('DOMContentLoaded', (event) => {
148
            document.querySelectorAll('pre code').forEach((block) => {
149
                hljs.highlightBlock(block);
150
            });
151
        });
152
153
        // ace 编辑器
154
        var editor = ace.edit('mdeditor');//左侧编辑框
155
        editor.setTheme('ace/theme/chrome');
156
        editor.getSession().setMode('ace/mode/markdown');
157
        editor.renderer.setShowPrintMargin(false);
158
159
        var imgUrl = '';//上传图片返回的url
160
161
        // codemirror
162
        // var editor = CodeMirror.fromTextArea(document.getElementById("mdeditor"), {
163
        //     theme: "solarized",	//设置主题
164
        //     mode: "markdown",    //实现groovy代码高亮
165
        //     // mode: "text/x-java", //实现Java代码高亮
166
        //     lineNumbers: true,	//显示行号
167
        //     // lineWrapping: true,	//代码折叠
168
        //     // foldGutter: true,
169
        //     // gutters: ["CodeMirror-linenumbers", "CodeMirror-foldgutter"],
170
        //     // matchBrackets: true,	//括号匹配
171
        //     //readOnly: true,        //只读
172
        // });
173
174
        // textarea
175
        // editor = {
176
        //     getValue() {
177
        //         return $("#mdeditor").val();
178
        //     }
179
        // };     
180
        var storage = window.sessionStorage
181
182
        function edit() {
183
            $("#myModal").modal('show');
184
        }
185
186
        function save(doc) {
187
            var text = editor.getValue();
188
            // console.log(editor.getValue());
189
            // return false;
190
            params = {
191
                'doc': doc,
192
                'content': text
193
            };
194
            axios({
195
                method: "POST",
196
                url: `/save`,
197
                data: JSON.stringify(params),
198
            }).then(function (res) {
199
                if (res.data.code == 0) {
200
                    // acen_edit.destroy();
201
                    // acen_edit.container.remove();
202
                    console.log(res.data.msg);
203
                    alert("保存成功");
204
                    $("#myModal").modal('hide');
205
                    setTimeout(window.location.reload(), 1500);
206
                } else {
207
                    alert(res.data.msg);
208
                }
209
            }).catch(function (error) {
210
                console.log(error);
211
            });
212
        }
213
    </script>
214
</body>
215
216
</html>

+ 97 - 0
view/login.php

@ -0,0 +1,97 @@
1
<!DOCTYPE HTML>
2
<html xmlns="http://www.w3.org/1999/xhtml">
3
4
<head>
5
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
6
    <link type="text/css" rel="stylesheet" href="/static/css/login.css" />
7
    <script type="text/javascript" src="/static/js/jquery.min.js"></script>
8
</head>
9
10
<body class="login">
11
    <div class="login_m">
12
        <div class="login_logo">
13
            <img src="/static/img/logo.png" width="196" height="46">
14
        </div>
15
        <div class="login_boder">
16
            <div class="login_padding" id="login_model">
17
                <form id="login_form" method="POST">
18
                    <div class="username">
19
                        <h2>USERNAME</h2>
20
                        <label>
21
                            <input type="text" id="username" name="username" class="txt_input" placeholder="your username">
22
                        </label>
23
                    </div>
24
                    <div class="password">
25
                        <h2>PASSWORD</h2>
26
                        <label>
27
                            <input type="password" id="userpwd" name="password" class="txt_input" placeholder="the password">
28
                        </label>
29
                    </div>
30
                    <div class="forgot_password">
31
                        <h2>
32
                            <a href="javascript:void(0);" onclick="getPwd();">Forgot your password?</a>
33
                        </h2>
34
                        <label>
35
                            <span class="fspan"></span>
36
                        </label>
37
                    </div>
38
                    <div class="button">
39
                        <label>
40
                            <a href="javascript:void(0);" id="button" class="sub_button">登&nbsp;陆</a>
41
                            <!-- <input type="submit" class="sub_button"  id="button" value="登陆" style="opacity: 0.7;"> -->
42
                        </label>
43
                    </div>
44
                </form>
45
            </div>
46
            <!--login_padding  Sign up end-->
47
        </div>
48
        <!--login_boder end-->
49
        <div class="copyrights">Collect from
50
            <a href="#">huwhois@163.com</a>
51
        </div>
52
    </div>
53
    <!--login_m end-->
54
55
    <script type="text/javascript">
56
        $(function () {
57
            $('#button').css('opacity', 0.7).hover(function () {
58
                $(this).stop().fadeTo(650, 1);
59
            }, function () {
60
                $(this).stop().fadeTo(650, 0.7);
61
            });
62
63
            $("#button").click(function () {
64
                var uname = $("#username").val();
65
                var upwd = $("#userpwd").val();
66
67
                $.post('/dologin', {
68
                   'username' :  uname,
69
                   'password' :  upwd,
70
                }, function(res){
71
                    console.log(res);
72
                    if (res.code == 0) {
73
                        window.location.href = "/index";
74
                    } else {
75
                        alert(res.msg);
76
                    }
77
                    return false;
78
                }, 'json');
79
            });
80
        });
81
82
        function KeyDown() {
83
            if (event.keyCode == 13) {
84
                event.returnValue = false;
85
                event.cancel = true;
86
                $("#button").click();
87
            }
88
        }
89
90
        function getPwd() {
91
            $('.fspan').html("* 请联系网站管理员");
92
        }
93
    </script>
94
95
</body>
96
97
</html>

+ 84 - 0
view/userlist.php

@ -0,0 +1,84 @@
1
<!DOCTYPE html>
2
<html>
3
4
<head lang="en">
5
    <meta charset="UTF-8">
6
    <link rel="stylesheet" href="/static/css/bootstrap.min.css">
7
    <script src="/static/js/jquery.min.js"></script>
8
    <script src="/static/js/bootstrap.min.js"></script>
9
    <title>用户列表</title>
10
11
    <style>
12
        .box {
13
            width: 80%;
14
            margin: auto;
15
            margin-top: 60px;
16
            padding-left: 10px;
17
        }
18
    </style>
19
</head>
20
21
<body>
22
    <div class="box">
23
        <div class="row col-md-8">
24
            <button type="button" class="btn btn-primary">新增</button>
25
            <table class="table table-bordered">
26
                <thead>
27
                    <tr>
28
                        <th>
29
                            id
30
                        </th>
31
                        <th>
32
                            用户名
33
                        </th>
34
                        <th>
35
                            创建时间
36
                        </th>
37
                        <th>
38
                            删除
39
                        </th>
40
                    </tr>
41
                </thead>
42
                <tbody>
43
                    <?php
44
                    foreach ($list as $value) {
45
                    ?>
46
                        <tr>
47
                            <td><?php echo $value['id']; ?></td>
48
                            <td><?php echo $value['username']; ?></td>
49
                            <td><?php echo date('Y-m-d H:i:s', $value['create_time']); ?></td>
50
                            <td><a type="button" class="btn btn-danger" href="javascript:del(<?php echo $value['id']; ?>)">
51
                                <span class="glyphicon glyphicon-trash" aria-hidden="true"></span></a></td>
52
                        </tr>
53
                    <?php
54
                    }
55
                    ?>
56
                </tbody>
57
            </table>
58
        </div>
59
    </div>
60
    
61
62
63
    <script>
64
        function del(id)
65
        {
66
            $.post('/userdelete', {
67
                   'userid' :  id,
68
                }, function(res){
69
                    console.log(res);
70
                    if (res.code == 0) {
71
                        alert('操作成功');
72
                        
73
                        window.location.reload();
74
                    } else {
75
                        alert(res.msg);
76
                    }
77
                    return false;
78
                }, 'json');
79
        }
80
81
    </script>
82
</body>
83
84
</html>