Move action posts now show the forum the topic has been moved to.
Move modlog events now show the forum the topic has been moved to. Moved the .action_icon styling from topic.html into the theme stylesheets. Added the topic.action_topic_move_dest phrase.
This commit is contained in:
parent
86885dd4bb
commit
2d366ce6a0
@ -656,6 +656,7 @@
|
||||
"topic.action_topic_stick":"This topic was pinned by <a href='%s'>%s</a>",
|
||||
"topic.action_topic_unstick":"This topic was unpinned by <a href='%s'>%s</a>",
|
||||
"topic.action_topic_move":"This topic was moved by <a href='%s'>%s</a>",
|
||||
"topic.action_topic_move_dest":"This topic was moved to <a href='%s'>%s</a> by <a href='%s'>%s</a>",
|
||||
"topic.action_topic_default":"%s has happened",
|
||||
|
||||
"topic.your_information":"Your information",
|
||||
|
@ -51,11 +51,13 @@ func handleUnknownTopic(topic *common.Topic, err error) *common.Topic {
|
||||
}
|
||||
|
||||
// TODO: Move the log building logic into /common/ and it's own abstraction
|
||||
// TODO: Localise this
|
||||
func topicElementTypeAction(action string, elementType string, elementID int, actor *common.User, topic *common.Topic) (out string) {
|
||||
if action == "delete" {
|
||||
return fmt.Sprintf("Topic #%d was deleted by <a href='%s'>%s</a>", elementID, actor.Link, actor.Name)
|
||||
}
|
||||
switch action {
|
||||
aarr := strings.Split(action, "-")
|
||||
switch aarr[0] {
|
||||
case "lock":
|
||||
out = "<a href='%s'>%s</a> was locked by <a href='%s'>%s</a>"
|
||||
case "unlock":
|
||||
@ -65,6 +67,13 @@ func topicElementTypeAction(action string, elementType string, elementID int, ac
|
||||
case "unstick":
|
||||
out = "<a href='%s'>%s</a> was unpinned by <a href='%s'>%s</a>"
|
||||
case "move":
|
||||
if len(aarr) == 2 {
|
||||
fid, _ := strconv.Atoi(aarr[1])
|
||||
forum, err := common.Forums.Get(fid)
|
||||
if err == nil {
|
||||
return fmt.Sprintf("<a href='%s'>%s</a> was moved to <a href='%s'>%s</a> by <a href='%s'>%s</a>", topic.Link, topic.Title, forum.Link, forum.Name, actor.Link, actor.Name)
|
||||
}
|
||||
}
|
||||
out = "<a href='%s'>%s</a> was moved by <a href='%s'>%s</a>" // TODO: Add where it was moved to, we'll have to change the source data for that, most likely? Investigate that and try to work this in
|
||||
default:
|
||||
return fmt.Sprintf("Unknown action '%s' on elementType '%s' by <a href='%s'>%s</a>", action, elementType, actor.Link, actor.Name)
|
||||
|
@ -190,7 +190,8 @@ func ViewTopic(w http.ResponseWriter, r *http.Request, user common.User, header
|
||||
// We really shouldn't have inline HTML, we should do something about this...
|
||||
if replyItem.ActionType != "" {
|
||||
var action string
|
||||
switch replyItem.ActionType {
|
||||
aarr := strings.Split(replyItem.ActionType, "-")
|
||||
switch aarr[0] {
|
||||
case "lock":
|
||||
action = "lock"
|
||||
replyItem.ActionIcon = "🔒︎"
|
||||
@ -204,15 +205,25 @@ func ViewTopic(w http.ResponseWriter, r *http.Request, user common.User, header
|
||||
action = "unstick"
|
||||
replyItem.ActionIcon = "📌︎"
|
||||
case "move":
|
||||
action = "move"
|
||||
if len(aarr) == 2 {
|
||||
fid, _ := strconv.Atoi(aarr[1])
|
||||
forum, err := common.Forums.Get(fid)
|
||||
if err == nil {
|
||||
replyItem.ActionType = phrases.GetTmplPhrasef("topic.action_topic_move_dest", forum.Link, forum.Name, replyItem.UserLink, replyItem.CreatedByName)
|
||||
} else {
|
||||
action = "move"
|
||||
}
|
||||
} else {
|
||||
action = "move"
|
||||
}
|
||||
replyItem.ActionIcon = ""
|
||||
default:
|
||||
// TODO: Only fire this off if a corresponding phrase for the ActionType doesn't exist? Or maybe have some sort of action registry?
|
||||
replyItem.ActionType = phrases.GetTmplPhrasef("topic.action_topic_default", replyItem.ActionType)
|
||||
replyItem.ActionIcon = ""
|
||||
}
|
||||
if action != "" {
|
||||
replyItem.ActionType = phrases.GetTmplPhrasef("topic.action_topic_"+action, replyItem.UserLink, replyItem.CreatedByName)
|
||||
} else {
|
||||
// TODO: Only fire this off if a corresponding phrase for the ActionType doesn't exist? Or maybe have some sort of action registry?
|
||||
replyItem.ActionType = phrases.GetTmplPhrasef("topic.action_topic_default", replyItem.ActionType)
|
||||
replyItem.ActionIcon = ""
|
||||
}
|
||||
}
|
||||
|
||||
@ -228,6 +239,7 @@ func ViewTopic(w http.ResponseWriter, r *http.Request, user common.User, header
|
||||
header.Hooks.VhookNoRet("topic_reply_row_assign", &tpage, &replyItem)
|
||||
// TODO: Use a pointer instead to make it easier to abstract this loop? What impact would this have on escape analysis?
|
||||
tpage.ItemList = append(tpage.ItemList, replyItem)
|
||||
//log.Printf("r: %d-%d", replyItem.ID, len(tpage.ItemList)-1)
|
||||
}
|
||||
err = rows.Err()
|
||||
if err != nil {
|
||||
@ -266,6 +278,7 @@ func ViewTopic(w http.ResponseWriter, r *http.Request, user common.User, header
|
||||
//log.Printf("amap: %+v\n", amap)
|
||||
//log.Printf("attachMap: %+v\n", attachMap)
|
||||
for id, attach := range amap {
|
||||
//log.Print("id:", id)
|
||||
tpage.ItemList[attachMap[id]].Attachments = attach
|
||||
/*for _, a := range attach {
|
||||
log.Printf("a: %+v\n", a)
|
||||
@ -929,8 +942,8 @@ func MoveTopicSubmit(w http.ResponseWriter, r *http.Request, user common.User, s
|
||||
return common.InternalErrorJS(err, w, r)
|
||||
}
|
||||
|
||||
// TODO: Log more data so we can list the destination forum in the action post?
|
||||
err = addTopicAction("move", topic, user)
|
||||
// ? - Is there a better way of doing this?
|
||||
err = addTopicAction("move-"+strconv.Itoa(fid), topic, user)
|
||||
if err != nil {
|
||||
return common.InternalErrorJS(err, w, r)
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
<div class="rowblock post_container" aria-label="{{lang "topic.current_page_aria"}}" style="overflow: hidden;">{{range .ItemList}}
|
||||
{{if .ActionType}}
|
||||
<article {{scope "post_action"}} id="post-{{.ID}}" itemscope itemtype="http://schema.org/CreativeWork" class="rowitem passive deletable_block editable_parent post_item action_item">
|
||||
<span class="action_icon" style="font-size: 18px;padding-right: 5px;">{{.ActionIcon}}</span>
|
||||
<span class="action_icon">{{.ActionIcon}}</span>
|
||||
<span itemprop="text">{{.ActionType}}</span>
|
||||
</article>
|
||||
{{else}}
|
||||
|
@ -253,6 +253,11 @@ h1, h2, h3, h4, h5 {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.action_item .action_icon {
|
||||
font-size: 18px;
|
||||
padding-right: 5px;
|
||||
}
|
||||
|
||||
/* TODO: Rewrite the closed topic header so that it looks more consistent with the rest of the theme */
|
||||
.topic_closed_head .topic_status_closed {
|
||||
margin-bottom: -10px;
|
||||
|
@ -782,6 +782,10 @@ red {
|
||||
text-align: center;
|
||||
background-color: rgb(255,245,245);
|
||||
}
|
||||
.action_item .action_icon {
|
||||
font-size: 18px;
|
||||
padding-right: 5px;
|
||||
}
|
||||
|
||||
blockquote {
|
||||
border: 1px solid hsl(0, 0%, 80%);
|
||||
|
Loading…
Reference in New Issue
Block a user