diff options
Diffstat (limited to 'cmd/web/templates/home')
-rw-r--r-- | cmd/web/templates/home/htmx-home-feed.tmpl | 3 | ||||
-rw-r--r-- | cmd/web/templates/home/htmx-home-page.tmpl | 3 | ||||
-rw-r--r-- | cmd/web/templates/home/index.tmpl | 45 | ||||
-rw-r--r-- | cmd/web/templates/home/partials/article-favorite-button.tmpl | 6 | ||||
-rw-r--r-- | cmd/web/templates/home/partials/feed-navigation.tmpl | 17 | ||||
-rw-r--r-- | cmd/web/templates/home/partials/pagination.tmpl | 18 | ||||
-rw-r--r-- | cmd/web/templates/home/partials/post-preview.tmpl | 60 | ||||
-rw-r--r-- | cmd/web/templates/home/partials/tag-item-list.tmpl | 12 |
8 files changed, 164 insertions, 0 deletions
diff --git a/cmd/web/templates/home/htmx-home-feed.tmpl b/cmd/web/templates/home/htmx-home-feed.tmpl new file mode 100644 index 0000000..eb24863 --- /dev/null +++ b/cmd/web/templates/home/htmx-home-feed.tmpl @@ -0,0 +1,3 @@ +{{ template "home/partials/post-preview" . }} +{{ template "home/partials/feed-navigation" . }} +{{ template "home/partials/pagination" . }}
\ No newline at end of file diff --git a/cmd/web/templates/home/htmx-home-page.tmpl b/cmd/web/templates/home/htmx-home-page.tmpl new file mode 100644 index 0000000..575f328 --- /dev/null +++ b/cmd/web/templates/home/htmx-home-page.tmpl @@ -0,0 +1,3 @@ +{{ template "home/index" . }} +{{ template "components/navbar" . }} +{{ template "components/head" . }}
\ No newline at end of file diff --git a/cmd/web/templates/home/index.tmpl b/cmd/web/templates/home/index.tmpl new file mode 100644 index 0000000..65fee1d --- /dev/null +++ b/cmd/web/templates/home/index.tmpl @@ -0,0 +1,45 @@ +<div class="home-page"> + <div class="banner"> + <div class="container"> + <h1 class="logo-font">Projecty</h1> + <p>A place to share your projects.</p> + </div> + </div> + + <div class="container page"> + <div class="row"> + + <div class="col-md-9"> + <div class="feed-toggle"> + <ul id="feed-navigation" class="nav nav-pills outline-active"></ul> + </div> + + <div id="feed-post-preview" + hx-trigger="load" + + {{ if .Tag }} + hx-get="/htmx/home/tag-feed/{{ .TagSlug }}?page={{ .CurrentPage }}" + {{ else if .Personal }} + hx-get="/htmx/home/your-feed?page={{ .CurrentPage }}" + {{ else }} + hx-get="/htmx/home/global-feed?page={{ .CurrentPage }}" + {{ end }} + ></div> + + <nav id="feed-pagination"></nav> + </div> + + <div class="col-md-3"> + <div class="sidebar"> + <p>Popular Tags</p> + + <div id="popular-tag-list" class="tag-list" + hx-trigger="load" + hx-get="/htmx/home/tag-list" + ></div> + </div> + </div> + + </div> + </div> +</div> diff --git a/cmd/web/templates/home/partials/article-favorite-button.tmpl b/cmd/web/templates/home/partials/article-favorite-button.tmpl new file mode 100644 index 0000000..c26226a --- /dev/null +++ b/cmd/web/templates/home/partials/article-favorite-button.tmpl @@ -0,0 +1,6 @@ +<button class="btn btn-outline-primary btn-sm pull-xs-right {{ if .IsFavorited }} active {{ end }}" + hx-post="/htmx/home/articles/{{ .Slug }}/favorite" + hx-swap="outerHTML" +> + <i class="ion-heart"></i> {{ .GetFavoriteCount }} +</button>
\ No newline at end of file diff --git a/cmd/web/templates/home/partials/feed-navigation.tmpl b/cmd/web/templates/home/partials/feed-navigation.tmpl new file mode 100644 index 0000000..0a2356a --- /dev/null +++ b/cmd/web/templates/home/partials/feed-navigation.tmpl @@ -0,0 +1,17 @@ +<ul id="feed-navigation" class="nav nav-pills outline-active" hx-swap-oob="true"> + {{ range $item := .FeedNavbarItems }} + <li class="nav-item"> + <a class="nav-link {{ if $item.IsActive }} active {{ end }}" + {{ if not $item.IsActive }} + href="{{ $item.HXPushURL }}" + hx-get="{{ $item.HXGetURL }}" + hx-trigger="click" + hx-target="#feed-post-preview" + hx-push-url="{{ $item.HXPushURL }}" + {{ end }} + > + {{ $item.Title }} + </a> + </li> + {{ end }} +</ul>
\ No newline at end of file diff --git a/cmd/web/templates/home/partials/pagination.tmpl b/cmd/web/templates/home/partials/pagination.tmpl new file mode 100644 index 0000000..2ca4042 --- /dev/null +++ b/cmd/web/templates/home/partials/pagination.tmpl @@ -0,0 +1,18 @@ +<nav id="feed-pagination" hx-swap-oob="true"> + {{ if .HasPagination }} + {{ $CurrentPagination := .CurrentPagination }} + {{ $PathPagination := .PathPagination }} + {{ $PushPathPagination := .PushPathPagination }} + <ul class="pagination"> + {{ range $index := Iterate 1 .TotalPagination }} + <li class="page-item {{ if eq $CurrentPagination $index }} active {{ end }}"> + <a class="page-link" + href="/{{ $PathPagination }}?page={{ $index }}" + hx-push-url="/{{ $PushPathPagination }}?page={{ $index }}" + hx-get="/htmx/home/{{ $PathPagination }}?page={{ $index }}" + >{{ $index }}</a> + </li> + {{ end }} + </ul> + {{ end }} +</nav> diff --git a/cmd/web/templates/home/partials/post-preview.tmpl b/cmd/web/templates/home/partials/post-preview.tmpl new file mode 100644 index 0000000..7ef2111 --- /dev/null +++ b/cmd/web/templates/home/partials/post-preview.tmpl @@ -0,0 +1,60 @@ +<div id="feed-post-preview" hx-swap-oob="true"> + {{ if .HasArticles }} + {{ range $article := .Articles }} + + <div class="post-preview"> + <div class="post-meta"> + <a href="/users/{{ $article.User.Username }}" + hx-push-url="/users/{{ $article.User.Username }}" + hx-get="/htmx/users/{{ $article.User.Username }}" + hx-target="#app-body" + > + <img src="{{ $article.User.Image }}" /> + </a> + + <div class="info"> + <a href="/users/{{ $article.User.Username }}" + hx-push-url="/users/{{ $article.User.Username }}" + hx-get="/htmx/users/{{ $article.User.Username }}" + hx-target="#app-body" + class="author" + > + {{ $article.User.Name }} + </a> + <span class="date">{{ $article.GetFormattedCreatedAt }}</span> + </div> + + {{ template "home/partials/article-favorite-button" $article }} + + </div> + <a href="/articles/{{ $article.Slug }}" + hx-push-url="/articles/{{ $article.Slug }}" + hx-get="/htmx/articles/{{ $article.Slug }}" + hx-target="#app-body" + class="preview-link" + > + <h1>{{ $article.Title }}</h1> + <p>{{ $article.Description }}</p> + + <div class="m-t-1"> + <span>Read more...</span> + + <ul class="tag-list"> + {{ range $tag := $article.Tags }} + <li class="tag-default tag-pill tag-outline">{{ $tag.Name }}</li> + {{ end }} + </ul> + </div> + </a> + </div> + {{ end }} + {{ end }} + + {{ if not .HasArticles }} + <div class="post-preview"> + <div class="alert alert-warning" role="alert"> + No articles are here... yet. + </div> + </div> + {{ end }} +</div>
\ No newline at end of file diff --git a/cmd/web/templates/home/partials/tag-item-list.tmpl b/cmd/web/templates/home/partials/tag-item-list.tmpl new file mode 100644 index 0000000..eac4e53 --- /dev/null +++ b/cmd/web/templates/home/partials/tag-item-list.tmpl @@ -0,0 +1,12 @@ +<div id="popular-tag-list" class="tag-list" hx-swap-oob="true"> + {{ if .HasTags }} + {{ range $tag := .Tags }} + <a class="label label-pill label-default" + href="/tag-feed/{{ $tag.Name }}" + hx-get="/htmx/home/tag-feed/{{ $tag.Name }}" + hx-target="#feed-post-preview" + hx-push-url="/tag-feed/{{ $tag.Name }}" + >{{ $tag.Name }}</a> + {{ end }} + {{ end }} +</div>
\ No newline at end of file |