summaryrefslogtreecommitdiff
path: root/internal
diff options
context:
space:
mode:
Diffstat (limited to 'internal')
-rw-r--r--internal/api/util/template.go21
-rw-r--r--internal/processing/account/statuses.go3
-rw-r--r--internal/web/domain-blocklist.go1
-rw-r--r--internal/web/profile.go35
-rw-r--r--internal/web/settings-panel.go8
-rw-r--r--internal/web/thread.go12
-rw-r--r--internal/web/web.go1
7 files changed, 72 insertions, 9 deletions
diff --git a/internal/api/util/template.go b/internal/api/util/template.go
index ec04a4d97..38e79484f 100644
--- a/internal/api/util/template.go
+++ b/internal/api/util/template.go
@@ -48,10 +48,10 @@ type WebPage struct {
// Can be nil.
Stylesheets []string
- // Paths to JS files to add to
- // the page as "script" entries.
+ // JS files to add to the
+ // page as "script" entries.
// Can be nil.
- Javascript []string
+ Javascript []JavascriptEntry
// Extra parameters to pass to
// the template for rendering,
@@ -60,6 +60,21 @@ type WebPage struct {
Extra map[string]any
}
+type JavascriptEntry struct {
+ // Insert <script> tag at the end
+ // of <body> rather than in <head>.
+ Bottom bool
+
+ // Path to the js file.
+ Src string
+
+ // Use async="" attribute.
+ Async bool
+
+ // Use defer="" attribute.
+ Defer bool
+}
+
// TemplateWebPage renders the given HTML template and
// page params within the standard GtS "page" template.
//
diff --git a/internal/processing/account/statuses.go b/internal/processing/account/statuses.go
index 701fe44ae..3b4e067f9 100644
--- a/internal/processing/account/statuses.go
+++ b/internal/processing/account/statuses.go
@@ -144,6 +144,7 @@ func (p *Processor) WebStatusesGet(
ctx context.Context,
targetAccountID string,
mediaOnly bool,
+ limit int,
maxID string,
) (*apimodel.PageableResponse, gtserror.WithCode) {
account, err := p.state.DB.GetAccountByID(ctx, targetAccountID)
@@ -164,7 +165,7 @@ func (p *Processor) WebStatusesGet(
ctx,
account,
mediaOnly,
- 20,
+ limit,
maxID,
)
if err != nil && !errors.Is(err, db.ErrNoEntries) {
diff --git a/internal/web/domain-blocklist.go b/internal/web/domain-blocklist.go
index 5d631e0f7..309e629f2 100644
--- a/internal/web/domain-blocklist.go
+++ b/internal/web/domain-blocklist.go
@@ -68,7 +68,6 @@ func (m *Module) domainBlockListGETHandler(c *gin.Context) {
Instance: instance,
OGMeta: apiutil.OGBase(instance),
Stylesheets: []string{cssFA},
- Javascript: []string{jsFrontend},
Extra: map[string]any{"blocklist": domainBlocks},
}
diff --git a/internal/web/profile.go b/internal/web/profile.go
index 52d918b48..e8483921d 100644
--- a/internal/web/profile.go
+++ b/internal/web/profile.go
@@ -142,11 +142,22 @@ func (m *Module) prepareProfile(c *gin.Context) *profile {
}
}
+ // Limit varies depending on whether this is a gallery view or not.
+ // If gallery view, we want a nice full screen of media, else we
+ // don't want to overwhelm the viewer with a shitload of posts.
+ var limit int
+ if account.WebLayout == "gallery" {
+ limit = 40
+ } else {
+ limit = 20
+ }
+
// Get statuses from maxStatusID onwards (or from top if empty string).
statusResp, errWithCode := m.processor.Account().WebStatusesGet(
ctx,
account.ID,
mediaOnly,
+ limit,
maxStatusID,
)
if errWithCode != nil {
@@ -230,7 +241,17 @@ func (m *Module) profileMicroblog(c *gin.Context, p *profile) {
Instance: p.instance,
OGMeta: apiutil.OGBase(p.instance).WithAccount(p.account),
Stylesheets: stylesheets,
- Javascript: []string{jsFrontend},
+ Javascript: []apiutil.JavascriptEntry{
+ {
+ Src: jsFrontend,
+ Async: true,
+ Defer: true,
+ },
+ {
+ Bottom: true,
+ Src: jsBlurhash,
+ },
+ },
Extra: map[string]any{
"account": p.account,
"rssFeed": p.rssFeed,
@@ -294,7 +315,17 @@ func (m *Module) profileGallery(c *gin.Context, p *profile) {
Instance: p.instance,
OGMeta: apiutil.OGBase(p.instance).WithAccount(p.account),
Stylesheets: stylesheets,
- Javascript: []string{jsFrontend},
+ Javascript: []apiutil.JavascriptEntry{
+ {
+ Src: jsFrontend,
+ Async: true,
+ Defer: true,
+ },
+ {
+ Bottom: true,
+ Src: jsBlurhash,
+ },
+ },
Extra: map[string]any{
"account": p.account,
"rssFeed": p.rssFeed,
diff --git a/internal/web/settings-panel.go b/internal/web/settings-panel.go
index ec8166e95..9b27fe871 100644
--- a/internal/web/settings-panel.go
+++ b/internal/web/settings-panel.go
@@ -54,7 +54,13 @@ func (m *Module) SettingsPanelHandler(c *gin.Context) {
cssStatus, // Used for rendering stub/fake statuses.
cssSettings,
},
- Javascript: []string{jsSettings},
+ Javascript: []apiutil.JavascriptEntry{
+ {
+ Src: jsSettings,
+ Async: true,
+ Defer: true,
+ },
+ },
}
apiutil.TemplateWebPage(c, page)
diff --git a/internal/web/thread.go b/internal/web/thread.go
index 60f7ac4d2..0b296a75b 100644
--- a/internal/web/thread.go
+++ b/internal/web/thread.go
@@ -146,7 +146,17 @@ func (m *Module) threadGETHandler(c *gin.Context) {
Instance: instance,
OGMeta: apiutil.OGBase(instance).WithStatus(context.Status),
Stylesheets: stylesheets,
- Javascript: []string{jsFrontend},
+ Javascript: []apiutil.JavascriptEntry{
+ {
+ Src: jsFrontend,
+ Async: true,
+ Defer: true,
+ },
+ {
+ Bottom: true,
+ Src: jsBlurhash,
+ },
+ },
Extra: map[string]any{
"context": context,
},
diff --git a/internal/web/web.go b/internal/web/web.go
index dbfc2a3b5..15814942a 100644
--- a/internal/web/web.go
+++ b/internal/web/web.go
@@ -68,6 +68,7 @@ const (
cssTag = distPathPrefix + "/tag.css"
jsFrontend = distPathPrefix + "/frontend.js" // Progressive enhancement frontend JS.
+ jsBlurhash = distPathPrefix + "/blurhash.js" // Blurhash rendering JS.
jsSettings = distPathPrefix + "/settings.js" // Settings panel React application.
)