Skip to content

Commit

Permalink
updated layout
Browse files Browse the repository at this point in the history
  • Loading branch information
olivM committed Apr 7, 2009
1 parent 911a9cb commit c2b5ca0
Show file tree
Hide file tree
Showing 17 changed files with 241 additions and 9 deletions.
8 changes: 4 additions & 4 deletions app/controllers/account_controller.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
class AccountController < ApplicationController
before_filter :login_required
before_filter :user_info
before_filter :notebooks_info

layout 'main'

def index

end

def notebooks
@notebooks = User.find(session[:user_id]).notebooks
end

end
8 changes: 8 additions & 0 deletions app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ class ApplicationController < ActionController::Base
# Scrub sensitive parameters from your log
# filter_parameter_logging :password

def notebooks_info
@notebooks = @user.notebooks
end

def user_info
@user = User.find(session[:user_id])
end

def login_required
if session[:user_id]
@user ||= User.find(session[:user_id])
Expand Down
66 changes: 66 additions & 0 deletions app/controllers/notebook_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
class NotebookController < ApplicationController

before_filter :login_required
before_filter :user_info
before_filter :notebooks_info

before_filter :notebook_info, :except => [:index, :new, :create]

layout 'main'

def notebook_info
@notebook = Notebook.find(params[:id])
end

def index
end

def show
respond_to do |format|
format.html # show.html.erb
format.xml { render :xml => @notebook }
end
end

def new
@notebook = Notebook.new

respond_to do |format|
format.html # new.html.erb
format.xml { render :xml => @notebook }
end
end

def create
@notebook = Notebook.new(params[:notebook])
@notebook.creator = @user

respond_to do |format|
if @notebook.save
flash[:notice] = 'Notebook was successfully created.'
format.html { redirect_to(@notebook) }
format.xml { render :xml => @notebook, :status => :created, :location => @notebook }
else
format.html { render :action => "new" }
format.xml { render :xml => @notebook.errors, :status => :unprocessable_entity }
end
end
end

def edit
end

def update
respond_to do |format|
if @notebook.update_attributes(params[:notebook])
flash[:notice] = 'Panel was successfully updated.'
format.html { redirect_to(@notebook) }
format.xml { head :ok }
else
format.html { render :action => "edit" }
format.xml { render :xml => @notebook.errors, :status => :unprocessable_entity }
end
end
end

end
1 change: 1 addition & 0 deletions app/controllers/session_controller.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
class SessionController < ApplicationController

skip_before_filter :login_required, :only => [:new, :create]

def new
Expand Down
2 changes: 2 additions & 0 deletions app/helpers/notebook_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module NotebookHelper
end
3 changes: 0 additions & 3 deletions app/views/account/index.haml
Original file line number Diff line number Diff line change
@@ -1,3 +0,0 @@
- for notebook in @notebooks
%li
%a{:href=> "/notebook/notebook.name"}=notebook.name
30 changes: 28 additions & 2 deletions app/views/layouts/main.haml
Original file line number Diff line number Diff line change
@@ -1,2 +1,28 @@
#sidebar
= render_component :controller => 'account', :action => 'notebooks'
!!!
%html
%head
%link{ :rel => "shortcut icon", :href => "/favicon.ico", :type => "image/x-icon"}/
%title= controller.controller_name.capitalize
= javascript_include_tag 'http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js'
= javascript_include_tag 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.1/jquery-ui.min.js'
= javascript_include_tag 'jquery.editinplace.packed'
= javascript_include_tag 'main'
= stylesheet_link_tag 'main'

%body

#container

#header
#account
%a{:href => "/account"}=@user.name

#sidebar
%a{:href => "/notebook/new"} new
%ul#notebooks
- for notebook in @notebooks
%li{:class => ( ! @notebook.nil? and @notebook.id == notebook.id ? 'selected' : '' )}
%a{:href => "/notebook/show/#{notebook.id}"}=notebook.name

#main
= yield
14 changes: 14 additions & 0 deletions app/views/notebook/edit.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
-form_for @notebook do |f|

%p
= f.error_messages

%p
=f.text_field :name

%p
=f.text_area :content

%p
= submit_tag 'save'

Empty file added app/views/notebook/index.haml
Empty file.
13 changes: 13 additions & 0 deletions app/views/notebook/new.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
-form_for @notebook, :url => { :action => "create" } do |f|

= f.error_messages

%p
=f.text_field :name

%p
=f.text_area :content

%p
= submit_tag 'save'

6 changes: 6 additions & 0 deletions app/views/notebook/show.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
%h2=@notebook.name

%a{:href => "/notebook/edit/#{@notebook.id}"} edit

#notebook_content
=@notebook.content
2 changes: 2 additions & 0 deletions config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
ActionController::Routing::Routes.draw do |map|
# The priority is based upon order of creation: first created -> highest priority.

map.resources :notebooks, :controller => 'notebook'

# Sample of regular route:
# map.connect 'products/:id', :controller => 'catalog', :action => 'view'
# Keep in mind you can assign values other than :controller and :action
Expand Down
17 changes: 17 additions & 0 deletions public/javascripts/jquery.editinplace.packed.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 31 additions & 0 deletions public/stylesheets/main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
html {
margin: 0;
padding: 0; }

body {
margin: 0;
padding: 0;
font: 14px Arial,Verdana,Helvetica,sans-serif;
background-color: #eee;
color: #000; }

ul {
list-style: none;
padding: 0 0 0 10px; }

#container {
padding: 10px; }
#container #account {
text-align: right; }
#container #sidebar {
float: left;
width: 200px;
height: 100%;
padding: 1px 5px 1px 1px;
margin-right: 10px; }
#container #sidebar #notebooks li {
padding: 2px 3px 4px 5px; }
#container #sidebar #notebooks li.selected {
background-color: #ccf; }
#container #main {
float: left; }
37 changes: 37 additions & 0 deletions public/stylesheets/sass/main.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
html
:margin 0
:padding 0

body
:margin 0
:padding 0
:font 14px Arial,Verdana,Helvetica,sans-serif
:background-color #eee
:color #000

ul
:list-style none
:padding 0 0 0 10px

#container
:padding 10px

#account
:text-align right

#sidebar
:float left
:width 200px
:height 100%
:padding 1px 5px 1px 1px
:margin-right 10px

#notebooks
li
:padding 2px 3px 4px 5px
li.selected
:background-color #ccf

#main
:float left

8 changes: 8 additions & 0 deletions test/functional/notebook_controller_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
require 'test_helper'

class NotebookControllerTest < ActionController::TestCase
# Replace this with your real tests.
test "the truth" do
assert true
end
end
4 changes: 4 additions & 0 deletions test/unit/helpers/notebook_helper_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
require 'test_helper'

class NotebookHelperTest < ActionView::TestCase
end

0 comments on commit c2b5ca0

Please sign in to comment.