diff options
Diffstat (limited to 'views/new.templ')
-rw-r--r-- | views/new.templ | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/views/new.templ b/views/new.templ new file mode 100644 index 0000000..c83a4a9 --- /dev/null +++ b/views/new.templ @@ -0,0 +1,51 @@ +package views + +import ( + "fmt" + "gitrepo.ru/neonxp/gorum/models" + "gitrepo.ru/neonxp/gorum/utils" + "strconv" +) + +templ NewPost(parent *models.Node) { + @Layout(parent.Parent) { + <article> + <header class="post-header"> + <span> + { parent.Author.Username } + </span> + <span> + { utils.FormatDate(parent.CreatedAt) } + </span> + </header> + @templ.Raw(utils.MarkdownToHTML(parent.Text)) + </article> + @NewPostForm(parent) + } +} +templ NewTopic(parent *models.Node) { + @Layout(parent.Parent) { + <h1>{parent.Text}</h1> + @NewTopicForm(parent) + } +} + +templ NewPostForm(parent *models.Node) { + <form method="post" action={ templ.URL(fmt.Sprintf("/p/%d/new", parent.ID)) }> + @CSRF() + <input type="hidden" name="type" value={ strconv.Itoa(int(models.PostType)) }/> + <label for="text"><strong>Ответ</strong></label> + <textarea name="text" id="text" placeholder="текст..." rows="5"></textarea> + <input type="submit" value="Создать"/> + </form> +} + +templ NewTopicForm(parent *models.Node) { + <form method="post" action={ templ.URL(fmt.Sprintf("/t/%d/new", parent.ID)) }> + @CSRF() + <input type="hidden" name="type" value={ strconv.Itoa(int(models.TopicType)) }/> + <label for="text"><strong>Новая тема</strong></label> + <input type="text" name="text" id="text" placeholder="название темы..." /> + <input type="submit" value="Создать"/> + </form> +} |