From 8e15dbd73035c2a2198a2828a20ddcebe0739823 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Tue, 3 Jul 2018 13:58:57 -0400 Subject: Implemented streams Currently there are no links to the pages for editing stream updates, and the admin panel for managing streams could probably have a better look & feel, but here's some basic working functionality. refs #8 --- app/views/admin/blogs/edit.html.haml | 2 +- app/views/admin/blogs/new.html.haml | 2 +- app/views/admin/streams/_form.html.haml | 25 +++++++++++++++++++++++++ app/views/admin/streams/edit.html.haml | 2 ++ app/views/admin/streams/index.html.haml | 13 +++++++++++++ app/views/admin/streams/new.html.haml | 2 ++ app/views/admin/updates/_form.html.haml | 22 ++++++++++++++++++++++ app/views/admin/updates/edit.html.haml | 2 ++ app/views/admin/updates/new.html.haml | 2 ++ app/views/blogs/_blog.html.haml | 2 +- app/views/layouts/admin.html.haml | 4 ++++ app/views/streams/_stream.html.haml | 6 ++++++ app/views/streams/show.html.haml | 2 ++ app/views/updates/_update.html.haml | 3 +++ 14 files changed, 86 insertions(+), 3 deletions(-) create mode 100644 app/views/admin/streams/_form.html.haml create mode 100644 app/views/admin/streams/edit.html.haml create mode 100644 app/views/admin/streams/index.html.haml create mode 100644 app/views/admin/streams/new.html.haml create mode 100644 app/views/admin/updates/_form.html.haml create mode 100644 app/views/admin/updates/edit.html.haml create mode 100644 app/views/admin/updates/new.html.haml create mode 100644 app/views/streams/_stream.html.haml create mode 100644 app/views/streams/show.html.haml create mode 100644 app/views/updates/_update.html.haml (limited to 'app/views') diff --git a/app/views/admin/blogs/edit.html.haml b/app/views/admin/blogs/edit.html.haml index 3f4d412..f356069 100644 --- a/app/views/admin/blogs/edit.html.haml +++ b/app/views/admin/blogs/edit.html.haml @@ -1,2 +1,2 @@ -= form_for @blog, url: admin_blog_url(@blog), html: { id: "blog-form" } do |f| += form_for @blog, url: admin_blog_url(@blog), html: { id: "entry-form" } do |f| = render partial: "form", locals: { f: f } diff --git a/app/views/admin/blogs/new.html.haml b/app/views/admin/blogs/new.html.haml index 914f27b..0005278 100644 --- a/app/views/admin/blogs/new.html.haml +++ b/app/views/admin/blogs/new.html.haml @@ -1,2 +1,2 @@ -= form_for @blog, url: admin_blogs_url, html: { id: "blog-form" } do |f| += form_for @blog, url: admin_blogs_url, html: { id: "entry-form" } do |f| = render partial: "form", locals: { f: f } diff --git a/app/views/admin/streams/_form.html.haml b/app/views/admin/streams/_form.html.haml new file mode 100644 index 0000000..ce457cb --- /dev/null +++ b/app/views/admin/streams/_form.html.haml @@ -0,0 +1,25 @@ +%fieldset#content + .title-field + = f.label :title + = f.text_field :title, placeholder: "Title" + .slug-field + = f.label :slug, "https://feffernoo.se/thinks/" + = f.text_field :slug, placeholder: "insert-slug-here" + .body-field + = f.label :body + = f.cktext_area :body +%fieldset#details + - if f.object.errors.any? + #errors.details-module + %h3 Error! + %ul + - f.object.errors.full_messages.each do |error| + %li= error + .details-module + = f.fields_for :records, Record.new do |builder| + .should-create-record-field + = builder.check_box :_destroy, {checked: false}, "0", "1" + = builder.label :_destroy, "Create record?" + .record-description-field + = builder.text_area :description, placeholder: "record text" + .details-module= f.submit diff --git a/app/views/admin/streams/edit.html.haml b/app/views/admin/streams/edit.html.haml new file mode 100644 index 0000000..1b58331 --- /dev/null +++ b/app/views/admin/streams/edit.html.haml @@ -0,0 +1,2 @@ += form_for @stream, url: admin_stream_url(@stream), html: { id: "entry-form" } do |f| + = render partial: "form", locals: { f: f } diff --git a/app/views/admin/streams/index.html.haml b/app/views/admin/streams/index.html.haml new file mode 100644 index 0000000..c69c6f9 --- /dev/null +++ b/app/views/admin/streams/index.html.haml @@ -0,0 +1,13 @@ +%table#entries + %tr + %th Title + %th Date created + %th + - @streams.each do |stream| + %tr{ class: cycle("even", "odd") } + %td= stream.title + %td= stream.created_at.strftime("%B %d, %Y, %l:%M%P") + %td + %ul.admin-actions + %li= link_to "Edit", edit_admin_stream_url(stream) + %li= link_to "Add Update", new_admin_stream_update_url(stream) diff --git a/app/views/admin/streams/new.html.haml b/app/views/admin/streams/new.html.haml new file mode 100644 index 0000000..52febf5 --- /dev/null +++ b/app/views/admin/streams/new.html.haml @@ -0,0 +1,2 @@ += form_for @stream, url: admin_streams_url, html: { id: "entry-form" } do |f| + = render partial: "form", locals: { f: f } diff --git a/app/views/admin/updates/_form.html.haml b/app/views/admin/updates/_form.html.haml new file mode 100644 index 0000000..9dd8741 --- /dev/null +++ b/app/views/admin/updates/_form.html.haml @@ -0,0 +1,22 @@ +%fieldset#content + .title-field + = f.label :title + = f.text_field :title, value: @stream.title, readonly: true + .body-field + = f.label :body + = f.cktext_area :body +%fieldset#details + - if f.object.errors.any? + #errors.details-module + %h3 Error! + %ul + - f.object.errors.full_messages.each do |error| + %li= error + .details-module + = f.fields_for :records, Record.new do |builder| + .should-create-record-field + = builder.check_box :_destroy, {checked: false}, "0", "1" + = builder.label :_destroy, "Create record?" + .record-description-field + = builder.text_area :description, placeholder: "record text" + .details-module= f.submit diff --git a/app/views/admin/updates/edit.html.haml b/app/views/admin/updates/edit.html.haml new file mode 100644 index 0000000..5651d23 --- /dev/null +++ b/app/views/admin/updates/edit.html.haml @@ -0,0 +1,2 @@ += form_for @update, url: admin_stream_update_url(@stream, @update), html: { id: "entry-form" } do |f| + = render partial: "form", locals: { f: f } diff --git a/app/views/admin/updates/new.html.haml b/app/views/admin/updates/new.html.haml new file mode 100644 index 0000000..14c6d77 --- /dev/null +++ b/app/views/admin/updates/new.html.haml @@ -0,0 +1,2 @@ += form_for @update, url: admin_stream_updates_url(@stream), html: { id: "entry-form" } do |f| + = render partial: "form", locals: { f: f } diff --git a/app/views/blogs/_blog.html.haml b/app/views/blogs/_blog.html.haml index e83d21a..91b1d20 100644 --- a/app/views/blogs/_blog.html.haml +++ b/app/views/blogs/_blog.html.haml @@ -1,3 +1,3 @@ %article#blog-post %h2#blog-title= blog.title - %section#blog-content= blog.body.html_safe + %section#blog-content.entry-content= blog.body.html_safe diff --git a/app/views/layouts/admin.html.haml b/app/views/layouts/admin.html.haml index 7f8c171..68bbd96 100644 --- a/app/views/layouts/admin.html.haml +++ b/app/views/layouts/admin.html.haml @@ -24,5 +24,9 @@ = link_to "Blogs", admin_blogs_url, class: "major-link" %ul.minors %li.minor= link_to "New blog", new_admin_blog_url + %li{major_sidebar_attrs("streams")} + = link_to "Streams", admin_streams_url, class: "major-link" + %ul.minors + %li.minor= link_to "New stream", new_admin_stream_url #main = yield diff --git a/app/views/streams/_stream.html.haml b/app/views/streams/_stream.html.haml new file mode 100644 index 0000000..84a6478 --- /dev/null +++ b/app/views/streams/_stream.html.haml @@ -0,0 +1,6 @@ +%article#stream-post + %h2#stream-title= stream.title + - unless stream.body.blank? + %header#stream-intro.entry-content= stream.body.html_safe + - unless stream.updates.empty? + = render stream.updates diff --git a/app/views/streams/show.html.haml b/app/views/streams/show.html.haml new file mode 100644 index 0000000..dcec0a2 --- /dev/null +++ b/app/views/streams/show.html.haml @@ -0,0 +1,2 @@ +.breadcrumb= link_to "← Back to home page", root_path += render @stream diff --git a/app/views/updates/_update.html.haml b/app/views/updates/_update.html.haml new file mode 100644 index 0000000..c8ce224 --- /dev/null +++ b/app/views/updates/_update.html.haml @@ -0,0 +1,3 @@ +%section.stream-update.entry-content{ id: "update-#{update.id}" } + %time.update-posted= update.created_at.strftime("%b #{update.created_at.day.ordinalize} %Y at %-I:%M:%S%P") + = update.body.html_safe -- cgit 1.4.1