parent
867eb53b35
commit
eac223158a
|
@ -38,7 +38,7 @@ var (
|
||||||
titleElementReg = regexp.MustCompile("</?h[1-6]>")
|
titleElementReg = regexp.MustCompile("</?h[1-6]>")
|
||||||
hashtagReg = regexp.MustCompile(`{{\[\[\|\|([^|]+)\|\|\]\]}}`)
|
hashtagReg = regexp.MustCompile(`{{\[\[\|\|([^|]+)\|\|\]\]}}`)
|
||||||
markeddownReg = regexp.MustCompile("<p>(.+)</p>")
|
markeddownReg = regexp.MustCompile("<p>(.+)</p>")
|
||||||
mentionReg = regexp.MustCompile(`@[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]+\b`)
|
mentionReg = regexp.MustCompile(`@([A-Za-z0-9._%+-]+)(@[A-Za-z0-9.-]+\.[A-Za-z]+)\b`)
|
||||||
)
|
)
|
||||||
|
|
||||||
func (p *Post) formatContent(cfg *config.Config, c *Collection, isOwner bool) {
|
func (p *Post) formatContent(cfg *config.Config, c *Collection, isOwner bool) {
|
||||||
|
@ -87,8 +87,8 @@ func applyMarkdownSpecial(data []byte, skipNoFollow bool, baseURL string, cfg *c
|
||||||
tagPrefix = "/read/t/"
|
tagPrefix = "/read/t/"
|
||||||
}
|
}
|
||||||
md = []byte(hashtagReg.ReplaceAll(md, []byte("<a href=\""+tagPrefix+"$1\" class=\"hashtag\"><span>#</span><span class=\"p-category\">$1</span></a>")))
|
md = []byte(hashtagReg.ReplaceAll(md, []byte("<a href=\""+tagPrefix+"$1\" class=\"hashtag\"><span>#</span><span class=\"p-category\">$1</span></a>")))
|
||||||
handlePrefix := cfg.App.Host + "/mention:"
|
handlePrefix := cfg.App.Host + "/@/"
|
||||||
md = []byte(mentionReg.ReplaceAll(md, []byte("<a href=\""+handlePrefix+"$0\" class=\"mention\">$0</a>")))
|
md = []byte(mentionReg.ReplaceAll(md, []byte("<a href=\""+handlePrefix+"$1$2\" class=\"mention\">@$1$2</a>")))
|
||||||
}
|
}
|
||||||
// Strip out bad HTML
|
// Strip out bad HTML
|
||||||
policy := getSanitizationPolicy()
|
policy := getSanitizationPolicy()
|
||||||
|
|
|
@ -71,7 +71,7 @@ func InitRoutes(apper Apper, r *mux.Router) *mux.Router {
|
||||||
write.HandleFunc(niCfg.InfoURL, handler.LogHandlerFunc(http.HandlerFunc(ni.NodeInfo)))
|
write.HandleFunc(niCfg.InfoURL, handler.LogHandlerFunc(http.HandlerFunc(ni.NodeInfo)))
|
||||||
|
|
||||||
// handle mentions
|
// handle mentions
|
||||||
write.HandleFunc("/mention:{handle}", handler.Web(handleViewMention, UserLevelReader))
|
write.HandleFunc("/@/{handle}", handler.Web(handleViewMention, UserLevelReader))
|
||||||
|
|
||||||
configureSlackOauth(handler, write, apper.App())
|
configureSlackOauth(handler, write, apper.App())
|
||||||
configureWriteAsOauth(handler, write, apper.App())
|
configureWriteAsOauth(handler, write, apper.App())
|
||||||
|
|
Loading…
Reference in New Issue