Changeset 593
- Timestamp:
- 09/09/07 18:20:12 (1 year ago)
- Files:
-
- apps/marble/trunk/app/controllers/admin/blogs.rb (modified) (8 diffs)
- apps/marble/trunk/app/controllers/admin/comments.rb (modified) (8 diffs)
- apps/marble/trunk/app/controllers/admin/posts.rb (modified) (8 diffs)
- apps/marble/trunk/app/controllers/admin/users.rb (modified) (11 diffs)
- apps/marble/trunk/app/controllers/application.rb (modified) (1 diff)
- apps/marble/trunk/app/controllers/auth.rb (added)
- apps/marble/trunk/app/models/user.rb (modified) (1 diff)
- apps/marble/trunk/app/views/layout/one_column.html.erb (modified) (1 diff)
- apps/marble/trunk/config/dependencies.rb (modified) (1 diff)
- apps/marble/trunk/config/router.rb (modified) (1 diff)
- apps/marble/trunk/lib/magic_scaffold.rb (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
apps/marble/trunk/app/controllers/admin/blogs.rb
r583 r593 13 13 @blogs = @page.all 14 14 15 render :inline => <<- ERB.indent(2)15 render :inline => <<-HTML.indent(2) 16 16 <%- if @blogs.size == 0 -%> 17 17 No blogs to show … … 39 39 links.join(" | ") 40 40 %> 41 ERB41 HTML 42 42 end 43 43 … … 47 47 raise Admin::Blogs::Gone, "blog ##{id} is gone" unless @blog 48 48 49 render :inline => <<- ERB.indent(2)49 render :inline => <<-HTML.indent(2) 50 50 <ul> 51 51 <li><strong>Id:</strong> <%= @blog.id %></li> … … 54 54 </ul> 55 55 <a href="#{url(:blogs)}">list blogs</a> 56 ERB56 HTML 57 57 end 58 58 … … 60 60 @blog = Blog.new(params[:blog] || {}) 61 61 62 render :inline => <<- ERB.indent(2)62 render :inline => <<-HTML.indent(2) 63 63 <form method="post" action="<%= url(:blogs) %>"> 64 64 <ul> … … 68 68 <input type="submit" value="Create" /> 69 69 </form> 70 ERB70 HTML 71 71 end 72 72 … … 87 87 @blog.values.merge!(params[:blog]) if params[:blog] 88 88 89 render :inline => <<- ERB.indent(2)89 render :inline => <<-HTML.indent(2) 90 90 <form method="post" action="<%= url(:blog) %>"> 91 91 <input type="hidden" name="_method" value="put" /> … … 100 100 <input type="submit" value="Delete" /> 101 101 </form> 102 ERB102 HTML 103 103 end 104 104 apps/marble/trunk/app/controllers/admin/comments.rb
r583 r593 14 14 @comments = @page.all 15 15 16 render :inline => <<- ERB.indent(2)16 render :inline => <<-HTML.indent(2) 17 17 <%- if @comments.size == 0 -%> 18 18 No comments to show … … 46 46 links.join(" | ") 47 47 %> 48 ERB48 HTML 49 49 end 50 50 … … 54 54 raise Admin::Comments::Gone, "comment ##{id} is gone" unless @comment 55 55 56 render :inline => <<- ERB.indent(2)56 render :inline => <<-HTML.indent(2) 57 57 <ul> 58 58 <li><strong>Id:</strong> <%= @comment.id %></li> … … 64 64 </ul> 65 65 <a href="#{url(:comments)}">list comments</a> 66 ERB66 HTML 67 67 end 68 68 … … 70 70 @comment = Comment.new(params[:comment] || {}) 71 71 72 render :inline => <<- ERB.indent(2)72 render :inline => <<-HTML.indent(2) 73 73 <form method="post" action="<%= url(:comments) %>"> 74 74 <ul> … … 81 81 <input type="submit" value="Create" /> 82 82 </form> 83 ERB83 HTML 84 84 end 85 85 … … 100 100 @comment.values.merge!(params[:comment]) if params[:comment] 101 101 102 render :inline => <<- ERB.indent(2)102 render :inline => <<-HTML.indent(2) 103 103 <form method="post" action="<%= url(:comment) %>"> 104 104 <input type="hidden" name="_method" value="put" /> … … 116 116 <input type="submit" value="Delete" /> 117 117 </form> 118 ERB118 HTML 119 119 end 120 120 apps/marble/trunk/app/controllers/admin/posts.rb
r583 r593 13 13 @posts = @page.all 14 14 15 render :inline => <<- ERB.indent(2)15 render :inline => <<-HTML.indent(2) 16 16 <%- if @posts.size == 0 -%> 17 17 No posts to show … … 41 41 links.join(" | ") 42 42 %> 43 ERB43 HTML 44 44 end 45 45 … … 49 49 raise Admin::Posts::Gone, "post ##{id} is gone" unless @post 50 50 51 render :inline => <<- ERB.indent(2)51 render :inline => <<-HTML.indent(2) 52 52 <ul> 53 53 <li><strong>Id:</strong> <%= @post.id %></li> … … 57 57 </ul> 58 58 <a href="#{url(:posts)}">list posts</a> 59 ERB59 HTML 60 60 end 61 61 … … 63 63 @post = Post.new(params[:post] || {}) 64 64 65 render :inline => <<- ERB.indent(2)65 render :inline => <<-HTML.indent(2) 66 66 <form method="post" action="<%= url(:posts) %>"> 67 67 <ul> … … 72 72 <input type="submit" value="Create" /> 73 73 </form> 74 ERB74 HTML 75 75 end 76 76 … … 91 91 @post.values.merge!(params[:post]) if params[:post] 92 92 93 render :inline => <<- ERB.indent(2)93 render :inline => <<-HTML.indent(2) 94 94 <form method="post" action="<%= url(:post) %>"> 95 95 <input type="hidden" name="_method" value="put" /> … … 105 105 <input type="submit" value="Delete" /> 106 106 </form> 107 ERB107 HTML 108 108 end 109 109 apps/marble/trunk/app/controllers/admin/users.rb
r583 r593 13 13 @users = @page.all 14 14 15 render :inline => <<- ERB.indent(2)15 render :inline => <<-HTML.indent(2) 16 16 <%- if @users.size == 0 -%> 17 17 No users to show … … 24 24 <th>Email</th> 25 25 <th>Password</th> 26 <th>Can create blogs</th> 26 27 </tr> 27 28 <%- @users.each do |u| -%> … … 32 33 <td><%= u.email %></td> 33 34 <td><%= u.password %></td> 35 <td><%= u.can_create_blogs %></td> 34 36 <td><a href="<%= url(:edit_user, :id => u.id) %>">edit</a></td> 35 37 </tr> … … 43 45 links.join(" | ") 44 46 %> 45 ERB47 HTML 46 48 end 47 49 … … 51 53 raise Admin::Users::Gone, "user ##{id} is gone" unless @user 52 54 53 render :inline => <<- ERB.indent(2)55 render :inline => <<-HTML.indent(2) 54 56 <ul> 55 57 <li><strong>Id:</strong> <%= @user.id %></li> … … 58 60 <li><strong>Email:</strong> <%= @user.email %></li> 59 61 <li><strong>Password:</strong> <%= @user.password %></li> 62 <li><strong>Can create blogs:</strong> <%= @user.can_create_blogs %></li> 60 63 </ul> 61 64 <a href="#{url(:users)}">list users</a> 62 ERB65 HTML 63 66 end 64 67 … … 66 69 @user = User.new(params[:user] || {}) 67 70 68 render :inline => <<- ERB.indent(2)71 render :inline => <<-HTML.indent(2) 69 72 <form method="post" action="<%= url(:users) %>"> 70 73 <ul> … … 73 76 <div class="form-element"><label for="user_email">Email:</label><br/><%= control_for @user, :email, :text %></div> 74 77 <div class="form-element"><label for="user_password">Password:</label><br/><%= control_for @user, :password, :text %></div> 78 <div class="form-element"><label for="user_can_create_blogs">Can create blogs:</label><br/><%= control_for @user, :can_create_blogs, :text %></div> 75 79 </ul> 76 80 <input type="submit" value="Create" /> 77 81 </form> 78 ERB82 HTML 79 83 end 80 84 … … 95 99 @user.values.merge!(params[:user]) if params[:user] 96 100 97 render :inline => <<- ERB.indent(2)101 render :inline => <<-HTML.indent(2) 98 102 <form method="post" action="<%= url(:user) %>"> 99 103 <input type="hidden" name="_method" value="put" /> … … 103 107 <div class="form-element"><label for="user_email">Email:</label><br/><%= control_for @user, :email, :text %></div> 104 108 <div class="form-element"><label for="user_password">Password:</label><br/><%= control_for @user, :password, :text %></div> 109 <div class="form-element"><label for="user_can_create_blogs">Can create blogs:</label><br/><%= control_for @user, :can_create_blogs, :text %></div> 105 110 </ul> 106 111 <input type="submit" value="Save" /> … … 110 115 <input type="submit" value="Delete" /> 111 116 </form> 112 ERB117 HTML 113 118 end 114 119 apps/marble/trunk/app/controllers/application.rb
r583 r593 2 2 class Application < Merb::Controller 3 3 self._layout = :one_column 4 attr_accessor :current_user 5 6 before :find_current_user 7 def find_current_user 8 @current_user = User[:id => session[:user_id]] if session[:user_id] 9 end 4 10 end 5 11 apps/marble/trunk/app/models/user.rb
r500 r593 6 6 varchar :email 7 7 varchar :password 8 boolean :can_create_blogs 8 9 end 9 10 apps/marble/trunk/app/views/layout/one_column.html.erb
r584 r593 11 11 <img src="/images/marble.jpg"> 12 12 <h1>Marble</h1> 13 <%- if @current_user -%> 14 Welcome, <%= @current_user.first_name %> 15 <%- end -%> 13 16 <hr /> 14 17 </div> apps/marble/trunk/config/dependencies.rb
r582 r593 10 10 # Need to get merb_sequel from svn, package it, and install it in deps/ before the next line: 11 11 dependency "merb_sequel" 12 13 # require 'validator' 14 # Merb::AbstractController.send(:include, ValidatorMixin) 12 15 13 16 require 'magic_scaffold' apps/marble/trunk/config/router.rb
r583 r593 32 32 end 33 33 34 r.match("/signin").to(:controller => 'auth', :action => 'signin').name(:signin) 35 r.match("/signout").to(:controller => 'auth', :action => 'signout').name(:signout) 36 34 37 # Default route, usually you don't want to change this 35 38 r.default_routes apps/marble/trunk/lib/magic_scaffold.rb
r583 r593 97 97 @#{plural} = @page.all 98 98 99 render :inline => <<- ERB.indent(2)99 render :inline => <<-HTML.indent(2) 100 100 <%- if @#{plural}.size == 0 -%> 101 101 No #{plural} to show … … 119 119 links.join(" | ") 120 120 %> 121 ERB121 HTML 122 122 end 123 123 RUBY … … 135 135 raise #{self}::Gone, "#{singular} #\#{id} is gone" unless @#{singular} 136 136 137 render :inline => <<- ERB.indent(2)137 render :inline => <<-HTML.indent(2) 138 138 <ul> 139 139 #{listing.gsub("\n", "\n" + " ")} 140 140 </ul> 141 141 <a href="\#{url(:#{plural})}">list #{plural}</a> 142 ERB142 HTML 143 143 end 144 144 RUBY … … 156 156 @#{singular} = #{model_class}.new(params[:#{singular}] || {}) 157 157 158 render :inline => <<- ERB.indent(2)158 render :inline => <<-HTML.indent(2) 159 159 <form method="post" action="<%= url(:#{plural}) %>"> 160 160 <ul> … … 163 163 <input type="submit" value="Create" /> 164 164 </form> 165 ERB165 HTML 166 166 end 167 167 RUBY … … 194 194 @#{singular}.values.merge!(params[:#{singular}]) if params[:#{singular}] 195 195 196 render :inline => <<- ERB.indent(2)196 render :inline => <<-HTML.indent(2) 197 197 <form method="post" action="<%= url(:#{singular}) %>"> 198 198 <input type="hidden" name="_method" value="put" /> … … 206 206 <input type="submit" value="Delete" /> 207 207 </form> 208 ERB208 HTML 209 209 end 210 210 RUBY
