Show More
Commit Description:
[web] added configurations...
Commit Description:
[web] added configurations
git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@156 6386c4cd-e34a-4fa8-8920-d93eb39b512e
References:
File last commit:
Show/Diff file:
Action:
app/helpers/application_helper.rb
| 49 lines
| 1.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 | |||
# main page | ||||
|
r36 | append_to menu_items, '[Main]', 'main', 'list' | ||
|
r51 | append_to menu_items, '[Submissions]', 'main', 'submission' | ||
|
r44 | append_to menu_items, '[Test]', 'test', 'index' | ||
|
r25 | |||
# admin menu | ||||
|
r27 | if (user!=nil) and (user.admin?) | ||
|
r36 | 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' | ||||
|
r25 | end | ||
# general options | ||||
|
r36 | append_to menu_items, '[Settings]', 'users', 'index' | ||
|
r76 | |||
if (user!=nil) and (user.admin?) | ||||
append_to menu_items, '[Site config]', 'configurations', 'index' | ||||
end | ||||
|
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) | ||
now = Time.now | ||||
st = '' | ||||
if (time.yday != now.yday) or | ||||
(time.year != now.year) | ||||
st = time.strftime("%x ") | ||||
end | ||||
st + time.strftime("%X") | ||||
end | ||||
|
r0 | end | ||