Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Stacks model added.

  • Loading branch information...
commit 35db20e1db2bbdd61d72fb240bdbcc3d339ca907 1 parent d4ea15d
Cicero Oliveira authored
3  app/controllers/notes_controller.rb
View
@@ -2,7 +2,8 @@ class NotesController < ApplicationController
# GET /notes
# GET /notes.xml
def index
- @notes = Note.all
+ @stacks = Stack.first
+ @notes = @stacks.notes.all
respond_to do |format|
format.html # index.html.erb
2  app/controllers/stacks_controller.rb
View
@@ -0,0 +1,2 @@
+class StacksController < ApplicationController
+end
2  app/helpers/stacks_helper.rb
View
@@ -0,0 +1,2 @@
+module StacksHelper
+end
2  app/models/note.rb
View
@@ -9,4 +9,6 @@ class Note
validates :color, :inclusion => {:in => COLORS}
validates :text, :owner, :presence => true
+
+ embedded_in :stack
end
9 app/models/stack.rb
View
@@ -0,0 +1,9 @@
+class Stack
+ include Mongoid::Document
+ include Mongoid::Timestamps
+ field :name, :type => String
+
+ validates :name, :presence => true
+
+ embeds_many :notes
+end
0  app/stylesheets/application.css
View
No changes.
22 app/stylesheets/application.scss
View
@@ -4,6 +4,14 @@ $color-cream: #f6f1d3;
$color-brown: #47423c;
$color-red: #d95853;
+ol {
+ list-style: none;
+}
+
+ul, li {
+ margin: 0;
+}
+
body {
background-color: $color-brown;
}
@@ -27,7 +35,7 @@ header {
}
*.new_note_button {
- margin-top: 1em;
+ margin: 1em;
}
section .new_note, .ui-dialog {
@@ -67,7 +75,7 @@ section .new_note {
}
}
-.content {
+#content {
background-color: $color-cream;
min-height: 500px;
}
@@ -114,7 +122,7 @@ section .new_note {
}
p {
- font-family: arial, sans-serif;
+ font-family: "Reenie Beanie", arial, sans-serif;
font-size: 200%;
line-height: 1.0;
padding: 10px;
@@ -155,4 +163,12 @@ section .new_note {
h1 {
color: $alp-green;
}
+}
+
+#stacks li h2 {
+ background-color: $color-cream;
+ border: 3px solid white;
+ $default-box-shadow-color: $color-red;
+ //@include box-shadow();//(10px 10px 7px rgba(0, 0, 0, .7));
+ @include border-radius;
}
24 app/stylesheets/clear_grid.scss
View
@@ -0,0 +1,24 @@
+.clear {
+ clear: both;
+ display: block;
+ overflow: hidden;
+ visibility: hidden;
+ width: 0;
+ height: 0;
+}
+
+/* http://www.yuiblog.com/blog/2010/09/27/clearfix-reloaded-overflowhidden-demystified */
+
+.clearfix:before,
+.clearfix:after {
+ content: '\0020';
+ display: block;
+ overflow: hidden;
+ visibility: hidden;
+ width: 0;
+ height: 0;
+}
+
+.clearfix:after {
+ clear: both;
+}
7 app/views/layouts/application.html.haml
View
@@ -9,6 +9,7 @@
= stylesheet_link_tag 'grid.css', :media => 'screen, projection'
= stylesheet_link_tag 'text.css', :media => 'screen, projection'
= stylesheet_link_tag 'application.css', :media => 'screen, projection'
+ = stylesheet_link_tag 'clear_grid'
/[if lt IE 7]
= stylesheet_link_tag 'ie6.css', :media => 'screen, projection'
= stylesheet_link_tag "http://fonts.googleapis.com/css?family=Reenie+Beanie:regular"
@@ -18,5 +19,7 @@
%header.grid_12
%h1
=link_to "Sticky Stacks", root_url
- %section.content.grid_12
- = yield
+ .clear
+ %section#content.grid_12
+ = yield
+ .clear
9 app/views/notes/index.html.haml
View
@@ -1,7 +1,10 @@
-.new_sticky.grid_12
+.new_sticky.grid_12.alpha.omega
%div#note-form{title: "Note", style: "display:none"}
=#%div#note-form{title: "Note"}
= link_to 'New Sticky', new_note_path, :class => "new_note_button", :remote => true
-%notes
- =render @notes
+.clear
+
+#stacks.grid_12.alpha.omega
+ %ol
+ =render @stacks
5 app/views/stacks/_stack.html.haml
View
@@ -0,0 +1,5 @@
+%li{:id => stack.id}
+ %h2
+ =link_to stack.name, "#"
+ %ol.notes
+ =render @notes
4 config/routes.rb
View
@@ -1,5 +1,7 @@
Notes::Application.routes.draw do
- resources :notes
+ #resources :stacks do
+ resources :notes
+ #end
# The priority is based upon order of creation:
# first created -> highest priority.
1  db/seeds.rb
View
@@ -5,3 +5,4 @@
#
# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
# Mayor.create(:name => 'Daley', :city => cities.first)
+Stack.create(name: "General")
8 public/javascripts/application.js
View
@@ -1,2 +1,10 @@
// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
+
+// Turn stacks into accordions
+// jQuery(document).ready(function(){
+// $('#stacks li h2').click(function(){
+// $(this).next().toggle('slow');
+// return false;
+// }).next().hide();
+// });
5 spec/controllers/stacks_controller_spec.rb
View
@@ -0,0 +1,5 @@
+require 'spec_helper'
+
+describe StacksController do
+
+end
7 spec/factories/stacks.rb
View
@@ -0,0 +1,7 @@
+# Read about factories at http://github.com/thoughtbot/factory_girl
+
+FactoryGirl.define do
+ factory :stack do
+ name "MyString"
+ end
+end
15 spec/helpers/stacks_helper_spec.rb
View
@@ -0,0 +1,15 @@
+require 'spec_helper'
+
+# Specs in this file have access to a helper object that includes
+# the StacksHelper. For example:
+#
+# describe StacksHelper do
+# describe "string concat" do
+# it "concats two strings with spaces" do
+# helper.concat_strings("this","that").should == "this that"
+# end
+# end
+# end
+describe StacksHelper do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
5 spec/models/stack_spec.rb
View
@@ -0,0 +1,5 @@
+require 'spec_helper'
+
+describe Stack do
+ pending "add some examples to (or delete) #{__FILE__}"
+end
Please sign in to comment.
Something went wrong with that request. Please try again.