Description:
use jquery by default
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r554:50143f71e61a - - 12 files changed: 95 inserted, 50 deleted

@@ -0,0 +1,2
1 + $ ->
2 + $(".select2").select2()
@@ -0,0 +1,35
1 + %header.navbar.navbar-default.navbar-fixed-top
2 + %nav
3 + .container-fluid
4 + .navbar-header
5 + %a.navbar-brand{href: main_list_path} หน้าหลัก
6 + .collapse.navbar-collapse
7 + %ul.nav.navbar-nav
8 + - if (@current_user!=nil) and (GraderConfiguration.show_tasks_to?(@current_user))
9 + = add_menu("#{I18n.t 'menu.tasks'}", 'tasks', 'list')
10 + = add_menu("#{I18n.t 'menu.submissions'}", 'main', 'submission')
11 + = add_menu("#{I18n.t 'menu.test'}", 'test', 'index')
12 + - if GraderConfiguration['right.user_hall_of_fame']
13 + = add_menu("#{I18n.t 'menu.hall_of_fame'}", 'report', 'problem_hof')
14 + %ul.nav.navbar-nav.navbar-right
15 + = add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-question-sign')}".html_safe, 'main', 'help')
16 + = add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-comment')}".html_safe, 'messages', 'list', {title: I18n.t('menu.messages'), data: {toggle: 'tooltip'}})
17 + - if GraderConfiguration['system.user_setting_enabled']
18 + = add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-cog')}".html_safe, 'users', 'index', {title: I18n.t('menu.settings'), data: {toggle: 'tooltip'}})
19 + = add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-log-out')} #{@current_user.full_name}".html_safe, 'main', 'login', {title: I18n.t('menu.log_out'), data: {toggle: 'tooltip'}})
20 +
21 + - if (@current_user!=nil) and (session[:admin])
22 + %nav.navbar.navbar-default.navbar-fixed-top.navbar-inverse.secondnavbar
23 + .container-fluid
24 + .collapse.navbar-collapse
25 + %ul.nav.navbar-nav
26 + = add_menu( '[Announcements]', 'announcements', 'index')
27 + = add_menu( '[Msg console]', 'messages', 'console')
28 + = add_menu( '[Problems]', 'problems', 'index')
29 + = add_menu( '[Users]', 'user_admin', 'index')
30 + = add_menu( '[Results]', 'user_admin', 'user_stat')
31 + = add_menu( '[Report]', 'report', 'multiple_login')
32 + = add_menu( '[Graders]', 'graders', 'list')
33 + = add_menu( '[Contests]', 'contest_management', 'index')
34 + = add_menu( '[Sites]', 'sites', 'index')
35 + = add_menu( '[System config]', 'configurations', 'index')
@@ -0,0 +1,6
1 + = form_tag({:action => 'submit'}, :multipart => true) do
2 + %b Problem:
3 + = select 'submission', 'problem_id', [[(t 'main.specified_in_header'),'-1']] + @problems.collect {|p| [p.full_name, p.id]}, {:selected => '-1'}, { class: 'select2' }
4 + %b File:
5 + = file_field_tag 'file'
6 + = submit_tag 'Submit'
@@ -1,16 +1,18
1 source 'https://rubygems.org'
1 source 'https://rubygems.org'
2
2
3 gem 'rails', '3.2.21'
3 gem 'rails', '3.2.21'
4
4
5 + gem 'select2-rails'
6 +
5 # Bundle edge Rails instead:
7 # Bundle edge Rails instead:
6 # gem 'rails', :git => 'git://github.com/rails/rails.git'
8 # gem 'rails', :git => 'git://github.com/rails/rails.git'
7
9
8 gem 'mysql2'
10 gem 'mysql2'
9
11
10 # Gems used only for assets and not required
12 # Gems used only for assets and not required
11 # in production environments by default.
13 # in production environments by default.
12 group :assets do
14 group :assets do
13 gem 'sass-rails', '~> 3.2.6'
15 gem 'sass-rails', '~> 3.2.6'
14 gem 'coffee-rails', '~> 3.2.2'
16 gem 'coffee-rails', '~> 3.2.2'
15
17
16 # See https://github.com/sstephenson/execjs#readme for more supported runtimes
18 # See https://github.com/sstephenson/execjs#readme for more supported runtimes
@@ -126,24 +126,26
126 activemodel (>= 3.0)
126 activemodel (>= 3.0)
127 activesupport (>= 3.0)
127 activesupport (>= 3.0)
128 railties (>= 3.0)
128 railties (>= 3.0)
129 rspec-collection_matchers
129 rspec-collection_matchers
130 rspec-core (~> 2.99.0)
130 rspec-core (~> 2.99.0)
131 rspec-expectations (~> 2.99.0)
131 rspec-expectations (~> 2.99.0)
132 rspec-mocks (~> 2.99.0)
132 rspec-mocks (~> 2.99.0)
133 sass (3.4.11)
133 sass (3.4.11)
134 sass-rails (3.2.6)
134 sass-rails (3.2.6)
135 railties (~> 3.2.0)
135 railties (~> 3.2.0)
136 sass (>= 3.1.10)
136 sass (>= 3.1.10)
137 tilt (~> 1.3)
137 tilt (~> 1.3)
138 + select2-rails (4.0.1)
139 + thor (~> 0.14)
138 sprockets (2.2.3)
140 sprockets (2.2.3)
139 hike (~> 1.2)
141 hike (~> 1.2)
140 multi_json (~> 1.0)
142 multi_json (~> 1.0)
141 rack (~> 1.0)
143 rack (~> 1.0)
142 tilt (~> 1.1, != 1.3.0)
144 tilt (~> 1.1, != 1.3.0)
143 test-unit (3.0.9)
145 test-unit (3.0.9)
144 power_assert
146 power_assert
145 thor (0.19.1)
147 thor (0.19.1)
146 tilt (1.4.1)
148 tilt (1.4.1)
147 treetop (1.4.15)
149 treetop (1.4.15)
148 polyglot
150 polyglot
149 polyglot (>= 0.3.1)
151 polyglot (>= 0.3.1)
@@ -167,16 +169,17
167 jquery-rails
169 jquery-rails
168 jquery-tablesorter
170 jquery-tablesorter
169 jquery-timepicker-addon-rails
171 jquery-timepicker-addon-rails
170 jquery-ui-sass-rails
172 jquery-ui-sass-rails
171 mail
173 mail
172 mysql2
174 mysql2
173 prototype-rails
175 prototype-rails
174 rails (= 3.2.21)
176 rails (= 3.2.21)
175 rdiscount
177 rdiscount
176 rouge
178 rouge
177 rspec-rails (~> 2.99.0)
179 rspec-rails (~> 2.99.0)
178 sass-rails (~> 3.2.6)
180 sass-rails (~> 3.2.6)
181 + select2-rails
179 test-unit
182 test-unit
180 uglifier
183 uglifier
181 verification!
184 verification!
182 will_paginate (~> 3.0.7)
185 will_paginate (~> 3.0.7)
@@ -1,18 +1,26
1 // This is a manifest file that'll be compiled into application.js, which will include all the files
1 // This is a manifest file that'll be compiled into application.js, which will include all the files
2 // listed below.
2 // listed below.
3 //
3 //
4 // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
4 // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5 // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
5 // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6 //
6 //
7 // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
7 // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8 // the compiled file.
8 // the compiled file.
9 //
9 //
10 // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
10 // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11 // GO AFTER THE REQUIRES BELOW.
11 // GO AFTER THE REQUIRES BELOW.
12 //
12 //
13 - //= require prototype
13 + //= require jquery
14 - //= require prototype_ujs
14 + //= require jquery_ujs
15 - //= require effects
15 + //= require jquery.ui.all
16 - //= require dragdrop
17 - //= require controls
18 //= require bootstrap-sprockets
16 //= require bootstrap-sprockets
17 + //= require custom
18 + //= require select2
19 +
20 +
21 + // since this is after blank line, it is not downloaded
22 + //x= require prototype
23 + //x= require prototype_ujs
24 + //x= require effects
25 + //x= require dragdrop
26 + //x= require controls
@@ -1,48 +1,51
1 /*
1 /*
2 * This is a manifest file that'll be compiled into application.css, which will include all the files
2 * This is a manifest file that'll be compiled into application.css, which will include all the files
3 * listed below.
3 * listed below.
4 *
4 *
5 * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
5 * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6 * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
6 * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7 *
7 *
8 * You're free to add application-wide styles to this file and they'll appear at the bottom of the
8 * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9 * compiled file so the styles you add here take precedence over styles defined in any styles
9 * compiled file so the styles you add here take precedence over styles defined in any styles
10 * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
10 * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11 * file per style scope.
11 * file per style scope.
12 *
12 *
13 - *= require_tree .
13 + // bootstrap says that we should not do this, but @import each file instead
14 - *= require_self
14 + # *= require_tree .
15 + # *= require_self
15 */
16 */
16
17
17 -
18 + @import jquery.ui.all
19 + @import jquery.ui.core
18 @import jquery.ui.core
20 @import jquery.ui.core
19 @import jquery.ui.theme
21 @import jquery.ui.theme
20 @import jquery.ui.datepicker
22 @import jquery.ui.datepicker
21 @import jquery.ui.slider
23 @import jquery.ui.slider
22 @import jquery-ui-timepicker-addon
24 @import jquery-ui-timepicker-addon
23 @import jquery-tablesorter/theme.metro-dark
25 @import jquery-tablesorter/theme.metro-dark
24 @import tablesorter-theme.cafe
26 @import tablesorter-theme.cafe
25
27
26 -
28 + @import bootstrap-sprockets
27 - @import "bootstrap-sprockets"
29 + @import bootstrap
28 - @import "bootstrap"
30 + @import select2
31 + @import select2-bootstrap
29
32
30 .secondnavbar
33 .secondnavbar
31 top: 50px
34 top: 50px
32
35
33 body
36 body
34 background: white image-url("topbg.jpg") repeat-x top center
37 background: white image-url("topbg.jpg") repeat-x top center
35 - font-size: 13px
38 + //font-size: 13px
36 - font-family: Tahoma, "sans-serif"
39 + //font-family: Tahoma, "sans-serif"
37 margin: 10px
40 margin: 10px
38 padding: 10px
41 padding: 10px
39 padding-top: 100px
42 padding-top: 100px
40
43
41
44
42 input
45 input
43 font-family: Tahoma, "sans-serif"
46 font-family: Tahoma, "sans-serif"
44
47
45
48
46 h1
49 h1
47 font-size: 24px
50 font-size: 24px
48 color: #334488
51 color: #334488
@@ -1,18 +1,25
1 class ApplicationController < ActionController::Base
1 class ApplicationController < ActionController::Base
2 protect_from_forgery
2 protect_from_forgery
3
3
4 + before_filter :current_user
5 +
4 SINGLE_USER_MODE_CONF_KEY = 'system.single_user_mode'
6 SINGLE_USER_MODE_CONF_KEY = 'system.single_user_mode'
5 MULTIPLE_IP_LOGIN_CONF_KEY = 'right.multiple_ip_login'
7 MULTIPLE_IP_LOGIN_CONF_KEY = 'right.multiple_ip_login'
6
8
9 + # Returns the current logged-in user (if any).
10 + def current_user
11 + @current_user ||= User.find(session[:user_id])
12 + end
13 +
7 def admin_authorization
14 def admin_authorization
8 return false unless authenticate
15 return false unless authenticate
9 user = User.find(session[:user_id], :include => ['roles'])
16 user = User.find(session[:user_id], :include => ['roles'])
10 unless user.admin?
17 unless user.admin?
11 flash[:notice] = 'You are not authorized to view the page you requested'
18 flash[:notice] = 'You are not authorized to view the page you requested'
12 redirect_to :controller => 'main', :action => 'login' unless user.admin?
19 redirect_to :controller => 'main', :action => 'login' unless user.admin?
13 return false
20 return false
14 end
21 end
15 return true
22 return true
16 end
23 end
17
24
18 def authorization_by_roles(allowed_roles)
25 def authorization_by_roles(allowed_roles)
@@ -6,32 +6,32
6 right_menu = ''
6 right_menu = ''
7 user = User.find(session[:user_id])
7 user = User.find(session[:user_id])
8
8
9 if (user!=nil) and (GraderConfiguration.show_tasks_to?(user))
9 if (user!=nil) and (GraderConfiguration.show_tasks_to?(user))
10 left_menu << add_menu("#{I18n.t 'menu.tasks'}", 'tasks', 'list')
10 left_menu << add_menu("#{I18n.t 'menu.tasks'}", 'tasks', 'list')
11 left_menu << add_menu("#{I18n.t 'menu.submissions'}", 'main', 'submission')
11 left_menu << add_menu("#{I18n.t 'menu.submissions'}", 'main', 'submission')
12 left_menu << add_menu("#{I18n.t 'menu.test'}", 'test', 'index')
12 left_menu << add_menu("#{I18n.t 'menu.test'}", 'test', 'index')
13 end
13 end
14
14
15 if GraderConfiguration['right.user_hall_of_fame']
15 if GraderConfiguration['right.user_hall_of_fame']
16 left_menu << add_menu("#{I18n.t 'menu.hall_of_fame'}", 'report', 'problem_hof')
16 left_menu << add_menu("#{I18n.t 'menu.hall_of_fame'}", 'report', 'problem_hof')
17 end
17 end
18 - left_menu << add_menu("#{I18n.t 'menu.help'}", 'main', 'help')
19 -
20
18
21 - right_menu << add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-comment')} #{I18n.t 'menu.messages'}".html_safe, 'messages', 'list')
19 + right_menu << add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-question-sign')}".html_safe, 'main', 'help')
20 + right_menu << add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-comment')}".html_safe, 'messages', 'list', {title: I18n.t('menu.messages'), data: {toggle: 'tooltip'}})
22 if GraderConfiguration['system.user_setting_enabled']
21 if GraderConfiguration['system.user_setting_enabled']
23 - right_menu << add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-cog')} #{I18n.t 'menu.settings'}".html_safe, 'users', 'index')
22 + right_menu << add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-cog')}".html_safe, 'users', 'index', {title: I18n.t('menu.settings'), data: {toggle: 'tooltip'}})
24 end
23 end
25 - right_menu << add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-log-out')} #{I18n.t 'menu.log_out'}".html_safe, 'main', 'login',)
24 + right_menu << add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-log-out')} #{user.full_name}".html_safe, 'main', 'login', {title: I18n.t('menu.log_out'), data: {toggle: 'tooltip'}})
25 +
26
26
27 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')
27 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')
28 end
28 end
29
29
30 def add_menu(title, controller, action,html_option = {})
30 def add_menu(title, controller, action,html_option = {})
31 link_option = {controller: controller, action: action}
31 link_option = {controller: controller, action: action}
32 html_option[:class] = (html_option[:class] || '') + " active" if current_page?(link_option)
32 html_option[:class] = (html_option[:class] || '') + " active" if current_page?(link_option)
33 content_tag(:li, link_to(title,link_option),html_option)
33 content_tag(:li, link_to(title,link_option),html_option)
34 end
34 end
35
35
36 def user_header
36 def user_header
37 menu_items = ''
37 menu_items = ''
@@ -1,30 +1,15
1 <!DOCTYPE html>
1 <!DOCTYPE html>
2 %html
2 %html
3 %head
3 %head
4 %title= GraderConfiguration['contest.name']
4 %title= GraderConfiguration['contest.name']
5 = stylesheet_link_tag "application", :media => "all"
5 = stylesheet_link_tag "application", :media => "all"
6 = javascript_include_tag "application"
6 = javascript_include_tag "application"
7 = csrf_meta_tags
7 = csrf_meta_tags
8 = content_for :header
8 = content_for :header
9 = yield :head
9 = yield :head
10
10
11 %body
11 %body
12 - %nav.navbar.navbar-default.navbar-fixed-top
12 + = render 'layouts/header'
13 - .container-fluid
14 - .navbar-header
15 - %a.navbar-brand{href: main_list_path} หน้าหลัก
16 - .collapse.navbar-collapse
17 - = navbar_user_header #call helper function
18 - %nav.navbar.navbar-default.navbar-fixed-top.navbar-inverse.secondnavbar
19 - .container-fluid
20 - .collapse.navbar-collapse
21 - %ul.nav.navbar-nav
22 - %li
23 - %a{href:'#'}hahaha
24 -
25 - %div.userbar
26 - = user_header
27
13
28 = content_tag(:p,flash[:notice],:style => "color:green") if flash[:notice]!=nil
14 = content_tag(:p,flash[:notice],:style => "color:green") if flash[:notice]!=nil
29 = yield
15 = yield
30 -
@@ -13,32 +13,34
13 .submitbox
13 .submitbox
14 = error_messages_for 'submission'
14 = error_messages_for 'submission'
15 = render :partial => 'submission_box'
15 = render :partial => 'submission_box'
16
16
17
17
18 %hr/
18 %hr/
19
19
20 - if (GraderConfiguration.contest_mode?) and (@user.site!=nil) and (@user.site.started!=true)
20 - if (GraderConfiguration.contest_mode?) and (@user.site!=nil) and (@user.site.started!=true)
21 %p=t 'main.start_soon'
21 %p=t 'main.start_soon'
22
22
23 - if GraderConfiguration.show_tasks_to?(@user)
23 - if GraderConfiguration.show_tasks_to?(@user)
24 - if not GraderConfiguration.multicontests?
24 - if not GraderConfiguration.multicontests?
25 - %table.info
25 + %table.table.table-striped
26 - %tr.info-head
26 + %thead
27 - %th
27 + %tr.info-head
28 - %th Tasks name
28 + %th #
29 - %th Full name
29 + %th Tasks name
30 - %th # of sub(s)
30 + %th Full name
31 - %th Results
31 + %th # of sub(s)
32 - = render :partial => 'problem', :collection => @problems
32 + %th Results
33 + %tbody
34 + = render :partial => 'problem', :collection => @problems
33 - else
35 - else
34 - @contest_problems.each do |cp|
36 - @contest_problems.each do |cp|
35 - if cp[:problems].length > 0
37 - if cp[:problems].length > 0
36 %h2{:class =>'contest-title'}
38 %h2{:class =>'contest-title'}
37 = "#{cp[:contest] ? cp[:contest].title : 'Public problems'}"
39 = "#{cp[:contest] ? cp[:contest].title : 'Public problems'}"
38 %table.info
40 %table.info
39 %tr.info-head
41 %tr.info-head
40 %th
42 %th
41 %th Tasks name
43 %th Tasks name
42 %th Full name
44 %th Full name
43 %th # of sub(s)
45 %th # of sub(s)
44 %th Results
46 %th Results
deleted file
You need to be logged in to leave comments. Login now