From 23e030a95d29e5b394687b4a55dd3977b0dd26c2 Mon Sep 17 00:00:00 2001 From: James Mills Date: Sat, 30 Jan 2021 23:50:26 +1000 Subject: [PATCH] Add types package --- internal/context.go | 7 ++- internal/templates/_partials.html | 87 +++---------------------------- types/item.go | 13 +++++ types/results.go | 3 ++ 4 files changed, 29 insertions(+), 81 deletions(-) create mode 100644 types/item.go create mode 100644 types/results.go diff --git a/internal/context.go b/internal/context.go index e5fb575..a659c39 100644 --- a/internal/context.go +++ b/internal/context.go @@ -7,9 +7,11 @@ import ( log "github.com/sirupsen/logrus" "github.com/vcraescu/go-paginator" + "github.com/justinas/nosurf" + "git.mills.io/prologic/spyda" "git.mills.io/prologic/spyda/internal/session" - "github.com/justinas/nosurf" + "git.mills.io/prologic/spyda/types" ) type Meta struct { @@ -50,7 +52,8 @@ type Context struct { Title string Meta Meta - Pager *paginator.Paginator + Results types.Results + Pager *paginator.Paginator // Report abuse ReportURL string diff --git a/internal/templates/_partials.html b/internal/templates/_partials.html index 5140f3e..a4439d9 100644 --- a/internal/templates/_partials.html +++ b/internal/templates/_partials.html @@ -27,84 +27,13 @@ {{ end }} {{ define "item" }} -
-
-
- {{ if $.User.Is $.Twt.Twter.URL }} - - - - {{ else }} - {{ if isLocalURL $.Twt.Twter.URL }} - - - {{ else }} - - {{ if $.Twt.Twter.Avatar }} - - {{ else }} - - {{ end }} - {{ end }} - - {{ end }} -
-
- {{ if $.User.Is $.Twt.Twter.URL }} - me - {{ else }} - {{ if isLocalURL $.Twt.Twter.URL }} - {{ $.Twt.Twter.Nick }} - {{ else }} - - {{ $.Twt.Twter.Nick }} - @{{ $.Twt.Twter.URL | hostnameFromURL }} - - {{ end }} - {{ end }} -
- - - -  ({{ $.Twt.Created | time }}) - {{ if $.Authenticated }} -   - - - - - {{ end }} -
-
-
-
- {{ $.Twt.Text | formatTwt }} -
-
- + {{ end }} @@ -115,7 +44,7 @@ {{ range $idx, $item := $.Results }} {{ template "item" (dict "Item" $item) }} {{ else }} - No search results found. + No search results found. {{ end }} {{ template "pager" $.Pager }} diff --git a/types/item.go b/types/item.go new file mode 100644 index 0000000..66754b9 --- /dev/null +++ b/types/item.go @@ -0,0 +1,13 @@ +package types + +type Item struct { + ID int + Length int + + URL string + Title string + Author string + Summary string + Content string + HTMLContent string +} diff --git a/types/results.go b/types/results.go new file mode 100644 index 0000000..10d7f21 --- /dev/null +++ b/types/results.go @@ -0,0 +1,3 @@ +package types + +type Results []Item