[feature] Set/show instance language(s); show post language on frontend (#2362)

* update go text, include text/display

* [feature] Set instance langs, show post lang on frontend

* go fmt

* WebGet

* set language for whole article, don't use FA icon

* mention instance languages + other optional config vars

* little tweak

* put languages in config properly

* warn log language parse

* change some naming around

* tidy up validate a bit

* lint

* rename LanguageTmpl in template
This commit is contained in:
tobi 2023-11-17 11:35:28 +01:00 committed by GitHub
commit fc02d3c6f7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
73 changed files with 55005 additions and 141 deletions

View file

@ -39,6 +39,7 @@ func (m *Module) aboutGETHandler(c *gin.Context) {
c.HTML(http.StatusOK, "about.tmpl", gin.H{
"instance": instance,
"languages": config.GetInstanceLanguages().DisplayStrs(),
"ogMeta": ogBase(instance),
"blocklistExposed": config.GetInstanceExposeSuspendedWeb(),
"stylesheets": []string{

View file

@ -121,21 +121,17 @@ func (m *Module) profileGETHandler(c *gin.Context) {
var (
maxStatusID = apiutil.ParseMaxID(c.Query(apiutil.MaxIDKey), "")
paging = maxStatusID != ""
pinnedStatuses *apimodel.PageableResponse
pinnedStatuses []*apimodel.Status
)
if !paging {
// Client opened bare profile (from the top)
// so load + display pinned statuses.
pinnedStatuses, errWithCode = m.processor.Account().PinnedStatusesGet(ctx, authed.Account, targetAccount.ID)
pinnedStatuses, errWithCode = m.processor.Account().WebStatusesGetPinned(ctx, targetAccount.ID)
if errWithCode != nil {
apiutil.WebErrorHandler(c, errWithCode, instanceGet)
return
}
} else {
// Don't load pinned statuses at
// the top of profile while paging.
pinnedStatuses = new(apimodel.PageableResponse)
}
// Get statuses from maxStatusID onwards (or from top if empty string).
@ -162,7 +158,7 @@ func (m *Module) profileGETHandler(c *gin.Context) {
"robotsMeta": robotsMeta,
"statuses": statusResp.Items,
"statuses_next": statusResp.NextLink,
"pinned_statuses": pinnedStatuses.Items,
"pinned_statuses": pinnedStatuses,
"show_back_to_top": paging,
"stylesheets": stylesheets,
"javascript": []string{distPathPrefix + "/frontend.js"},

View file

@ -111,7 +111,7 @@ func (m *Module) threadGETHandler(c *gin.Context) {
}
// Get the status itself from the processor using provided ID and authorization (if any).
status, errWithCode := m.processor.Status().Get(ctx, authed.Account, targetStatusID)
status, errWithCode := m.processor.Status().WebGet(ctx, targetStatusID)
if errWithCode != nil {
apiutil.WebErrorHandler(c, errWithCode, instanceGet)
return