mirror of
https://github.com/GwynethLlewelyn/goswi.git
synced 2026-08-14 00:58:00 +00:00
Style: new: show all notifications & offline IMs
This commit is contained in:
+16
-12
@@ -6,6 +6,7 @@ package main
|
||||
import (
|
||||
"database/sql"
|
||||
"encoding/gob"
|
||||
"fmt"
|
||||
"html/template"
|
||||
"net/http"
|
||||
"strconv"
|
||||
@@ -20,7 +21,7 @@ type FeedMessage struct {
|
||||
PostParentID string `json:"PostParentID"`
|
||||
PosterID string `json:"PosterID"` // UUID of poster. Feed messages are seen by everyone.
|
||||
PostID string `json:"PostID"` // primary key
|
||||
Username string `json:"Username"` // will be constructed by getting it from the UserAccounts table
|
||||
Username template.HTML `json:"Username"` // will be constructed by getting it from the UserAccounts table and adding a bit of HTML
|
||||
Libravatar string `json:"Libravatar"`
|
||||
PostMarkup template.HTML `json:"PostMarkup"` // actual message. May contain HTML.
|
||||
Chronostamp string `json:"Chronostamp"`
|
||||
@@ -95,8 +96,9 @@ func GetTopFeedMessages(c *gin.Context) {
|
||||
&email,
|
||||
)
|
||||
oneMessage.PostMarkup = template.HTML(bluemondaySafeHTML.Sanitize(unsafeMessage))
|
||||
oneMessage.Username = firstName + " " + lastName
|
||||
oneMessage.Libravatar = getLibravatar(email, oneMessage.Username, 60)
|
||||
username := firstName + " " + lastName
|
||||
oneMessage.Username = template.HTML(bluemondaySafeHTML.Sanitize(fmt.Sprintf("<span title=\"%s\" data-toggle=\"tooltip\">%s</span>", oneMessage.PosterID, username)))
|
||||
oneMessage.Libravatar = getLibravatar(email, username, 60)
|
||||
// do something to the time
|
||||
if messageTimeStamp.Valid {
|
||||
oneMessage.Chronostamp = humanize.Time(messageTimeStamp.Time)
|
||||
@@ -180,8 +182,10 @@ func getFeedMessages(c *gin.Context) {
|
||||
&email,
|
||||
)
|
||||
oneMessage.PostMarkup = template.HTML(bluemondaySafeHTML.Sanitize(unsafeMessage))
|
||||
oneMessage.Username = firstName + " " + lastName
|
||||
oneMessage.Libravatar = getLibravatar(email, oneMessage.Username, 60)
|
||||
username := firstName + " " + lastName
|
||||
oneMessage.Username = template.HTML(bluemondaySafeHTML.Sanitize(fmt.Sprintf("<span title=\"%s\" data-toggle=\"tooltip\">%s</span>", oneMessage.PosterID, username)))
|
||||
oneMessage.Libravatar = getLibravatar(email, username, 60)
|
||||
|
||||
// do something to the time
|
||||
if messageTimeStamp.Valid {
|
||||
// No need to humanize timestamps here.
|
||||
@@ -200,13 +204,13 @@ func getFeedMessages(c *gin.Context) {
|
||||
config.LogTracef("getFeedMessages(): All messages for user %q: %+v\n", username, messages)
|
||||
// now call the template
|
||||
c.HTML(http.StatusOK, "tables.tpl", environment(c, gin.H{
|
||||
"needsTables": true,
|
||||
"needsMap": false,
|
||||
"moreValidation": true,
|
||||
"Debug": *config["ginMode"] == "debug" || *config["ginMode"] == "trace",
|
||||
"titleCommon": *config["titleCommon"] + "Feed Messages for: " + username,
|
||||
"feedMessages": messages,
|
||||
"numberMessages": numberFeedMessages, // for debug
|
||||
"needsTables": true,
|
||||
"needsMap": false,
|
||||
"moreValidation": true,
|
||||
"Debug": *config["ginMode"] == "debug" || *config["ginMode"] == "trace",
|
||||
"titleCommon": *config["titleCommon"] + "Feed Messages for: " + username,
|
||||
"feedMessages": messages,
|
||||
"numberFeedMessages": numberFeedMessages, // for debug
|
||||
}))
|
||||
return
|
||||
}
|
||||
|
||||
+8
-5
@@ -17,7 +17,7 @@ import (
|
||||
type OfflineIM struct {
|
||||
ID string `json:"ID"`
|
||||
PrincipalID string `json:"PrincipalID"`
|
||||
Username string `json:"Username"` // will be constructed by getting it from the UserAccounts table
|
||||
Username template.HTML `json:"Username"` // will be constructed by getting it from the UserAccounts table with some HTML (so, sanitize first!)
|
||||
Libravatar string `json:"Libravatar"`
|
||||
FromID string `json:"FromID"`
|
||||
Message template.HTML `json:"Message"` // may contain HTML, so it will be sanitised later on (gwyneth 20200815)
|
||||
@@ -83,8 +83,9 @@ func GetTopOfflineMessages(c *gin.Context) {
|
||||
&email,
|
||||
)
|
||||
oneMessage.Message = template.HTML(bluemondaySafeHTML.Sanitize(unsafeMessage))
|
||||
oneMessage.Username = firstName + " " + lastName
|
||||
oneMessage.Libravatar = getLibravatar(email, oneMessage.Username, 60)
|
||||
username := firstName + " " + lastName
|
||||
oneMessage.Username = template.HTML(bluemondaySafeHTML.Sanitize(fmt.Sprintf("<span title=\"%s\" data-toggle=\"tooltip\">%s</span>", oneMessage.FromID, username)))
|
||||
oneMessage.Libravatar = getLibravatar(email, username, 60)
|
||||
// do something to the time
|
||||
if messageTimeStamp.Valid {
|
||||
oneMessage.TMStamp = humanize.Time(messageTimeStamp.Time)
|
||||
@@ -165,8 +166,9 @@ func getOfflineMessages(c *gin.Context) {
|
||||
&email,
|
||||
)
|
||||
oneMessage.Message = template.HTML(bluemondaySafeHTML.Sanitize(unsafeMessage))
|
||||
oneMessage.Username = firstName + " " + lastName
|
||||
oneMessage.Libravatar = getLibravatar(email, oneMessage.Username, 60)
|
||||
username := firstName + " " + lastName
|
||||
oneMessage.Username = template.HTML(bluemondaySafeHTML.Sanitize(fmt.Sprintf("<span title=\"%s\" data-toggle=\"tooltip\">%s</span>", oneMessage.FromID, username)))
|
||||
oneMessage.Libravatar = getLibravatar(email, username, 60)
|
||||
// do something to the time
|
||||
if messageTimeStamp.Valid {
|
||||
// No need to humanize timestamps here.
|
||||
@@ -192,6 +194,7 @@ func getOfflineMessages(c *gin.Context) {
|
||||
"moreValidation": true,
|
||||
"titleCommon": *config["titleCommon"] + "Offline Messages for: " + username,
|
||||
"offlineMessages": messages,
|
||||
"numberMessages": numberMessages,
|
||||
"Debug": *config["ginMode"] == "debug" || *config["ginMode"] == "trace",
|
||||
"BoxTitle": "Debug info:",
|
||||
"BoxContent": fmt.Sprintf("<p><b>Number of messages:</b> %d</p>", numberMessages), // for debug
|
||||
|
||||
@@ -110,12 +110,12 @@
|
||||
],
|
||||
"columns": [
|
||||
{ "data": "ID" },
|
||||
{ "data": "FromID" },
|
||||
{ "data": "Username" },
|
||||
{
|
||||
"data": "Avatar",
|
||||
render: function (data, type, row, meta) {
|
||||
return '<img class="rounded-circle" src="' + data + '" alt="' + target[2] + '">';
|
||||
"data": "Libravatar",
|
||||
"render": function (data, type, row, meta) {
|
||||
return '<img class="rounded-circle" src="' + data + '" alt="">';
|
||||
}
|
||||
},
|
||||
{ "data": "Message" },
|
||||
{ "data": "TMStamp" },
|
||||
@@ -137,8 +137,9 @@
|
||||
{ "data": "Username" },
|
||||
{
|
||||
"data": "Libravatar",
|
||||
render: function (data, type, row, meta) {
|
||||
return '<img class="rounded-circle" src="' + data + '" alt="' + target[2] + '">';
|
||||
"render": function (data, type, row, meta) {
|
||||
return '<img class="rounded-circle" src="' + data + '" alt="">';
|
||||
}
|
||||
},
|
||||
{ "data": "PostMarkup" },
|
||||
{ "data": "Chronostamp" },
|
||||
|
||||
+20
-20
@@ -25,22 +25,20 @@
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>FromID</th>
|
||||
<th>Username</th>
|
||||
<th>Avatar</th>
|
||||
<th>Message</th>
|
||||
<th>TMStamp</th>
|
||||
<th>Date</th>
|
||||
</tr>
|
||||
</thead>
|
||||
{{- if gt .offlineMessages 20 -}}
|
||||
{{- if gt .numberMessages 20 -}}
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>FromID</th>
|
||||
<th>Username</th>
|
||||
<th>Avatar</th>
|
||||
<th>Message</th>
|
||||
<th>TMStamp</th>
|
||||
<th>Date</th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
{{- end -}}
|
||||
@@ -52,29 +50,31 @@
|
||||
<th>PosterID</th>
|
||||
<th>PostID</th>
|
||||
<th>Username</th>
|
||||
<th>PostMarkup</th>
|
||||
<th>Chronostamp</th>
|
||||
<th>Visibility</th>
|
||||
<th>Comment</th>
|
||||
<th>Commentlock</th>
|
||||
<th>Editlock</th>
|
||||
<th>Feedgroup</th>
|
||||
<th>Avatar</th>
|
||||
<th>Message</th>
|
||||
<th>Date</th>
|
||||
<th class="hidden">Visibility</th>
|
||||
<th class="hidden">Comment</th>
|
||||
<th class="hidden">Commentlock</th>
|
||||
<th class="hidden">Editlock</th>
|
||||
<th class="hidden">Feedgroup</th>
|
||||
</tr>
|
||||
</thead>
|
||||
{{- if gt .feedMessages 20 -}}
|
||||
{{- if gt .numberFeedMessages 20 -}}
|
||||
<tfoot>
|
||||
<tr>
|
||||
<th>PostParentID</th>
|
||||
<th>PosterID</th>
|
||||
<th>PostID</th>
|
||||
<th>Username</th>
|
||||
<th>PostMarkup</th>
|
||||
<th>Chronostamp</th>
|
||||
<th>Visibility</th>
|
||||
<th>Comment</th>
|
||||
<th>Commentlock</th>
|
||||
<th>Editlock</th>
|
||||
<th>Feedgroup</th>
|
||||
<th>Avatar</th>
|
||||
<th>Message</th>
|
||||
<th>Date</th>
|
||||
<th class="hidden">Visibility</th>
|
||||
<th class="hidden">Comment</th>
|
||||
<th class="hidden">Commentlock</th>
|
||||
<th class="hidden">Editlock</th>
|
||||
<th class="hidden">Feedgroup</th>
|
||||
</tr>
|
||||
</tfoot>
|
||||
{{- end -}}
|
||||
|
||||
Reference in New Issue
Block a user