diff --git a/app/controllers/main_controller.rb b/app/controllers/main_controller.rb --- a/app/controllers/main_controller.rb +++ b/app/controllers/main_controller.rb @@ -11,12 +11,11 @@ end def login - MainController.layout 'login' + MainController.layout 'empty' reset_session end def list - MainController.layout 'application' @problems = Problem.find_available_problems @prob_submissions = Array.new @user = User.find(session[:user_id]) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -4,19 +4,30 @@ def user_header options = '' user = User.find(session[:user_id]) - if user.admin? - options = options + ' ' + - (link_to_unless_current '[Problem admin]', - :controller => 'problems', :action => 'index') - options = options + ' ' + - (link_to_unless_current '[User admin]', - :controller => 'user_admin', :action => 'index') - end + + # main page options += link_to_unless_current '[Main]', :controller => 'main', :action => 'list' + options += ' ' + + # admin menu + if user.admin? + options += + (link_to_unless_current '[Problem admin]', + :controller => 'problems', :action => 'index') + ' ' + options += + (link_to_unless_current '[User admin]', + :controller => 'user_admin', :action => 'index') + ' ' + options += + (link_to_unless_current '[User stat]', + :controller => 'user_admin', :action => 'user_stat') + ' ' + end + + # general options options += link_to_unless_current '[Settings]', :controller => 'users', :action => 'index' - options = options + ' ' + + options += ' ' + options += link_to('[Log out]', {:controller => 'main', :action => 'login'}) options end diff --git a/app/views/layouts/application.rhtml b/app/views/layouts/application.rhtml --- a/app/views/layouts/application.rhtml +++ b/app/views/layouts/application.rhtml @@ -6,7 +6,7 @@ Grader! <%= stylesheet_link_tag 'application' %> - <%= javascript_include_tag :defaults %> + <%= yield :head %> diff --git a/app/views/layouts/empty.html.erb b/app/views/layouts/empty.html.erb new file mode 100644 --- /dev/null +++ b/app/views/layouts/empty.html.erb @@ -0,0 +1,15 @@ + + + + + + Grader! + <%= stylesheet_link_tag 'application' %> + + + +<%= yield %> + + + diff --git a/app/views/layouts/login.html.erb b/app/views/layouts/login.html.erb deleted file mode 100644 --- a/app/views/layouts/login.html.erb +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - Grader! - <%= stylesheet_link_tag 'application' %> - - - -<%= yield %> - - - diff --git a/app/views/layouts/problems.rhtml b/app/views/layouts/problems.rhtml deleted file mode 100644 --- a/app/views/layouts/problems.rhtml +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - Problems: <%= controller.action_name %> - <%= stylesheet_link_tag 'scaffold' %> - <%= javascript_include_tag :defaults %> - - - -

<%= flash[:notice] %>

- -<%= yield %> - - - diff --git a/app/views/layouts/user_admin.rhtml b/app/views/layouts/user_admin.rhtml deleted file mode 100644 --- a/app/views/layouts/user_admin.rhtml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - - UserAdmin: <%= controller.action_name %> - <%= stylesheet_link_tag 'scaffold' %> - - - -

<%= flash[:notice] %>

- -<%= yield %> - - - diff --git a/app/views/problems/list.rhtml b/app/views/problems/list.rhtml --- a/app/views/problems/list.rhtml +++ b/app/views/problems/list.rhtml @@ -1,3 +1,8 @@ +<% content_for :head do %> + <%= stylesheet_link_tag 'scaffold' %> + <%= javascript_include_tag :defaults %> +<% end %> +

Listing problems

diff --git a/app/views/user_admin/list.rhtml b/app/views/user_admin/list.rhtml --- a/app/views/user_admin/list.rhtml +++ b/app/views/user_admin/list.rhtml @@ -1,9 +1,8 @@ -

Listing users

+<% content_for :head do %> + <%= stylesheet_link_tag 'scaffold' %> +<% end %> -
-<%= link_to 'Stat', :action => 'user_stat' %> -<%= link_to 'Main', :controller => 'main', :action => 'list' %> -
+

Listing users

Quick add diff --git a/app/views/user_admin/show.rhtml b/app/views/user_admin/show.rhtml --- a/app/views/user_admin/show.rhtml +++ b/app/views/user_admin/show.rhtml @@ -1,3 +1,5 @@ +

User information

+ <% for column in User.content_columns %>

<%= column.human_name %>: <%=h @user.send(column.name) %> diff --git a/app/views/users/index.html.haml b/app/views/users/index.html.haml --- a/app/views/users/index.html.haml +++ b/app/views/users/index.html.haml @@ -1,3 +1,6 @@ + +- content_for :head do + = javascript_include_tag :defaults %h1 Your account settings