From ad80c40944743515a45d70014e8d5ffb88cd74fc Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sun, 25 Jun 2017 00:00:28 -0400 Subject: Started designing index page --- app/assets/javascripts/entries.coffee | 3 ++ app/assets/javascripts/records.coffee | 3 ++ app/assets/stylesheets/application.css | 59 +++++++++++++++++++++++++++++++ app/assets/stylesheets/entries.scss | 3 ++ app/assets/stylesheets/records.scss | 61 +++++++++++++++++++++++++++++++++ app/controllers/entries_controller.rb | 7 ++++ app/controllers/records_controller.rb | 7 ++++ app/helpers/entries_helper.rb | 2 ++ app/helpers/records_helper.rb | 2 ++ app/models/blog.rb | 4 +++ app/models/entry.rb | 9 +++++ app/models/record.rb | 5 +++ app/views/entries/show.html.haml | 2 ++ app/views/layouts/application.html.erb | 14 -------- app/views/layouts/application.html.haml | 14 ++++++++ app/views/records/index.html.haml | 7 ++++ 16 files changed, 188 insertions(+), 14 deletions(-) create mode 100644 app/assets/javascripts/entries.coffee create mode 100644 app/assets/javascripts/records.coffee create mode 100644 app/assets/stylesheets/entries.scss create mode 100644 app/assets/stylesheets/records.scss create mode 100644 app/controllers/entries_controller.rb create mode 100644 app/controllers/records_controller.rb create mode 100644 app/helpers/entries_helper.rb create mode 100644 app/helpers/records_helper.rb create mode 100644 app/models/blog.rb create mode 100644 app/models/entry.rb create mode 100644 app/models/record.rb create mode 100644 app/views/entries/show.html.haml delete mode 100644 app/views/layouts/application.html.erb create mode 100644 app/views/layouts/application.html.haml create mode 100644 app/views/records/index.html.haml (limited to 'app') diff --git a/app/assets/javascripts/entries.coffee b/app/assets/javascripts/entries.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/entries.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/javascripts/records.coffee b/app/assets/javascripts/records.coffee new file mode 100644 index 0000000..24f83d1 --- /dev/null +++ b/app/assets/javascripts/records.coffee @@ -0,0 +1,3 @@ +# Place all the behaviors and hooks related to the matching controller here. +# All this logic will automatically be available in application.js. +# You can use CoffeeScript in this file: http://coffeescript.org/ diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css index d05ea0f..6fd12b7 100644 --- a/app/assets/stylesheets/application.css +++ b/app/assets/stylesheets/application.css @@ -10,6 +10,65 @@ * files in this directory. Styles in this file should be added after the last require_* statement. * It is generally better to create a new file per style scope. * + *= require normalize-rails *= require_tree . *= require_self */ + +@import url('https://fonts.googleapis.com/css?family=Inconsolata'); + +body { + background-color: #bfefff; +} + +#container { + margin: 5em auto 0; + width: 50%; + border: 1px solid black; + background-color: white; + box-sizing: border-box; + -webkit-border-top-left-radius: 15px; + -webkit-border-top-right-radius: 15px; + -moz-border-radius-topleft: 15px; + -moz-border-radius-topright: 15px; + border-top-left-radius: 15px; + border-top-right-radius: 15px; +} + +#banner { + width: 100%; + border-bottom: 1px solid black; + padding: 1em; + box-sizing: border-box; +} + +#banner h1 { + text-align: center; + margin: 0; +} + +#banner h1 a { + text-decoration: none; + color: black; +} + +#banner h1 a:visited { + color: black; +} + +#main { + display: -webkit-flex; + display: flex; +} + +#content { + width: 75%; + box-sizing: border-box; + border-right: 1px solid black; +} + +#sidebar { + width: 25%; + box-sizing: border-box; + padding-right: 1em; +} diff --git a/app/assets/stylesheets/entries.scss b/app/assets/stylesheets/entries.scss new file mode 100644 index 0000000..f779b1b --- /dev/null +++ b/app/assets/stylesheets/entries.scss @@ -0,0 +1,3 @@ +// 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/ diff --git a/app/assets/stylesheets/records.scss b/app/assets/stylesheets/records.scss new file mode 100644 index 0000000..0054edd --- /dev/null +++ b/app/assets/stylesheets/records.scss @@ -0,0 +1,61 @@ +// Place all the styles related to the Records controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ + +#records { + padding: 0; + margin: 0 1em; + + & > li { + display: block; + padding: .25em 0; + + .description { + a { + text-decoration: none; + color: black; + font-family: 'Inconsolata', monospace; + + &:hover { + text-decoration: underline; + } + + &:visited { + color: black; + } + } + } + + .tags { + margin: .25em; + display: flex; + padding-left: 0; + + li { + display: inline; + font-size: .75em; + font-family: 'Inconsolata', monospace; + padding: .25em; + -webkit-border-radius: 5px; + -moz-border-radius: 5px; + border-radius: 5px; + + &.record-date { + background-color: #fef1bf; + } + + &.entry-type { + text-transform: uppercase; + + &.entry-type-blog { + background-color: #90fefb; + } + } + + & + li { + margin-left: 1em; + } + } + } + } +} diff --git a/app/controllers/entries_controller.rb b/app/controllers/entries_controller.rb new file mode 100644 index 0000000..89d06c0 --- /dev/null +++ b/app/controllers/entries_controller.rb @@ -0,0 +1,7 @@ +class EntriesController < ApplicationController + + def show + @entry = Entry.where(directory: params[:directory], slug: params[:slug]).first + end + +end diff --git a/app/controllers/records_controller.rb b/app/controllers/records_controller.rb new file mode 100644 index 0000000..200d63c --- /dev/null +++ b/app/controllers/records_controller.rb @@ -0,0 +1,7 @@ +class RecordsController < ApplicationController + + def index + @records = Record.order(created_at: :desc).limit(20) + end + +end diff --git a/app/helpers/entries_helper.rb b/app/helpers/entries_helper.rb new file mode 100644 index 0000000..ed8c595 --- /dev/null +++ b/app/helpers/entries_helper.rb @@ -0,0 +1,2 @@ +module EntriesHelper +end diff --git a/app/helpers/records_helper.rb b/app/helpers/records_helper.rb new file mode 100644 index 0000000..e63c599 --- /dev/null +++ b/app/helpers/records_helper.rb @@ -0,0 +1,2 @@ +module RecordsHelper +end diff --git a/app/models/blog.rb b/app/models/blog.rb new file mode 100644 index 0000000..d2b1c27 --- /dev/null +++ b/app/models/blog.rb @@ -0,0 +1,4 @@ +class Blog < Entry + validates :title, :body, presence: true +end + diff --git a/app/models/entry.rb b/app/models/entry.rb new file mode 100644 index 0000000..22b330a --- /dev/null +++ b/app/models/entry.rb @@ -0,0 +1,9 @@ +class Entry < ApplicationRecord + has_many :records, as: :recordable + + validates :slug, presence: true, format: /\A[-a-z0-9]+\z/ + + def path + "/says/#{slug}" + end +end diff --git a/app/models/record.rb b/app/models/record.rb new file mode 100644 index 0000000..5837702 --- /dev/null +++ b/app/models/record.rb @@ -0,0 +1,5 @@ +class Record < ApplicationRecord + belongs_to :recordable, polymorphic: true + + validates :description, :recordable, presence: true +end diff --git a/app/views/entries/show.html.haml b/app/views/entries/show.html.haml new file mode 100644 index 0000000..8a2a2a9 --- /dev/null +++ b/app/views/entries/show.html.haml @@ -0,0 +1,2 @@ +

Entries#show

+

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

diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb deleted file mode 100644 index 732b30e..0000000 --- a/app/views/layouts/application.html.erb +++ /dev/null @@ -1,14 +0,0 @@ - - - - Thoughts - <%= csrf_meta_tags %> - - <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> - <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> - - - - <%= yield %> - - diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml new file mode 100644 index 0000000..ad1e8df --- /dev/null +++ b/app/views/layouts/application.html.haml @@ -0,0 +1,14 @@ +!!! 5 +%html + %head + %title Thoughts + = csrf_meta_tags + = stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' + = javascript_include_tag 'application', 'data-turbolinks-track': 'reload' + %body + #container + #banner + %h1= link_to "Thoughts", root_url + #main + #content= yield + #sidebar I'm Fef. diff --git a/app/views/records/index.html.haml b/app/views/records/index.html.haml new file mode 100644 index 0000000..29c9dfb --- /dev/null +++ b/app/views/records/index.html.haml @@ -0,0 +1,7 @@ +%ul#records + - @records.each do |record| + %li + %span.description= link_to record.description, record.recordable.path + %ul.tags + %li.record-date= record.created_at.strftime("%m.%e.%y") + %li.entry-type{ class: "entry-type-#{record.recordable.type.downcase}" }= record.recordable.type -- cgit 1.4.1