Skip to content
This repository was archived by the owner on May 30, 2023. It is now read-only.

Commit 158702e

Browse files
committed
Merge remote-tracking branch 'origin/develop' into develop
2 parents d14d771 + 1a877f6 commit 158702e

File tree

3 files changed

+25
-5
lines changed

3 files changed

+25
-5
lines changed

assets/css/main.css

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,7 @@ h2 {
9696
}
9797
span.redacted {
9898
color: red;
99+
}
100+
tr.evHighlight {
101+
background-color: yellow;
99102
}

src/github.com/t3chguy/matrix-static/matrix-static.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,13 @@ func main() {
177177

178178
roomRouter := publicRouter.Group("/room/:roomID/")
179179
{
180+
roomRouter.GET("/$:eventID", func(c *gin.Context) {
181+
eventID := c.Param("eventID")
182+
roomID := c.Param("roomID")
183+
184+
c.Redirect(http.StatusTemporaryRedirect, "/room/"+roomID+"/?anchor=$"+eventID+"&highlight")
185+
})
186+
180187
// Load room worker into request object so that we can do any clean up etc here
181188
roomRouter.Use(func(c *gin.Context) {
182189
roomID := c.Param("roomID")
@@ -245,6 +252,7 @@ func main() {
245252
}
246253

247254
events := mxclient.ReverseEventsCopy(jobResult.Events)
255+
_, highlight := c.GetQuery("highlight")
248256

249257
templates.WritePageTemplate(c.Writer, &templates.RoomChatPage{
250258
RoomInfo: jobResult.RoomInfo,
@@ -259,6 +267,7 @@ func main() {
259267

260268
Sanitizer: sanitizerFn,
261269
HomeserverBaseURL: client.HomeserverURL.String(),
270+
Highlight: highlight,
262271
})
263272
})
264273

src/github.com/t3chguy/matrix-static/templates/room-chat.qtpl

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,9 @@
5757
AtTopEnd bool
5858
AtBottomEnd bool
5959

60-
Sanitizer *sanitizer.Sanitizer
60+
Sanitizer *sanitizer.Sanitizer
6161
HomeserverBaseURL string
62+
Highlight bool
6263
}
6364
%}
6465

@@ -233,14 +234,18 @@
233234
}
234235
%}
235236

236-
{% func (p *RoomChatPage) printEvent(ev, prevEv *gomatrix.Event) %}
237+
{% func (p *RoomChatPage) printEvent(ev, prevEv *gomatrix.Event, highlight bool) %}
237238
{% if needsDateSeparator(ev, prevEv) %}
238239
<tr class="timestamp dateSep">
239240
<td colspan="3">{%s parseEventTimestamp(ev.Timestamp).Format("2 Jan 2006") %}</td>
240241
</tr>
241242
{% endif %}
242243

244+
{% if highlight %}
245+
<tr class="evHighlight">
246+
{% else %}
243247
<tr>
248+
{% endif %}
244249
<td class="timestamp nowrap">
245250
{% code
246251
time := parseEventTimestamp(ev.Timestamp)
@@ -348,9 +353,12 @@
348353
</tr>
349354
</thead>
350355
<tbody>
351-
{% code var prevEv gomatrix.Event %}
352-
{% for _, event := range p.Events %}
353-
{%= p.printEvent(&event, &prevEv) %}
356+
{% code
357+
var prevEv gomatrix.Event
358+
numEvents := len(p.Events)
359+
%}
360+
{% for i, event := range p.Events %}
361+
{%= p.printEvent(&event, &prevEv, i == numEvents - 1) %}
354362
{% code prevEv = event %}
355363
{% endfor %}
356364
</tbody>

0 commit comments

Comments
 (0)