-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #313 from huangsihao7/vv2
feat : change yap to v2
- Loading branch information
Showing
44 changed files
with
2,685 additions
and
2,197 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import ( | ||
c "context" | ||
|
||
"github.com/qiniu/x/log" | ||
) | ||
|
||
id := param("id") | ||
token, err := Request.Cookie("token") | ||
uid, err := community.ParseJwtToken(token.Value) | ||
if err != nil { | ||
log.Error("token parse error") | ||
json { | ||
"code": 0, | ||
"err": err.Error(), | ||
} | ||
} | ||
err = community.DeleteArticle(c.TODO(), uid, id) | ||
if err != nil { | ||
json { | ||
"code": 0, | ||
"err": "delete failed", | ||
} | ||
} else { | ||
json { | ||
"code": 200, | ||
"msg": "delete success", | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import ( | ||
c "context" | ||
|
||
"github.com/qiniu/x/log" | ||
) | ||
|
||
id := param("id") | ||
token, err := Request.Cookie("token") | ||
uid, err := community.ParseJwtToken(token.Value) | ||
if err != nil { | ||
log.Error("token parse error") | ||
json { | ||
"code": 0, | ||
"err": err.Error(), | ||
} | ||
} | ||
err = community.DelMedia(c.TODO(), uid, id) | ||
if err != nil { | ||
json { | ||
"code": 0, | ||
"err": "delete failed", | ||
} | ||
} else { | ||
json { | ||
"code": 200, | ||
"msg": "delete success", | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import ( | ||
c "context" | ||
|
||
"github.com/goplus/community/internal/core" | ||
"github.com/qiniu/x/log" | ||
) | ||
|
||
var user *core.User | ||
|
||
token, err := Request.Cookie("token") | ||
if token != nil { | ||
user, err = community.GetUser(token.Value) | ||
if err != nil { | ||
log.Error("get user error") | ||
json { | ||
"code": 0, | ||
"err": err.Error(), | ||
} | ||
} | ||
} | ||
|
||
// Get Article Info | ||
articles, next, err := community.ListArticle(c.TODO(), core.MarkBegin, limitConst, "", labelConst) | ||
if err != nil { | ||
log.Error("get article error:", err) | ||
} | ||
|
||
yap "home", { | ||
"User": user, | ||
"Items": articles, | ||
"Next": next, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import ( | ||
"github.com/goplus/community/internal/core" | ||
"github.com/qiniu/x/log" | ||
) | ||
|
||
var user *core.User | ||
|
||
token, err := Request.Cookie("token") | ||
if token != nil { | ||
user, err = community.GetUser(token.Value) | ||
if err != nil { | ||
log.Error("get user error") | ||
json { | ||
"code": 0, | ||
"err": err.Error(), | ||
} | ||
} | ||
} | ||
yap "edit", { | ||
"User": user, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import ( | ||
c "context" | ||
|
||
"github.com/qiniu/x/log" | ||
) | ||
|
||
id := param("id") | ||
article, err := community.Article(c.TODO(), id) | ||
if err != nil { | ||
log.Error("get article error:", err) | ||
json { | ||
"code": 0, | ||
"err": "get article failed", | ||
} | ||
} | ||
json { | ||
"code": 200, | ||
"data": article, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import ( | ||
c "context" | ||
"strconv" | ||
|
||
"github.com/qiniu/x/log" | ||
) | ||
|
||
from := param("from") | ||
limit := param("limit") | ||
searchValue := param("value") | ||
label := param("label") | ||
|
||
limitInt, err := strconv.Atoi(limit) | ||
if err != nil { | ||
limitInt = limitConst | ||
} | ||
|
||
// Get Article Info | ||
articles, next, err := community.ListArticle(c.TODO(), from, limitInt, searchValue, label) | ||
if err != nil { | ||
log.Error("get article error:", err) | ||
json { | ||
"code": 0, | ||
"err": "get article failed", | ||
} | ||
} | ||
json { | ||
"code": 200, | ||
"items": articles, | ||
"next": next, | ||
"value": searchValue, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import ( | ||
c "context" | ||
"fmt" | ||
) | ||
|
||
id := param("id") | ||
fileKey, err := community.GetMediaUrl(c.TODO(), id) | ||
htmlUrl := fmt.Sprintf("%s%s", domain, fileKey) | ||
if err != nil { | ||
json { | ||
"code": 500, | ||
"err": "have no html media", | ||
} | ||
} | ||
json { | ||
"code": 200, | ||
"url": htmlUrl, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import ( | ||
c "context" | ||
|
||
"github.com/qiniu/x/log" | ||
) | ||
|
||
id := param("id") | ||
article, err := community.GetTranslateArticle(c.TODO(), id) | ||
|
||
if err != nil { | ||
log.Info(err) | ||
json { | ||
"code": 0, | ||
} | ||
} | ||
json { | ||
"code": 200, | ||
"content": article.Content, | ||
"tags": article.Tags, | ||
"title": article.Title, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import ( | ||
gopaccountsdk "github.com/liuscraft/gop-casdoor-account-sdk" | ||
) | ||
|
||
pv := param("pv") | ||
token, err := Request.Cookie("token") | ||
if err != nil { | ||
json { | ||
"code": 200, | ||
} | ||
return | ||
} | ||
switch pv { | ||
case "Twitter": | ||
case "Facebook": | ||
case "Github": | ||
case "WeChat": | ||
default: | ||
pv = "" | ||
} | ||
gac, err := gopaccountsdk.GetClient(token.Value) | ||
if err == nil { | ||
gac.UnLink(pv) | ||
} | ||
json { | ||
"code": 200, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import ( | ||
c "context" | ||
"strconv" | ||
|
||
"github.com/qiniu/x/log" | ||
) | ||
|
||
id := param("id") | ||
page := param("page") | ||
limit := param("limit") | ||
|
||
limitInt, err := strconv.Atoi(limit) | ||
if err != nil { | ||
limitInt = mediaLimitConst | ||
} | ||
items, total, err := community.GetArticlesByUid(c.TODO(), id, page, limitInt) | ||
if err != nil { | ||
log.Error("get article list error:", err) | ||
json { | ||
"code": 0, | ||
"err": err.Error(), | ||
"total": 0, | ||
} | ||
} | ||
json { | ||
"code": 200, | ||
"items": items, | ||
"total": total, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import ( | ||
gopaccountsdk "github.com/liuscraft/gop-casdoor-account-sdk" | ||
) | ||
|
||
token, err := Request.Cookie("token") | ||
if err != nil { | ||
json { | ||
"code": 500, | ||
} | ||
return | ||
} | ||
gac, err := gopaccountsdk.GetClient(token.Value) | ||
if err != nil { | ||
json { | ||
"code": 500, | ||
} | ||
return | ||
} | ||
qrData, ticket, err := gac.GetProviderWeChatQRCode("provider_wechat") | ||
if err != nil { | ||
json { | ||
"code": 500, | ||
} | ||
return | ||
} | ||
json { | ||
"data": qrData, | ||
"data2": ticket, | ||
"code": 200, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import ( | ||
c "context" | ||
"strconv" | ||
) | ||
|
||
format := param("format") | ||
uid := param("id") | ||
page := param("page") | ||
limit := param("limit") | ||
|
||
limitInt, err := strconv.Atoi(limit) | ||
if err != nil { | ||
limitInt = mediaLimitConst | ||
} | ||
pageInt, err := strconv.Atoi(page) | ||
if err != nil { | ||
json { | ||
"code": 400, | ||
"total": 0, | ||
"err": err.Error(), | ||
} | ||
} | ||
files, total, err := community.ListMediaByUserId(c.TODO(), uid, format, pageInt, limitInt) | ||
if err != nil { | ||
json { | ||
"code": 0, | ||
"total": total, | ||
"err": err.Error(), | ||
} | ||
} else { | ||
json { | ||
"code": 200, | ||
"total": total, | ||
"items": files, | ||
} | ||
} |
Oops, something went wrong.