diff --git a/model/replyContext.go b/model/replyContext.go new file mode 100644 index 0000000..b17aacb --- /dev/null +++ b/model/replyContext.go @@ -0,0 +1,7 @@ +package model + +type ReplyContext struct { + InReplyToID string + InReplyToName string + ReplyContent string +} diff --git a/renderer/model.go b/renderer/model.go index 053c2fd..ce81e78 100644 --- a/renderer/model.go +++ b/renderer/model.go @@ -2,6 +2,7 @@ package renderer import ( "mastodon" + "web/model" ) type NavbarTemplateData struct { @@ -37,17 +38,15 @@ func NewTimelinePageTemplateData(statuses []*mastodon.Status, hasNext bool, next type ThreadPageTemplateData struct { Statuses []*mastodon.Status - ReplyToID string - ReplyContent string + ReplyContext *model.ReplyContext ReplyMap map[string][]mastodon.ReplyInfo NavbarData *NavbarTemplateData } -func NewThreadPageTemplateData(statuses []*mastodon.Status, replyToID string, replyContent string, replyMap map[string][]mastodon.ReplyInfo, navbarData *NavbarTemplateData) *ThreadPageTemplateData { +func NewThreadPageTemplateData(statuses []*mastodon.Status, replyContext *model.ReplyContext, replyMap map[string][]mastodon.ReplyInfo, navbarData *NavbarTemplateData) *ThreadPageTemplateData { return &ThreadPageTemplateData{ Statuses: statuses, - ReplyToID: replyToID, - ReplyContent: replyContent, + ReplyContext: replyContext, ReplyMap: replyMap, NavbarData: navbarData, } diff --git a/service/service.go b/service/service.go index 4d74449..db7a1d7 100644 --- a/service/service.go +++ b/service/service.go @@ -276,10 +276,9 @@ func (svc *service) ServeThreadPage(ctx context.Context, client io.Writer, c *ma return } - var content string - var replyToID string + var replyContext *model.ReplyContext if reply { - replyToID = id + var content string if u.ID != status.Account.ID { content += "@" + status.Account.Acct + " " } @@ -288,6 +287,11 @@ func (svc *service) ServeThreadPage(ctx context.Context, client io.Writer, c *ma content += "@" + status.Mentions[i].Acct + " " } } + replyContext = &model.ReplyContext{ + InReplyToID: id, + InReplyToName: status.Account.Acct, + ReplyContent: content, + } } context, err := c.GetStatusContext(ctx, id) @@ -310,7 +314,7 @@ func (svc *service) ServeThreadPage(ctx context.Context, client io.Writer, c *ma return } - data := renderer.NewThreadPageTemplateData(statuses, replyToID, content, replyMap, navbarData) + data := renderer.NewThreadPageTemplateData(statuses, replyContext, replyMap, navbarData) err = svc.renderer.RenderThreadPage(ctx, client, data) if err != nil { return diff --git a/static/main.css b/static/main.css index 8341172..4f8d156 100644 --- a/static/main.css +++ b/static/main.css @@ -107,7 +107,7 @@ margin-right: 8px; } -.timeline-post-form { +.post-form { margin: 8px 0; } diff --git a/templates/postform.tmpl b/templates/postform.tmpl new file mode 100644 index 0000000..3f6eeaa --- /dev/null +++ b/templates/postform.tmpl @@ -0,0 +1,16 @@ +
+ diff --git a/templates/thread.tmpl b/templates/thread.tmpl index d4c88de..9d8f650 100644 --- a/templates/thread.tmpl +++ b/templates/thread.tmpl @@ -3,21 +3,11 @@