summaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorLauris BH <lauris@nix.lv>2017-12-04 01:14:26 +0200
committerGitHub <noreply@github.com>2017-12-04 01:14:26 +0200
commit5dc37b187c8b839a15ff73758799f218ddeb3bc9 (patch)
treeb63e5ca72c7b9e72c79408ace82dfcba992b5793 /modules
parente59adcde655aac0e8afd3249407c9a0a2b1b1d6b (diff)
downloadgitea-5dc37b187c8b839a15ff73758799f218ddeb3bc9.tar.gz
gitea-5dc37b187c8b839a15ff73758799f218ddeb3bc9.zip
Add reactions to issues/PR and comments (#2856)
Diffstat (limited to 'modules')
-rw-r--r--modules/auth/repo_form.go10
-rw-r--r--modules/context/context.go2
-rw-r--r--modules/setting/setting.go2
-rw-r--r--modules/templates/helper.go16
4 files changed, 29 insertions, 1 deletions
diff --git a/modules/auth/repo_form.go b/modules/auth/repo_form.go
index f066fc630f..221f7221a4 100644
--- a/modules/auth/repo_form.go
+++ b/modules/auth/repo_form.go
@@ -268,6 +268,16 @@ func (f *CreateCommentForm) Validate(ctx *macaron.Context, errs binding.Errors)
return validate(errs, ctx.Data, f, ctx.Locale)
}
+// ReactionForm form for adding and removing reaction
+type ReactionForm struct {
+ Content string `binding:"Required;In(+1,-1,laugh,confused,heart,hooray)"`
+}
+
+// Validate validates the fields
+func (f *ReactionForm) Validate(ctx *macaron.Context, errs binding.Errors) binding.Errors {
+ return validate(errs, ctx.Data, f, ctx.Locale)
+}
+
// _____ .__.__ __
// / \ |__| | ____ _______/ |_ ____ ____ ____
// / \ / \| | | _/ __ \ / ___/\ __\/ _ \ / \_/ __ \
diff --git a/modules/context/context.go b/modules/context/context.go
index 10a84cd9b1..d050d3a938 100644
--- a/modules/context/context.go
+++ b/modules/context/context.go
@@ -211,7 +211,7 @@ func Contexter() macaron.Handler {
ctx.Data["SignedUserName"] = ctx.User.Name
ctx.Data["IsAdmin"] = ctx.User.IsAdmin
} else {
- ctx.Data["SignedUserID"] = 0
+ ctx.Data["SignedUserID"] = int64(0)
ctx.Data["SignedUserName"] = ""
}
diff --git a/modules/setting/setting.go b/modules/setting/setting.go
index f8da952413..1eedfc1c93 100644
--- a/modules/setting/setting.go
+++ b/modules/setting/setting.go
@@ -256,6 +256,7 @@ var (
IssuePagingNum int
RepoSearchPagingNum int
FeedMaxCommitNum int
+ ReactionMaxUserNum int
ThemeColorMetaTag string
MaxDisplayFileSize int64
ShowUserEmail bool
@@ -279,6 +280,7 @@ var (
IssuePagingNum: 10,
RepoSearchPagingNum: 10,
FeedMaxCommitNum: 5,
+ ReactionMaxUserNum: 10,
ThemeColorMetaTag: `#6cc644`,
MaxDisplayFileSize: 8388608,
Admin: struct {
diff --git a/modules/templates/helper.go b/modules/templates/helper.go
index 42e465aeaa..c8b872d9f5 100644
--- a/modules/templates/helper.go
+++ b/modules/templates/helper.go
@@ -8,6 +8,7 @@ import (
"bytes"
"container/list"
"encoding/json"
+ "errors"
"fmt"
"html/template"
"mime"
@@ -162,6 +163,21 @@ func NewFuncMap() []template.FuncMap {
return setting.DisableGitHooks
},
"TrN": TrN,
+ "Dict": func(values ...interface{}) (map[string]interface{}, error) {
+ if len(values)%2 != 0 {
+ return nil, errors.New("invalid dict call")
+ }
+ dict := make(map[string]interface{}, len(values)/2)
+ for i := 0; i < len(values); i += 2 {
+ key, ok := values[i].(string)
+ if !ok {
+ return nil, errors.New("dict keys must be strings")
+ }
+ dict[key] = values[i+1]
+ }
+ return dict, nil
+ },
+ "Printf": fmt.Sprintf,
}}
}