# HG changeset patch # User Nattee Niparnan # Date 2016-02-06 19:11:17 # Node ID d50bf0fc7252d8cf3e6ec241da5c7eb52fd56dcc # Parent af432c550f8ef9b96d457843fa03bdc9933fadb2 bootstrap navbar diff --git a/app/assets/stylesheets/application.css.sass b/app/assets/stylesheets/application.css.sass --- a/app/assets/stylesheets/application.css.sass +++ b/app/assets/stylesheets/application.css.sass @@ -1,3 +1,19 @@ +/* + * This is a manifest file that'll be compiled into application.css, which will include all the files + * listed below. + * + * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets, + * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path. + * + * You're free to add application-wide styles to this file and they'll appear at the bottom of the + * compiled file so the styles you add here take precedence over styles defined in any styles + * defined in the other CSS/SCSS files in this directory. It is generally better to create a new + * file per style scope. + * + *= require_tree . + *= require_self + */ + @import jquery.ui.core @import jquery.ui.theme @@ -11,12 +27,16 @@ @import "bootstrap-sprockets" @import "bootstrap" +.secondnavbar + top: 50px + body background: white image-url("topbg.jpg") repeat-x top center font-size: 13px font-family: Tahoma, "sans-serif" margin: 10px padding: 10px + padding-top: 100px input 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 @@ -1,6 +1,38 @@ # Methods added to this helper will be available to all templates in the application. module ApplicationHelper + def navbar_user_header + left_menu = '' + right_menu = '' + user = User.find(session[:user_id]) + + if (user!=nil) and (GraderConfiguration.show_tasks_to?(user)) + left_menu << add_menu("#{I18n.t 'menu.tasks'}", 'tasks', 'list') + left_menu << add_menu("#{I18n.t 'menu.submissions'}", 'main', 'submission') + left_menu << add_menu("#{I18n.t 'menu.test'}", 'test', 'index') + end + + if GraderConfiguration['right.user_hall_of_fame'] + left_menu << add_menu("#{I18n.t 'menu.hall_of_fame'}", 'report', 'problem_hof') + end + left_menu << add_menu("#{I18n.t 'menu.help'}", 'main', 'help') + + + right_menu << add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-comment')} #{I18n.t 'menu.messages'}".html_safe, 'messages', 'list') + if GraderConfiguration['system.user_setting_enabled'] + right_menu << add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-cog')} #{I18n.t 'menu.settings'}".html_safe, 'users', 'index') + end + right_menu << add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-log-out')} #{I18n.t 'menu.log_out'}".html_safe, 'main', 'login',) + + result = content_tag(:ul,left_menu.html_safe,class: 'nav navbar-nav') + content_tag(:ul,right_menu.html_safe,class: 'nav navbar-nav navbar-right') + end + + def add_menu(title, controller, action,html_option = {}) + link_option = {controller: controller, action: action} + html_option[:class] = (html_option[:class] || '') + " active" if current_page?(link_option) + content_tag(:li, link_to(title,link_option),html_option) + end + def user_header menu_items = '' user = User.find(session[:user_id]) diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -9,10 +9,22 @@ = yield :head %body - -%div.userbar - = user_header + %nav.navbar.navbar-default.navbar-fixed-top + .container-fluid + .navbar-header + %a.navbar-brand{href: main_list_path} หน้าหลัก + .collapse.navbar-collapse + = navbar_user_header #call helper function + %nav.navbar.navbar-default.navbar-fixed-top.navbar-inverse.secondnavbar + .container-fluid + .collapse.navbar-collapse + %ul.nav.navbar-nav + %li + %a{href:'#'}hahaha -= content_tag(:p,flash[:notice],:style => "color:green") if flash[:notice]!=nil -= yield + %div.userbar + = user_header + = content_tag(:p,flash[:notice],:style => "color:green") if flash[:notice]!=nil + = yield + diff --git a/config/routes.rb b/config/routes.rb --- a/config/routes.rb +++ b/config/routes.rb @@ -1,4 +1,6 @@ CafeGrader::Application.routes.draw do + root :to => 'main#login' + get "report/login" resources :contests @@ -8,63 +10,12 @@ resources :grader_configuration, controller: 'configurations' - # The priority is based upon order of creation: - # first created -> highest priority. - - # Sample of regular route: - # match 'products/:id' => 'catalog#view' - # Keep in mind you can assign values other than :controller and :action - - # Sample of named route: - # match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase - # This route can be invoked with purchase_url(:id => product.id) - - # Sample resource route (maps HTTP verbs to controller actions automatically): - # resources :products - - # Sample resource route with options: - # resources :products do - # member do - # get 'short' - # post 'toggle' - # end - # - # collection do - # get 'sold' - # end - # end - - # Sample resource route with sub-resources: - # resources :products do - # resources :comments, :sales - # resource :seller - # end - - # Sample resource route with more complex sub-resources - # resources :products do - # resources :comments - # resources :sales do - # get 'recent', :on => :collection - # end - # end - - # Sample resource route within a namespace: - # namespace :admin do - # # Directs /admin/products/* to Admin::ProductsController - # # (app/controllers/admin/products_controller.rb) - # resources :products - # end - - # You can have the root of your site routed with "root" - # just remember to delete public/index.html. - # root :to => 'welcome#index' - - root :to => 'main#login' - match 'tasks/view/:file.:ext' => 'tasks#view' match 'tasks/download/:id/:file.:ext' => 'tasks#download' + match 'heartbeat/:id/edit' => 'heartbeat#edit' - match 'heartbeat/:id/edit' => 'heartbeat#edit' + #main + get "main/list" # See how all your routes lay out with "rake routes"