Skip to content

Commit

Permalink
Merge branch 'dev' into fix/video-list
Browse files Browse the repository at this point in the history
  • Loading branch information
IRONICBo authored Feb 21, 2024
2 parents 0967cf5 + 8bcaa1d commit 6f16dad
Show file tree
Hide file tree
Showing 17 changed files with 1,569 additions and 1,852 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ go.work
# gop_autogen.go
dist/
node_modules/
.vscode/
97 changes: 60 additions & 37 deletions cmd/gopcomm/community_yap.gox
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/goplus/community/internal/core"
"github.com/goplus/community/translation"
_ "github.com/joho/godotenv/autoload"
gopaccountsdk "github.com/liuscraft/gop-casdoor-account-sdk"
"github.com/qiniu/x/xlog"
language "golang.org/x/text/language"
)
Expand Down Expand Up @@ -74,10 +75,10 @@ get "/p/:id", ctx => {
"Title": article.Title,
"Content": article.Content,
// "HtmlUrl": article.HtmlUrl,
"Tags": article.Tags,
"Cover": article.Cover,
"Mtime": article.Mtime.Format(layoutUS),
"Author": article.User,
"Tags": article.Tags,
"Cover": article.Cover,
"Mtime": article.Mtime.Format(layoutUS),
"Author": article.User,
// "User": article.User,
}
}
Expand Down Expand Up @@ -120,22 +121,43 @@ get "/user/:id", ctx => {
"UserId": user.Id,
}
}

get "/userEdit", ctx => {
var user *core.User
get "/userUnlink", ctx => {
pv := ctx.param("pv")
token, err := core.GetToken(ctx)
if err != nil {
http.Redirect(ctx.ResponseWriter, ctx.Request, "/login", http.StatusTemporaryRedirect)
return
}
switch pv {
case "Twitter":
case "Facebook":
case "Github":
case "WeChat":
default:
pv = ""
}
gac, err := gopaccountsdk.GetClient(token.Value)
if err == nil {
user, err = community.GetUser(token.Value)
if err != nil {
xLog.Error("get user error:", err)
}
gac.UnLink(pv)
}

http.Redirect(ctx.ResponseWriter, ctx.Request, "/userEdit", http.StatusTemporaryRedirect)
}
get "/userEdit", ctx => {
token, err := core.GetToken(ctx)
if err != nil {
http.Redirect(ctx.ResponseWriter, ctx.Request, "/error", http.StatusTemporaryRedirect)
}
gac, err := gopaccountsdk.GetClient(token.Value)
if err != nil {
http.Redirect(ctx.ResponseWriter, ctx.Request, "/error", http.StatusTemporaryRedirect)
}
appInfo, _ := community.GetApplicationInfo()
appInfoStr, _ := json.Marshal(*appInfo)
binds, _ := json.Marshal(gac.GetProviderBindStatus())
ctx.yap "user_edit", {
"User": user,
"User": gac.GetUserSimple(),
"Application": string(appInfoStr),
"Binds": string(binds),
}
}

Expand All @@ -149,7 +171,7 @@ get "/add", ctx => {
}
}
ctx.yap "edit", {
"User": user,
"User": user,
}
}

Expand Down Expand Up @@ -359,15 +381,15 @@ post "/commit", ctx => {
// get user id
token, err := core.GetToken(ctx)
if err != nil {
xLog.Info("token",err)
xLog.Info("token", err)
ctx.json {
"code": 0,
"err": "no token",
}
}
uid, err := community.ParseJwtToken(token.Value)
if err != nil {
xLog.Info("uid",err)
xLog.Info("uid", err)
ctx.json {
"code": 0,
"err": err.Error(),
Expand All @@ -379,11 +401,11 @@ post "/commit", ctx => {
ID: id,
Title: ctx.param("title"),
UId: uid,
Cover: ctx.param("cover"),
Cover: ctx.param("cover"),
Tags: ctx.param("tags"),
Abstract: ctx.param("abstract"),
},
Content: mdData,
Content: mdData,
TransContent: transData,
}
id, _ = community.PutArticle(todo, uid, article)
Expand Down Expand Up @@ -462,26 +484,26 @@ get "/getMediaUrl/:id", ctx => {
get "/getVideoAndSubtitle/:id", ctx => {
id := ctx.param("id")
fileKey, err := community.GetMediaUrl(todo, id)
m:=make(map[string]string,2)
format,err:=community.GetMediaType(todo,id)
if err!=nil {
ctx.json {
"code": 500,
"err": err.Error(),
}
m := make(map[string]string, 2)
format, err := community.GetMediaType(todo, id)
if err != nil {
ctx.json {
"code": 500,
"err": err.Error(),
}
}
if format == "video/mp4" {
subtitle,err:=community.GetVideoSubtitle(todo,id)
if err!=nil{
if err != nil {
ctx.json {
"code": 500,
"err": err.Error(),
}
}
return
}
m["subtitle"] = domain+subtitle
subtitle, err := community.GetVideoSubtitle(todo, id)
if err != nil {
if err != nil {
ctx.json {
"code": 500,
"err": err.Error(),
}
}
return
}
m["subtitle"] = domain + subtitle
}
htmlUrl := fmt.Sprintf("%s%s", domain, fileKey)
if err != nil {
Expand Down Expand Up @@ -551,7 +573,7 @@ get "/callback", ctx => {
origin_path := ctx.URL.Query().Get("origin_path")
unurl, err := url.QueryUnescape(origin_path)
if err != nil {
xLog.Info("Unurl error",err)
xLog.Info("Unurl error", err)
unurl = "/"
}

Expand All @@ -575,6 +597,7 @@ run(endpoint, func(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
defer func() {
if err := recover(); err != nil {
xLog.Error(err)
http.Redirect(w, r, "/failed", http.StatusFound)
}
}()
Expand Down
2 changes: 1 addition & 1 deletion cmd/gopcomm/gop_autogen.go
Original file line number Diff line number Diff line change
Expand Up @@ -662,4 +662,4 @@ func (this *community_yap) MainEntry() {
}
func main() {
yap.Gopt_App_Main(new(community_yap))
}
}
16 changes: 12 additions & 4 deletions cmd/gopcomm/yap/article_yap.html
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<link href="https://fonts.proxy.ustclug.org/css2?family=Noto+Sans+SC&display=swap" rel="stylesheet">

<!-- markdown -->
<link rel="stylesheet" href="/static/GoplusMarkdown/style.css">
<link rel="stylesheet" href="/static/GoplusMarkdown/style7.css">
<link rel="stylesheet" href="https://cdn.plyr.io/3.6.8/plyr.css" >
<script data-widgets="code" src="https://goplus.org/widgets/loader.js"></script>

Expand All @@ -51,7 +51,9 @@
<script src="https://cdn.plyr.io/3.6.8/plyr.js"></script>
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
<script data-widgets="code" src="https://goplus.org/widgets/loader.js"></script>
<script src="/static/GoplusMarkdown/GoplusMarkdown.umd.cjs"></script>
<script src="/static/GoplusMarkdown/GoplusMarkdown11.umd.cjs"></script>



<script type="importmap">
{ "imports": {
Expand Down Expand Up @@ -156,8 +158,9 @@
<!-- Tags & Title & Update Time -->
<header class="mb-4 not-format">
<!-- Tags -->
<div class="flex flex-row items-center">
<span v-for="(item, index) in tags.split(';')"
<!-- TODO: 分割为字符数组 -->
<div class="flex flex-row items-center" v-for="(item, index) in tags.split(';')">
<span
class="mr-3 inline-flex items-center bg-blue-100 text-blue-800 text-xs font-medium px-2.5 py-0.5 rounded-full dark:bg-green-900 dark:text-green-300">
<span class="w-2 h-2 me-1 bg-blue-500 rounded-full"></span>
${ item }
Expand Down Expand Up @@ -396,6 +399,11 @@ <h1 class="my-4 text-4xl font-extrabold leading-tight text-gray-900">
},
components: {
MarkdownViewer: window.GoplusMarkdown.MarkdownViewer
},
mounted() {
const p = new Plyr('video', {captions: {active: true}});
var htmlStr = document.documentElement.outerHTML; // 获取完整的HTML结构
console.log("===============", htmlStr)
}
});

Expand Down
Loading

0 comments on commit 6f16dad

Please sign in to comment.