Skip to content

Commit

Permalink
haml
Browse files Browse the repository at this point in the history
  • Loading branch information
mdobrota committed Feb 5, 2012
1 parent aa20a78 commit 41ae8f3
Show file tree
Hide file tree
Showing 30 changed files with 194 additions and 103 deletions.
6 changes: 6 additions & 0 deletions Gemfile
Expand Up @@ -7,6 +7,7 @@ gem 'rails', '3.1.0'

gem 'pg', '0.12.2'
gem 'devise', '2.0.0'
gem 'haml-rails'

# Gems used only for assets and not required
# in production environments by default.
Expand All @@ -20,6 +21,11 @@ group :assets do
gem 'uglifier'
end

group :development do
gem 'hpricot'
gem 'ruby_parser'
end

gem 'jquery-rails'

# To use ActiveModel has_secure_password
Expand Down
13 changes: 13 additions & 0 deletions Gemfile.lock
Expand Up @@ -48,7 +48,14 @@ GEM
erubis (2.7.0)
execjs (1.3.0)
multi_json (~> 1.0)
haml (3.1.4)
haml-rails (0.3.4)
actionpack (~> 3.0)
activesupport (~> 3.0)
haml (~> 3.0)
railties (~> 3.0)
hike (1.2.1)
hpricot (0.8.6)
i18n (0.6.0)
jquery-rails (1.0.19)
railties (~> 3.0)
Expand Down Expand Up @@ -90,12 +97,15 @@ GEM
rake (0.9.2.2)
rdoc (3.12)
json (~> 1.4)
ruby_parser (2.3.1)
sexp_processor (~> 3.0)
sass (3.1.12)
sass-rails (3.1.5)
actionpack (~> 3.1.0)
railties (~> 3.1.0)
sass (~> 3.1.10)
tilt (~> 1.3.2)
sexp_processor (3.0.10)
sprockets (2.0.3)
hike (~> 1.2)
rack (~> 1.0)
Expand All @@ -118,8 +128,11 @@ PLATFORMS
DEPENDENCIES
coffee-rails
devise (= 2.0.0)
haml-rails
hpricot
jquery-rails
pg (= 0.12.2)
rails (= 3.1.0)
ruby_parser
sass-rails
uglifier
11 changes: 11 additions & 0 deletions app/controllers/reading_speed_tests_controller.rb
@@ -0,0 +1,11 @@
class ReadingSpeedTestsController < ApplicationController
def new
@reading_speed_test = ReadingSpeedTest.setup_for(current_user)
end

def create
end

def show
end
end
7 changes: 7 additions & 0 deletions app/models/content.rb
@@ -1,2 +1,9 @@
class Content < ActiveRecord::Base

class << self
def for_reading_speed_test
first
end
end

end
13 changes: 13 additions & 0 deletions app/models/reading_speed_test.rb
@@ -0,0 +1,13 @@
class ReadingSpeedTest < ActiveRecord::Base
belongs_to :user
belongs_to :content

class << self
def setup_for(test_taker)
new(
:user => test_taker,
:content => Content.for_reading_speed_test
)
end
end
end
29 changes: 0 additions & 29 deletions app/views/contents/_form.html.erb

This file was deleted.

23 changes: 23 additions & 0 deletions app/views/contents/_form.html.haml
@@ -0,0 +1,23 @@
= form_for(@content) do |f|
- if @content.errors.any?
#error_explanation
%h2
= pluralize(@content.errors.count, "error")
prohibited this content from being saved:
%ul
- @content.errors.full_messages.each do |msg|
%li= msg
.field
= f.label :body
%br/
= f.text_area :body
.field
= f.label :source_name
%br/
= f.text_field :source_name
.field
= f.label :source_link
%br/
= f.text_field :source_link
.actions
= f.submit
6 changes: 0 additions & 6 deletions app/views/contents/edit.html.erb

This file was deleted.

5 changes: 5 additions & 0 deletions app/views/contents/edit.html.haml
@@ -0,0 +1,5 @@
%h1 Editing content
= render 'form'
= link_to 'Show', @content
|
\#{link_to 'Back', contents_path}
27 changes: 0 additions & 27 deletions app/views/contents/index.html.erb

This file was deleted.

19 changes: 19 additions & 0 deletions app/views/contents/index.html.haml
@@ -0,0 +1,19 @@
%h1 Listing contents
%table
%tr
%th Body
%th Source name
%th Source link
%th
%th
%th
- @contents.each do |content|
%tr
%td= content.body
%td= content.source_name
%td= content.source_link
%td= link_to 'Show', content
%td= link_to 'Edit', edit_content_path(content)
%td= link_to 'Destroy', content, confirm: 'Are you sure?', method: :delete
%br/
= link_to 'New Content', new_content_path
5 changes: 0 additions & 5 deletions app/views/contents/new.html.erb

This file was deleted.

3 changes: 3 additions & 0 deletions app/views/contents/new.html.haml
@@ -0,0 +1,3 @@
%h1 New content
= render 'form'
= link_to 'Back', contents_path
18 changes: 0 additions & 18 deletions app/views/contents/show.html.erb

This file was deleted.

12 changes: 12 additions & 0 deletions app/views/contents/show.html.haml
@@ -0,0 +1,12 @@
%p
%b Body:
= @content.body
%p
%b Source name:
= @content.source_name
%p
%b Source link:
= @content.source_link
= link_to 'Edit', edit_content_path(@content)
|
\#{link_to 'Back', contents_path}
File renamed without changes.
16 changes: 0 additions & 16 deletions app/views/layouts/application.html.erb

This file was deleted.

12 changes: 12 additions & 0 deletions app/views/layouts/application.html.haml
@@ -0,0 +1,12 @@
!!!
%html
%head
%title SpeedReading
= stylesheet_link_tag "application", :media => "all"
= javascript_include_tag "application"
= csrf_meta_tags
%body
%p= user_header
%p.notice= notice
%p.alert= alert
= yield
5 changes: 5 additions & 0 deletions app/views/reading_speed_tests/new.html.haml
@@ -0,0 +1,5 @@
This test will measure your reading speed. Click the start button when you are ready and done when you are finished reading.
%button#start_reading Start
#content
= @reading_speed_test.content.body
%button#finished_reading Done
1 change: 1 addition & 0 deletions config/routes.rb
@@ -1,5 +1,6 @@
SpeedReading::Application.routes.draw do
resources :contents
resources :reading_speed_tests, :only => [:new, :create, :show]

devise_for :users

Expand Down
14 changes: 14 additions & 0 deletions db/migrate/20120204234009_create_reading_speed_tests.rb
@@ -0,0 +1,14 @@
class CreateReadingSpeedTests < ActiveRecord::Migration
def change
create_table :reading_speed_tests do |t|
t.integer :content_id
t.integer :user_id
t.integer :wpm

t.timestamps
end

add_index :reading_speed_tests, :content_id
add_index :reading_speed_tests, :user_id
end
end
13 changes: 12 additions & 1 deletion db/schema.rb
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 20120204214723) do
ActiveRecord::Schema.define(:version => 20120204234009) do

create_table "contents", :force => true do |t|
t.text "body"
Expand All @@ -21,6 +21,17 @@
t.datetime "updated_at"
end

create_table "reading_speed_tests", :force => true do |t|
t.integer "content_id"
t.integer "user_id"
t.integer "wpm"
t.datetime "created_at"
t.datetime "updated_at"
end

add_index "reading_speed_tests", ["content_id"], :name => "index_reading_speed_tests_on_content_id"
add_index "reading_speed_tests", ["user_id"], :name => "index_reading_speed_tests_on_user_id"

create_table "users", :force => true do |t|
t.string "email", :default => "", :null => false
t.string "encrypted_password", :default => "", :null => false
Expand Down
Binary file not shown.
19 changes: 19 additions & 0 deletions public/assets/application-28647733cd84612bf5e3fa1139aa7f16.js

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file modified public/assets/jquery.min-e3cda086d77f5617dc07d5ee81cee7b2.js.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion public/assets/manifest.yml
Expand Up @@ -2,5 +2,5 @@
rails.png: rails-e4b51606cd77fda2615e7439907bfc92.png
jquery-ui.min.js: jquery-ui.min-8b9c16ed13b920aebcfef3197711f61b.js
jquery.min.js: jquery.min-e3cda086d77f5617dc07d5ee81cee7b2.js
application.js: application-7e970d38ffc1f6ba53fd359ea77e154a.js
application.js: application-28647733cd84612bf5e3fa1139aa7f16.js
application.css: application-1c9609bc58b1e77c196de29021583379.css
11 changes: 11 additions & 0 deletions test/fixtures/reading_speed_tests.yml
@@ -0,0 +1,11 @@
# Read about fixtures at http://api.rubyonrails.org/classes/Fixtures.html

one:
content_id: 1
user_id: 1
wpm: 1

two:
content_id: 1
user_id: 1
wpm: 1
7 changes: 7 additions & 0 deletions test/unit/reading_speed_test_test.rb
@@ -0,0 +1,7 @@
require 'test_helper'

class ReadingSpeedTestTest < ActiveSupport::TestCase
# test "the truth" do
# assert true
# end
end

0 comments on commit 41ae8f3

Please sign in to comment.