Skip to content

Commit

Permalink
Merge pull request #94 from bmf-san/feature/update-post-design
Browse files Browse the repository at this point in the history
個別記事ページのデザイン調整
  • Loading branch information
bmf-san authored Apr 17, 2024
2 parents 8967106 + 6479047 commit 3a8836d
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 8 deletions.
7 changes: 5 additions & 2 deletions app/controller/post_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -432,8 +432,11 @@ func (pc *PostController) Show() http.Handler {
}

buf, err = pc.Presenter.ExecutePostShow(buf, r, &presenter.PostShow{
Post: &post,
LinkSupport: os.Getenv("BASE_URL") + "/support",
Post: &post,
TwitterShareURL: "https://twitter.com/share?url=" + os.Getenv("BASE_URL") + "/" + post.Title + "&text=" + post.Title + "&via=bmf_san" + "&related=bmf_san",
FacebookShareURL: "http://www.facebook.com/share.php?u=" + os.Getenv("BASE_URL") + "/" + post.Title,
HatenaShareURL: "http://b.hatena.ne.jp/add?mode=confirm&url=" + os.Getenv("BASE_URL") + "/" + post.Title + "&title=" + post.Title,
SupportURL: os.Getenv("BASE_URL") + "/support",
})
if err != nil {
pc.Logger.ErrorContext(r.Context(), err.Error())
Expand Down
7 changes: 5 additions & 2 deletions app/presenter/post.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,11 @@ type PostIndexByTag struct {

// PostShow is a data for show template.
type PostShow struct {
Post *model.Post
LinkSupport string
Post *model.Post
TwitterShareURL string
FacebookShareURL string
HatenaShareURL string
SupportURL string
}

// ExecutePostIndex responses a index template.
Expand Down
2 changes: 1 addition & 1 deletion app/templates/partial/posts.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<article>
<h1 class="font-size-large"><b><a class="color-text" href="/posts/{{ $v.Title }}">{{ $v.Title }}</a></b></h1>
<p class="margin-0rem"><a href="/posts/categories/{{ $v.Category.Name }}">{{ $v.Category.Name }}</a></p>
<span class="article-date">{{ $v.CreatedAt.Format "2006 Jan 02" }}</span>
<span class="article-date">{{ $v.CreatedAt.Format "2006年1月2日" }}</span>
<p>{{ striptags $v.HTMLBody | summary }}</p>
<div>
{{ range $v.Tags }}
Expand Down
13 changes: 10 additions & 3 deletions app/templates/post/show.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<div class="text-align-center">
<h1 class="text-align-center color-text-reverse">{{ .Post.Post.Title }}</h1>
<p><a class="color-text-reverse" href="/posts/categories/{{ .Post.Post.Category.Name }}">{{ .Post.Post.Category.Name }}</a></p>
<p><span class="article-date color-text-reverse">{{ .Post.Post.UpdatedAt.Format "2006年1月2日 01:02:03" }} 更新</span></p>
<p><span class="article-date color-text-reverse padding-1rem">{{ .Post.Post.CreatedAt.Format "2006年1月2日" }} 作成</span><span class="article-date color-text-reverse padding-1rem">{{ .Post.Post.UpdatedAt.Format "2006年1月2日" }} 更新</span></p>
</div>
</div>
</div>
Expand Down Expand Up @@ -58,7 +58,14 @@
</div>
<div class="row">
<div class="col">
<button style="width:100%" onclick="window.open({{ .Post.LinkSupport }})">bmf-tech.comをサポートする!</button>
<a class="tag" href="{{ .Post.TwitterShareURL }}" rel="nofollow noopener" target="_blank">Xにシェアする</a>
<a class="tag" href="{{ .Post.FacebookShareURL }}" rel="nofollow noopener" target="_blank">Facebookにシェアする</a>
<a class="tag" href="{{ .Post.HatenaShareURL }}" rel="nofollow noopener" target="_blank">はてなにシェアする</a>
</div>
</div>
<div class="row">
<div class="col">
<button style="width:100%" onclick="window.open({{ .Post.SupportURL }})">bmf-tech.comをサポートする!</button>
</div>
</div>
<div class="row">
Expand All @@ -74,4 +81,4 @@
{{ end }}
{{ define "script" }}
<script async src="../js/toc.js"></script>
{{ end }}
{{ end }}

0 comments on commit 3a8836d

Please sign in to comment.