Skip to content
This repository was archived by the owner on Jul 11, 2019. It is now read-only.

Commit 316b1a3

Browse files
committed
use tango instead of xweb for web interface
1 parent d61df3c commit 316b1a3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+524
-358
lines changed

config.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ port=2121
66
[web]
77
enable=true
88
listen=:8181
9-
ssl=true
9+
tls=false
1010

1111
[admin]
1212
user=admin

main.go

+4-2
Original file line numberDiff line numberDiff line change
@@ -83,9 +83,11 @@ func main() {
8383
weblisten, _ := cfg.GetValue("web", "listen")
8484
admin, _ := cfg.GetValue("admin", "user")
8585
pass, _ := cfg.GetValue("admin", "pass")
86-
ssl, _ := cfg.Bool("web", "ssl")
86+
tls, _ := cfg.Bool("web", "tls")
87+
certFile, _ := cfg.GetValue("web", "certFile")
88+
keyFile, _ := cfg.GetValue("web", "keyFile")
8789

88-
go web.Web(weblisten, "static", "templates", admin, pass, ssl)
90+
go web.Web(weblisten, "static", "templates", admin, pass, tls, certFile, keyFile)
8991
}
9092

9193
ftpName, _ := cfg.GetValue("server", "name")
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

templates/base/base.html

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!DOCTYPE html>
2+
<html lang="zh-cn">
3+
<head>
4+
{{template "head" .}}
5+
</head>
6+
<body>
7+
<div class="container">
8+
{{template "nav" .}}
9+
{{template "body" .}}
10+
</div>
11+
{{template "footer" .}}
12+
</body>
13+
</html>

templates/base/common.html

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{{define "head"}}
2+
{{template "base/head.html" .}}
3+
{{end}}
4+
5+
{{define "nav"}}
6+
{{template "base/nav.html" .}}
7+
{{end}}
8+
9+
{{define "footer"}}
10+
{{template "base/foot.html" .}}
11+
{{end}}

templates/base/common_nohead.html

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{{define "nav"}}
2+
{{template "base/nav.html" .}}
3+
{{end}}
4+
5+
{{define "footer"}}
6+
{{template "base/foot.html" .}}
7+
{{end}}
File renamed without changes.

templates/base/head.html

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
2+
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
3+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
4+
<link rel="stylesheet" href="/public/css/bootstrap-theme.css"/>
5+
<link href="/public/css/bootstrap.css" rel="stylesheet">
6+
<script src="/public/js/jquery.min.js"></script>
7+
<script src="/public/js/bootstrap.js"></script>
8+
<link rel="stylesheet" href="/public/css/bootstrap-theme.css" />

templates/nav.html templates/base/nav.html

+5-5
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@
1717
</div>
1818
<div class="collapse navbar-collapse" role="navigation" id="navbar-collapse">
1919
<ul class="nav navbar-nav">
20-
{{if IsAdmin}}
21-
<li{{if isCurModule 1}} class="active"{{end}}><a href="/user">用户管理</a></li>
22-
<li{{if isCurModule 2}} class="active"{{end}}><a href="/group">组管理</a></li>
23-
<li{{if isCurModule 3}} class="active"{{end}}><a href="/perm">权限管理</a></li>
20+
{{if .IsAdmin}}
21+
<li{{if call .isCurModule 1}} class="active"{{end}}><a href="/user">用户管理</a></li>
22+
<li{{if call .isCurModule 2}} class="active"{{end}}><a href="/group">组管理</a></li>
23+
<li{{if call .isCurModule 3}} class="active"{{end}}><a href="/perm">权限管理</a></li>
2424
{{end}}
2525
</ul>
2626
<ul class="nav navbar-nav navbar-right">
27-
<li{{if isCurModule 4}} class="active"{{end}}><a href="/user/chgpass">修改密码</a></li>
27+
<li{{if call .isCurModule 4}} class="active"{{end}}><a href="/user/chgpass">修改密码</a></li>
2828
<li><a href="/logout">退出 </a></li>
2929
</ul>
3030
</div>

templates/group/add.html

+7-14
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
<!DOCTYPE html>
2-
<html lang="zh-cn">
3-
<head>
4-
{{include "head.html"}}
5-
</head>
6-
<body>
7-
<div class="container">
8-
{{include "nav.html"}}
9-
<div style="padding:10px;padding-top:60px">
1+
{{template "base/base.html" .}}
2+
{{template "base/common.html" .}}
3+
4+
{{define "body"}}
5+
<div style="padding:10px;padding-top:60px">
106
<form class="form-horizontal" method="post">
11-
{{XsrfFormHtml}}
7+
{{.XsrfFormHtml}}
128
<legend>添加组</legend>
139
<div class="control-group">
1410
<label class="control-label" for="inputEmail">组名称:</label>
@@ -22,7 +18,4 @@
2218
</div>
2319
</form>
2420
</div>
25-
</div>
26-
{{include "foot.html"}}
27-
</body>
28-
</html>
21+
{{end}}

templates/group/edit.html

+5-12
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
<!DOCTYPE html>
2-
<html lang="zh-cn">
3-
<head>
4-
{{include "head.html"}}
5-
</head>
6-
<body>
7-
<div class="container">
8-
{{include "nav.html"}}
1+
{{template "base/base.html" .}}
2+
{{template "base/common.html" .}}
3+
4+
{{define "body"}}
95
<div style="padding:10px;padding-top:60px">
106
<div class="row"><legend>修改组:{{.T.user.Name}}</legend></div>
117
<div class="row">
@@ -40,7 +36,4 @@
4036
</div>
4137
</div>
4238
</div>
43-
</div>
44-
{{include "foot.html"}}
45-
</body>
46-
</html>
39+
{{end}}

templates/group/list.html

+5-12
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
<!DOCTYPE html>
2-
<html lang="zh-cn">
3-
<head>
4-
{{include "head.html"}}
5-
</head>
6-
<body>
7-
<div class="container">
8-
{{include "nav.html"}}
1+
{{template "base/base.html" .}}
2+
{{template "base/common.html" .}}
3+
4+
{{define "body"}}
95
<div class="text-right" style="padding:10px;padding-top:60px"><a href="/group/add" class="btn btn-large btn-primary">添加</a>
106
</div>
117
<table class="table table-bordered table-hover">
@@ -24,7 +20,4 @@
2420
{{end}}
2521
</tbody>
2622
</table>
27-
</div>
28-
{{include "foot.html"}}
29-
</body>
30-
</html>
23+
{{end}}

templates/head.html

-9
This file was deleted.

templates/login.html

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<!DOCTYPE html>
22
<html lang="zh-cn">
33
<head>
4-
{{include "head.html"}}
4+
{{template "base/head.html" .}}
55
<style type="text/css">
66
body {
77
padding-top: 40px;
@@ -39,11 +39,11 @@
3939
<body>
4040
<div class="container">
4141
<form class="form-signin" method="post">
42-
{{XsrfFormHtml}}
42+
{{.XsrfFormHtml}}
4343
<h2 class="form-signin-heading">GoFtp管理系统</h2>
4444
<input name="name" type="text" class="input-block-level" placeholder="账号">
4545
<input name="pass" type="password" class="input-block-level" placeholder="密码">
46-
<input type="submit" value="登录" class="btn btn-large btn-primary">&nbsp; <font color=red>{{.T.msg}}</font>
46+
<input type="submit" value="登录" class="btn btn-large btn-primary">&nbsp; <font color=red>{{.msg}}</font>
4747
</form>
4848
</div>
4949
</body>

templates/perm/list.html

+22-25
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
<!DOCTYPE html>
2-
<html lang="zh-cn">
3-
<head>
4-
{{include "head.html"}}
1+
{{template "base/base.html" .}}
2+
{{template "base/common_nohead.html" .}}
3+
4+
{{define "head"}}
5+
{{template "base/head.html"}}
56
<script>
67
function updateGroup(name, newgroup) {
78
$.ajax({
@@ -56,13 +57,12 @@
5657
})
5758
})
5859
</script>
59-
</head>
60-
<body>
61-
<div class="container">
62-
{{include "nav.html"}}
63-
<div class="row" style="padding:10px;padding-top:60px">
60+
{{end}}
61+
62+
{{define "body"}}
63+
<div class="row" style="padding:10px;padding-top:60px">
6464
<div class="col-md-10">
65-
当前目录:{{.T.path}}
65+
当前目录:{{.path}}
6666
</div>
6767
<div class="col-md-2 text-right">
6868
</div>
@@ -74,14 +74,14 @@
7474
<th>权限(Others)</th><th>操作</th>
7575
</thead>
7676
<tbody>
77-
{{$parent := .T.parent}}
78-
{{if ne .T.path "/"}}
77+
{{$parent := .parent}}
78+
{{if ne .path "/"}}
7979
<tr><td colspan="8"><a href="/perm/?path={{$parent}}">..</a></td>
8080
</tr>
8181
{{end}}
82-
{{$users := .T.users}}
83-
{{$groups := .T.groups}}
84-
{{range .T.infos}}
82+
{{$users := .users}}
83+
{{$groups := .groups}}
84+
{{range .infos}}
8585
<tr><td>
8686
{{$name := .Name}}
8787
{{$owner := .Owner}}
@@ -102,17 +102,14 @@
102102
<option{{if eq $group .}} selected{{end}}>{{.}}</option>
103103
{{end}}
104104
</select></td>
105-
<td><input id="owner_r_{{$name}}" class="check" type="checkbox"{{if hasPerm .Mode 1 "r"}} checked{{end}}> r
106-
<input id="owner_w_{{$name}}" class="check" type="checkbox"{{if hasPerm .Mode 2 "w"}} checked{{end}}> w</td>
107-
<td><input id="group_r_{{$name}}" class="check" type="checkbox"{{if hasPerm .Mode 4 "r"}} checked{{end}}> r
108-
<input id="group_w_{{$name}}" class="check" type="checkbox"{{if hasPerm .Mode 5 "w"}} checked{{end}}> w</td>
109-
<td><input id="other_r_{{$name}}" class="check" type="checkbox"{{if hasPerm .Mode 7 "r"}} checked{{end}}> r
110-
<input id="other_w_{{$name}}" class="check" type="checkbox"{{if hasPerm .Mode 8 "w"}} checked{{end}}> w</td>
105+
<td><input id="owner_r_{{$name}}" class="check" type="checkbox"{{if call $.hasPerm .Mode 1 "r"}} checked{{end}}> r
106+
<input id="owner_w_{{$name}}" class="check" type="checkbox"{{if call $.hasPerm .Mode 2 "w"}} checked{{end}}> w</td>
107+
<td><input id="group_r_{{$name}}" class="check" type="checkbox"{{if call $.hasPerm .Mode 4 "r"}} checked{{end}}> r
108+
<input id="group_w_{{$name}}" class="check" type="checkbox"{{if call $.hasPerm .Mode 5 "w"}} checked{{end}}> w</td>
109+
<td><input id="other_r_{{$name}}" class="check" type="checkbox"{{if call $.hasPerm .Mode 7 "r"}} checked{{end}}> r
110+
<input id="other_w_{{$name}}" class="check" type="checkbox"{{if call $.hasPerm .Mode 8 "w"}} checked{{end}}> w</td>
111111
<td> </td></tr>
112112
{{end}}
113113
</tbody>
114114
</table>
115-
</div>
116-
{{include "foot.html"}}
117-
</body>
118-
</html>
115+
{{end}}

templates/user/add.html

+7-14
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
<!DOCTYPE html>
2-
<html lang="zh-cn">
3-
<head>
4-
{{include "head.html"}}
5-
</head>
6-
<body>
7-
<div class="container">
8-
{{include "nav.html"}}
9-
<div style="padding:10px;padding-top:60px">
1+
{{template "base/base.html" .}}
2+
{{template "base/common.html" .}}
3+
4+
{{define "body"}}
5+
<div style="padding:10px;padding-top:60px">
106
<form class="form-horizontal" method="post">
11-
{{XsrfFormHtml}}
7+
{{.XsrfFormHtml}}
128
<legend>添加账号</legend>
139
<div class="control-group">
1410
<label class="control-label" for="inputEmail">账号名称:</label>
@@ -28,7 +24,4 @@
2824
</div>
2925
</form>
3026
</div>
31-
</div>
32-
{{include "foot.html"}}
33-
</body>
34-
</html>
27+
{{end}}

templates/user/chgpass.html

+8-15
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
1-
<!DOCTYPE html>
2-
<html lang="zh-cn">
3-
<head>
4-
{{include "head.html"}}
5-
</head>
6-
<body>
7-
<div class="container">
8-
{{include "nav.html"}}
9-
<div style="padding:10px;padding-top:60px">
1+
{{template "base/base.html" .}}
2+
{{template "base/common.html" .}}
3+
4+
{{define "body"}}
5+
<div style="padding:10px;padding-top:60px">
106
<form class="form-horizontal" method="post">
11-
{{XsrfFormHtml}}
7+
{{.XsrfFormHtml}}
128
<legend>修改密码</legend>
139
<div class="control-group">
1410
<label class="control-label" for="inputEmail">账号名称:</label>
15-
<div class="controls"><input type="text" name="name" readonly value="{{session "userId"}}" />
11+
<div class="controls"><input type="text" name="name" readonly value="{{.userId}}" />
1612
</div>
1713
</div>
1814
<div class="control-group">
@@ -28,7 +24,4 @@
2824
</div>
2925
</form>
3026
</div>
31-
</div>
32-
{{include "foot.html"}}
33-
</body>
34-
</html>
27+
{{end}}

0 commit comments

Comments
 (0)