about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rw-r--r--Gemfile3
-rw-r--r--Gemfile.lock7
-rw-r--r--app/assets/javascripts/entries.coffee3
-rw-r--r--app/assets/javascripts/records.coffee3
-rw-r--r--app/assets/stylesheets/application.css59
-rw-r--r--app/assets/stylesheets/entries.scss3
-rw-r--r--app/assets/stylesheets/records.scss61
-rw-r--r--app/controllers/entries_controller.rb7
-rw-r--r--app/controllers/records_controller.rb7
-rw-r--r--app/helpers/entries_helper.rb2
-rw-r--r--app/helpers/records_helper.rb2
-rw-r--r--app/models/blog.rb4
-rw-r--r--app/models/entry.rb9
-rw-r--r--app/models/record.rb5
-rw-r--r--app/views/entries/show.html.haml2
-rw-r--r--app/views/layouts/application.html.erb14
-rw-r--r--app/views/layouts/application.html.haml14
-rw-r--r--app/views/records/index.html.haml7
-rw-r--r--config/routes.rb7
-rw-r--r--db/migrate/20170624183854_create_records.rb10
-rw-r--r--db/migrate/20170625004938_create_entries.rb12
-rw-r--r--db/schema.rb34
-rw-r--r--test/controllers/entries_controller_test.rb9
-rw-r--r--test/controllers/records_controller_test.rb9
-rw-r--r--test/fixtures/entries.yml15
-rw-r--r--test/fixtures/links.yml9
-rw-r--r--test/fixtures/posts.yml9
-rw-r--r--test/fixtures/records.yml7
-rw-r--r--test/models/entry_test.rb7
-rw-r--r--test/models/link_test.rb7
-rw-r--r--test/models/post_test.rb7
-rw-r--r--test/models/record_test.rb7
33 files changed, 350 insertions, 14 deletions
diff --git a/.gitignore b/.gitignore index dcc5b36..7511a24 100644 --- a/.gitignore +++ b/.gitignore
@@ -19,5 +19,8 @@
19 19
20/node_modules 20/node_modules
21/yarn-error.log 21/yarn-error.log
22/tmux*.log
23*.swp
24tags
22 25
23.byebug_history 26.byebug_history
diff --git a/Gemfile b/Gemfile index ed467b0..e2147ef 100644 --- a/Gemfile +++ b/Gemfile
@@ -52,3 +52,6 @@ end
52 52
53# Windows does not include zoneinfo files, so bundle the tzinfo-data gem 53# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
54gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] 54gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
55
56gem 'haml'
57gem 'normalize-rails'
diff --git a/Gemfile.lock b/Gemfile.lock index 7b51875..60b7136 100644 --- a/Gemfile.lock +++ b/Gemfile.lock
@@ -66,6 +66,9 @@ GEM
66 ffi (1.9.18) 66 ffi (1.9.18)
67 globalid (0.4.0) 67 globalid (0.4.0)
68 activesupport (>= 4.2.0) 68 activesupport (>= 4.2.0)
69 haml (5.0.1)
70 temple (>= 0.8.0)
71 tilt
69 i18n (0.8.4) 72 i18n (0.8.4)
70 jbuilder (2.7.0) 73 jbuilder (2.7.0)
71 activesupport (>= 4.2.0) 74 activesupport (>= 4.2.0)
@@ -88,6 +91,7 @@ GEM
88 nio4r (2.1.0) 91 nio4r (2.1.0)
89 nokogiri (1.8.0) 92 nokogiri (1.8.0)
90 mini_portile2 (~> 2.2.0) 93 mini_portile2 (~> 2.2.0)
94 normalize-rails (4.1.1)
91 public_suffix (2.0.5) 95 public_suffix (2.0.5)
92 puma (3.9.1) 96 puma (3.9.1)
93 rack (2.0.3) 97 rack (2.0.3)
@@ -145,6 +149,7 @@ GEM
145 activesupport (>= 4.0) 149 activesupport (>= 4.0)
146 sprockets (>= 3.0.0) 150 sprockets (>= 3.0.0)
147 sqlite3 (1.3.13) 151 sqlite3 (1.3.13)
152 temple (0.8.0)
148 thor (0.19.4) 153 thor (0.19.4)
149 thread_safe (0.3.6) 154 thread_safe (0.3.6)
150 tilt (2.0.7) 155 tilt (2.0.7)
@@ -173,8 +178,10 @@ DEPENDENCIES
173 byebug 178 byebug
174 capybara (~> 2.13) 179 capybara (~> 2.13)
175 coffee-rails (~> 4.2) 180 coffee-rails (~> 4.2)
181 haml
176 jbuilder (~> 2.5) 182 jbuilder (~> 2.5)
177 listen (>= 3.0.5, < 3.2) 183 listen (>= 3.0.5, < 3.2)
184 normalize-rails
178 puma (~> 3.7) 185 puma (~> 3.7)
179 rails (~> 5.1.1) 186 rails (~> 5.1.1)
180 sass-rails (~> 5.0) 187 sass-rails (~> 5.0)
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 @@
1# Place all the behaviors and hooks related to the matching controller here.
2# All this logic will automatically be available in application.js.
3# 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 @@
1# Place all the behaviors and hooks related to the matching controller here.
2# All this logic will automatically be available in application.js.
3# 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 @@
10 * files in this directory. Styles in this file should be added after the last require_* statement. 10 * files in this directory. Styles in this file should be added after the last require_* statement.
11 * It is generally better to create a new file per style scope. 11 * It is generally better to create a new file per style scope.
12 * 12 *
13 *= require normalize-rails
13 *= require_tree . 14 *= require_tree .
14 *= require_self 15 *= require_self
15 */ 16 */
17
18@import url('https://fonts.googleapis.com/css?family=Inconsolata');
19
20body {
21 background-color: #bfefff;
22}
23
24#container {
25 margin: 5em auto 0;
26 width: 50%;
27 border: 1px solid black;
28 background-color: white;
29 box-sizing: border-box;
30 -webkit-border-top-left-radius: 15px;
31 -webkit-border-top-right-radius: 15px;
32 -moz-border-radius-topleft: 15px;
33 -moz-border-radius-topright: 15px;
34 border-top-left-radius: 15px;
35 border-top-right-radius: 15px;
36}
37
38#banner {
39 width: 100%;
40 border-bottom: 1px solid black;
41 padding: 1em;
42 box-sizing: border-box;
43}
44
45#banner h1 {
46 text-align: center;
47 margin: 0;
48}
49
50#banner h1 a {
51 text-decoration: none;
52 color: black;
53}
54
55#banner h1 a:visited {
56 color: black;
57}
58
59#main {
60 display: -webkit-flex;
61 display: flex;
62}
63
64#content {
65 width: 75%;
66 box-sizing: border-box;
67 border-right: 1px solid black;
68}
69
70#sidebar {
71 width: 25%;
72 box-sizing: border-box;
73 padding-right: 1em;
74}
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 @@
1// Place all the styles related to the Entries controller here.
2// They will automatically be included in application.css.
3// 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 @@
1// Place all the styles related to the Records controller here.
2// They will automatically be included in application.css.
3// You can use Sass (SCSS) here: http://sass-lang.com/
4
5#records {
6 padding: 0;
7 margin: 0 1em;
8
9 & > li {
10 display: block;
11 padding: .25em 0;
12
13 .description {
14 a {
15 text-decoration: none;
16 color: black;
17 font-family: 'Inconsolata', monospace;
18
19 &:hover {
20 text-decoration: underline;
21 }
22
23 &:visited {
24 color: black;
25 }
26 }
27 }
28
29 .tags {
30 margin: .25em;
31 display: flex;
32 padding-left: 0;
33
34 li {
35 display: inline;
36 font-size: .75em;
37 font-family: 'Inconsolata', monospace;
38 padding: .25em;
39 -webkit-border-radius: 5px;
40 -moz-border-radius: 5px;
41 border-radius: 5px;
42
43 &.record-date {
44 background-color: #fef1bf;
45 }
46
47 &.entry-type {
48 text-transform: uppercase;
49
50 &.entry-type-blog {
51 background-color: #90fefb;
52 }
53 }
54
55 & + li {
56 margin-left: 1em;
57 }
58 }
59 }
60 }
61}
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 @@
1class EntriesController < ApplicationController
2
3 def show
4 @entry = Entry.where(directory: params[:directory], slug: params[:slug]).first
5 end
6
7end
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 @@
1class RecordsController < ApplicationController
2
3 def index
4 @records = Record.order(created_at: :desc).limit(20)
5 end
6
7end
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 @@
1module EntriesHelper
2end
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 @@
1module RecordsHelper
2end
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 @@
1class Blog < Entry
2 validates :title, :body, presence: true
3end
4
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 @@
1class Entry < ApplicationRecord
2 has_many :records, as: :recordable
3
4 validates :slug, presence: true, format: /\A[-a-z0-9]+\z/
5
6 def path
7 "/says/#{slug}"
8 end
9end
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 @@
1class Record < ApplicationRecord
2 belongs_to :recordable, polymorphic: true
3
4 validates :description, :recordable, presence: true
5end
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 @@
1<h1>Entries#show</h1>
2<p>Find me in app/views/entries/show.html.erb</p>
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 @@
1<!DOCTYPE html>
2<html>
3 <head>
4 <title>Thoughts</title>
5 <%= csrf_meta_tags %>
6
7 <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
8 <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
9 </head>
10
11 <body>
12 <%= yield %>
13 </body>
14</html>
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 @@
1!!! 5
2%html
3 %head
4 %title Thoughts
5 = csrf_meta_tags
6 = stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload'
7 = javascript_include_tag 'application', 'data-turbolinks-track': 'reload'
8 %body
9 #container
10 #banner
11 %h1= link_to "Thoughts", root_url
12 #main
13 #content= yield
14 #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 @@
1%ul#records
2 - @records.each do |record|
3 %li
4 %span.description= link_to record.description, record.recordable.path
5 %ul.tags
6 %li.record-date= record.created_at.strftime("%m.%e.%y")
7 %li.entry-type{ class: "entry-type-#{record.recordable.type.downcase}" }= record.recordable.type
diff --git a/config/routes.rb b/config/routes.rb index 787824f..64b02aa 100644 --- a/config/routes.rb +++ b/config/routes.rb
@@ -1,3 +1,10 @@
1Rails.application.routes.draw do 1Rails.application.routes.draw do
2 # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html 2 # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
3 root "records#index"
4
5 get 'says/:slug', to: 'entries#show'
6
7 # get ':directory/:slug', to: 'entries#show', constraints: lambda { |request|
8 # Entry::DIRECTORIES.include? request.path_parameters['directory']
9 # }
3end 10end
diff --git a/db/migrate/20170624183854_create_records.rb b/db/migrate/20170624183854_create_records.rb new file mode 100644 index 0000000..d407e15 --- /dev/null +++ b/db/migrate/20170624183854_create_records.rb
@@ -0,0 +1,10 @@
1class CreateRecords < ActiveRecord::Migration[5.1]
2 def change
3 create_table :records do |t|
4 t.text :description
5 t.references :recordable, polymorphic: true, index: true
6
7 t.timestamps
8 end
9 end
10end
diff --git a/db/migrate/20170625004938_create_entries.rb b/db/migrate/20170625004938_create_entries.rb new file mode 100644 index 0000000..0fb85b2 --- /dev/null +++ b/db/migrate/20170625004938_create_entries.rb
@@ -0,0 +1,12 @@
1class CreateEntries < ActiveRecord::Migration[5.1]
2 def change
3 create_table :entries do |t|
4 t.string :title
5 t.text :body
6 t.string :slug, null: false
7 t.string :type, null: false
8
9 t.timestamps
10 end
11 end
12end
diff --git a/db/schema.rb b/db/schema.rb new file mode 100644 index 0000000..6eca6ad --- /dev/null +++ b/db/schema.rb
@@ -0,0 +1,34 @@
1# This file is auto-generated from the current state of the database. Instead
2# of editing this file, please use the migrations feature of Active Record to
3# incrementally modify your database, and then regenerate this schema definition.
4#
5# Note that this schema.rb definition is the authoritative source for your
6# database schema. If you need to create the application database on another
7# system, you should be using db:schema:load, not running all the migrations
8# from scratch. The latter is a flawed and unsustainable approach (the more migrations
9# you'll amass, the slower it'll run and the greater likelihood for issues).
10#
11# It's strongly recommended that you check this file into your version control system.
12
13ActiveRecord::Schema.define(version: 20170625004938) do
14
15 create_table "entries", force: :cascade do |t|
16 t.string "title"
17 t.text "body"
18 t.string "directory", null: false
19 t.string "slug", null: false
20 t.string "type", null: false
21 t.datetime "created_at", null: false
22 t.datetime "updated_at", null: false
23 end
24
25 create_table "records", force: :cascade do |t|
26 t.text "description"
27 t.string "recordable_type"
28 t.integer "recordable_id"
29 t.datetime "created_at", null: false
30 t.datetime "updated_at", null: false
31 t.index ["recordable_type", "recordable_id"], name: "index_records_on_recordable_type_and_recordable_id"
32 end
33
34end
diff --git a/test/controllers/entries_controller_test.rb b/test/controllers/entries_controller_test.rb new file mode 100644 index 0000000..6e2db59 --- /dev/null +++ b/test/controllers/entries_controller_test.rb
@@ -0,0 +1,9 @@
1require 'test_helper'
2
3class EntriesControllerTest < ActionDispatch::IntegrationTest
4 test "should get show" do
5 get entries_show_url
6 assert_response :success
7 end
8
9end
diff --git a/test/controllers/records_controller_test.rb b/test/controllers/records_controller_test.rb new file mode 100644 index 0000000..6eeb2c3 --- /dev/null +++ b/test/controllers/records_controller_test.rb
@@ -0,0 +1,9 @@
1require 'test_helper'
2
3class RecordsControllerTest < ActionDispatch::IntegrationTest
4 test "should get index" do
5 get records_index_url
6 assert_response :success
7 end
8
9end
diff --git a/test/fixtures/entries.yml b/test/fixtures/entries.yml new file mode 100644 index 0000000..7bb736a --- /dev/null +++ b/test/fixtures/entries.yml
@@ -0,0 +1,15 @@
1# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
2
3one:
4 title: MyString
5 body: MyText
6 directory: MyString
7 slug: MyString
8 type:
9
10two:
11 title: MyString
12 body: MyText
13 directory: MyString
14 slug: MyString
15 type:
diff --git a/test/fixtures/links.yml b/test/fixtures/links.yml new file mode 100644 index 0000000..1560785 --- /dev/null +++ b/test/fixtures/links.yml
@@ -0,0 +1,9 @@
1# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
2
3one:
4 directory: MyString
5 slug: MyString
6
7two:
8 directory: MyString
9 slug: MyString
diff --git a/test/fixtures/posts.yml b/test/fixtures/posts.yml new file mode 100644 index 0000000..e192dee --- /dev/null +++ b/test/fixtures/posts.yml
@@ -0,0 +1,9 @@
1# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
2
3one:
4 title: MyString
5 body: MyText
6
7two:
8 title: MyString
9 body: MyText
diff --git a/test/fixtures/records.yml b/test/fixtures/records.yml new file mode 100644 index 0000000..2e0c8cd --- /dev/null +++ b/test/fixtures/records.yml
@@ -0,0 +1,7 @@
1# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
2
3one:
4 description: MyText
5
6two:
7 description: MyText
diff --git a/test/models/entry_test.rb b/test/models/entry_test.rb new file mode 100644 index 0000000..d3293bc --- /dev/null +++ b/test/models/entry_test.rb
@@ -0,0 +1,7 @@
1require 'test_helper'
2
3class EntryTest < ActiveSupport::TestCase
4 # test "the truth" do
5 # assert true
6 # end
7end
diff --git a/test/models/link_test.rb b/test/models/link_test.rb new file mode 100644 index 0000000..944bfce --- /dev/null +++ b/test/models/link_test.rb
@@ -0,0 +1,7 @@
1require 'test_helper'
2
3class LinkTest < ActiveSupport::TestCase
4 # test "the truth" do
5 # assert true
6 # end
7end
diff --git a/test/models/post_test.rb b/test/models/post_test.rb new file mode 100644 index 0000000..6d9d463 --- /dev/null +++ b/test/models/post_test.rb
@@ -0,0 +1,7 @@
1require 'test_helper'
2
3class PostTest < ActiveSupport::TestCase
4 # test "the truth" do
5 # assert true
6 # end
7end
diff --git a/test/models/record_test.rb b/test/models/record_test.rb new file mode 100644 index 0000000..47cf779 --- /dev/null +++ b/test/models/record_test.rb
@@ -0,0 +1,7 @@
1require 'test_helper'
2
3class RecordTest < ActiveSupport::TestCase
4 # test "the truth" do
5 # assert true
6 # end
7end