Show More
Commit Description:
[web] fix time.new, time.now to use gmtime...
Commit Description:
[web] fix time.new, time.now to use gmtime
git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@249 6386c4cd-e34a-4fa8-8920-d93eb39b512e
References:
File last commit:
Show/Diff file:
Action:
app/helpers/application_helper.rb
| 84 lines
| 2.3 KiB
| text/x-ruby
| RubyLexer
|
|
r0 | # Methods added to this helper will be available to all templates in the application. | ||
module ApplicationHelper | ||||
|
r13 | |||
|
r22 | def user_header | ||
|
r36 | menu_items = '' | ||
|
r13 | user = User.find(session[:user_id]) | ||
|
r25 | |||
|
r104 | if (user!=nil) and (session[:admin]) | ||
|
r77 | # admin menu | ||
menu_items << "<b>Administrative task:</b> " | ||||
|
r97 | append_to menu_items, '[Announcements]', 'announcements', 'index' | ||
|
r102 | append_to menu_items, '[Msg console]', 'messages', 'console' | ||
|
r77 | append_to menu_items, '[Problem admin]', 'problems', 'index' | ||
append_to menu_items, '[User admin]', 'user_admin', 'index' | ||||
append_to menu_items, '[User stat]', 'user_admin', 'user_stat' | ||||
|
r105 | append_to menu_items, '[Graders]', 'graders', 'list' | ||
|
r77 | append_to menu_items, '[Site config]', 'configurations', 'index' | ||
menu_items << "<br/>" | ||||
end | ||||
|
r25 | # main page | ||
|
r36 | append_to menu_items, '[Main]', 'main', 'list' | ||
|
r102 | append_to menu_items, '[Messages]', 'messages', 'list' | ||
|
r88 | append_to menu_items, '[Tasks]', 'tasks', 'list' | ||
|
r51 | append_to menu_items, '[Submissions]', 'main', 'submission' | ||
|
r44 | append_to menu_items, '[Test]', 'test', 'index' | ||
|
r107 | append_to menu_items, '[Help]', 'main', 'help' | ||
#append_to menu_items, '[Settings]', 'users', 'index' | ||||
|
r36 | append_to menu_items, '[Log out]', 'main', 'login' | ||
menu_items | ||||
end | ||||
def append_to(option,label, controller, action) | ||||
option << ' ' if option!='' | ||||
option << link_to_unless_current(label, | ||||
:controller => controller, | ||||
:action => action) | ||||
|
r13 | end | ||
|
r65 | def format_short_time(time) | ||
|
r120 | now = Time.now.gmtime | ||
|
r65 | st = '' | ||
if (time.yday != now.yday) or | ||||
(time.year != now.year) | ||||
st = time.strftime("%x ") | ||||
end | ||||
st + time.strftime("%X") | ||||
end | ||||
|
r78 | |||
def user_title_bar(user) | ||||
|
r85 | if user.site!=nil and user.site.finished? | ||
contest_over_string = <<CONTEST_OVER | ||||
<tr><td colspan="2" align="center"> | ||||
<span class="contest-over-msg">THE CONTEST IS OVER</span> | ||||
</td></tr> | ||||
CONTEST_OVER | ||||
end | ||||
|
r78 | <<TITLEBAR | ||
<div class="title"> | ||||
<table> | ||||
|
r85 | #{contest_over_string} | ||
|
r78 | <tr> | ||
<td class="left-col"> | ||||
#{user.full_name}<br/> | ||||
|
r120 | Current time is #{format_short_time(Time.new.gmtime)} UTC<br/> | ||
|
r78 | </td> | ||
<td class="right-col">APIO'08</td> | ||||
</tr> | ||||
</table> | ||||
</div> | ||||
TITLEBAR | ||||
end | ||||
|
r105 | def read_textfile(fname,max_size=2048) | ||
begin | ||||
File.open(fname).read(max_size) | ||||
rescue | ||||
nil | ||||
end | ||||
end | ||||
|
r0 | end | ||