From e47e83cf6bded3d1924b4d500193e7876833ef83 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sun, 2 Jul 2017 13:03:43 -0400 Subject: Created admin panel Currently allows you to create and edit blogs, including associated records. Uses a WYSIWYG editor that allows uploading images. Also included jQuery :( --- app/views/admin/blogs/_form.html.haml | 23 +++++++++++++++++++++++ app/views/admin/blogs/edit.html.haml | 2 ++ app/views/admin/blogs/index.html.haml | 10 ++++++++++ app/views/admin/blogs/new.html.haml | 2 ++ app/views/admin/dashboard/index.html.haml | 1 + app/views/entries/edit.html.haml | 11 ----------- app/views/layouts/admin.html.haml | 27 +++++++++++++++++++++++++++ app/views/layouts/application.html.haml | 1 + 8 files changed, 66 insertions(+), 11 deletions(-) create mode 100644 app/views/admin/blogs/_form.html.haml create mode 100644 app/views/admin/blogs/edit.html.haml create mode 100644 app/views/admin/blogs/index.html.haml create mode 100644 app/views/admin/blogs/new.html.haml create mode 100644 app/views/admin/dashboard/index.html.haml delete mode 100644 app/views/entries/edit.html.haml create mode 100644 app/views/layouts/admin.html.haml (limited to 'app/views') diff --git a/app/views/admin/blogs/_form.html.haml b/app/views/admin/blogs/_form.html.haml new file mode 100644 index 0000000..55a297a --- /dev/null +++ b/app/views/admin/blogs/_form.html.haml @@ -0,0 +1,23 @@ +- if f.object.errors.any? + %ul#errors + - f.object.errors.full_messages.each do |error| + %li= error +%fieldset#content + .title-field + = f.label :title + = f.text_field :title, placeholder: "Title" + .slug-field + = f.label :slug, "https://feffernoo.se/says/" + = f.text_field :slug, placeholder: "insert-slug-here" + .body-field + = f.label :body + = f.cktext_area :body +%fieldset#details + .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/blogs/edit.html.haml b/app/views/admin/blogs/edit.html.haml new file mode 100644 index 0000000..3f4d412 --- /dev/null +++ b/app/views/admin/blogs/edit.html.haml @@ -0,0 +1,2 @@ += form_for @blog, url: admin_blog_url(@blog), html: { id: "blog-form" } do |f| + = render partial: "form", locals: { f: f } diff --git a/app/views/admin/blogs/index.html.haml b/app/views/admin/blogs/index.html.haml new file mode 100644 index 0000000..448617a --- /dev/null +++ b/app/views/admin/blogs/index.html.haml @@ -0,0 +1,10 @@ +%table#entries + %tr + %th Title + %th Date created + %th + - @blogs.each do |blog| + %tr{ class: cycle("even", "odd") } + %td= blog.title + %td= blog.created_at.strftime("%B %d, %Y, %l:%M%P") + %td= link_to "Edit", edit_admin_blog_url(blog) diff --git a/app/views/admin/blogs/new.html.haml b/app/views/admin/blogs/new.html.haml new file mode 100644 index 0000000..914f27b --- /dev/null +++ b/app/views/admin/blogs/new.html.haml @@ -0,0 +1,2 @@ += form_for @blog, url: admin_blogs_url, html: { id: "blog-form" } do |f| + = render partial: "form", locals: { f: f } diff --git a/app/views/admin/dashboard/index.html.haml b/app/views/admin/dashboard/index.html.haml new file mode 100644 index 0000000..eaac627 --- /dev/null +++ b/app/views/admin/dashboard/index.html.haml @@ -0,0 +1 @@ +Welcome to the the ubiquitous administration panel! diff --git a/app/views/entries/edit.html.haml b/app/views/entries/edit.html.haml deleted file mode 100644 index 1872366..0000000 --- a/app/views/entries/edit.html.haml +++ /dev/null @@ -1,11 +0,0 @@ -= form_for @entry, url: @entry.path do |f| - .field - = f.label :title - = f.text_field :title - .field - = f.label :body - = f.text_area :body - .field - = f.label :slug - = f.text_field :slug - = f.submit diff --git a/app/views/layouts/admin.html.haml b/app/views/layouts/admin.html.haml new file mode 100644 index 0000000..a2c2d95 --- /dev/null +++ b/app/views/layouts/admin.html.haml @@ -0,0 +1,27 @@ +!!! 5 +%html + %head + %title Thoughts - Admin + = csrf_meta_tags + = stylesheet_link_tag 'admin', media: 'all', 'data-turbolinks-track': 'reload' + = javascript_include_tag 'application', 'data-turbolinks-track': 'reload' + %body + #banner= link_to "Thoughts", root_url + #container + %ul#sidebar + %li{major_sidebar_attrs("dashboard")} + = link_to "Dashboard", admin_url, class: "major-link" + %li{major_sidebar_attrs("blogs")} + = link_to "Blogs", admin_blogs_url, class: "major-link" + %ul.minors + %li.minor= link_to "New blog", new_admin_blog_url + #main + - if flash[:alert] + #flash.flash-alert + %span.flash-tag ERROR: + = flash.alert + - if flash[:notice] + #flash.flash-notice + %span.flash-tag NOTICE: + = flash.notice + = yield diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index 2a9e2eb..5148df4 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -21,6 +21,7 @@ - if not user_signed_in? %li= link_to "Log in", new_user_session_path - if user_signed_in? + %li= link_to "Admin", admin_url %li= link_to "Log out", destroy_user_session_path, method: :delete #main %header#banner= link_to "feffernoo.se", root_url -- cgit 1.4.1