From 5ff9457ee3d2f1c636da8d13c47c608543d2e5f7 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Thu, 29 Jun 2017 14:53:15 -0400 Subject: Worked on style of blog posts --- .gitignore | 1 + app/assets/stylesheets/application.css.scss | 16 +++++++++ app/assets/stylesheets/entries.scss | 54 +++++++++++++++++++++++++++++ app/controllers/entries_controller.rb | 21 ++++++++++- app/views/entries/show.html.haml | 4 +-- config/routes.rb | 3 ++ 6 files changed, 96 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 164d25a..33232cd 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,4 @@ tags .byebug_history .DS_Store +*.swo diff --git a/app/assets/stylesheets/application.css.scss b/app/assets/stylesheets/application.css.scss index 6ec040a..0fa0535 100644 --- a/app/assets/stylesheets/application.css.scss +++ b/app/assets/stylesheets/application.css.scss @@ -16,6 +16,8 @@ */ @import url('https://fonts.googleapis.com/css?family=Inconsolata'); +@import url('https://fonts.googleapis.com/css?family=Slabo+27px'); +@import url('https://fonts.googleapis.com/css?family=Roboto:400,700'); body#main-body { background-color: #bfefff; @@ -207,3 +209,17 @@ body#userdata-body { .sidebar-module a:visited { color: #352712; } + +.breadcrumb { + margin-left: 1em; + + a, a:visited { + color: #555d66; + text-decoration: none; + font-size: .75em; + } + + a:hover { + text-decoration: underline; + } +} diff --git a/app/assets/stylesheets/entries.scss b/app/assets/stylesheets/entries.scss index f779b1b..6833141 100644 --- a/app/assets/stylesheets/entries.scss +++ b/app/assets/stylesheets/entries.scss @@ -1,3 +1,57 @@ // Place all the styles related to the Entries controller here. // They will automatically be included in application.css. // You can use Sass (SCSS) here: http://sass-lang.com/ + +#blog-post { + font-size: 16px; + line-height: 24px; + margin: 0 3em; + + h2 { + font-size: 45px; + line-height: 48px; + margin-top: .5em; + } + + h3 { + font-size: 37px; + line-height: 42px; + } + + h2, h3 { + font-family: 'Slabo 27px', serif; + margin-bottom: 0; + font-weight: normal; + } + + #blog-content { + hyphens: auto; + word-wrap: break-word; + font-family: 'Roboto', sans-serif; + text-align: justify; + + a { + text-decoration: none; + font-weight: bold; + + &, &:visited { + color: #ee2c2c; + } + + &:hover { + text-decoration: underline; + color: #9ea1ad; + } + } + + li { + & + li { + margin-top: 1em; + } + } + + img { + max-width: 100%; + } + } +} diff --git a/app/controllers/entries_controller.rb b/app/controllers/entries_controller.rb index 89d06c0..366de53 100644 --- a/app/controllers/entries_controller.rb +++ b/app/controllers/entries_controller.rb @@ -1,7 +1,26 @@ class EntriesController < ApplicationController + before_action :authenticate_user!, only: [:edit, :update] def show - @entry = Entry.where(directory: params[:directory], slug: params[:slug]).first + @entry = Entry.where(slug: params[:slug]).first end + def edit + @entry = Entry.where(slug: params[:slug]).first + end + + def update + @entry = Entry.where(slug: params[:slug]).first + + if @entry.update_attributes(entry_params) + flash.notice = "" + end + end + + private + + def entry_params + params.require(:blog).permit(:title, :body, :slug) + end + end diff --git a/app/views/entries/show.html.haml b/app/views/entries/show.html.haml index 8a2a2a9..3a9337c 100644 --- a/app/views/entries/show.html.haml +++ b/app/views/entries/show.html.haml @@ -1,2 +1,2 @@ -

Entries#show

-

Find me in app/views/entries/show.html.erb

+.breadcrumb= link_to "← Back to home page", root_path += render @entry diff --git a/config/routes.rb b/config/routes.rb index 9c94f8a..e409840 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -4,6 +4,9 @@ Rails.application.routes.draw do root "records#index" get 'says/:slug', to: 'entries#show' + get 'says/:slug/edit', to: 'entries#edit' + put 'says/:slug', to: 'entries#update' + patch 'says/:slug', to: 'entries#update' # get ':directory/:slug', to: 'entries#show', constraints: lambda { |request| # Entry::DIRECTORIES.include? request.path_parameters['directory'] -- cgit 1.4.1