Merge branch 'master' into new-beego-path

pull/662/head
roberChen 2021-04-01 11:33:19 +08:00
commit 47a5d5b05c
5 changed files with 62 additions and 56 deletions

View File

@ -1,65 +1,53 @@
version: "{build}"
clone_folder: c:\gopath\src\github.com\lifei6671\mindoc
version: 1.0.{build}
branches:
only:
- master
image: Visual Studio 2015
clone_folder: c:\gopath\src\github.com\mindoc-org\mindoc
init:
- cmd: >-
if [%tbs_arch%]==[x86] SET PATH=C:\MinGW\bin;%PATH%
if [%tbs_arch%]==[x64] SET PATH=C:\mingw-w64\x86_64-7.2.0-posix-seh-rt_v5-rev1\mingw64;C:\mingw-w64\x86_64-7.2.0-posix-seh-rt_v5-rev1\mingw64\bin;%PATH%
SET PATH=%GOPATH%\bin;%GOBIN%;%PATH%
FOR /f "delims=" %%i IN ('go version') DO (SET GO_VERSION=%%i)
environment:
GOPATH: c:\gopath
GOVERSION: "1.12"
GOBIN: c:\gobin
GO111MODULE: on
CGO_ENABLED: 1
matrix:
- tbs_arch: "x86"
tbs_tools: "mingw"
tbs_static_runtime: 1
- tbs_arch: x86
GOARCH: 386
- tbs_arch: "x64"
tbs_tools: "mingw"
tbs_static_runtime: 1
- tbs_arch: x64
GOARCH: amd64
install:
- ps: if($env:tbs_tools -eq 'mingw' -and $env:tbs_arch -eq 'x64')
{
Start-FileDownload "http://libgd.blob.core.windows.net/mingw/x86_64-4.9.1-release-posix-seh-rt_v3-rev1.7z" -FileName mingw_x86_64.7z;
7z x -oC:\ mingw_x86_64.7z | out-null;
}
- ps: if($env:tbs_tools -eq 'mingw' -and $env:tbs_arch -eq 'x86')
{
Start-FileDownload "http://libgd.blob.core.windows.net/mingw/i686-4.9.1-release-posix-dwarf-rt_v3-rev1.7z" -FileName mingw_x86.7z;
7z x -oC:\ mingw_x86.7z | out-null;
}
- set PATH=%GOPATH%\bin;c:\go\bin;%PATH%
- echo %PATH%
- echo %GOPATH%
- go version
- go env
- cmd: >-
echo %PATH%
echo %GO_VERSION%
go env
where gcc
where g++
build_script:
- if [%tbs_tools%]==[mingw] if [%tbs_arch%]==[x86] SET PATH=C:\mingw32\bin;%PATH%
- if [%tbs_tools%]==[mingw] if [%tbs_arch%]==[x64] SET PATH=C:\mingw64\bin;%PATH%
- set CGO_ENABLED=1
- for /f "delims=" %%i in ('go version') do (set GO_VERSION=%%i)
- cd c:\gopath\src\github.com\lifei6671\mindoc
- go mod tidy
- go build -v -o "mindoc_windows_%GOARCH%.exe" -ldflags="-w -X github.com/mindoc-org/mindoc/conf.VERSION=%APPVEYOR_REPO_TAG_NAME% -X 'github.com/mindoc-org/mindoc/conf.BUILD_TIME=%date% %time%' -X 'conf.GO_VERSION=%GO_VERSION%'"
- 7z a -t7z -r mindoc_windows_%GOARCH%.7z conf/*.conf* static/* mindoc_windows_%GOARCH%.exe views/* uploads/*
- cmd: >-
cd c:\gopath\src\github.com\mindoc-org\mindoc
go mod tidy
go build -ldflags "-w"
go build -v -o "mindoc_windows_%GOARCH%.exe" -ldflags="-w -X github.com/mindoc-org/mindoc/conf.VERSION=%APPVEYOR_REPO_TAG_NAME% -X 'github.com/mindoc-org/mindoc/conf.BUILD_TIME=%date% %time%' -X 'conf.GO_VERSION=%GO_VERSION%'"
7z a -t7z -r mindoc_windows_%GOARCH%.7z conf/*.conf* static/* mindoc_windows_%GOARCH%.exe views/* uploads/*
test_script:
- mindoc_windows_%GOARCH%.exe version
- cmd: >-
cd c:\gopath\src\github.com\mindoc-org\mindoc
notifications:
- provider: Email
to:
- lifei6671@163.com
on_build_success: false
artifacts:
- path: mindoc_windows_%GOARCH%.7z
name: Releases
deploy:
- provider: GitHub
auth_token:
secure: "Qkhxloft5lBKti7O+vVS+Vrxh7CBAUVhlfdZ9ptBXjFtjt6jHXnaBA2uv2OYbISB"
draft: false
prerelease: false
artifact: mindoc_windows_%GOARCH%.7z
on:
appveyor_repo_tag: true
mindoc_windows_%GOARCH%.exe version
deploy: off

View File

@ -144,17 +144,22 @@ func (c *DocumentController) Read() {
doc.AttachList = attach
}
doc.IncrViewCount(doc.DocumentId)
c.Data["ViewCount"] = doc.ViewCount + 1
if c.IsAjax() {
var data struct {
DocTitle string `json:"doc_title"`
Body string `json:"body"`
Title string `json:"title"`
Version int64 `json:"version"`
ViewCount int `json:"view_count"`
}
data.DocTitle = doc.DocumentName
data.Body = doc.Release
data.Title = doc.DocumentName + " - Powered by MinDoc"
data.Version = doc.Version
data.ViewCount = doc.ViewCount + 1
c.JsonResult(0, "ok", data)
}

View File

@ -42,6 +42,7 @@ type Document struct {
Version int64 `orm:"column(version);type(bigint);" json:"version"`
//是否展开子目录0 否/1 是 /2 空间节点,单击时展开下一级
IsOpen int `orm:"column(is_open);type(int);default(0)" json:"is_open"`
ViewCount int `orm:"column(view_count);type(int)" json:"view_count"`
AttachList []*Attachment `orm:"-" json:"attach"`
}
@ -385,3 +386,11 @@ func (item *Document) Processor() *Document {
}
return item
}
// 增加阅读次数
func (item *Document) IncrViewCount(id int) {
o := orm.NewOrm()
o.QueryTable(item.TableNameWithPrefix()).Filter("document_id", id).Update(orm.Params{
"view_count": orm.ColValue(orm.ColAdd, 1),
})
}

View File

@ -65,6 +65,7 @@ function loadDocument($url, $id, $callback) {
$("title").text(data.title);
$("#article-title").text(data.doc_title);
$("#article-info").text(data.doc_info);
$("#view_count").text("阅读次数:" + data.view_count);
events.trigger('article.open', {$url: $url, $id: $id});
@ -80,6 +81,7 @@ function loadDocument($url, $id, $callback) {
var doc_title = res.data.doc_title;
var title = res.data.title;
var doc_info = res.data.doc_info;
var view_count = res.data.view_count;
$body = body;
if (typeof $callback === "function" ) {
@ -90,6 +92,7 @@ function loadDocument($url, $id, $callback) {
$("title").text(title);
$("#article-title").text(doc_title);
$("#article-info").text(doc_info);
$("#view_count").text("阅读次数:" + view_count);
events.data($id, res.data);

View File

@ -146,6 +146,7 @@
</div>
<div class="m-copyright">
<p>
<div id="view_count">阅读次数:{{.ViewCount}}</div>
本文档使用 <a href="https://www.iminho.me" target="_blank">MinDoc</a> 发布
</p>
</div>