mirror of
				https://github.com/superseriousbusiness/gotosocial.git
				synced 2025-10-30 23:02:25 -05:00 
			
		
		
		
	[chore] little frontend tweaks (#3852)
* [chore] little frontend tweaks * beep boop * poke * clarify server time
This commit is contained in:
		
					parent
					
						
							
								e78e817057
							
						
					
				
			
			
				commit
				
					
						4c9901fc03
					
				
			
		
					 6 changed files with 18 additions and 44 deletions
				
			
		|  | @ -26,7 +26,6 @@ import ( | ||||||
| 	"reflect" | 	"reflect" | ||||||
| 	"regexp" | 	"regexp" | ||||||
| 	"strings" | 	"strings" | ||||||
| 	"time" |  | ||||||
| 	"unsafe" | 	"unsafe" | ||||||
| 
 | 
 | ||||||
| 	"github.com/gin-gonic/gin" | 	"github.com/gin-gonic/gin" | ||||||
|  | @ -128,7 +127,6 @@ var funcMap = template.FuncMap{ | ||||||
| 	"oddOrEven":        oddOrEven, | 	"oddOrEven":        oddOrEven, | ||||||
| 	"subtract":         subtract, | 	"subtract":         subtract, | ||||||
| 	"timestampPrecise": timestampPrecise, | 	"timestampPrecise": timestampPrecise, | ||||||
| 	"timestamp":        timestamp, |  | ||||||
| 	"timestampVague":   timestampVague, | 	"timestampVague":   timestampVague, | ||||||
| 	"visibilityIcon":   visibilityIcon, | 	"visibilityIcon":   visibilityIcon, | ||||||
| } | } | ||||||
|  | @ -174,29 +172,6 @@ const ( | ||||||
| 	badTimestamp = "bad timestamp" | 	badTimestamp = "bad timestamp" | ||||||
| ) | ) | ||||||
| 
 | 
 | ||||||
| func timestamp(stamp string) string { |  | ||||||
| 	t, err := util.ParseISO8601(stamp) |  | ||||||
| 	if err != nil { |  | ||||||
| 		log.Errorf(nil, "error parsing timestamp %s: %s", stamp, err) |  | ||||||
| 		return badTimestamp |  | ||||||
| 	} |  | ||||||
| 
 |  | ||||||
| 	t = t.Local() |  | ||||||
| 
 |  | ||||||
| 	tYear, tMonth, tDay := t.Date() |  | ||||||
| 	now := time.Now() |  | ||||||
| 	currentYear, currentMonth, currentDay := now.Date() |  | ||||||
| 
 |  | ||||||
| 	switch { |  | ||||||
| 	case tYear == currentYear && tMonth == currentMonth && tDay == currentDay: |  | ||||||
| 		return "Today, " + t.Format(justTime) |  | ||||||
| 	case tYear == currentYear: |  | ||||||
| 		return t.Format(dateTime) |  | ||||||
| 	default: |  | ||||||
| 		return t.Format(dateYear) |  | ||||||
| 	} |  | ||||||
| } |  | ||||||
| 
 |  | ||||||
| func timestampPrecise(stamp string) string { | func timestampPrecise(stamp string) string { | ||||||
| 	t, err := util.ParseISO8601(stamp) | 	t, err := util.ParseISO8601(stamp) | ||||||
| 	if err != nil { | 	if err != nil { | ||||||
|  |  | ||||||
|  | @ -182,22 +182,22 @@ Array.from(document.getElementsByClassName("plyr-video")).forEach((video) => { | ||||||
| 	video._plyrContainer = player.elements.container; | 	video._plyrContainer = player.elements.container; | ||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
| document.addEventListener('DOMContentLoaded', () => { | Array.from(document.getElementsByTagName('time')).forEach(timeTag => { | ||||||
| 	const timeTags = document.getElementsByTagName('time'); |  | ||||||
| 	Array.from(timeTags).forEach(timeTag => { |  | ||||||
| 	const datetime = timeTag.getAttribute('datetime'); | 	const datetime = timeTag.getAttribute('datetime'); | ||||||
| 	const currentText = timeTag.textContent.trim(); | 	const currentText = timeTag.textContent.trim(); | ||||||
| 		// Only format if current text contains precise time
 | 	// Only format if current text contains precise time.
 | ||||||
| 	if (currentText.match(/\d{2}:\d{2}/)) { | 	if (currentText.match(/\d{2}:\d{2}/)) { | ||||||
| 		const date = new Date(datetime); | 		const date = new Date(datetime); | ||||||
| 			timeTag.textContent = date.toLocaleString(undefined, { | 		timeTag.textContent = date.toLocaleString( | ||||||
|  | 			undefined, | ||||||
|  | 			{ | ||||||
| 				year: 'numeric', | 				year: 'numeric', | ||||||
| 				month: 'short', | 				month: 'short', | ||||||
| 				day: '2-digit', | 				day: '2-digit', | ||||||
| 				hour: '2-digit', | 				hour: '2-digit', | ||||||
| 				minute: '2-digit', | 				minute: '2-digit', | ||||||
| 				hour12: false | 				hour12: false | ||||||
| 			}); | 			}, | ||||||
|  | 		); | ||||||
| 	} | 	} | ||||||
| }); | }); | ||||||
| }); |  | ||||||
|  |  | ||||||
|  | @ -180,7 +180,7 @@ | ||||||
|                 {{- end }} |                 {{- end }} | ||||||
|                 {{- end }} |                 {{- end }} | ||||||
|             </dl> |             </dl> | ||||||
|             <a class="u-url u-uid" rel="me" href="/@{{- .account.Username -}}" class="hidden"></a> |             <a class="u-url u-uid hidden" rel="me" href="/@{{- .account.Username -}}"></a> | ||||||
|         </div> |         </div> | ||||||
|     </section> |     </section> | ||||||
|     <div class="column-split"> |     <div class="column-split"> | ||||||
|  |  | ||||||
|  | @ -18,7 +18,7 @@ | ||||||
| */ -}} | */ -}} | ||||||
| 
 | 
 | ||||||
| {{- define "ariaLabel" -}} | {{- define "ariaLabel" -}} | ||||||
| @{{ .Account.Acct -}}, {{ timestamp .CreatedAt -}} | @{{ .Account.Acct -}}, {{ .CreatedAt | timestampPrecise -}} (server time) | ||||||
| {{- if .LanguageTag -}} | {{- if .LanguageTag -}} | ||||||
|     , language {{ .LanguageTag.DisplayStr -}} |     , language {{ .LanguageTag.DisplayStr -}} | ||||||
| {{- end -}} | {{- end -}} | ||||||
|  | @ -52,5 +52,4 @@ | ||||||
| id="{{- .ID -}}{{- if .Pinned -}}-pinned{{- end -}}" | id="{{- .ID -}}{{- if .Pinned -}}-pinned{{- end -}}" | ||||||
| role="region" | role="region" | ||||||
| aria-label="{{- template "ariaLabel" . -}}" | aria-label="{{- template "ariaLabel" . -}}" | ||||||
| class="status expanded h-entry" |  | ||||||
| {{- end }} | {{- end }} | ||||||
|  | @ -23,14 +23,14 @@ | ||||||
|         <div class="stats-item published-at text-cutoff"> |         <div class="stats-item published-at text-cutoff"> | ||||||
|             <dt class="sr-only">Published</dt> |             <dt class="sr-only">Published</dt> | ||||||
|             <dd> |             <dd> | ||||||
|                 <time class="dt-published" datetime="{{- .CreatedAt -}}">{{- .CreatedAt -}}</time> |                 <time class="dt-published" datetime="{{- .CreatedAt -}}">{{- .CreatedAt | timestampPrecise -}}</time> | ||||||
|             </dd> |             </dd> | ||||||
|         </div> |         </div> | ||||||
|         {{- if .EditedAt -}} |         {{- if .EditedAt -}} | ||||||
|         <div class="stats-item edited-at text-cutoff"> |         <div class="stats-item edited-at text-cutoff"> | ||||||
|             <dt class="sr-only">Edited</dt> |             <dt class="sr-only">Edited</dt> | ||||||
|             <dd> |             <dd> | ||||||
|                 (edited <time class="dt-updated" datetime="{{- .EditedAt -}}">{{- .EditedAt -}}</time>) |                 (edited <time class="dt-updated" datetime="{{- .EditedAt -}}">{{- .EditedAt | timestampPrecise -}}</time>) | ||||||
|             </dd> |             </dd> | ||||||
|         </div> |         </div> | ||||||
|         {{ end }} |         {{ end }} | ||||||
|  |  | ||||||
|  | @ -40,9 +40,9 @@ | ||||||
|             Poll  |             Poll  | ||||||
|             {{- end -}} |             {{- end -}} | ||||||
|             {{- if .Poll.Expired -}} |             {{- if .Poll.Expired -}} | ||||||
|             closed <time datetime="{{- .Poll.ExpiresAt -}}">{{- .Poll.ExpiresAt -}}</time> |             closed <time datetime="{{- .Poll.ExpiresAt -}}">{{- .Poll.ExpiresAt | timestampPrecise -}}</time> | ||||||
|             {{- else if .Poll.ExpiresAt -}} |             {{- else if .Poll.ExpiresAt -}} | ||||||
|             open until <time datetime="{{- .Poll.ExpiresAt -}}">{{- .Poll.ExpiresAt -}}</time> |             open until <time datetime="{{- .Poll.ExpiresAt -}}">{{- .Poll.ExpiresAt | timestampPrecise -}}</time> | ||||||
|             {{- else -}} |             {{- else -}} | ||||||
|             open forever |             open forever | ||||||
|             {{- end -}} |             {{- end -}} | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue