Skip to content

Commit

Permalink
sass and compass working together
Browse files Browse the repository at this point in the history
  • Loading branch information
Corey Purcell committed Aug 17, 2010
1 parent 62cbc08 commit 12999c1
Show file tree
Hide file tree
Showing 19 changed files with 539 additions and 236 deletions.
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ end

gem "haml", ">= 3.0.12"
gem "haml-rails"
gem 'acts-as-taggable-on'
gem 'compass', ">= 0.10.4"
# Use unicorn as the web server
# gem 'unicorn'

Expand Down
5 changes: 5 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,12 @@ GEM
activemodel (= 3.0.0.rc)
activesupport (= 3.0.0.rc)
activesupport (3.0.0.rc)
acts-as-taggable-on (2.0.6)
arel (0.4.0)
activesupport (>= 3.0.0.beta)
builder (2.1.2)
compass (0.10.4)
haml (>= 3.0.4)
diff-lcs (1.1.2)
erubis (2.6.6)
abstract (>= 1.0.0)
Expand Down Expand Up @@ -95,6 +98,8 @@ PLATFORMS
ruby

DEPENDENCIES
acts-as-taggable-on
compass (>= 0.10.4)
factory_girl_rails (>= 1.0.0)
haml (>= 3.0.12)
haml-rails
Expand Down
3 changes: 1 addition & 2 deletions app/models/task.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
class Task < ActiveRecord::Base

belongs_to :list

acts_as_taggable_on :tags
scope :completed, where(:completed => true)
scope :incomplete, where(:completed => false)
end
10 changes: 10 additions & 0 deletions app/stylesheets/_mixins.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
@mixin box($color: rgb(230, 230, 230), $border: rgb(221,221,221), $radius: 5px, $padding: 5px, $margin: 0.5em)
-moz-border-radius: $radius
-webkit-border-radius: $radius
border-radius: $radius
background-color: rgba(0, 0, 0, 0.05)
margin-bottom: $margin
padding: $padding
background-color: $color
border: 1px solid $border

17 changes: 16 additions & 1 deletion app/stylesheets/screen.sass
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
@import "compass/reset"
@import "standard"
@import "mixins"

@import "compass/css3/box-shadow"

.task
width: 100%
@include box(white, white)
@include box-shadow(#333,1px,1px,2px)
form.mark_complete
display: inline

ul.tags
display: inline
float: right
margin-top: 2px
li
display: inline
list-style-type: none
padding-right: 5px
@include box(rgb(231,235,249),rgb(188,202,240), 7px, 4px, 0)

ul#complete li.task
text-decoration: line-through
2 changes: 1 addition & 1 deletion app/views/layouts/application.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
%html
%head
%title Todo
= stylesheet_link_tag 'compiled/screen'
= stylesheet_link_tag 'screen'
= javascript_include_tag :defaults
= csrf_meta_tag
%body.content
Expand Down
3 changes: 2 additions & 1 deletion app/views/lists/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@

= form_for [@list, @task], :remote => true do |f|
%p
~f.text_field :description
~f.text_field :description, :placeholder => "New to do"
=f.text_field :tag_list, :placeholder => "Tags"
~f.submit
%hr
= link_to "Back to list index", lists_path
3 changes: 3 additions & 0 deletions app/views/tasks/_task.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,8 @@
= form_tag complete_task_path(@list.id, task.id), :class => "mark_complete", :remote => true do
= check_box_tag "complete", "1", false, "data-remote".to_sym => true, :action => complete_task_path(@list.id, task.id)
= "#{task.description}"
%ul.tags
- task.tag_list.each do |tag|
%li=tag


2 changes: 2 additions & 0 deletions config.ru
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# This file is used by Rack-based servers to start the application.

require ::File.expand_path('../config/environment', __FILE__)
#use Rack::Static, :urls => ["/stylesheets/compiled"], :root => "tmp"

run Todo::Application
11 changes: 11 additions & 0 deletions config/compass.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# This configuration file works with both the Compass command line tool and within Rails.
# Require any additional compass plugins here.
project_type = :rails
project_path = Compass::AppIntegration::Rails.root
# Set this to the root of your project when deployed:
http_path = "/"
css_dir = "public/stylesheets"
sass_dir = "app/stylesheets"
environment = Compass::AppIntegration::Rails.env
# To enable relative paths to assets via compass helper functions. Uncomment:
# relative_assets = true
1 change: 1 addition & 0 deletions config/environments/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,5 @@

# Print deprecation notices to the Rails logger
config.active_support.deprecation = :log
Sass::Plugin.options[:always_check] = true
end
3 changes: 3 additions & 0 deletions config/environments/production.rb
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,7 @@

# Send deprecation notices to registered listeners
config.active_support.deprecation = :notify

Sass::Plugin.options[:always_check] = false

end
3 changes: 3 additions & 0 deletions config/initializers/compass.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
require 'compass'
require 'compass/app_integration/rails'
Compass::AppIntegration::Rails.initialize!
28 changes: 28 additions & 0 deletions db/migrate/20100817123058_acts_as_taggable_on_migration.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
class ActsAsTaggableOnMigration < ActiveRecord::Migration
def self.up
create_table :tags do |t|
t.string :name
end

create_table :taggings do |t|
t.references :tag

# You should make sure that the column created is
# long enough to store the required class names.
t.references :taggable, :polymorphic => true
t.references :tagger, :polymorphic => true

t.string :context

t.datetime :created_at
end

add_index :taggings, :tag_id
add_index :taggings, [:taggable_id, :taggable_type, :context]
end

def self.down
drop_table :taggings
drop_table :tags
end
end
19 changes: 18 additions & 1 deletion db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended to check this file into your version control system.

ActiveRecord::Schema.define(:version => 20100813184240) do
ActiveRecord::Schema.define(:version => 20100817123058) do

create_table "lists", :force => true do |t|
t.string "name"
Expand All @@ -19,6 +19,23 @@
t.datetime "updated_at"
end

create_table "taggings", :force => true do |t|
t.integer "tag_id"
t.integer "taggable_id"
t.string "taggable_type"
t.integer "tagger_id"
t.string "tagger_type"
t.string "context"
t.datetime "created_at"
end

add_index "taggings", ["tag_id"], :name => "index_taggings_on_tag_id"
add_index "taggings", ["taggable_id", "taggable_type", "context"], :name => "index_taggings_on_taggable_id_and_taggable_type_and_context"

create_table "tags", :force => true do |t|
t.string "name"
end

create_table "tasks", :force => true do |t|
t.string "description"
t.boolean "completed", :default => false
Expand Down
Loading

0 comments on commit 12999c1

Please sign in to comment.