PttWeb:修订间差异

来自Gea-Suan Lin's Wiki
跳到导航 跳到搜索
此页面具有访问限制。如果您看见此消息,则说明您没有权限访问此页面。
第53行: 第53行:


 其中<code>layout.html</code>內需要有<code>ROOT</code>:
 其中<code>layout.html</code>內需要有<code>ROOT</code>:
<syntaxhighlight lang="smarty">
{{- define "ROOT" -}}
{{- end -}}
</syntaxhighlight>
而<code>bbsarticle.html</code>內:


<syntaxhighlight lang="smarty">
<syntaxhighlight lang="smarty">
第62行: 第69行:
</head>
</head>
<body>
<body>
{{- template "bbsarticle.html" . -}}
<pre>
{{ .Content }}
</pre>
</body>
</body>
</html>
</html>
{{- end -}}
{{- end -}}
</syntaxhighlight>
而<code>bbsarticle.html</code>內:
<syntaxhighlight lang="smarty">
<pre>
{{ .Content }}
</pre>
</syntaxhighlight>
</syntaxhighlight>



2020年12月28日 (一) 07:57的版本

PttWebPttBBS的网页界面。

概要

PttWeb是一个Golang写的界面,透过gRPCPttBBS的服务器沟通。

相依性套件

先安装需要的套件:

sudo apt install -y build-essential golang golang-goprotobuf-dev; sudo apt clean

编译

这边是参考.travis-ci.yml的方式编译[1]

export GOPATH="$HOME/go"; go get -u github.com/ptt/pttweb; go get google.golang.org/grpc; go get -u github.com/golang/protobuf/{proto,protoc-gen-go}; make -C $GOPATH/src/github.com/ptt/pttweb/proto; go get -u -t -f github.com/ptt/pttweb/...

编译完成后会在~/go/bin里面看到执行档。

设定

PttWeb需要一个config.json,设定可以参考config.go,最少需要指定这四个参数:

{
    "Bind": ["tcp:127.0.0.1:8000"],
    "BoarddAddress": "127.0.0.1:3000",
    "MemcachedAddress": "127.0.0.1:11211",
    "TemplateDirectory": "/home/bbs/templates"
}

其中/home/bbs/templates/内需要有这些档案:

askover18.html
bbsarticle.html
bbsindex.html
captcha.html
classlist.html
common.html
error.html
layout.html
manarticle.html
manindex.html
notfound.html

其中layout.html内需要有ROOT

{{- define "ROOT" -}}
{{- end -}}

bbsarticle.html内:

{{- define "ROOT" -}}
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
</head>
<body>
<pre>
{{ .Content }}
</pre>
</body>
</html>
{{- end -}}

执行

用以下指令执行:

~/go/bin/pttweb -conf ~/pttweb/config.json

相关连结

参考资料

外部链接