add support of markdown in comment create and edit
This commit is contained in:
@@ -5,6 +5,7 @@ Remark42 is a self-hosted, lightweight, and simple (yet functional) comment engi
|
||||
- Social login via Google, Facebook and Github
|
||||
- Multi-level nested comments with both tree and plain presentations
|
||||
- Import from disqus
|
||||
- Markdown support
|
||||
- Moderator can remove comments and block users
|
||||
- Voting and pinning system
|
||||
- Sortable comments
|
||||
|
||||
@@ -23,6 +23,7 @@ import (
|
||||
"github.com/umputun/remark/app/rest/common"
|
||||
"github.com/umputun/remark/app/rest/format"
|
||||
"github.com/umputun/remark/app/store"
|
||||
"gopkg.in/russross/blackfriday.v2"
|
||||
)
|
||||
|
||||
// Server is a rest access server
|
||||
@@ -139,6 +140,9 @@ func (s *Server) createCommentCtrl(w http.ResponseWriter, r *http.Request) {
|
||||
comment.User = user
|
||||
comment.User.IP = strings.Split(r.RemoteAddr, ":")[0]
|
||||
|
||||
// render markdown
|
||||
comment.Text = string(blackfriday.Run([]byte(comment.Text)))
|
||||
|
||||
log.Printf("[DEBUG] create comment %+v", comment)
|
||||
|
||||
// check if user blocked
|
||||
@@ -179,6 +183,10 @@ func (s *Server) updateCommentCtrl(w http.ResponseWriter, r *http.Request) {
|
||||
}
|
||||
locator := store.Locator{SiteID: r.URL.Query().Get("site"), URL: r.URL.Query().Get("url")}
|
||||
id := chi.URLParam(r, "id")
|
||||
|
||||
// render markdown
|
||||
edit.Text = string(blackfriday.Run([]byte(edit.Text)))
|
||||
|
||||
log.Printf("[DEBUG] update comment %s, %+v", id, edit)
|
||||
|
||||
var currComment store.Comment
|
||||
|
||||
+1
-1
@@ -13,7 +13,7 @@ POST https://demo.remark42.com/api/v1/comment
|
||||
Content-Type: application/json
|
||||
|
||||
{
|
||||
"text": "comment blah http://radio-t.com",
|
||||
"text": "comment *blah* http://radio-t.com",
|
||||
"user" : {
|
||||
"name": "umputun",
|
||||
"id": "@umputun",
|
||||
|
||||
Vendored
+18
@@ -124,12 +124,24 @@
|
||||
"revision": "05e8a0eda380579888eb53c394909df027f06991",
|
||||
"revisionTime": "2017-07-13T16:51:06Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "HkNUuhYSk5C2fTMa536jBiORq44=",
|
||||
"path": "github.com/shurcooL/sanitized_anchor_name",
|
||||
"revision": "86672fcb3f950f35f2e675df2240550f2a50762f",
|
||||
"revisionTime": "2017-09-05T02:47:45Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "J+ppEq6nYMKxhB9+c+MD1x9UwSc=",
|
||||
"path": "github.com/stretchr/testify/assert",
|
||||
"revision": "05e8a0eda380579888eb53c394909df027f06991",
|
||||
"revisionTime": "2017-07-13T16:51:06Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "7vs6dSc1PPGBKyzb/SCIyeMJPLQ=",
|
||||
"path": "github.com/stretchr/testify/require",
|
||||
"revision": "2aa2c176b9dab406a6970f6a55f513e8a8c8b18f",
|
||||
"revisionTime": "2017-08-14T20:04:35Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "Y+HGqEkYM15ir+J93MEaHdyFy0c=",
|
||||
"path": "golang.org/x/net/context",
|
||||
@@ -201,6 +213,12 @@
|
||||
"path": "golang.org/x/sys/unix",
|
||||
"revision": "478fcf54317e52ab69f40bb4c7a1520288d7f7ea",
|
||||
"revisionTime": "2016-12-05T15:46:50Z"
|
||||
},
|
||||
{
|
||||
"checksumSHA1": "WrnWl9sC9qr8Ny0wkfKfnuwIxDM=",
|
||||
"path": "gopkg.in/russross/blackfriday.v2",
|
||||
"revision": "cadec560ec52d93835bf2f15bd794700d3a2473b",
|
||||
"revisionTime": "2017-08-06T17:10:14Z"
|
||||
}
|
||||
],
|
||||
"rootPath": "github.com/umputun/remark"
|
||||
|
||||
Reference in New Issue
Block a user