diff options
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | app/assets/stylesheets/application.css.scss | 16 | ||||
-rw-r--r-- | app/assets/stylesheets/entries.scss | 54 | ||||
-rw-r--r-- | app/controllers/entries_controller.rb | 21 | ||||
-rw-r--r-- | app/views/entries/show.html.haml | 4 | ||||
-rw-r--r-- | 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 | |||
25 | 25 | ||
26 | .byebug_history | 26 | .byebug_history |
27 | .DS_Store | 27 | .DS_Store |
28 | *.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 @@ | |||
16 | */ | 16 | */ |
17 | 17 | ||
18 | @import url('https://fonts.googleapis.com/css?family=Inconsolata'); | 18 | @import url('https://fonts.googleapis.com/css?family=Inconsolata'); |
19 | @import url('https://fonts.googleapis.com/css?family=Slabo+27px'); | ||
20 | @import url('https://fonts.googleapis.com/css?family=Roboto:400,700'); | ||
19 | 21 | ||
20 | body#main-body { | 22 | body#main-body { |
21 | background-color: #bfefff; | 23 | background-color: #bfefff; |
@@ -207,3 +209,17 @@ body#userdata-body { | |||
207 | .sidebar-module a:visited { | 209 | .sidebar-module a:visited { |
208 | color: #352712; | 210 | color: #352712; |
209 | } | 211 | } |
212 | |||
213 | .breadcrumb { | ||
214 | margin-left: 1em; | ||
215 | |||
216 | a, a:visited { | ||
217 | color: #555d66; | ||
218 | text-decoration: none; | ||
219 | font-size: .75em; | ||
220 | } | ||
221 | |||
222 | a:hover { | ||
223 | text-decoration: underline; | ||
224 | } | ||
225 | } | ||
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 @@ | |||
1 | // Place all the styles related to the Entries controller here. | 1 | // Place all the styles related to the Entries controller here. |
2 | // They will automatically be included in application.css. | 2 | // They will automatically be included in application.css. |
3 | // You can use Sass (SCSS) here: http://sass-lang.com/ | 3 | // You can use Sass (SCSS) here: http://sass-lang.com/ |
4 | |||
5 | #blog-post { | ||
6 | font-size: 16px; | ||
7 | line-height: 24px; | ||
8 | margin: 0 3em; | ||
9 | |||
10 | h2 { | ||
11 | font-size: 45px; | ||
12 | line-height: 48px; | ||
13 | margin-top: .5em; | ||
14 | } | ||
15 | |||
16 | h3 { | ||
17 | font-size: 37px; | ||
18 | line-height: 42px; | ||
19 | } | ||
20 | |||
21 | h2, h3 { | ||
22 | font-family: 'Slabo 27px', serif; | ||
23 | margin-bottom: 0; | ||
24 | font-weight: normal; | ||
25 | } | ||
26 | |||
27 | #blog-content { | ||
28 | hyphens: auto; | ||
29 | word-wrap: break-word; | ||
30 | font-family: 'Roboto', sans-serif; | ||
31 | text-align: justify; | ||
32 | |||
33 | a { | ||
34 | text-decoration: none; | ||
35 | font-weight: bold; | ||
36 | |||
37 | &, &:visited { | ||
38 | color: #ee2c2c; | ||
39 | } | ||
40 | |||
41 | &:hover { | ||
42 | text-decoration: underline; | ||
43 | color: #9ea1ad; | ||
44 | } | ||
45 | } | ||
46 | |||
47 | li { | ||
48 | & + li { | ||
49 | margin-top: 1em; | ||
50 | } | ||
51 | } | ||
52 | |||
53 | img { | ||
54 | max-width: 100%; | ||
55 | } | ||
56 | } | ||
57 | } | ||
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 @@ | |||
1 | class EntriesController < ApplicationController | 1 | class EntriesController < ApplicationController |
2 | before_action :authenticate_user!, only: [:edit, :update] | ||
2 | 3 | ||
3 | def show | 4 | def show |
4 | @entry = Entry.where(directory: params[:directory], slug: params[:slug]).first | 5 | @entry = Entry.where(slug: params[:slug]).first |
5 | end | 6 | end |
6 | 7 | ||
8 | def edit | ||
9 | @entry = Entry.where(slug: params[:slug]).first | ||
10 | end | ||
11 | |||
12 | def update | ||
13 | @entry = Entry.where(slug: params[:slug]).first | ||
14 | |||
15 | if @entry.update_attributes(entry_params) | ||
16 | flash.notice = "" | ||
17 | end | ||
18 | end | ||
19 | |||
20 | private | ||
21 | |||
22 | def entry_params | ||
23 | params.require(:blog).permit(:title, :body, :slug) | ||
24 | end | ||
25 | |||
7 | end | 26 | 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 @@ | |||
1 | <h1>Entries#show</h1> | 1 | .breadcrumb= link_to "← Back to home page", root_path |
2 | <p>Find me in app/views/entries/show.html.erb</p> | 2 | = 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 | |||
4 | root "records#index" | 4 | root "records#index" |
5 | 5 | ||
6 | get 'says/:slug', to: 'entries#show' | 6 | get 'says/:slug', to: 'entries#show' |
7 | get 'says/:slug/edit', to: 'entries#edit' | ||
8 | put 'says/:slug', to: 'entries#update' | ||
9 | patch 'says/:slug', to: 'entries#update' | ||
7 | 10 | ||
8 | # get ':directory/:slug', to: 'entries#show', constraints: lambda { |request| | 11 | # get ':directory/:slug', to: 'entries#show', constraints: lambda { |request| |
9 | # Entry::DIRECTORIES.include? request.path_parameters['directory'] | 12 | # Entry::DIRECTORIES.include? request.path_parameters['directory'] |