Skip to content

Commit

Permalink
Rename renderer => builder
Browse files Browse the repository at this point in the history
  • Loading branch information
benpate committed Mar 12, 2024
1 parent 3d27e1b commit b285b02
Show file tree
Hide file tree
Showing 197 changed files with 1,769 additions and 1,769 deletions.
4 changes: 2 additions & 2 deletions _embed/templates/admin-connections/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@

<div class="pure-g">

{{- $renderer := . -}}
{{- $builder := . -}}
{{- range .Providers -}}
{{ $client := $renderer.Client .Value }}
{{ $client := $builder.Client .Value }}
{{- if eq .Group "OAUTH" -}}
<div class="pure-u-1 pure-u-md-1-2 pure-u-lg-1-3 pure-u-xl-1-4">
<div class="card align-center">
Expand Down
6 changes: 3 additions & 3 deletions _embed/templates/stream-outbox-message/replies.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{{- $publishedDate := .QueryParam "published" -}}
{{- $pageSize := 12 -}}

{{- $renderer := . -}}
{{- $builder := . -}}
{{- $replies := .RepliesBefore $publishedDate $pageSize -}}

{{- if eq $replies.Length $pageSize -}}
Expand Down Expand Up @@ -71,8 +71,8 @@
</div>
</div>

{{- if $renderer.IsAuthenticated -}}
{{- if $renderer.NotMe $object.Actor.ID -}}
{{- if $builder.IsAuthenticated -}}
{{- if $builder.NotMe $object.Actor.ID -}}
<div class="text-xs margin-left-md nowrap">
<span
hx-get="/@me/inbox/actor-button?url={{$object.Actor.ID}}"
Expand Down
2 changes: 1 addition & 1 deletion _embed/templates/stream-outbox-reply/create.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!-- Arguments collected from renderer data -->
<!-- Arguments collected from builder data -->
{{- $postTo := .GetString "postTo" | addQueryParams "templateId=outbox-reply" -}}

<form id="outbox-message" hx-post="{{$postTo}}" hx-push-url="false" hx-indicator="#outbox-message" data-script="
Expand Down
12 changes: 6 additions & 6 deletions _embed/templates/user-inbox/actor-button.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

<span hx-get="/@me/inbox/actor-button?{{.QueryString}}" hx-trigger="refresh" hx-target="this" hx-swap="outerHTML" script="install refreshPeers(id:'{{$url}}')">
{{- if not $following.IsNew -}}
{{- $subRenderer := .SubRenderer $following -}}
{{- template "actor-button-follow" $subRenderer -}}
{{- $subBuilder := .SubBuilder $following -}}
{{- template "actor-button-follow" $subBuilder -}}

{{- else -}}
{{- $rule := .HasRule "ACTOR" $url -}}
Expand All @@ -13,12 +13,12 @@
{{- template "actor-button-none" . -}}

{{- else if eq "MUTE" $rule.Action -}}
{{- $subRenderer := .SubRenderer $rule -}}
{{- template "actor-button-mute" $subRenderer -}}
{{- $subBuilder := .SubBuilder $rule -}}
{{- template "actor-button-mute" $subBuilder -}}

{{- else if eq "BLOCK" $rule.Action -}}
{{- $subRenderer := .SubRenderer $rule -}}
{{- template "actor-button-block" $subRenderer -}}
{{- $subBuilder := .SubBuilder $rule -}}
{{- template "actor-button-block" $subBuilder -}}

{{- else -}}
{{- template "actor-button-none" . -}}
Expand Down
10 changes: 5 additions & 5 deletions _embed/templates/user-inbox/list-before.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

{{- $internalID := .QueryParam "origin.followingId" -}}
{{- $layout := $folder.Layout | lowerCase -}}
{{- $inboxRenderer := . -}}
{{- $inboxBuilder := . -}}

{{- if eq 12 (len $inbox) -}}
<div
Expand All @@ -36,13 +36,13 @@
tabIndex="0">

{{- if eq "SOCIAL" $folder.Layout -}}
{{- template "list-social" (array $inboxRenderer $message) -}}
{{- template "list-social" (array $inboxBuilder $message) -}}
{{- else if eq "NEWSPAPER" $folder.Layout -}}
{{- template "list-newspaper" (array $inboxRenderer $message) -}}
{{- template "list-newspaper" (array $inboxBuilder $message) -}}
{{- else if eq "MAGAZINE" $folder.Layout -}}
{{- template "list-magazine" (array $inboxRenderer $message) -}}
{{- template "list-magazine" (array $inboxBuilder $message) -}}
{{- else -}}
{{- template "list-social" (array $inboxRenderer $message) -}}
{{- template "list-social" (array $inboxBuilder $message) -}}
{{- end -}}
</div>

Expand Down
4 changes: 2 additions & 2 deletions _embed/templates/user-inbox/list-magazine.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{- $inboxRenderer := index . 0 -}}
{{- $inboxBuilder := index . 0 -}}
{{- $message := index . 1 -}}
{{- $stream := $inboxRenderer.ActivityStream $message.URL -}}
{{- $stream := $inboxBuilder.ActivityStream $message.URL -}}
{{- $image := $stream.ImageOrIcon -}}

<div class="margin-bottom">
Expand Down
4 changes: 2 additions & 2 deletions _embed/templates/user-inbox/list-newspaper.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{- $inboxRenderer := index . 0 -}}
{{- $inboxBuilder := index . 0 -}}
{{- $message := index . 1 -}}
{{- $stream := $inboxRenderer.ActivityStream $message.URL -}}
{{- $stream := $inboxBuilder.ActivityStream $message.URL -}}
{{- $image := $stream.IconOrImage -}}
<div class="flex-row margin-bottom" style="justify-content:space-between;" hx-push-url="true">

Expand Down
4 changes: 2 additions & 2 deletions _embed/templates/user-inbox/list-social.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{{- $inboxRenderer := index . 0 -}}
{{- $inboxBuilder := index . 0 -}}
{{- $message := index . 1 -}}
{{- $stream := $inboxRenderer.ActivityStream $message.URL -}}
{{- $stream := $inboxBuilder.ActivityStream $message.URL -}}
{{- $image := $stream.ImageOrIcon -}}
{{- $attributedTo := $stream.AttributedTo -}}

Expand Down
10 changes: 5 additions & 5 deletions _embed/templates/user-inbox/list.html
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

{{- if gt (len $inbox) 0 -}}

{{- $inboxRenderer := . -}}
{{- $inboxBuilder := . -}}
{{- range $index, $message := $inbox -}}

<div
Expand All @@ -42,13 +42,13 @@
script="install listItem(messageId:'{{.MessageID.Hex}}')">

{{- if eq "SOCIAL" $folder.Layout -}}
{{- template "list-social" (array $inboxRenderer $message) -}}
{{- template "list-social" (array $inboxBuilder $message) -}}
{{- else if eq "NEWSPAPER" $folder.Layout -}}
{{- template "list-newspaper" (array $inboxRenderer $message) -}}
{{- template "list-newspaper" (array $inboxBuilder $message) -}}
{{- else if eq "MAGAZINE" $folder.Layout -}}
{{- template "list-magazine" (array $inboxRenderer $message) -}}
{{- template "list-magazine" (array $inboxBuilder $message) -}}
{{- else -}}
{{- template "list-social" (array $inboxRenderer $message) -}}
{{- template "list-social" (array $inboxBuilder $message) -}}
{{- end -}}

</div>
Expand Down
4 changes: 2 additions & 2 deletions _embed/templates/user-inbox/responses-replies-list.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{{- $publishedDate := .QueryParam "published" -}}

{{- $pageSize := 4 -}}
{{- $renderer := . -}}
{{- $builder := . -}}

{{- $replies := .RepliesBefore $url $publishedDate $pageSize -}}

Expand Down Expand Up @@ -46,7 +46,7 @@
</span>

{{- if $actor.NotNil -}}
{{- if $renderer.IsMe $object.Actor.ID -}}
{{- if $builder.IsMe $object.Actor.ID -}}
<span class="button" disabled>{{icon "more-horizontal"}}</span>
{{- else -}}
<span
Expand Down
4 changes: 2 additions & 2 deletions _embed/templates/user-inbox/responses-replies-recursive.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
{{- $followingID := .QueryParam "origin.followingId" -}}

{{- $pageSize := 4 -}}
{{- $renderer := . -}}
{{- $builder := . -}}

{{- $replies := .RepliesAfter $url "0" $pageSize -}}

Expand Down Expand Up @@ -39,7 +39,7 @@
hx-trigger="load">
</span>
{{- if $object.Actor.NotNil -}}
{{- if $renderer.IsMe $object.Actor.ID -}}
{{- if $builder.IsMe $object.Actor.ID -}}
<span class="button" disabled>{{icon "more-horizontal"}}</span>
{{- else -}}
<span
Expand Down
8 changes: 4 additions & 4 deletions _embed/templates/user-outbox/outbox-list.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{{- $outboxRenderer := . -}}
{{- $outboxBuilder := . -}}
{{- $outbox := .Outbox.Top12.ByPublishDate.Reverse.Slice -}}

{{- if ne 0 (len $outbox) -}}
{{- $last := $outbox.Last -}}
{{- $isMyself := .IsMyself -}}

{{- range $index, $stream := $outbox -}}
{{- $document := $outboxRenderer.ActivityStream $stream.URL -}}
{{- $document := $outboxBuilder.ActivityStream $stream.URL -}}
<hr>
<div class="hover-trigger flex-row">
<div script="on click go to url '/{{$stream.ID}}'" role="link" class="flex-grow-1 flex-row h-entry margin-bottom turboclick">
Expand All @@ -26,15 +26,15 @@
<div class="text-sm text-light-gray p-published">{{$stream.PublishDate | humanizeTime}}</div>
</div>
</div>
{{- if $outboxRenderer.UserCan "edit" -}}
{{- if $outboxBuilder.UserCan "edit" -}}
<div class="text-sm">
<button hx-get="/{{$stream.ID}}/edit">Edit</button>
</div>
{{- end -}}
</div>
{{- end -}}

<div hx-get="{{$outboxRenderer.ProfileURL}}/outbox-list?publishDate=LT:{{$last.PublishDate}}" hx-push-url="false" hx-trigger="intersect once" hx-target="this" hx-swap="outerHTML">
<div hx-get="{{$outboxBuilder.ProfileURL}}/outbox-list?publishDate=LT:{{$last.PublishDate}}" hx-push-url="false" hx-trigger="intersect once" hx-target="this" hx-swap="outerHTML">
Loading recent posts...
</div>

Expand Down
8 changes: 4 additions & 4 deletions _embed/templates/user-outbox/replied-list.html
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{{- $outboxRenderer := . -}}
{{- $outboxBuilder := . -}}
{{- $outbox := .Replies.Top12.ByPublishDate.Reverse.Slice -}}

{{- if ne 0 (len $outbox) -}}
{{- $last := $outbox.Last -}}
{{- $isMyself := .IsMyself -}}

{{- range $index, $stream := $outbox -}}
{{- $document := $outboxRenderer.ActivityStream $stream.URL -}}
{{- $document := $outboxBuilder.ActivityStream $stream.URL -}}
<hr>
<div class="hover-trigger flex-row">
<div script="on click go to url '/{{$stream.ID}}'" role="link" class="flex-grow-1 flex-row h-entry margin-bottom turboclick">
Expand All @@ -26,15 +26,15 @@
<div class="text-sm text-light-gray p-published">{{$stream.PublishDate | humanizeTime}}</div>
</div>
</div>
{{- if $outboxRenderer.UserCan "edit" -}}
{{- if $outboxBuilder.UserCan "edit" -}}
<div class="text-sm">
<button hx-get="/{{$stream.ID}}/edit">Edit</button>
</div>
{{- end -}}
</div>
{{- end -}}

<div hx-get="{{$outboxRenderer.ProfileURL}}/outbox-list?publishDate=LT:{{$last.PublishDate}}" hx-push-url="false" hx-trigger="intersect once" hx-target="this" hx-swap="outerHTML">
<div hx-get="{{$outboxBuilder.ProfileURL}}/outbox-list?publishDate=LT:{{$last.PublishDate}}" hx-push-url="false" hx-trigger="intersect once" hx-target="this" hx-swap="outerHTML">
Loading recent posts...
</div>

Expand Down
6 changes: 3 additions & 3 deletions render/render.go → build/build.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
/*
Package render contains render objects, which are passed to HTML templates
Package build contains build objects, which are passed to HTML templates
to generate HTML pages. Render objects wrap a specific model object,
providing some safety against direct access to protected data. Render
objects also include additional methods to query related records in the
database. For example, the "Stream" renderer has queries for `Ancestors`,
database. For example, the "Stream" builder has queries for `Ancestors`,
`Parent`, `Siblings`, and `Children` streams.
This package also contains implementations for all the action steps available
to template designers.
*/
package render
package build
46 changes: 23 additions & 23 deletions render/renderer_.go → build/builder_.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package render
package build

import (
"html/template"
Expand All @@ -13,28 +13,28 @@ import (
"go.mongodb.org/mongo-driver/bson/primitive"
)

// Renderer safely wraps model objects for consumption by an html Template
type Renderer interface {
// Builder safely wraps model objects for consumption by an html Template
type Builder interface {

// Render is the main entry-point for templates to use a Renderer
// Render is the main entry-point for templates to use a Builder
Render() (template.HTML, error) // Render function outputs an HTML template
View(string) (template.HTML, error) // Render function outputs an HTML template

// COMMON API METHODS
Host() string // String representation of the protocol + hostname
Protocol() string // String representation of the HTTP protocol to use when addressing this record (http:// or https://)
Hostname() string // Hostname for this server
Token() string // URL Token of the record being rendered
Token() string // URL Token of the record being builded
NavigationID() string // ID of the Top-Level item to highlight in the navigation.
PageTitle() string // Human-friendly title to put at the top of the page.
Summary() string // Human-friendly summary to put at the top of the page (maybe)
Permalink() string // Permanent link to the record being rendered
Permalink() string // Permanent link to the record being builded
BasePath() string // URL Path of the root of this object, without any additional actions.
URL() string // Complete URL of the requested page
QueryParam(string) string // Query parameter of the requested page
SetQueryParam(string, string) // Sets a queryString parameter
ActionID() string // Token that identifies the action requested via the URL.
Action() model.Action // The pipeline action to be taken by this renderer
Action() model.Action // The pipeline action to be taken by this builder
IsAuthenticated() bool // Returns TRUE if the user is signed in
IsPartialRequest() bool // Returns TRUE if this is an HTMX request for a page fragment
UserCan(string) bool // Returns TRUE if the signed-in user has access to the named action
Expand All @@ -52,21 +52,21 @@ type Renderer interface {
GetContent() template.HTML
SetContent(string)

factory() Factory // The service factory
request() *http.Request // The original http.Request that we are responding to
response() http.ResponseWriter // The original http.ResponseWriter that we are responding to
authorization() model.Authorization // The user's authorization data from the context
service() service.ModelService // The abstracted ModelService the backs this Renderer
templateRole() string // Returns the role that the current template plays in the system. Used for choosing child template.
template() model.Template // The template used for this renderer (if any)
objectType() string // The type of object being rendered
schema() schema.Schema // Schema to use to validate this Object
object() data.Object // Model Object being rendered
objectID() primitive.ObjectID // MongoDB ObjectID of the Object being rendered
getUser() (model.User, error) // Retrieves the currently-logged-in user
lookupProvider() form.LookupProvider // Retrieves the LookupProvider for this user
debug() // Outputs debug information to the console
clone(action string) (Renderer, error) // Creates a new Renderer with the same type and object, but a different action
factory() Factory // The service factory
request() *http.Request // The original http.Request that we are responding to
response() http.ResponseWriter // The original http.ResponseWriter that we are responding to
authorization() model.Authorization // The user's authorization data from the context
service() service.ModelService // The abstracted ModelService the backs this Builder
templateRole() string // Returns the role that the current template plays in the system. Used for choosing child template.
template() model.Template // The template used for this builder (if any)
objectType() string // The type of object being builded
schema() schema.Schema // Schema to use to validate this Object
object() data.Object // Model Object being builded
objectID() primitive.ObjectID // MongoDB ObjectID of the Object being builded
getUser() (model.User, error) // Retrieves the currently-logged-in user
lookupProvider() form.LookupProvider // Retrieves the LookupProvider for this user
debug() // Outputs debug information to the console
clone(action string) (Builder, error) // Creates a new Builder with the same type and object, but a different action

executeTemplate(io.Writer, string, any) error // The HTML template used by this Renderer
executeTemplate(io.Writer, string, any) error // The HTML template used by this Builder
}
Loading

0 comments on commit b285b02

Please sign in to comment.