From 91a4560af3c5b9315d7285765f693b5fe5dad6bb Mon Sep 17 00:00:00 2001
From: 6543 <6543@obermui.de>
Date: Fri, 8 Nov 2019 22:42:14 +0100
Subject: [PATCH 01/17] add [ui] Reactions
---
custom/conf/app.ini.sample | 2 ++
modules/setting/setting.go | 2 ++
2 files changed, 4 insertions(+)
diff --git a/custom/conf/app.ini.sample b/custom/conf/app.ini.sample
index aa580e6a55b65..0b127e28c6da9 100644
--- a/custom/conf/app.ini.sample
+++ b/custom/conf/app.ini.sample
@@ -149,6 +149,8 @@ SHOW_USER_EMAIL = true
DEFAULT_THEME = gitea
; All available themes. Allow users select personalized themes regardless of the value of `DEFAULT_THEME`.
THEMES = gitea,arc-green
+; All available reactions. Allow users react with different emoji's
+REACTIONS = +1, -1, laugh, confused, heart, hooray, eyes
; Whether the full name of the users should be shown where possible. If the full name isn't set, the username will be used.
DEFAULT_SHOW_FULL_NAME = false
; Whether to search within description at repository search on explore page.
diff --git a/modules/setting/setting.go b/modules/setting/setting.go
index f2112f59f1c1f..b32dc8e526ef8 100644
--- a/modules/setting/setting.go
+++ b/modules/setting/setting.go
@@ -169,6 +169,7 @@ var (
DefaultShowFullName bool
DefaultTheme string
Themes []string
+ Reactions []string
SearchRepoDescription bool
UseServiceWorker bool
@@ -198,6 +199,7 @@ var (
MaxDisplayFileSize: 8388608,
DefaultTheme: `gitea`,
Themes: []string{`gitea`, `arc-green`},
+ Reactions: []string{`+1`, `-1`, `laugh`, `confused`, `heart`, `hooray`, `eyes`},
Admin: struct {
UserPagingNum int
RepoPagingNum int
From 845edfd9d1fbf2d5174a8b09926ee6428d36090d Mon Sep 17 00:00:00 2001
From: 6543 <6543@obermui.de>
Date: Sat, 9 Nov 2019 18:51:21 +0100
Subject: [PATCH 02/17] move contend check from form to go functions
---
modules/auth/repo_form.go | 2 +-
routers/repo/issue.go | 12 ++++++++++++
2 files changed, 13 insertions(+), 1 deletion(-)
diff --git a/modules/auth/repo_form.go b/modules/auth/repo_form.go
index 1c873f2ea3669..e3f6410c374b7 100644
--- a/modules/auth/repo_form.go
+++ b/modules/auth/repo_form.go
@@ -347,7 +347,7 @@ func (f *CreateCommentForm) Validate(ctx *macaron.Context, errs binding.Errors)
// ReactionForm form for adding and removing reaction
type ReactionForm struct {
- Content string `binding:"Required;In(+1,-1,laugh,confused,heart,hooray)"`
+ Content string `binding:"Required"`
}
// Validate validates the fields
diff --git a/routers/repo/issue.go b/routers/repo/issue.go
index 739370da6927c..6a8dabc30fe13 100644
--- a/routers/repo/issue.go
+++ b/routers/repo/issue.go
@@ -1445,6 +1445,12 @@ func ChangeIssueReaction(ctx *context.Context, form auth.ReactionForm) {
return
}
+ if !util.IsStringInSlice(form.Content, setting.UI.Reactions) {
+ log.Error("ChangeIssueReaction: " + form.Content + " is no allowed reaction")
+ ctx.Error(403)
+ return
+ }
+
switch ctx.Params(":action") {
case "react":
reaction, err := models.CreateIssueReaction(ctx.User, issue, form.Content)
@@ -1540,6 +1546,12 @@ func ChangeCommentReaction(ctx *context.Context, form auth.ReactionForm) {
return
}
+ if !util.IsStringInSlice(form.Content, setting.UI.Reactions) {
+ log.Error("ChangeIssueReaction: " + form.Content + " is no allowed reaction")
+ ctx.Error(403)
+ return
+ }
+
switch ctx.Params(":action") {
case "react":
reaction, err := models.CreateCommentReaction(ctx.User, comment.Issue, comment, form.Content)
From 67ccdd5f921271cd7225154c4de0f5f92737993e Mon Sep 17 00:00:00 2001
From: 6543 <6543@obermui.de>
Date: Sat, 9 Nov 2019 19:12:02 +0100
Subject: [PATCH 03/17] use else if
---
templates/repo/issue/view_content/reactions.tmpl | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/templates/repo/issue/view_content/reactions.tmpl b/templates/repo/issue/view_content/reactions.tmpl
index f4810f48493c8..fce820f87e3b3 100644
--- a/templates/repo/issue/view_content/reactions.tmpl
+++ b/templates/repo/issue/view_content/reactions.tmpl
@@ -2,12 +2,10 @@
{{if eq $key "hooray"}}
:tada:
+ {{else if eq $key "laugh"}}
+ :laughing:
{{else}}
- {{if eq $key "laugh"}}
- :laughing:
- {{else}}
- :{{$key}}:
- {{end}}
+ :{{$key}}:
{{end}}
{{len $value}}
From cdbd3096d4e69b7bd6207a850b4e0dc380b64c57 Mon Sep 17 00:00:00 2001
From: 6543 <6543@obermui.de>
Date: Sat, 9 Nov 2019 20:11:46 +0100
Subject: [PATCH 04/17] check if reaction is allowed only on react (so previous
custom reaction can be still removed)
---
routers/repo/issue.go | 24 ++++++++++++------------
1 file changed, 12 insertions(+), 12 deletions(-)
diff --git a/routers/repo/issue.go b/routers/repo/issue.go
index 6a8dabc30fe13..d8d278befb06d 100644
--- a/routers/repo/issue.go
+++ b/routers/repo/issue.go
@@ -1445,14 +1445,14 @@ func ChangeIssueReaction(ctx *context.Context, form auth.ReactionForm) {
return
}
- if !util.IsStringInSlice(form.Content, setting.UI.Reactions) {
- log.Error("ChangeIssueReaction: " + form.Content + " is no allowed reaction")
- ctx.Error(403)
- return
- }
-
switch ctx.Params(":action") {
case "react":
+ if !util.IsStringInSlice(form.Content, setting.UI.Reactions) {
+ log.Error("ChangeIssueReaction: " + form.Content + " is no allowed reaction")
+ ctx.Error(403)
+ return
+ }
+
reaction, err := models.CreateIssueReaction(ctx.User, issue, form.Content)
if err != nil {
log.Info("CreateIssueReaction: %s", err)
@@ -1546,14 +1546,14 @@ func ChangeCommentReaction(ctx *context.Context, form auth.ReactionForm) {
return
}
- if !util.IsStringInSlice(form.Content, setting.UI.Reactions) {
- log.Error("ChangeIssueReaction: " + form.Content + " is no allowed reaction")
- ctx.Error(403)
- return
- }
-
switch ctx.Params(":action") {
case "react":
+ if !util.IsStringInSlice(form.Content, setting.UI.Reactions) {
+ log.Error("ChangeIssueReaction: " + form.Content + " is no allowed reaction")
+ ctx.Error(403)
+ return
+ }
+
reaction, err := models.CreateCommentReaction(ctx.User, comment.Issue, comment, form.Content)
if err != nil {
log.Info("CreateCommentReaction: %s", err)
From fc5915b365afe61ab726304a7fd73fcba0f420f1 Mon Sep 17 00:00:00 2001
From: 6543 <6543@obermui.de>
Date: Sat, 9 Nov 2019 20:12:33 +0100
Subject: [PATCH 05/17] use $.AllowedReactions in templates
---
routers/repo/issue.go | 1 +
templates/repo/issue/view_content.tmpl | 4 ++--
.../repo/issue/view_content/add_reaction.tmpl | 15 +++++++++------
templates/repo/issue/view_content/comments.tmpl | 4 ++--
templates/repo/issue/view_content/reactions.tmpl | 2 +-
5 files changed, 15 insertions(+), 11 deletions(-)
diff --git a/routers/repo/issue.go b/routers/repo/issue.go
index d8d278befb06d..3388bc424b0e7 100644
--- a/routers/repo/issue.go
+++ b/routers/repo/issue.go
@@ -673,6 +673,7 @@ func ViewIssue(ctx *context.Context) {
}
}
ctx.Data["IssueWatch"] = iw
+ ctx.Data["AllowedReactions"] = setting.UI.Reactions
issue.RenderedContent = string(markdown.Render([]byte(issue.Content), ctx.Repo.RepoLink,
ctx.Repo.Repository.ComposeMetas()))
diff --git a/templates/repo/issue/view_content.tmpl b/templates/repo/issue/view_content.tmpl
index 5b5d7c45d75dc..8490841f9740c 100644
--- a/templates/repo/issue/view_content.tmpl
+++ b/templates/repo/issue/view_content.tmpl
@@ -28,7 +28,7 @@
{{end}}
{{if not $.Repository.IsArchived}}
- {{template "repo/issue/view_content/add_reaction" Dict "ctx" $ "ActionURL" (Printf "%s/issues/%d/reactions" $.RepoLink .Issue.Index) }}
+ {{template "repo/issue/view_content/add_reaction" Dict "ctx" $ "ActionURL" (Printf "%s/issues/%d/reactions" $.RepoLink .Issue.Index) "AllowedReactions" $.AllowedReactions}}
{{template "repo/issue/view_content/context_menu" Dict "ctx" $ "item" .Issue "delete" false "diff" false }}
{{end}}
@@ -47,7 +47,7 @@
{{$reactions := .Issue.Reactions.GroupByType}}
{{if $reactions}}
- {{template "repo/issue/view_content/reactions" Dict "ctx" $ "ActionURL" (Printf "%s/issues/%d/reactions" $.RepoLink .Issue.Index) "Reactions" $reactions }}
+ {{template "repo/issue/view_content/reactions" Dict "ctx" $ "ActionURL" (Printf "%s/issues/%d/reactions" $.RepoLink .Issue.Index) "Reactions" $reactions "AllowedReactions" $.AllowedReactions}}
{{end}}
{{if .Issue.Attachments}}
diff --git a/templates/repo/issue/view_content/add_reaction.tmpl b/templates/repo/issue/view_content/add_reaction.tmpl
index 626db5c261526..3bd64ff786caf 100644
--- a/templates/repo/issue/view_content/add_reaction.tmpl
+++ b/templates/repo/issue/view_content/add_reaction.tmpl
@@ -7,12 +7,15 @@
{{end}}
diff --git a/templates/repo/issue/view_content/comments.tmpl b/templates/repo/issue/view_content/comments.tmpl
index 1ea626ab84963..49d2e9bc5f71b 100644
--- a/templates/repo/issue/view_content/comments.tmpl
+++ b/templates/repo/issue/view_content/comments.tmpl
@@ -36,7 +36,7 @@
{{end}}
{{end}}
- {{template "repo/issue/view_content/add_reaction" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.RepoLink .ID) }}
+ {{template "repo/issue/view_content/add_reaction" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.RepoLink .ID) "AllowedReactions" $.AllowedReactions}}
{{template "repo/issue/view_content/context_menu" Dict "ctx" $ "item" . "delete" true "diff" false }}
{{end}}
@@ -55,7 +55,7 @@
{{$reactions := .Reactions.GroupByType}}
{{if $reactions}}
- {{template "repo/issue/view_content/reactions" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.RepoLink .ID) "Reactions" $reactions }}
+ {{template "repo/issue/view_content/reactions" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.RepoLink .ID) "Reactions" $reactions "AllowedReactions" $.AllowedReactions}}
{{end}}
{{if .Attachments}}
diff --git a/templates/repo/issue/view_content/reactions.tmpl b/templates/repo/issue/view_content/reactions.tmpl
index fce820f87e3b3..6225764bebc3f 100644
--- a/templates/repo/issue/view_content/reactions.tmpl
+++ b/templates/repo/issue/view_content/reactions.tmpl
@@ -10,4 +10,4 @@
{{len $value}}
{{end}}
-{{template "repo/issue/view_content/add_reaction" Dict "ctx" $.ctx "ActionURL" .ActionURL }}
+{{template "repo/issue/view_content/add_reaction" Dict "ctx" $.ctx "ActionURL" .ActionURL "AllowedReactions" $.AllowedReactions}}
From ca0e1242c5884e6dc9bdaf1c85eedb7d8bcb68f4 Mon Sep 17 00:00:00 2001
From: 6543 <6543@obermui.de>
Date: Sun, 10 Nov 2019 02:14:50 +0100
Subject: [PATCH 06/17] use ctx.Flash.Error
---
options/locale/locale_en-US.ini | 1 +
routers/repo/issue.go | 3 +--
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini
index be4522014f375..23e477c38d5a6 100644
--- a/options/locale/locale_en-US.ini
+++ b/options/locale/locale_en-US.ini
@@ -406,6 +406,7 @@ continue = Continue
cancel = Cancel
language = Language
ui = Theme
+forbidden_reaction = Reaction '%s' is no allowed!
lookup_avatar_by_mail = Look Up Avatar by Email Address
federated_avatar_lookup = Federated Avatar Lookup
diff --git a/routers/repo/issue.go b/routers/repo/issue.go
index 3388bc424b0e7..20a078257338d 100644
--- a/routers/repo/issue.go
+++ b/routers/repo/issue.go
@@ -1550,8 +1550,7 @@ func ChangeCommentReaction(ctx *context.Context, form auth.ReactionForm) {
switch ctx.Params(":action") {
case "react":
if !util.IsStringInSlice(form.Content, setting.UI.Reactions) {
- log.Error("ChangeIssueReaction: " + form.Content + " is no allowed reaction")
- ctx.Error(403)
+ ctx.Flash.Error(ctx.Tr("settings.forbidden_reaction", form.Content))
return
}
From 1973706556d658474b3c642a6726bf47ca3a47b0 Mon Sep 17 00:00:00 2001
From: 6543 <6543@obermui.de>
Date: Sun, 10 Nov 2019 02:23:39 +0100
Subject: [PATCH 07/17] use it there too
---
routers/repo/issue.go | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/routers/repo/issue.go b/routers/repo/issue.go
index 20a078257338d..ff42af7dd9e3d 100644
--- a/routers/repo/issue.go
+++ b/routers/repo/issue.go
@@ -1449,8 +1449,7 @@ func ChangeIssueReaction(ctx *context.Context, form auth.ReactionForm) {
switch ctx.Params(":action") {
case "react":
if !util.IsStringInSlice(form.Content, setting.UI.Reactions) {
- log.Error("ChangeIssueReaction: " + form.Content + " is no allowed reaction")
- ctx.Error(403)
+ ctx.Flash.Error(ctx.Tr("settings.forbidden_reaction", form.Content))
return
}
From adc83d6aeb08501385df8fe09ab6d6727d963898 Mon Sep 17 00:00:00 2001
From: 6543 <6543@obermui.de>
Date: Sun, 10 Nov 2019 09:45:54 +0100
Subject: [PATCH 08/17] add redirection
---
routers/repo/issue.go | 2 ++
1 file changed, 2 insertions(+)
diff --git a/routers/repo/issue.go b/routers/repo/issue.go
index ff42af7dd9e3d..ca6d4f4ba9dd8 100644
--- a/routers/repo/issue.go
+++ b/routers/repo/issue.go
@@ -1450,6 +1450,7 @@ func ChangeIssueReaction(ctx *context.Context, form auth.ReactionForm) {
case "react":
if !util.IsStringInSlice(form.Content, setting.UI.Reactions) {
ctx.Flash.Error(ctx.Tr("settings.forbidden_reaction", form.Content))
+ ctx.Redirect(ctx.Link)
return
}
@@ -1550,6 +1551,7 @@ func ChangeCommentReaction(ctx *context.Context, form auth.ReactionForm) {
case "react":
if !util.IsStringInSlice(form.Content, setting.UI.Reactions) {
ctx.Flash.Error(ctx.Tr("settings.forbidden_reaction", form.Content))
+ ctx.Redirect(ctx.Link)
return
}
From e40a3d2681c3970f48c354eebc25545861b95fd7 Mon Sep 17 00:00:00 2001
From: 6543 <6543@obermui.de>
Date: Wed, 13 Nov 2019 07:36:54 +0100
Subject: [PATCH 09/17] back to server error because a wrong reaction is a
template issue ...
---
options/locale/locale_en-US.ini | 1 -
routers/repo/issue.go | 6 ++----
2 files changed, 2 insertions(+), 5 deletions(-)
diff --git a/options/locale/locale_en-US.ini b/options/locale/locale_en-US.ini
index 23e477c38d5a6..be4522014f375 100644
--- a/options/locale/locale_en-US.ini
+++ b/options/locale/locale_en-US.ini
@@ -406,7 +406,6 @@ continue = Continue
cancel = Cancel
language = Language
ui = Theme
-forbidden_reaction = Reaction '%s' is no allowed!
lookup_avatar_by_mail = Look Up Avatar by Email Address
federated_avatar_lookup = Federated Avatar Lookup
diff --git a/routers/repo/issue.go b/routers/repo/issue.go
index ca6d4f4ba9dd8..0f33e7e585b21 100644
--- a/routers/repo/issue.go
+++ b/routers/repo/issue.go
@@ -1449,8 +1449,7 @@ func ChangeIssueReaction(ctx *context.Context, form auth.ReactionForm) {
switch ctx.Params(":action") {
case "react":
if !util.IsStringInSlice(form.Content, setting.UI.Reactions) {
- ctx.Flash.Error(ctx.Tr("settings.forbidden_reaction", form.Content))
- ctx.Redirect(ctx.Link)
+ log.Error("ChangeIssueReaction: Reaction '%s' is no allowed reaction", form.Content)
return
}
@@ -1550,8 +1549,7 @@ func ChangeCommentReaction(ctx *context.Context, form auth.ReactionForm) {
switch ctx.Params(":action") {
case "react":
if !util.IsStringInSlice(form.Content, setting.UI.Reactions) {
- ctx.Flash.Error(ctx.Tr("settings.forbidden_reaction", form.Content))
- ctx.Redirect(ctx.Link)
+ log.Error("ChangeIssueReaction: Reaction '%s' is no allowed reaction", form.Content)
return
}
From 629e0c739ba5db35214dd08e70df46f9d36b87ee Mon Sep 17 00:00:00 2001
From: 6543 <6543@obermui.de>
Date: Wed, 13 Nov 2019 09:30:51 +0100
Subject: [PATCH 10/17] add emoji list link
---
custom/conf/app.ini.sample | 1 +
1 file changed, 1 insertion(+)
diff --git a/custom/conf/app.ini.sample b/custom/conf/app.ini.sample
index 0b127e28c6da9..8d16d602cf47d 100644
--- a/custom/conf/app.ini.sample
+++ b/custom/conf/app.ini.sample
@@ -150,6 +150,7 @@ DEFAULT_THEME = gitea
; All available themes. Allow users select personalized themes regardless of the value of `DEFAULT_THEME`.
THEMES = gitea,arc-green
; All available reactions. Allow users react with different emoji's
+: For the whole list look at https://gitea.com/gitea/gitea.com/issues/8
REACTIONS = +1, -1, laugh, confused, heart, hooray, eyes
; Whether the full name of the users should be shown where possible. If the full name isn't set, the username will be used.
DEFAULT_SHOW_FULL_NAME = false
From 6ee03e2666403af8d3ee2ef54cdb2cbda739c1cc Mon Sep 17 00:00:00 2001
From: 6543 <6543@obermui.de>
Date: Wed, 13 Nov 2019 16:33:58 +0100
Subject: [PATCH 11/17] add docs entry
---
docs/content/doc/advanced/customizing-gitea.en-us.md | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/docs/content/doc/advanced/customizing-gitea.en-us.md b/docs/content/doc/advanced/customizing-gitea.en-us.md
index 362f4fb259209..7c66991f69cc8 100644
--- a/docs/content/doc/advanced/customizing-gitea.en-us.md
+++ b/docs/content/doc/advanced/customizing-gitea.en-us.md
@@ -161,6 +161,15 @@ Locales may change between versions, so keeping track of your customized locales
To add a custom Readme, add a markdown formatted file (without an `.md` extension) to `custom/options/readme`
+### Reactions
+
+To change reaction emoji's you can set allowed reactions at app.ini
+```
+[ui]
+REACTIONS = +1, -1, laugh, confused, heart, hooray, eyes
+```
+A full list of supported emoji's is at [emoji list](https://gitea.com/gitea/gitea.com/issues/8)
+
## Customizing the look of Gitea
As of version 1.6.0 Gitea has built-in themes. The two built-in themes are, the default theme `gitea`, and a dark theme `arc-green`. To change the look of your Gitea install change the value of `DEFAULT_THEME` in the [ui](https://docs.gitea.io/en-us/config-cheat-sheet/#ui-ui) section of `app.ini` to another one of the available options.
From 6c3cbde7d8daf676fd5f3fd3a83383261995ca99 Mon Sep 17 00:00:00 2001
From: 6543 <6543@obermui.de>
Date: Wed, 13 Nov 2019 18:08:35 +0100
Subject: [PATCH 12/17] small wording nit suggestions from @jolheiser - thx
---
routers/repo/issue.go | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/routers/repo/issue.go b/routers/repo/issue.go
index 0f33e7e585b21..26c34a3916095 100644
--- a/routers/repo/issue.go
+++ b/routers/repo/issue.go
@@ -1449,7 +1449,7 @@ func ChangeIssueReaction(ctx *context.Context, form auth.ReactionForm) {
switch ctx.Params(":action") {
case "react":
if !util.IsStringInSlice(form.Content, setting.UI.Reactions) {
- log.Error("ChangeIssueReaction: Reaction '%s' is no allowed reaction", form.Content)
+ log.Error("ChangeIssueReaction: '%s' is not an allowed reaction", form.Content)
return
}
@@ -1549,7 +1549,7 @@ func ChangeCommentReaction(ctx *context.Context, form auth.ReactionForm) {
switch ctx.Params(":action") {
case "react":
if !util.IsStringInSlice(form.Content, setting.UI.Reactions) {
- log.Error("ChangeIssueReaction: Reaction '%s' is no allowed reaction", form.Content)
+ log.Error("ChangeIssueReaction: '%s' is not an allowed reaction", form.Content)
return
}
From 3299075c232e11f210dac5014e25ffdf2207cc27 Mon Sep 17 00:00:00 2001
From: 6543 <6543@obermui.de>
Date: Thu, 21 Nov 2019 11:26:14 +0100
Subject: [PATCH 13/17] same reactions as github
---
custom/conf/app.ini.sample | 2 +-
modules/setting/setting.go | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/custom/conf/app.ini.sample b/custom/conf/app.ini.sample
index 8d16d602cf47d..8d11cfc293e14 100644
--- a/custom/conf/app.ini.sample
+++ b/custom/conf/app.ini.sample
@@ -151,7 +151,7 @@ DEFAULT_THEME = gitea
THEMES = gitea,arc-green
; All available reactions. Allow users react with different emoji's
: For the whole list look at https://gitea.com/gitea/gitea.com/issues/8
-REACTIONS = +1, -1, laugh, confused, heart, hooray, eyes
+REACTIONS = +1, -1, laugh, hooray, confused, heart, rocket, eyes
; Whether the full name of the users should be shown where possible. If the full name isn't set, the username will be used.
DEFAULT_SHOW_FULL_NAME = false
; Whether to search within description at repository search on explore page.
diff --git a/modules/setting/setting.go b/modules/setting/setting.go
index b32dc8e526ef8..a97ab94677e53 100644
--- a/modules/setting/setting.go
+++ b/modules/setting/setting.go
@@ -199,7 +199,7 @@ var (
MaxDisplayFileSize: 8388608,
DefaultTheme: `gitea`,
Themes: []string{`gitea`, `arc-green`},
- Reactions: []string{`+1`, `-1`, `laugh`, `confused`, `heart`, `hooray`, `eyes`},
+ Reactions: []string{`+1`, `-1`, `laugh`, `hooray`, `confused`, `heart`, `rocket`, `eyes`},
Admin: struct {
UserPagingNum int
RepoPagingNum int
From cad5add765895ac35f4c79325826e2b6f52d317f Mon Sep 17 00:00:00 2001
From: 6543 <6543@obermui.de>
Date: Thu, 21 Nov 2019 12:07:49 +0100
Subject: [PATCH 14/17] fix PR reactions
---
routers/repo/pull.go | 1 +
templates/repo/diff/comments.tmpl | 2 +-
templates/repo/issue/view_content/reactions.tmpl | 4 +++-
3 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/routers/repo/pull.go b/routers/repo/pull.go
index 0ff077b462d3f..78406de8acdc8 100644
--- a/routers/repo/pull.go
+++ b/routers/repo/pull.go
@@ -422,6 +422,7 @@ func PrepareViewPullInfo(ctx *context.Context, issue *models.Issue) *git.Compare
ctx.Data["NumCommits"] = compareInfo.Commits.Len()
ctx.Data["NumFiles"] = compareInfo.NumFiles
+ ctx.Data["AllowedReactions"] = setting.UI.Reactions
return compareInfo
}
diff --git a/templates/repo/diff/comments.tmpl b/templates/repo/diff/comments.tmpl
index cc62f19a327b9..d86cf4077d6c3 100644
--- a/templates/repo/diff/comments.tmpl
+++ b/templates/repo/diff/comments.tmpl
@@ -38,7 +38,7 @@
{{$reactions := .Reactions.GroupByType}}
{{if $reactions}}
- {{template "repo/issue/view_content/reactions" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.root.RepoLink .ID) "Reactions" $reactions }}
+ {{template "repo/issue/view_content/reactions" Dict "ctx" $ "ActionURL" (Printf "%s/comments/%d/reactions" $.root.RepoLink .ID) "Reactions" $reactions "AllowedReactions" $.AllowedReactions }}
{{end}}
diff --git a/templates/repo/issue/view_content/reactions.tmpl b/templates/repo/issue/view_content/reactions.tmpl
index 6225764bebc3f..4837370d22578 100644
--- a/templates/repo/issue/view_content/reactions.tmpl
+++ b/templates/repo/issue/view_content/reactions.tmpl
@@ -10,4 +10,6 @@
{{len $value}}
{{end}}
-{{template "repo/issue/view_content/add_reaction" Dict "ctx" $.ctx "ActionURL" .ActionURL "AllowedReactions" $.AllowedReactions}}
+{{if $.AllowedReactions}}
+ {{template "repo/issue/view_content/add_reaction" Dict "ctx" $.ctx "ActionURL" .ActionURL "AllowedReactions" $.AllowedReactions}}
+{{end}}
From 0e406a7cece355bcf7b31e9b458b1e8fb72b6581 Mon Sep 17 00:00:00 2001
From: 6543 <6543@obermui.de>
Date: Fri, 29 Nov 2019 00:09:57 +0100
Subject: [PATCH 15/17] handle error so template JS could check
---
routers/repo/issue.go | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/routers/repo/issue.go b/routers/repo/issue.go
index 26c34a3916095..a2f4022a7325f 100644
--- a/routers/repo/issue.go
+++ b/routers/repo/issue.go
@@ -1449,7 +1449,8 @@ func ChangeIssueReaction(ctx *context.Context, form auth.ReactionForm) {
switch ctx.Params(":action") {
case "react":
if !util.IsStringInSlice(form.Content, setting.UI.Reactions) {
- log.Error("ChangeIssueReaction: '%s' is not an allowed reaction", form.Content)
+ err := fmt.Errorf("ChangeIssueReaction: '%s' is not an allowed reaction", form.Content)
+ ctx.ServerError(err.Error(), err)
return
}
@@ -1549,7 +1550,8 @@ func ChangeCommentReaction(ctx *context.Context, form auth.ReactionForm) {
switch ctx.Params(":action") {
case "react":
if !util.IsStringInSlice(form.Content, setting.UI.Reactions) {
- log.Error("ChangeIssueReaction: '%s' is not an allowed reaction", form.Content)
+ err := fmt.Errorf("ChangeIssueReaction: '%s' is not an allowed reaction", form.Content)
+ ctx.ServerError(err.Error(), err)
return
}
From 1171bac6879b235dec66a23504e4ebe606eb34ee Mon Sep 17 00:00:00 2001
From: 6543 <6543@obermui.de>
Date: Fri, 29 Nov 2019 01:20:22 +0100
Subject: [PATCH 16/17] Add Integrations Test
---
integrations/issue_test.go | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/integrations/issue_test.go b/integrations/issue_test.go
index 5a4b75b7510e0..d46e35a946a5c 100644
--- a/integrations/issue_test.go
+++ b/integrations/issue_test.go
@@ -194,6 +194,32 @@ func TestIssueCommentClose(t *testing.T) {
assert.Equal(t, "Description", val)
}
+func TestIssueReaction(t *testing.T) {
+ defer prepareTestEnv(t)()
+ session := loginUser(t, "user2")
+ issueURL := testNewIssue(t, session, "user2", "repo1", "Title", "Description")
+
+ req := NewRequest(t, "GET", issueURL)
+ resp := session.MakeRequest(t, req, http.StatusOK)
+ htmlDoc := NewHTMLParser(t, resp.Body)
+
+ req = NewRequestWithValues(t, "POST", path.Join(issueURL, "/reactions/react"), map[string]string{
+ "_csrf": htmlDoc.GetCSRF(),
+ "content": "8ball",
+ })
+ session.MakeRequest(t, req, http.StatusInternalServerError)
+ req = NewRequestWithValues(t, "POST", path.Join(issueURL, "/reactions/react"), map[string]string{
+ "_csrf": htmlDoc.GetCSRF(),
+ "content": "eyes",
+ })
+ session.MakeRequest(t, req, http.StatusOK)
+ req = NewRequestWithValues(t, "POST", path.Join(issueURL, "/reactions/unreact"), map[string]string{
+ "_csrf": htmlDoc.GetCSRF(),
+ "content": "eyes",
+ })
+ session.MakeRequest(t, req, http.StatusOK)
+}
+
func TestIssueCrossReference(t *testing.T) {
defer prepareTestEnv(t)()
From 45c2e8a280428e00b0cf8f0bced69cc37d9fd671 Mon Sep 17 00:00:00 2001
From: 6543 <6543@obermui.de>
Date: Sat, 30 Nov 2019 18:29:04 +0100
Subject: [PATCH 17/17] add REACTIONS setting to cheat-sheet doc page
---
docs/content/doc/advanced/config-cheat-sheet.en-us.md | 1 +
1 file changed, 1 insertion(+)
diff --git a/docs/content/doc/advanced/config-cheat-sheet.en-us.md b/docs/content/doc/advanced/config-cheat-sheet.en-us.md
index 9fdcd2c82bbdf..4fc8511b8c62c 100644
--- a/docs/content/doc/advanced/config-cheat-sheet.en-us.md
+++ b/docs/content/doc/advanced/config-cheat-sheet.en-us.md
@@ -118,6 +118,7 @@ Values containing `#` or `;` must be quoted using `` ` `` or `"""`.
- `DEFAULT_THEME`: **gitea**: \[gitea, arc-green\]: Set the default theme for the Gitea install.
- `THEMES`: **gitea,arc-green**: All available themes. Allow users select personalized themes
regardless of the value of `DEFAULT_THEME`.
+- `REACTIONS`: All available reactions. Allow users react with different emoji's.
- `DEFAULT_SHOW_FULL_NAME`: **false**: Whether the full name of the users should be shown where possible. If the full name isn't set, the username will be used.
- `SEARCH_REPO_DESCRIPTION`: **true**: Whether to search within description at repository search on explore page.
- `USE_SERVICE_WORKER`: **true**: Whether to enable a Service Worker to cache frontend assets.