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: 89 inserted, 44 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 1 source 'https://rubygems.org'
2 2
3 3 gem 'rails', '3.2.21'
4 4
5 + gem 'select2-rails'
6 +
5 7 # Bundle edge Rails instead:
6 8 # gem 'rails', :git => 'git://github.com/rails/rails.git'
7 9
8 10 gem 'mysql2'
9 11
10 12 # Gems used only for assets and not required
11 13 # in production environments by default.
12 14 group :assets do
13 15 gem 'sass-rails', '~> 3.2.6'
14 16 gem 'coffee-rails', '~> 3.2.2'
15 17
16 18 # See https://github.com/sstephenson/execjs#readme for more supported runtimes
17 19 # gem 'therubyracer', :platforms => :ruby
18 20
19 21 gem 'uglifier'
20 22 end
21 23
22 24 gem 'prototype-rails'
23 25
24 26 # To use ActiveModel has_secure_password
25 27 # gem 'bcrypt-ruby', '~> 3.0.0'
26 28
27 29 # To use Jbuilder templates for JSON
28 30 # gem 'jbuilder'
29 31
30 32 # Use unicorn as the app server
31 33 # gem 'unicorn'
32 34
33 35 # Deploy with Capistrano
34 36 # gem 'capistrano'
35 37
36 38 # To use debugger
37 39 # gem 'debugger'
38 40 #
39 41
40 42 #in-place editor
41 43 gem 'best_in_place', '~> 3.0.1'
42 44
43 45 # jquery addition
44 46 gem 'jquery-rails'
45 47 gem 'jquery-ui-sass-rails'
46 48 gem 'jquery-timepicker-addon-rails'
47 49 gem 'jquery-tablesorter'
48 50
49 51 #syntax highlighter
50 52 gem 'rouge'
51 53
52 54 #add bootstrap
53 55 gem 'bootstrap-sass', '~> 3.2.0'
54 56 gem 'autoprefixer-rails'
55 57
56 58
57 59 gem 'haml'
58 60 gem 'mail'
59 61 gem 'rdiscount'
60 62 gem 'test-unit'
61 63 gem 'will_paginate', '~> 3.0.7'
62 64 gem 'dynamic_form'
63 65 gem 'in_place_editing'
64 66 gem 'verification', :git => 'https://github.com/sikachu/verification.git'
65 67
66 68 group :test, :development do
67 69 gem 'rspec-rails', '~> 2.99.0'
68 70 end
@@ -42,141 +42,144
42 42 json
43 43 best_in_place (3.0.3)
44 44 actionpack (>= 3.2)
45 45 railties (>= 3.2)
46 46 bootstrap-sass (3.2.0.2)
47 47 sass (~> 3.2)
48 48 builder (3.0.4)
49 49 coffee-rails (3.2.2)
50 50 coffee-script (>= 2.2.0)
51 51 railties (~> 3.2.0)
52 52 coffee-script (2.3.0)
53 53 coffee-script-source
54 54 execjs
55 55 coffee-script-source (1.9.0)
56 56 diff-lcs (1.2.5)
57 57 dynamic_form (1.1.4)
58 58 erubis (2.7.0)
59 59 execjs (2.3.0)
60 60 haml (4.0.6)
61 61 tilt
62 62 hike (1.2.3)
63 63 i18n (0.7.0)
64 64 in_place_editing (1.2.0)
65 65 journey (1.0.4)
66 66 jquery-rails (3.1.2)
67 67 railties (>= 3.0, < 5.0)
68 68 thor (>= 0.14, < 2.0)
69 69 jquery-tablesorter (1.13.4)
70 70 railties (>= 3.1, < 5)
71 71 jquery-timepicker-addon-rails (1.4.1)
72 72 railties (>= 3.1)
73 73 jquery-ui-rails (4.0.3)
74 74 jquery-rails
75 75 railties (>= 3.1.0)
76 76 jquery-ui-sass-rails (4.0.3.0)
77 77 jquery-rails
78 78 jquery-ui-rails (= 4.0.3)
79 79 railties (>= 3.1.0)
80 80 json (1.8.2)
81 81 mail (2.5.4)
82 82 mime-types (~> 1.16)
83 83 treetop (~> 1.4.8)
84 84 mime-types (1.25.1)
85 85 multi_json (1.10.1)
86 86 mysql2 (0.3.20)
87 87 polyglot (0.3.5)
88 88 power_assert (0.2.2)
89 89 prototype-rails (3.2.1)
90 90 rails (~> 3.2)
91 91 rack (1.4.5)
92 92 rack-cache (1.2)
93 93 rack (>= 0.4)
94 94 rack-ssl (1.3.4)
95 95 rack
96 96 rack-test (0.6.3)
97 97 rack (>= 1.0)
98 98 rails (3.2.21)
99 99 actionmailer (= 3.2.21)
100 100 actionpack (= 3.2.21)
101 101 activerecord (= 3.2.21)
102 102 activeresource (= 3.2.21)
103 103 activesupport (= 3.2.21)
104 104 bundler (~> 1.0)
105 105 railties (= 3.2.21)
106 106 railties (3.2.21)
107 107 actionpack (= 3.2.21)
108 108 activesupport (= 3.2.21)
109 109 rack-ssl (~> 1.3.2)
110 110 rake (>= 0.8.7)
111 111 rdoc (~> 3.4)
112 112 thor (>= 0.14.6, < 2.0)
113 113 rake (10.4.2)
114 114 rdiscount (2.1.8)
115 115 rdoc (3.12.2)
116 116 json (~> 1.4)
117 117 rouge (1.8.0)
118 118 rspec-collection_matchers (1.1.2)
119 119 rspec-expectations (>= 2.99.0.beta1)
120 120 rspec-core (2.99.2)
121 121 rspec-expectations (2.99.2)
122 122 diff-lcs (>= 1.1.3, < 2.0)
123 123 rspec-mocks (2.99.3)
124 124 rspec-rails (2.99.0)
125 125 actionpack (>= 3.0)
126 126 activemodel (>= 3.0)
127 127 activesupport (>= 3.0)
128 128 railties (>= 3.0)
129 129 rspec-collection_matchers
130 130 rspec-core (~> 2.99.0)
131 131 rspec-expectations (~> 2.99.0)
132 132 rspec-mocks (~> 2.99.0)
133 133 sass (3.4.11)
134 134 sass-rails (3.2.6)
135 135 railties (~> 3.2.0)
136 136 sass (>= 3.1.10)
137 137 tilt (~> 1.3)
138 + select2-rails (4.0.1)
139 + thor (~> 0.14)
138 140 sprockets (2.2.3)
139 141 hike (~> 1.2)
140 142 multi_json (~> 1.0)
141 143 rack (~> 1.0)
142 144 tilt (~> 1.1, != 1.3.0)
143 145 test-unit (3.0.9)
144 146 power_assert
145 147 thor (0.19.1)
146 148 tilt (1.4.1)
147 149 treetop (1.4.15)
148 150 polyglot
149 151 polyglot (>= 0.3.1)
150 152 tzinfo (0.3.43)
151 153 uglifier (2.7.0)
152 154 execjs (>= 0.3.0)
153 155 json (>= 1.8.0)
154 156 will_paginate (3.0.7)
155 157
156 158 PLATFORMS
157 159 ruby
158 160
159 161 DEPENDENCIES
160 162 autoprefixer-rails
161 163 best_in_place (~> 3.0.1)
162 164 bootstrap-sass (~> 3.2.0)
163 165 coffee-rails (~> 3.2.2)
164 166 dynamic_form
165 167 haml
166 168 in_place_editing
167 169 jquery-rails
168 170 jquery-tablesorter
169 171 jquery-timepicker-addon-rails
170 172 jquery-ui-sass-rails
171 173 mail
172 174 mysql2
173 175 prototype-rails
174 176 rails (= 3.2.21)
175 177 rdiscount
176 178 rouge
177 179 rspec-rails (~> 2.99.0)
178 180 sass-rails (~> 3.2.6)
181 + select2-rails
179 182 test-unit
180 183 uglifier
181 184 verification!
182 185 will_paginate (~> 3.0.7)
@@ -1,18 +1,26
1 1 // This is a manifest file that'll be compiled into application.js, which will include all the files
2 2 // listed below.
3 3 //
4 4 // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
5 5 // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
6 6 //
7 7 // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
8 8 // the compiled file.
9 9 //
10 10 // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
11 11 // GO AFTER THE REQUIRES BELOW.
12 12 //
13 - //= require prototype
14 - //= require prototype_ujs
15 - //= require effects
16 - //= require dragdrop
17 - //= require controls
13 + //= require jquery
14 + //= require jquery_ujs
15 + //= require jquery.ui.all
18 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 2 * This is a manifest file that'll be compiled into application.css, which will include all the files
3 3 * listed below.
4 4 *
5 5 * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6 6 * or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
7 7 *
8 8 * You're free to add application-wide styles to this file and they'll appear at the bottom of the
9 9 * compiled file so the styles you add here take precedence over styles defined in any styles
10 10 * defined in the other CSS/SCSS files in this directory. It is generally better to create a new
11 11 * file per style scope.
12 12 *
13 - *= require_tree .
14 - *= require_self
13 + // bootstrap says that we should not do this, but @import each file instead
14 + # *= require_tree .
15 + # *= require_self
15 16 */
16 17
17 -
18 + @import jquery.ui.all
19 + @import jquery.ui.core
18 20 @import jquery.ui.core
19 21 @import jquery.ui.theme
20 22 @import jquery.ui.datepicker
21 23 @import jquery.ui.slider
22 24 @import jquery-ui-timepicker-addon
23 25 @import jquery-tablesorter/theme.metro-dark
24 26 @import tablesorter-theme.cafe
25 27
26 -
27 - @import "bootstrap-sprockets"
28 - @import "bootstrap"
28 + @import bootstrap-sprockets
29 + @import bootstrap
30 + @import select2
31 + @import select2-bootstrap
29 32
30 33 .secondnavbar
31 34 top: 50px
32 35
33 36 body
34 37 background: white image-url("topbg.jpg") repeat-x top center
35 - font-size: 13px
36 - font-family: Tahoma, "sans-serif"
38 + //font-size: 13px
39 + //font-family: Tahoma, "sans-serif"
37 40 margin: 10px
38 41 padding: 10px
39 42 padding-top: 100px
40 43
41 44
42 45 input
43 46 font-family: Tahoma, "sans-serif"
44 47
45 48
46 49 h1
47 50 font-size: 24px
48 51 color: #334488
49 52 line-height: 2em
50 53
51 54
52 55 h2
53 56 font-size: 18px
54 57 color: #5566bb
55 58 line-height: 1.5em
56 59
57 60
58 61 hr
59 62 border-top: 1px solid #dddddd
60 63 border-bottom: 1px solid #eeeeee
61 64
62 65
63 66 a
64 67 color: #6666cc
65 68 text-decoration: none
66 69
67 70 &:link, &:visited
68 71 color: #6666cc
69 72 text-decoration: none
70 73
71 74 &:hover, &:focus
72 75 color: #111166
73 76 text-decoration: none
74 77
75 78
76 79 div
77 80 &.userbar
78 81 line-height: 1.5em
79 82 text-align: right
80 83 font-size: 12px
81 84
82 85 &.title
83 86 padding: 10px 0px
84 87 line-height: 1.5em
85 88 font-size: 13px
86 89
87 90 span.contest-over-msg
88 91 font-size: 15px
89 92 color: red
90 93
91 94 table
92 95 width: 100%
93 96 font-weight: bold
94 97
95 98 td
96 99 &.left-col
97 100 text-align: left
98 101 vertical-align: top
99 102 color: #444444
100 103
101 104 &.right-col
102 105 text-align: right
103 106 vertical-align: top
104 107 font-size: 18px
105 108 color: #116699
106 109
107 110
108 111 table.info
109 112 margin: 10px 0
110 113 border: 1px solid #666666
111 114 border-collapse: collapse
112 115 font-size: 12px
113 116
114 117 th
115 118 border: 1px solid #666666
116 119 line-height: 1.5em
117 120 padding: 0 0.5em
118 121
119 122 td
120 123 border-left: 1px solid #666666
121 124 border-right: 1px solid #666666
122 125 line-height: 1.5em
123 126 padding: 0 0.5em
124 127
125 128
126 129 tr
127 130 &.info-head
128 131 background: #777777
129 132 color: white
130 133
131 134 &.info-odd
132 135 background: #eeeeee
@@ -1,102 +1,109
1 1 class ApplicationController < ActionController::Base
2 2 protect_from_forgery
3 3
4 + before_filter :current_user
5 +
4 6 SINGLE_USER_MODE_CONF_KEY = 'system.single_user_mode'
5 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 14 def admin_authorization
8 15 return false unless authenticate
9 16 user = User.find(session[:user_id], :include => ['roles'])
10 17 unless user.admin?
11 18 flash[:notice] = 'You are not authorized to view the page you requested'
12 19 redirect_to :controller => 'main', :action => 'login' unless user.admin?
13 20 return false
14 21 end
15 22 return true
16 23 end
17 24
18 25 def authorization_by_roles(allowed_roles)
19 26 return false unless authenticate
20 27 user = User.find(session[:user_id])
21 28 unless user.roles.detect { |role| allowed_roles.member?(role.name) }
22 29 flash[:notice] = 'You are not authorized to view the page you requested'
23 30 redirect_to :controller => 'main', :action => 'login'
24 31 return false
25 32 end
26 33 end
27 34
28 35 protected
29 36
30 37 def authenticate
31 38 unless session[:user_id]
32 39 flash[:notice] = 'You need to login'
33 40 if GraderConfiguration[SINGLE_USER_MODE_CONF_KEY]
34 41 flash[:notice] = 'You need to login but you cannot log in at this time'
35 42 end
36 43 redirect_to :controller => 'main', :action => 'login'
37 44 return false
38 45 end
39 46
40 47 # check if run in single user mode
41 48 if GraderConfiguration[SINGLE_USER_MODE_CONF_KEY]
42 49 user = User.find(session[:user_id])
43 50 if user==nil or (not user.admin?)
44 51 flash[:notice] = 'You cannot log in at this time'
45 52 redirect_to :controller => 'main', :action => 'login'
46 53 return false
47 54 end
48 55 return true
49 56 end
50 57
51 58 if GraderConfiguration.multicontests?
52 59 user = User.find(session[:user_id])
53 60 return true if user.admin?
54 61 begin
55 62 if user.contest_stat(true).forced_logout
56 63 flash[:notice] = 'You have been automatically logged out.'
57 64 redirect_to :controller => 'main', :action => 'index'
58 65 end
59 66 rescue
60 67 end
61 68 end
62 69 return true
63 70 end
64 71
65 72 def authenticate_by_ip_address
66 73 #this assume that we have already authenticate normally
67 74 unless GraderConfiguration[MULTIPLE_IP_LOGIN_CONF_KEY]
68 75 user = User.find(session[:user_id])
69 76 if (not user.admin? and user.last_ip and user.last_ip != request.remote_ip)
70 77 flash[:notice] = "You cannot use the system from #{request.remote_ip}. Your last ip is #{user.last_ip}"
71 78 redirect_to :controller => 'main', :action => 'login'
72 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 80 return false
74 81 end
75 82 unless user.last_ip
76 83 user.last_ip = request.remote_ip
77 84 user.save
78 85 end
79 86 end
80 87 return true
81 88 end
82 89
83 90 def authorization
84 91 return false unless authenticate
85 92 user = User.find(session[:user_id])
86 93 unless user.roles.detect { |role|
87 94 role.rights.detect{ |right|
88 95 right.controller == self.class.controller_name and
89 96 (right.action == 'all' or right.action == action_name)
90 97 }
91 98 }
92 99 flash[:notice] = 'You are not authorized to view the page you requested'
93 100 #request.env['HTTP_REFERER'] ? (redirect_to :back) : (redirect_to :controller => 'login')
94 101 redirect_to :controller => 'main', :action => 'login'
95 102 return false
96 103 end
97 104 end
98 105
99 106 def verify_time_limit
100 107 return true if session[:user_id]==nil
101 108 user = User.find(session[:user_id], :include => :site)
102 109 return true if user==nil or user.site == nil
@@ -1,121 +1,121
1 1 # Methods added to this helper will be available to all templates in the application.
2 2 module ApplicationHelper
3 3
4 4 def navbar_user_header
5 5 left_menu = ''
6 6 right_menu = ''
7 7 user = User.find(session[:user_id])
8 8
9 9 if (user!=nil) and (GraderConfiguration.show_tasks_to?(user))
10 10 left_menu << add_menu("#{I18n.t 'menu.tasks'}", 'tasks', 'list')
11 11 left_menu << add_menu("#{I18n.t 'menu.submissions'}", 'main', 'submission')
12 12 left_menu << add_menu("#{I18n.t 'menu.test'}", 'test', 'index')
13 13 end
14 14
15 15 if GraderConfiguration['right.user_hall_of_fame']
16 16 left_menu << add_menu("#{I18n.t 'menu.hall_of_fame'}", 'report', 'problem_hof')
17 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 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 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 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 28 end
29 29
30 30 def add_menu(title, controller, action,html_option = {})
31 31 link_option = {controller: controller, action: action}
32 32 html_option[:class] = (html_option[:class] || '') + " active" if current_page?(link_option)
33 33 content_tag(:li, link_to(title,link_option),html_option)
34 34 end
35 35
36 36 def user_header
37 37 menu_items = ''
38 38 user = User.find(session[:user_id])
39 39
40 40 if (user!=nil) and (session[:admin])
41 41 # admin menu
42 42 menu_items << "<b>Administrative task:</b> "
43 43 append_to menu_items, '[Announcements]', 'announcements', 'index'
44 44 append_to menu_items, '[Msg console]', 'messages', 'console'
45 45 append_to menu_items, '[Problems]', 'problems', 'index'
46 46 append_to menu_items, '[Users]', 'user_admin', 'index'
47 47 append_to menu_items, '[Results]', 'user_admin', 'user_stat'
48 48 append_to menu_items, '[Report]', 'report', 'multiple_login'
49 49 append_to menu_items, '[Graders]', 'graders', 'list'
50 50 append_to menu_items, '[Contests]', 'contest_management', 'index'
51 51 append_to menu_items, '[Sites]', 'sites', 'index'
52 52 append_to menu_items, '[System config]', 'configurations', 'index'
53 53 menu_items << "<br/>"
54 54 end
55 55
56 56 # main page
57 57 append_to menu_items, "[#{I18n.t 'menu.main'}]", 'main', 'list'
58 58 append_to menu_items, "[#{I18n.t 'menu.messages'}]", 'messages', 'list'
59 59
60 60 if (user!=nil) and (GraderConfiguration.show_tasks_to?(user))
61 61 append_to menu_items, "[#{I18n.t 'menu.tasks'}]", 'tasks', 'list'
62 62 append_to menu_items, "[#{I18n.t 'menu.submissions'}]", 'main', 'submission'
63 63 append_to menu_items, "[#{I18n.t 'menu.test'}]", 'test', 'index'
64 64 end
65 65
66 66 if GraderConfiguration['right.user_hall_of_fame']
67 67 append_to menu_items, "[#{I18n.t 'menu.hall_of_fame'}]", 'report', 'problem_hof'
68 68 end
69 69 append_to menu_items, "[#{I18n.t 'menu.help'}]", 'main', 'help'
70 70
71 71 if GraderConfiguration['system.user_setting_enabled']
72 72 append_to menu_items, "[#{I18n.t 'menu.settings'}]", 'users', 'index'
73 73 end
74 74 append_to menu_items, "[#{I18n.t 'menu.log_out'}]", 'main', 'login'
75 75
76 76 menu_items.html_safe
77 77 end
78 78
79 79 def append_to(option,label, controller, action)
80 80 option << ' ' if option!=''
81 81 option << link_to_unless_current(label,
82 82 :controller => controller,
83 83 :action => action)
84 84 end
85 85
86 86 def format_short_time(time)
87 87 now = Time.now.gmtime
88 88 st = ''
89 89 if (time.yday != now.yday) or
90 90 (time.year != now.year)
91 91 st = time.strftime("%x ")
92 92 end
93 93 st + time.strftime("%X")
94 94 end
95 95
96 96 def format_short_duration(duration)
97 97 return '' if duration==nil
98 98 d = duration.to_f
99 99 return Time.at(d).gmtime.strftime("%X")
100 100 end
101 101
102 102 def read_textfile(fname,max_size=2048)
103 103 begin
104 104 File.open(fname).read(max_size)
105 105 rescue
106 106 nil
107 107 end
108 108 end
109 109
110 110 def user_title_bar(user)
111 111 header = ''
112 112 time_left = ''
113 113
114 114 #
115 115 # if the contest is over
116 116 if GraderConfiguration.time_limit_mode?
117 117 if user.contest_finished?
118 118 header = <<CONTEST_OVER
119 119 <tr><td colspan="2" align="center">
120 120 <span class="contest-over-msg">THE CONTEST IS OVER</span>
121 121 </td></tr>
@@ -1,30 +1,15
1 1 <!DOCTYPE html>
2 2 %html
3 3 %head
4 4 %title= GraderConfiguration['contest.name']
5 5 = stylesheet_link_tag "application", :media => "all"
6 6 = javascript_include_tag "application"
7 7 = csrf_meta_tags
8 8 = content_for :header
9 9 = yield :head
10 10
11 11 %body
12 - %nav.navbar.navbar-default.navbar-fixed-top
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
12 + = render 'layouts/header'
27 13
28 14 = content_tag(:p,flash[:notice],:style => "color:green") if flash[:notice]!=nil
29 15 = yield
30 -
@@ -1,53 +1,55
1 1 - content_for :head do
2 2 = javascript_include_tag "announcement_refresh"
3 3
4 4 = user_title_bar(@user)
5 5
6 6 .announcementbox{:style => (@announcements.length==0 ? "display:none" : "")}
7 7 %span{:class => 'title'}
8 8 Announcements
9 9 #announcementbox-body
10 10 = render :partial => 'announcement', :collection => @announcements
11 11
12 12 - if GraderConfiguration.show_submitbox_to?(@user)
13 13 .submitbox
14 14 = error_messages_for 'submission'
15 15 = render :partial => 'submission_box'
16 16
17 17
18 18 %hr/
19 19
20 20 - if (GraderConfiguration.contest_mode?) and (@user.site!=nil) and (@user.site.started!=true)
21 21 %p=t 'main.start_soon'
22 22
23 23 - if GraderConfiguration.show_tasks_to?(@user)
24 24 - if not GraderConfiguration.multicontests?
25 - %table.info
25 + %table.table.table-striped
26 + %thead
26 27 %tr.info-head
27 - %th
28 + %th #
28 29 %th Tasks name
29 30 %th Full name
30 31 %th # of sub(s)
31 32 %th Results
33 + %tbody
32 34 = render :partial => 'problem', :collection => @problems
33 35 - else
34 36 - @contest_problems.each do |cp|
35 37 - if cp[:problems].length > 0
36 38 %h2{:class =>'contest-title'}
37 39 = "#{cp[:contest] ? cp[:contest].title : 'Public problems'}"
38 40 %table.info
39 41 %tr.info-head
40 42 %th
41 43 %th Tasks name
42 44 %th Full name
43 45 %th # of sub(s)
44 46 %th Results
45 47 = render :partial => 'problem', :collection => cp[:problems]
46 48
47 49
48 50 %hr/
49 51
50 52 %script{:type => 'text/javascript'}
51 53 = "Announcement.refreshUrl = '#{url_for :controller => 'main', :action => 'announcements'}';"
52 54 Announcement.registerRefreshEventTimer();
53 55
deleted file
You need to be logged in to leave comments. Login now