This repository was archived by the owner on May 30, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +25
-5
lines changed
src/github.com/t3chguy/matrix-static Expand file tree Collapse file tree 3 files changed +25
-5
lines changed Original file line number Diff line number Diff line change 9696}
9797span .redacted {
9898 color : red;
99+ }
100+ tr .evHighlight {
101+ background-color : yellow;
99102}
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 5757 AtTopEnd bool
5858 AtBottomEnd bool
5959
60- Sanitizer *sanitizer.Sanitizer
60+ Sanitizer *sanitizer.Sanitizer
6161 HomeserverBaseURL string
62+ Highlight bool
6263 }
6364%}
6465
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)
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>
You can’t perform that action at this time.
0 commit comments