Description:
fixed layout problem, for real, using render :layout => ... git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@51 6386c4cd-e34a-4fa8-8920-d93eb39b512e
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r27:e418fd4486af - - 5 files changed: 26 inserted, 26 deleted

@@ -0,0 +1,22
1 + <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
2 + "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 +
4 + <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
5 + <head>
6 + <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
7 + <title>Grader!</title>
8 + <%= stylesheet_link_tag 'application' %>
9 + <%= yield :head %>
10 + </head>
11 + <body>
12 +
13 + <div class="userbar">
14 + <%= user_header %>
15 + </div>
16 +
17 + <p style="color: green"><%= flash[:notice] %></p>
18 +
19 + <%= yield %>
20 +
21 + </body>
22 + </html>
@@ -1,41 +1,39
1 class MainController < ApplicationController
1 class MainController < ApplicationController
2
2
3 before_filter :authenticate, :except => [:index, :login]
3 before_filter :authenticate, :except => [:index, :login]
4
4
5 - layout 'application'
6 -
7 verify :method => :post, :only => [:submit],
5 verify :method => :post, :only => [:submit],
8 :redirect_to => { :action => :index }
6 :redirect_to => { :action => :index }
9
7
10
8
11 def index
9 def index
12 redirect_to :action => 'login'
10 redirect_to :action => 'login'
13 end
11 end
14
12
15 def login
13 def login
16 - MainController.layout 'empty'
17 reset_session
14 reset_session
15 + render :action => 'login', :layout => 'empty'
18 end
16 end
19
17
20 def list
18 def list
21 @problems = Problem.find_available_problems
19 @problems = Problem.find_available_problems
22 @prob_submissions = Array.new
20 @prob_submissions = Array.new
23 @user = User.find(session[:user_id])
21 @user = User.find(session[:user_id])
24 @problems.each do |p|
22 @problems.each do |p|
25 c, sub = Submission.find_by_user_and_problem(@user.id,p.id)
23 c, sub = Submission.find_by_user_and_problem(@user.id,p.id)
26 @prob_submissions << [c,sub]
24 @prob_submissions << [c,sub]
27 end
25 end
28 end
26 end
29
27
30 def submit
28 def submit
31 submission = Submission.new(params[:submission])
29 submission = Submission.new(params[:submission])
32 submission.user_id = session[:user_id]
30 submission.user_id = session[:user_id]
33 submission.language_id = 0
31 submission.language_id = 0
34 source = params['file'].read
32 source = params['file'].read
35 if source.length > 100_000
33 if source.length > 100_000
36 flash[:notice] = 'Error: file too long'
34 flash[:notice] = 'Error: file too long'
37 elsif (lang = Submission.find_language_in_source(source))==nil
35 elsif (lang = Submission.find_language_in_source(source))==nil
38 flash[:notice] = 'Error: cannot determine language used'
36 flash[:notice] = 'Error: cannot determine language used'
39 elsif ((submission.problem_id==-1) and
37 elsif ((submission.problem_id==-1) and
40 !(problem=Submission.find_problem_in_source(source)))
38 !(problem=Submission.find_problem_in_source(source)))
41 flash[:notice] = 'Error: cannot determine problem submitted'
39 flash[:notice] = 'Error: cannot determine problem submitted'
@@ -1,35 +1,35
1 # Methods added to this helper will be available to all templates in the application.
1 # Methods added to this helper will be available to all templates in the application.
2 module ApplicationHelper
2 module ApplicationHelper
3
3
4 def user_header
4 def user_header
5 options = ''
5 options = ''
6 user = User.find(session[:user_id])
6 user = User.find(session[:user_id])
7
7
8 # main page
8 # main page
9 options += link_to_unless_current '[Main]',
9 options += link_to_unless_current '[Main]',
10 :controller => 'main', :action => 'list'
10 :controller => 'main', :action => 'list'
11 options += ' '
11 options += ' '
12
12
13 # admin menu
13 # admin menu
14 - if user.admin?
14 + if (user!=nil) and (user.admin?)
15 options +=
15 options +=
16 (link_to_unless_current '[Problem admin]',
16 (link_to_unless_current '[Problem admin]',
17 :controller => 'problems', :action => 'index') + ' '
17 :controller => 'problems', :action => 'index') + ' '
18 options +=
18 options +=
19 (link_to_unless_current '[User admin]',
19 (link_to_unless_current '[User admin]',
20 :controller => 'user_admin', :action => 'index') + ' '
20 :controller => 'user_admin', :action => 'index') + ' '
21 options +=
21 options +=
22 (link_to_unless_current '[User stat]',
22 (link_to_unless_current '[User stat]',
23 :controller => 'user_admin', :action => 'user_stat') + ' '
23 :controller => 'user_admin', :action => 'user_stat') + ' '
24 end
24 end
25
25
26 # general options
26 # general options
27 options += link_to_unless_current '[Settings]',
27 options += link_to_unless_current '[Settings]',
28 :controller => 'users', :action => 'index'
28 :controller => 'users', :action => 'index'
29 options += ' '
29 options += ' '
30 options +=
30 options +=
31 link_to('[Log out]', {:controller => 'main', :action => 'login'})
31 link_to('[Log out]', {:controller => 'main', :action => 'login'})
32 options
32 options
33 end
33 end
34
34
35 end
35 end
@@ -1,35 +1,37
1 <% content_for :head do %>
1 <% content_for :head do %>
2 <%= stylesheet_link_tag 'scaffold' %>
2 <%= stylesheet_link_tag 'scaffold' %>
3 <%= javascript_include_tag :defaults %>
3 <%= javascript_include_tag :defaults %>
4 <% end %>
4 <% end %>
5
5
6 <h1>Listing problems</h1>
6 <h1>Listing problems</h1>
7
7
8 <div class="usermenu">
8 <div class="usermenu">
9 <%= link_to 'Main', :controller => 'main', :action => 'list' %>
9 <%= link_to 'Main', :controller => 'main', :action => 'list' %>
10 </div>
10 </div>
11
11
12 + <%= link_to 'New problem', :action => 'new' %><br/>
13 +
12 <table>
14 <table>
13 <tr>
15 <tr>
14 <th>Name</th>
16 <th>Name</th>
15 <th>Full name</th>
17 <th>Full name</th>
16 <th>Full score</th>
18 <th>Full score</th>
17 <th>Date added</th>
19 <th>Date added</th>
18 <th>Available</th>
20 <th>Available</th>
19 </tr>
21 </tr>
20
22
21 <% for problem in @problems %>
23 <% for problem in @problems %>
22 <tr>
24 <tr>
23 <% @problem=problem %>
25 <% @problem=problem %>
24 <td><%= in_place_editor_field :problem, :name, {}, :rows=>1 %>
26 <td><%= in_place_editor_field :problem, :name, {}, :rows=>1 %>
25 <td><%= in_place_editor_field :problem, :full_name, {}, :rows=>1 %>
27 <td><%= in_place_editor_field :problem, :full_name, {}, :rows=>1 %>
26 <td><%= in_place_editor_field :problem, :full_score, {}, :rows=>1 %>
28 <td><%= in_place_editor_field :problem, :full_score, {}, :rows=>1 %>
27 <td><%= problem.date_added %>
29 <td><%= problem.date_added %>
28 <td><%= problem.available %>
30 <td><%= problem.available %>
29
31
30 <td><%= link_to '[Toggle]', :action => 'toggle_avail', :id => problem.id %></td>
32 <td><%= link_to '[Toggle]', :action => 'toggle_avail', :id => problem.id %></td>
31 <td><%= link_to '[Stat]', :action => 'stat', :id => problem.id %></td>
33 <td><%= link_to '[Stat]', :action => 'stat', :id => problem.id %></td>
32 <td><%= link_to '[Show]', :action => 'show', :id => problem %></td>
34 <td><%= link_to '[Show]', :action => 'show', :id => problem %></td>
33 <td><%= link_to '[Edit]', :action => 'edit', :id => problem %></td>
35 <td><%= link_to '[Edit]', :action => 'edit', :id => problem %></td>
34 <td><%= link_to '[Destroy]', { :action => 'destroy', :id => problem }, :confirm => 'Are you sure?', :method => :post %></td>
36 <td><%= link_to '[Destroy]', { :action => 'destroy', :id => problem }, :confirm => 'Are you sure?', :method => :post %></td>
35 </tr>
37 </tr>
deleted file
You need to be logged in to leave comments. Login now