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,68 +1,70
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
17 # gem 'therubyracer', :platforms => :ruby
19 # gem 'therubyracer', :platforms => :ruby
18
20
19 gem 'uglifier'
21 gem 'uglifier'
20 end
22 end
21
23
22 gem 'prototype-rails'
24 gem 'prototype-rails'
23
25
24 # To use ActiveModel has_secure_password
26 # To use ActiveModel has_secure_password
25 # gem 'bcrypt-ruby', '~> 3.0.0'
27 # gem 'bcrypt-ruby', '~> 3.0.0'
26
28
27 # To use Jbuilder templates for JSON
29 # To use Jbuilder templates for JSON
28 # gem 'jbuilder'
30 # gem 'jbuilder'
29
31
30 # Use unicorn as the app server
32 # Use unicorn as the app server
31 # gem 'unicorn'
33 # gem 'unicorn'
32
34
33 # Deploy with Capistrano
35 # Deploy with Capistrano
34 # gem 'capistrano'
36 # gem 'capistrano'
35
37
36 # To use debugger
38 # To use debugger
37 # gem 'debugger'
39 # gem 'debugger'
38 #
40 #
39
41
40 #in-place editor
42 #in-place editor
41 gem 'best_in_place', '~> 3.0.1'
43 gem 'best_in_place', '~> 3.0.1'
42
44
43 # jquery addition
45 # jquery addition
44 gem 'jquery-rails'
46 gem 'jquery-rails'
45 gem 'jquery-ui-sass-rails'
47 gem 'jquery-ui-sass-rails'
46 gem 'jquery-timepicker-addon-rails'
48 gem 'jquery-timepicker-addon-rails'
47 gem 'jquery-tablesorter'
49 gem 'jquery-tablesorter'
48
50
49 #syntax highlighter
51 #syntax highlighter
50 gem 'rouge'
52 gem 'rouge'
51
53
52 #add bootstrap
54 #add bootstrap
53 gem 'bootstrap-sass', '~> 3.2.0'
55 gem 'bootstrap-sass', '~> 3.2.0'
54 gem 'autoprefixer-rails'
56 gem 'autoprefixer-rails'
55
57
56
58
57 gem 'haml'
59 gem 'haml'
58 gem 'mail'
60 gem 'mail'
59 gem 'rdiscount'
61 gem 'rdiscount'
60 gem 'test-unit'
62 gem 'test-unit'
61 gem 'will_paginate', '~> 3.0.7'
63 gem 'will_paginate', '~> 3.0.7'
62 gem 'dynamic_form'
64 gem 'dynamic_form'
63 gem 'in_place_editing'
65 gem 'in_place_editing'
64 gem 'verification', :git => 'https://github.com/sikachu/verification.git'
66 gem 'verification', :git => 'https://github.com/sikachu/verification.git'
65
67
66 group :test, :development do
68 group :test, :development do
67 gem 'rspec-rails', '~> 2.99.0'
69 gem 'rspec-rails', '~> 2.99.0'
68 end
70 end
@@ -42,141 +42,144
42 json
42 json
43 best_in_place (3.0.3)
43 best_in_place (3.0.3)
44 actionpack (>= 3.2)
44 actionpack (>= 3.2)
45 railties (>= 3.2)
45 railties (>= 3.2)
46 bootstrap-sass (3.2.0.2)
46 bootstrap-sass (3.2.0.2)
47 sass (~> 3.2)
47 sass (~> 3.2)
48 builder (3.0.4)
48 builder (3.0.4)
49 coffee-rails (3.2.2)
49 coffee-rails (3.2.2)
50 coffee-script (>= 2.2.0)
50 coffee-script (>= 2.2.0)
51 railties (~> 3.2.0)
51 railties (~> 3.2.0)
52 coffee-script (2.3.0)
52 coffee-script (2.3.0)
53 coffee-script-source
53 coffee-script-source
54 execjs
54 execjs
55 coffee-script-source (1.9.0)
55 coffee-script-source (1.9.0)
56 diff-lcs (1.2.5)
56 diff-lcs (1.2.5)
57 dynamic_form (1.1.4)
57 dynamic_form (1.1.4)
58 erubis (2.7.0)
58 erubis (2.7.0)
59 execjs (2.3.0)
59 execjs (2.3.0)
60 haml (4.0.6)
60 haml (4.0.6)
61 tilt
61 tilt
62 hike (1.2.3)
62 hike (1.2.3)
63 i18n (0.7.0)
63 i18n (0.7.0)
64 in_place_editing (1.2.0)
64 in_place_editing (1.2.0)
65 journey (1.0.4)
65 journey (1.0.4)
66 jquery-rails (3.1.2)
66 jquery-rails (3.1.2)
67 railties (>= 3.0, < 5.0)
67 railties (>= 3.0, < 5.0)
68 thor (>= 0.14, < 2.0)
68 thor (>= 0.14, < 2.0)
69 jquery-tablesorter (1.13.4)
69 jquery-tablesorter (1.13.4)
70 railties (>= 3.1, < 5)
70 railties (>= 3.1, < 5)
71 jquery-timepicker-addon-rails (1.4.1)
71 jquery-timepicker-addon-rails (1.4.1)
72 railties (>= 3.1)
72 railties (>= 3.1)
73 jquery-ui-rails (4.0.3)
73 jquery-ui-rails (4.0.3)
74 jquery-rails
74 jquery-rails
75 railties (>= 3.1.0)
75 railties (>= 3.1.0)
76 jquery-ui-sass-rails (4.0.3.0)
76 jquery-ui-sass-rails (4.0.3.0)
77 jquery-rails
77 jquery-rails
78 jquery-ui-rails (= 4.0.3)
78 jquery-ui-rails (= 4.0.3)
79 railties (>= 3.1.0)
79 railties (>= 3.1.0)
80 json (1.8.2)
80 json (1.8.2)
81 mail (2.5.4)
81 mail (2.5.4)
82 mime-types (~> 1.16)
82 mime-types (~> 1.16)
83 treetop (~> 1.4.8)
83 treetop (~> 1.4.8)
84 mime-types (1.25.1)
84 mime-types (1.25.1)
85 multi_json (1.10.1)
85 multi_json (1.10.1)
86 mysql2 (0.3.20)
86 mysql2 (0.3.20)
87 polyglot (0.3.5)
87 polyglot (0.3.5)
88 power_assert (0.2.2)
88 power_assert (0.2.2)
89 prototype-rails (3.2.1)
89 prototype-rails (3.2.1)
90 rails (~> 3.2)
90 rails (~> 3.2)
91 rack (1.4.5)
91 rack (1.4.5)
92 rack-cache (1.2)
92 rack-cache (1.2)
93 rack (>= 0.4)
93 rack (>= 0.4)
94 rack-ssl (1.3.4)
94 rack-ssl (1.3.4)
95 rack
95 rack
96 rack-test (0.6.3)
96 rack-test (0.6.3)
97 rack (>= 1.0)
97 rack (>= 1.0)
98 rails (3.2.21)
98 rails (3.2.21)
99 actionmailer (= 3.2.21)
99 actionmailer (= 3.2.21)
100 actionpack (= 3.2.21)
100 actionpack (= 3.2.21)
101 activerecord (= 3.2.21)
101 activerecord (= 3.2.21)
102 activeresource (= 3.2.21)
102 activeresource (= 3.2.21)
103 activesupport (= 3.2.21)
103 activesupport (= 3.2.21)
104 bundler (~> 1.0)
104 bundler (~> 1.0)
105 railties (= 3.2.21)
105 railties (= 3.2.21)
106 railties (3.2.21)
106 railties (3.2.21)
107 actionpack (= 3.2.21)
107 actionpack (= 3.2.21)
108 activesupport (= 3.2.21)
108 activesupport (= 3.2.21)
109 rack-ssl (~> 1.3.2)
109 rack-ssl (~> 1.3.2)
110 rake (>= 0.8.7)
110 rake (>= 0.8.7)
111 rdoc (~> 3.4)
111 rdoc (~> 3.4)
112 thor (>= 0.14.6, < 2.0)
112 thor (>= 0.14.6, < 2.0)
113 rake (10.4.2)
113 rake (10.4.2)
114 rdiscount (2.1.8)
114 rdiscount (2.1.8)
115 rdoc (3.12.2)
115 rdoc (3.12.2)
116 json (~> 1.4)
116 json (~> 1.4)
117 rouge (1.8.0)
117 rouge (1.8.0)
118 rspec-collection_matchers (1.1.2)
118 rspec-collection_matchers (1.1.2)
119 rspec-expectations (>= 2.99.0.beta1)
119 rspec-expectations (>= 2.99.0.beta1)
120 rspec-core (2.99.2)
120 rspec-core (2.99.2)
121 rspec-expectations (2.99.2)
121 rspec-expectations (2.99.2)
122 diff-lcs (>= 1.1.3, < 2.0)
122 diff-lcs (>= 1.1.3, < 2.0)
123 rspec-mocks (2.99.3)
123 rspec-mocks (2.99.3)
124 rspec-rails (2.99.0)
124 rspec-rails (2.99.0)
125 actionpack (>= 3.0)
125 actionpack (>= 3.0)
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)
150 tzinfo (0.3.43)
152 tzinfo (0.3.43)
151 uglifier (2.7.0)
153 uglifier (2.7.0)
152 execjs (>= 0.3.0)
154 execjs (>= 0.3.0)
153 json (>= 1.8.0)
155 json (>= 1.8.0)
154 will_paginate (3.0.7)
156 will_paginate (3.0.7)
155
157
156 PLATFORMS
158 PLATFORMS
157 ruby
159 ruby
158
160
159 DEPENDENCIES
161 DEPENDENCIES
160 autoprefixer-rails
162 autoprefixer-rails
161 best_in_place (~> 3.0.1)
163 best_in_place (~> 3.0.1)
162 bootstrap-sass (~> 3.2.0)
164 bootstrap-sass (~> 3.2.0)
163 coffee-rails (~> 3.2.2)
165 coffee-rails (~> 3.2.2)
164 dynamic_form
166 dynamic_form
165 haml
167 haml
166 in_place_editing
168 in_place_editing
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,132 +1,135
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
49 line-height: 2em
52 line-height: 2em
50
53
51
54
52 h2
55 h2
53 font-size: 18px
56 font-size: 18px
54 color: #5566bb
57 color: #5566bb
55 line-height: 1.5em
58 line-height: 1.5em
56
59
57
60
58 hr
61 hr
59 border-top: 1px solid #dddddd
62 border-top: 1px solid #dddddd
60 border-bottom: 1px solid #eeeeee
63 border-bottom: 1px solid #eeeeee
61
64
62
65
63 a
66 a
64 color: #6666cc
67 color: #6666cc
65 text-decoration: none
68 text-decoration: none
66
69
67 &:link, &:visited
70 &:link, &:visited
68 color: #6666cc
71 color: #6666cc
69 text-decoration: none
72 text-decoration: none
70
73
71 &:hover, &:focus
74 &:hover, &:focus
72 color: #111166
75 color: #111166
73 text-decoration: none
76 text-decoration: none
74
77
75
78
76 div
79 div
77 &.userbar
80 &.userbar
78 line-height: 1.5em
81 line-height: 1.5em
79 text-align: right
82 text-align: right
80 font-size: 12px
83 font-size: 12px
81
84
82 &.title
85 &.title
83 padding: 10px 0px
86 padding: 10px 0px
84 line-height: 1.5em
87 line-height: 1.5em
85 font-size: 13px
88 font-size: 13px
86
89
87 span.contest-over-msg
90 span.contest-over-msg
88 font-size: 15px
91 font-size: 15px
89 color: red
92 color: red
90
93
91 table
94 table
92 width: 100%
95 width: 100%
93 font-weight: bold
96 font-weight: bold
94
97
95 td
98 td
96 &.left-col
99 &.left-col
97 text-align: left
100 text-align: left
98 vertical-align: top
101 vertical-align: top
99 color: #444444
102 color: #444444
100
103
101 &.right-col
104 &.right-col
102 text-align: right
105 text-align: right
103 vertical-align: top
106 vertical-align: top
104 font-size: 18px
107 font-size: 18px
105 color: #116699
108 color: #116699
106
109
107
110
108 table.info
111 table.info
109 margin: 10px 0
112 margin: 10px 0
110 border: 1px solid #666666
113 border: 1px solid #666666
111 border-collapse: collapse
114 border-collapse: collapse
112 font-size: 12px
115 font-size: 12px
113
116
114 th
117 th
115 border: 1px solid #666666
118 border: 1px solid #666666
116 line-height: 1.5em
119 line-height: 1.5em
117 padding: 0 0.5em
120 padding: 0 0.5em
118
121
119 td
122 td
120 border-left: 1px solid #666666
123 border-left: 1px solid #666666
121 border-right: 1px solid #666666
124 border-right: 1px solid #666666
122 line-height: 1.5em
125 line-height: 1.5em
123 padding: 0 0.5em
126 padding: 0 0.5em
124
127
125
128
126 tr
129 tr
127 &.info-head
130 &.info-head
128 background: #777777
131 background: #777777
129 color: white
132 color: white
130
133
131 &.info-odd
134 &.info-odd
132 background: #eeeeee
135 background: #eeeeee
@@ -1,102 +1,109
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)
19 return false unless authenticate
26 return false unless authenticate
20 user = User.find(session[:user_id])
27 user = User.find(session[:user_id])
21 unless user.roles.detect { |role| allowed_roles.member?(role.name) }
28 unless user.roles.detect { |role| allowed_roles.member?(role.name) }
22 flash[:notice] = 'You are not authorized to view the page you requested'
29 flash[:notice] = 'You are not authorized to view the page you requested'
23 redirect_to :controller => 'main', :action => 'login'
30 redirect_to :controller => 'main', :action => 'login'
24 return false
31 return false
25 end
32 end
26 end
33 end
27
34
28 protected
35 protected
29
36
30 def authenticate
37 def authenticate
31 unless session[:user_id]
38 unless session[:user_id]
32 flash[:notice] = 'You need to login'
39 flash[:notice] = 'You need to login'
33 if GraderConfiguration[SINGLE_USER_MODE_CONF_KEY]
40 if GraderConfiguration[SINGLE_USER_MODE_CONF_KEY]
34 flash[:notice] = 'You need to login but you cannot log in at this time'
41 flash[:notice] = 'You need to login but you cannot log in at this time'
35 end
42 end
36 redirect_to :controller => 'main', :action => 'login'
43 redirect_to :controller => 'main', :action => 'login'
37 return false
44 return false
38 end
45 end
39
46
40 # check if run in single user mode
47 # check if run in single user mode
41 if GraderConfiguration[SINGLE_USER_MODE_CONF_KEY]
48 if GraderConfiguration[SINGLE_USER_MODE_CONF_KEY]
42 user = User.find(session[:user_id])
49 user = User.find(session[:user_id])
43 if user==nil or (not user.admin?)
50 if user==nil or (not user.admin?)
44 flash[:notice] = 'You cannot log in at this time'
51 flash[:notice] = 'You cannot log in at this time'
45 redirect_to :controller => 'main', :action => 'login'
52 redirect_to :controller => 'main', :action => 'login'
46 return false
53 return false
47 end
54 end
48 return true
55 return true
49 end
56 end
50
57
51 if GraderConfiguration.multicontests?
58 if GraderConfiguration.multicontests?
52 user = User.find(session[:user_id])
59 user = User.find(session[:user_id])
53 return true if user.admin?
60 return true if user.admin?
54 begin
61 begin
55 if user.contest_stat(true).forced_logout
62 if user.contest_stat(true).forced_logout
56 flash[:notice] = 'You have been automatically logged out.'
63 flash[:notice] = 'You have been automatically logged out.'
57 redirect_to :controller => 'main', :action => 'index'
64 redirect_to :controller => 'main', :action => 'index'
58 end
65 end
59 rescue
66 rescue
60 end
67 end
61 end
68 end
62 return true
69 return true
63 end
70 end
64
71
65 def authenticate_by_ip_address
72 def authenticate_by_ip_address
66 #this assume that we have already authenticate normally
73 #this assume that we have already authenticate normally
67 unless GraderConfiguration[MULTIPLE_IP_LOGIN_CONF_KEY]
74 unless GraderConfiguration[MULTIPLE_IP_LOGIN_CONF_KEY]
68 user = User.find(session[:user_id])
75 user = User.find(session[:user_id])
69 if (not user.admin? and user.last_ip and user.last_ip != request.remote_ip)
76 if (not user.admin? and user.last_ip and user.last_ip != request.remote_ip)
70 flash[:notice] = "You cannot use the system from #{request.remote_ip}. Your last ip is #{user.last_ip}"
77 flash[:notice] = "You cannot use the system from #{request.remote_ip}. Your last ip is #{user.last_ip}"
71 redirect_to :controller => 'main', :action => 'login'
78 redirect_to :controller => 'main', :action => 'login'
72 puts "CHEAT: user #{user.login} tried to login from '#{request.remote_ip}' while last ip is '#{user.last_ip}' at #{Time.zone.now}"
79 puts "CHEAT: user #{user.login} tried to login from '#{request.remote_ip}' while last ip is '#{user.last_ip}' at #{Time.zone.now}"
73 return false
80 return false
74 end
81 end
75 unless user.last_ip
82 unless user.last_ip
76 user.last_ip = request.remote_ip
83 user.last_ip = request.remote_ip
77 user.save
84 user.save
78 end
85 end
79 end
86 end
80 return true
87 return true
81 end
88 end
82
89
83 def authorization
90 def authorization
84 return false unless authenticate
91 return false unless authenticate
85 user = User.find(session[:user_id])
92 user = User.find(session[:user_id])
86 unless user.roles.detect { |role|
93 unless user.roles.detect { |role|
87 role.rights.detect{ |right|
94 role.rights.detect{ |right|
88 right.controller == self.class.controller_name and
95 right.controller == self.class.controller_name and
89 (right.action == 'all' or right.action == action_name)
96 (right.action == 'all' or right.action == action_name)
90 }
97 }
91 }
98 }
92 flash[:notice] = 'You are not authorized to view the page you requested'
99 flash[:notice] = 'You are not authorized to view the page you requested'
93 #request.env['HTTP_REFERER'] ? (redirect_to :back) : (redirect_to :controller => 'login')
100 #request.env['HTTP_REFERER'] ? (redirect_to :back) : (redirect_to :controller => 'login')
94 redirect_to :controller => 'main', :action => 'login'
101 redirect_to :controller => 'main', :action => 'login'
95 return false
102 return false
96 end
103 end
97 end
104 end
98
105
99 def verify_time_limit
106 def verify_time_limit
100 return true if session[:user_id]==nil
107 return true if session[:user_id]==nil
101 user = User.find(session[:user_id], :include => :site)
108 user = User.find(session[:user_id], :include => :site)
102 return true if user==nil or user.site == nil
109 return true if user==nil or user.site == nil
@@ -1,121 +1,121
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 navbar_user_header
4 def navbar_user_header
5 left_menu = ''
5 left_menu = ''
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 = ''
38 user = User.find(session[:user_id])
38 user = User.find(session[:user_id])
39
39
40 if (user!=nil) and (session[:admin])
40 if (user!=nil) and (session[:admin])
41 # admin menu
41 # admin menu
42 menu_items << "<b>Administrative task:</b> "
42 menu_items << "<b>Administrative task:</b> "
43 append_to menu_items, '[Announcements]', 'announcements', 'index'
43 append_to menu_items, '[Announcements]', 'announcements', 'index'
44 append_to menu_items, '[Msg console]', 'messages', 'console'
44 append_to menu_items, '[Msg console]', 'messages', 'console'
45 append_to menu_items, '[Problems]', 'problems', 'index'
45 append_to menu_items, '[Problems]', 'problems', 'index'
46 append_to menu_items, '[Users]', 'user_admin', 'index'
46 append_to menu_items, '[Users]', 'user_admin', 'index'
47 append_to menu_items, '[Results]', 'user_admin', 'user_stat'
47 append_to menu_items, '[Results]', 'user_admin', 'user_stat'
48 append_to menu_items, '[Report]', 'report', 'multiple_login'
48 append_to menu_items, '[Report]', 'report', 'multiple_login'
49 append_to menu_items, '[Graders]', 'graders', 'list'
49 append_to menu_items, '[Graders]', 'graders', 'list'
50 append_to menu_items, '[Contests]', 'contest_management', 'index'
50 append_to menu_items, '[Contests]', 'contest_management', 'index'
51 append_to menu_items, '[Sites]', 'sites', 'index'
51 append_to menu_items, '[Sites]', 'sites', 'index'
52 append_to menu_items, '[System config]', 'configurations', 'index'
52 append_to menu_items, '[System config]', 'configurations', 'index'
53 menu_items << "<br/>"
53 menu_items << "<br/>"
54 end
54 end
55
55
56 # main page
56 # main page
57 append_to menu_items, "[#{I18n.t 'menu.main'}]", 'main', 'list'
57 append_to menu_items, "[#{I18n.t 'menu.main'}]", 'main', 'list'
58 append_to menu_items, "[#{I18n.t 'menu.messages'}]", 'messages', 'list'
58 append_to menu_items, "[#{I18n.t 'menu.messages'}]", 'messages', 'list'
59
59
60 if (user!=nil) and (GraderConfiguration.show_tasks_to?(user))
60 if (user!=nil) and (GraderConfiguration.show_tasks_to?(user))
61 append_to menu_items, "[#{I18n.t 'menu.tasks'}]", 'tasks', 'list'
61 append_to menu_items, "[#{I18n.t 'menu.tasks'}]", 'tasks', 'list'
62 append_to menu_items, "[#{I18n.t 'menu.submissions'}]", 'main', 'submission'
62 append_to menu_items, "[#{I18n.t 'menu.submissions'}]", 'main', 'submission'
63 append_to menu_items, "[#{I18n.t 'menu.test'}]", 'test', 'index'
63 append_to menu_items, "[#{I18n.t 'menu.test'}]", 'test', 'index'
64 end
64 end
65
65
66 if GraderConfiguration['right.user_hall_of_fame']
66 if GraderConfiguration['right.user_hall_of_fame']
67 append_to menu_items, "[#{I18n.t 'menu.hall_of_fame'}]", 'report', 'problem_hof'
67 append_to menu_items, "[#{I18n.t 'menu.hall_of_fame'}]", 'report', 'problem_hof'
68 end
68 end
69 append_to menu_items, "[#{I18n.t 'menu.help'}]", 'main', 'help'
69 append_to menu_items, "[#{I18n.t 'menu.help'}]", 'main', 'help'
70
70
71 if GraderConfiguration['system.user_setting_enabled']
71 if GraderConfiguration['system.user_setting_enabled']
72 append_to menu_items, "[#{I18n.t 'menu.settings'}]", 'users', 'index'
72 append_to menu_items, "[#{I18n.t 'menu.settings'}]", 'users', 'index'
73 end
73 end
74 append_to menu_items, "[#{I18n.t 'menu.log_out'}]", 'main', 'login'
74 append_to menu_items, "[#{I18n.t 'menu.log_out'}]", 'main', 'login'
75
75
76 menu_items.html_safe
76 menu_items.html_safe
77 end
77 end
78
78
79 def append_to(option,label, controller, action)
79 def append_to(option,label, controller, action)
80 option << ' ' if option!=''
80 option << ' ' if option!=''
81 option << link_to_unless_current(label,
81 option << link_to_unless_current(label,
82 :controller => controller,
82 :controller => controller,
83 :action => action)
83 :action => action)
84 end
84 end
85
85
86 def format_short_time(time)
86 def format_short_time(time)
87 now = Time.now.gmtime
87 now = Time.now.gmtime
88 st = ''
88 st = ''
89 if (time.yday != now.yday) or
89 if (time.yday != now.yday) or
90 (time.year != now.year)
90 (time.year != now.year)
91 st = time.strftime("%x ")
91 st = time.strftime("%x ")
92 end
92 end
93 st + time.strftime("%X")
93 st + time.strftime("%X")
94 end
94 end
95
95
96 def format_short_duration(duration)
96 def format_short_duration(duration)
97 return '' if duration==nil
97 return '' if duration==nil
98 d = duration.to_f
98 d = duration.to_f
99 return Time.at(d).gmtime.strftime("%X")
99 return Time.at(d).gmtime.strftime("%X")
100 end
100 end
101
101
102 def read_textfile(fname,max_size=2048)
102 def read_textfile(fname,max_size=2048)
103 begin
103 begin
104 File.open(fname).read(max_size)
104 File.open(fname).read(max_size)
105 rescue
105 rescue
106 nil
106 nil
107 end
107 end
108 end
108 end
109
109
110 def user_title_bar(user)
110 def user_title_bar(user)
111 header = ''
111 header = ''
112 time_left = ''
112 time_left = ''
113
113
114 #
114 #
115 # if the contest is over
115 # if the contest is over
116 if GraderConfiguration.time_limit_mode?
116 if GraderConfiguration.time_limit_mode?
117 if user.contest_finished?
117 if user.contest_finished?
118 header = <<CONTEST_OVER
118 header = <<CONTEST_OVER
119 <tr><td colspan="2" align="center">
119 <tr><td colspan="2" align="center">
120 <span class="contest-over-msg">THE CONTEST IS OVER</span>
120 <span class="contest-over-msg">THE CONTEST IS OVER</span>
121 </td></tr>
121 </td></tr>
@@ -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 -
@@ -1,53 +1,55
1 - content_for :head do
1 - content_for :head do
2 = javascript_include_tag "announcement_refresh"
2 = javascript_include_tag "announcement_refresh"
3
3
4 = user_title_bar(@user)
4 = user_title_bar(@user)
5
5
6 .announcementbox{:style => (@announcements.length==0 ? "display:none" : "")}
6 .announcementbox{:style => (@announcements.length==0 ? "display:none" : "")}
7 %span{:class => 'title'}
7 %span{:class => 'title'}
8 Announcements
8 Announcements
9 #announcementbox-body
9 #announcementbox-body
10 = render :partial => 'announcement', :collection => @announcements
10 = render :partial => 'announcement', :collection => @announcements
11
11
12 - if GraderConfiguration.show_submitbox_to?(@user)
12 - if GraderConfiguration.show_submitbox_to?(@user)
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
45 = render :partial => 'problem', :collection => cp[:problems]
47 = render :partial => 'problem', :collection => cp[:problems]
46
48
47
49
48 %hr/
50 %hr/
49
51
50 %script{:type => 'text/javascript'}
52 %script{:type => 'text/javascript'}
51 = "Announcement.refreshUrl = '#{url_for :controller => 'main', :action => 'announcements'}';"
53 = "Announcement.refreshUrl = '#{url_for :controller => 'main', :action => 'announcements'}';"
52 Announcement.registerRefreshEventTimer();
54 Announcement.registerRefreshEventTimer();
53
55
deleted file
You need to be logged in to leave comments. Login now