Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2c06df3

Browse files
committed
pkgdoc
1 parent ae9d1ca commit 2c06df3

File tree

2 files changed

+37
-50
lines changed

2 files changed

+37
-50
lines changed

src/http/controller/index.go

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
package controller
88

99
import (
10+
"bytes"
11+
"html/template"
1012
"logic"
1113
"model"
1214
"net/http"
@@ -110,5 +112,19 @@ func (IndexController) WrapUrl(ctx echo.Context) error {
110112

111113
// PkgdocHandler Go 语言文档中文版
112114
func (IndexController) Pkgdoc(ctx echo.Context) error {
113-
return render(ctx, "pkgdoc.html", map[string]interface{}{"activeDoc": "active"})
115+
// return render(ctx, "pkgdoc.html", map[string]interface{}{"activeDoc": "active"})
116+
tpl, err := template.ParseFiles(config.TemplateDir + "pkgdoc.html")
117+
if err != nil {
118+
logger.Errorln("parse file error:", err)
119+
return err
120+
}
121+
122+
buf := new(bytes.Buffer)
123+
err = tpl.Execute(buf, nil)
124+
if err != nil {
125+
logger.Errorln("execute template error:", err)
126+
return err
127+
}
128+
129+
return ctx.HTML(http.StatusOK, buf.String())
114130
}

template/pkgdoc.html

Lines changed: 20 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,20 @@
1-
{{define "title"}}Go语言标准库文档中文版{{end}}
2-
{{define "seo"}}<meta name="keywords" content="中文, 文档, 标准库, Go语言,Golang,Go社区,Go中文社区,Golang中文社区,Go语言社区,Go语言学习,学习Go语言,Go语言学习园地,Golang 中国,Golang中国,Golang China, Go语言论坛, Go语言中文网">
3-
<meta name="description" content="Go语言文档中文版,Go语言中文网,中国 Golang 社区,Go语言学习园地,致力于构建完善的 Golang 中文社区,Go语言爱好者的学习家园。分享 Go 语言知识,交流使用经验">{{end}}
4-
{{define "content"}}
5-
<div class="row">
6-
<div class="col-lg-12">
7-
<ol class="breadcrumb">
8-
<li><a href="/"><i class="glyphicon glyphicon-home"></i> 首页</a></li>
9-
<li><a href="/pkgdoc">标准库中文版</a></li>
10-
</ol>
11-
<div class="box_white">
12-
<iframe src="/static/pkgdoc/index.html" id="pkgdoc" width="100%" frameborder="0" framemargin="0" scrolling="no" name="pkgdoc" onload="autoHeight()"></iframe>
13-
</div>
14-
</div>
15-
</div>
16-
{{end}}
17-
{{define "js"}}
18-
<script type="text/javascript">
19-
function autoHeight(){
20-
var iframe = document.getElementById("pkgdoc");
21-
22-
if(iframe.Document){ // ie自有属性
23-
var addHeight = 0;
24-
var uri = iframe.Document.location.href;
25-
if (uri.indexOf('/static/pkgdoc/index.html') > 0) {
26-
addHeight = 25;
27-
}
28-
29-
iframe.style.height = iframe.Document.documentElement.scrollHeight + addHeight;
30-
} else if(iframe.contentDocument){ //ie,firefox,chrome,opera,safari
31-
var addHeight = 0;
32-
var uri = iframe.contentDocument.location.href;
33-
if (uri.indexOf('/static/pkgdoc/index.html') > 0) {
34-
addHeight = 25;
35-
}
36-
37-
iframe.height = iframe.contentDocument.body.offsetHeight + addHeight;
38-
}
39-
40-
// 源码链接,新窗口打开
41-
$('#pkgdoc').contents().find('a').on('mousedown', function(evt){
42-
var url = $(this).attr('href');
43-
if (url.indexOf('github.com') > 0) {
44-
$(this).attr('target', '_blank');
45-
}
46-
});
47-
}
48-
</script>
49-
{{end}}
1+
<!DOCTYPE html>
2+
<html lang="zh-CN">
3+
<head>
4+
<title>Go语言标准库文档中文版 | Go语言中文网 | Golang中文社区 | Golang中国</title>
5+
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no">
6+
<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
7+
<meta charset="utf-8">
8+
<link rel="shortcut icon" href="/static/img/go.ico">
9+
<link rel="apple-touch-icon" type="image/png" href="/static/img/logo2.png">
10+
<meta name="author" content="polaris <[email protected]>">
11+
<meta name="keywords" content="中文, 文档, 标准库, Go语言,Golang,Go社区,Go中文社区,Golang中文社区,Go语言社区,Go语言学习,学习Go语言,Go语言学习园地,Golang 中国,Golang中国,Golang China, Go语言论坛, Go语言中文网">
12+
<meta name="description" content="Go语言文档中文版,Go语言中文网,中国 Golang 社区,Go语言学习园地,致力于构建完善的 Golang 中文社区,Go语言爱好者的学习家园。分享 Go 语言知识,交流使用经验">
13+
</head>
14+
<frameset cols="15,85">
15+
<frame src="/static/pkgdoc/i.html">
16+
<frame name="main" src="/static/pkgdoc/main.html" tppabs="main.html" >
17+
<noframes>
18+
</noframes>
19+
</frameset>
20+
</html>

0 commit comments

Comments
 (0)