Show More
Commit Description:
bootstrap navbar
Commit Description:
bootstrap navbar
File last commit:
Show/Diff file:
Action:
app/helpers/application_helper.rb | 170 lines | 5.4 KiB | text/x-ruby | RubyLexer |
pramook
initial commit...
r0 # Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
jittat
added user settings...
r13
bootstrap navbar
r553 def navbar_user_header
left_menu = ''
right_menu = ''
user = User.find(session[:user_id])
if (user!=nil) and (GraderConfiguration.show_tasks_to?(user))
left_menu << add_menu("#{I18n.t 'menu.tasks'}", 'tasks', 'list')
left_menu << add_menu("#{I18n.t 'menu.submissions'}", 'main', 'submission')
left_menu << add_menu("#{I18n.t 'menu.test'}", 'test', 'index')
end
if GraderConfiguration['right.user_hall_of_fame']
left_menu << add_menu("#{I18n.t 'menu.hall_of_fame'}", 'report', 'problem_hof')
end
left_menu << add_menu("#{I18n.t 'menu.help'}", 'main', 'help')
right_menu << add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-comment')} #{I18n.t 'menu.messages'}".html_safe, 'messages', 'list')
if GraderConfiguration['system.user_setting_enabled']
right_menu << add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-cog')} #{I18n.t 'menu.settings'}".html_safe, 'users', 'index')
end
right_menu << add_menu("#{content_tag(:span,'',class: 'glyphicon glyphicon-log-out')} #{I18n.t 'menu.log_out'}".html_safe, 'main', 'login',)
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')
end
def add_menu(title, controller, action,html_option = {})
link_option = {controller: controller, action: action}
html_option[:class] = (html_option[:class] || '') + " active" if current_page?(link_option)
content_tag(:li, link_to(title,link_option),html_option)
end
jittat
small changes, layouts...
r22 def user_header
jittat
test interface upload...
r36 menu_items = ''
jittat
added user settings...
r13 user = User.find(session[:user_id])
jittat
clean up layouts...
r25
jittat
[web] improved log-in & roles efficiency...
r104 if (user!=nil) and (session[:admin])
jittat
[web] small styling, split out admin's menu, put config into table.info...
r77 # admin menu
menu_items << "<b>Administrative task:</b> "
jittat
[web] added announcement...
r97 append_to menu_items, '[Announcements]', 'announcements', 'index'
jittat
[web] added message feature...
r102 append_to menu_items, '[Msg console]', 'messages', 'console'
Jittat Fakcharoenphol
added individual contest mode
r217 append_to menu_items, '[Problems]', 'problems', 'index'
append_to menu_items, '[Users]', 'user_admin', 'index'
jittat
MERGED 308:HEAD from http://theory.cpe.ku.ac.th/grader/web/branches/ytopc08-2/, removed some registration info...
r162 append_to menu_items, '[Results]', 'user_admin', 'user_stat'
grafted from 2b2663ff0e59
r501 append_to menu_items, '[Report]', 'report', 'multiple_login'
jittat
[web] updated grader monitoring...
r105 append_to menu_items, '[Graders]', 'graders', 'list'
Jittat Fakcharoenphol
added contest model
r266 append_to menu_items, '[Contests]', 'contest_management', 'index'
jittat
MERGED 308:HEAD from http://theory.cpe.ku.ac.th/grader/web/branches/ytopc08-2/, removed some registration info...
r162 append_to menu_items, '[Sites]', 'sites', 'index'
append_to menu_items, '[System config]', 'configurations', 'index'
jittat
[web] small styling, split out admin's menu, put config into table.info...
r77 menu_items << "<br/>"
end
jittat
clean up layouts...
r25 # main page
jittat
MERGED 308:HEAD from http://theory.cpe.ku.ac.th/grader/web/branches/ytopc08-2/, removed some registration info...
r162 append_to menu_items, "[#{I18n.t 'menu.main'}]", 'main', 'list'
append_to menu_items, "[#{I18n.t 'menu.messages'}]", 'messages', 'list'
jittat
[web] added mode + access control, when sites started/finished...
r122
Jittat Fakcharoenphol
renamed model Configuration to GraderConfiguration, renamed rhtml views to erb, fixed other small errors
r320 if (user!=nil) and (GraderConfiguration.show_tasks_to?(user))
jittat
MERGED 308:HEAD from http://theory.cpe.ku.ac.th/grader/web/branches/ytopc08-2/, removed some registration info...
r162 append_to menu_items, "[#{I18n.t 'menu.tasks'}]", 'tasks', 'list'
append_to menu_items, "[#{I18n.t 'menu.submissions'}]", 'main', 'submission'
append_to menu_items, "[#{I18n.t 'menu.test'}]", 'test', 'index'
jittat
[web] added mode + access control, when sites started/finished...
r122 end
add options to allow hall of fame viewing by any user...
r424
prepare for better hall of fame
r425 if GraderConfiguration['right.user_hall_of_fame']
add options to allow hall of fame viewing by any user...
r424 append_to menu_items, "[#{I18n.t 'menu.hall_of_fame'}]", 'report', 'problem_hof'
end
jittat
MERGED 308:HEAD from http://theory.cpe.ku.ac.th/grader/web/branches/ytopc08-2/, removed some registration info...
r162 append_to menu_items, "[#{I18n.t 'menu.help'}]", 'main', 'help'
jittat
added 'user_setting_enabled' option...
r156
Jittat Fakcharoenphol
renamed model Configuration to GraderConfiguration, renamed rhtml views to erb, fixed other small errors
r320 if GraderConfiguration['system.user_setting_enabled']
jittat
MERGED 308:HEAD from http://theory.cpe.ku.ac.th/grader/web/branches/ytopc08-2/, removed some registration info...
r162 append_to menu_items, "[#{I18n.t 'menu.settings'}]", 'users', 'index'
jittat
added 'user_setting_enabled' option...
r156 end
jittat
MERGED 308:HEAD from http://theory.cpe.ku.ac.th/grader/web/branches/ytopc08-2/, removed some registration info...
r162 append_to menu_items, "[#{I18n.t 'menu.log_out'}]", 'main', 'login'
jittat
test interface upload...
r36
Jittat Fakcharoenphol
renamed model Configuration to GraderConfiguration, renamed rhtml views to erb, fixed other small errors
r320 menu_items.html_safe
jittat
test interface upload...
r36 end
def append_to(option,label, controller, action)
option << ' ' if option!=''
option << link_to_unless_current(label,
:controller => controller,
:action => action)
jittat
added user settings...
r13 end
jittat
[web] fixing ticket #10...
r65 def format_short_time(time)
jittat
[web] more use of utc time...
r120 now = Time.now.gmtime
jittat
[web] fixing ticket #10...
r65 st = ''
if (time.yday != now.yday) or
(time.year != now.year)
st = time.strftime("%x ")
end
st + time.strftime("%X")
end
Jittat Fakcharoenphol
added individual contest mode
r217 def format_short_duration(duration)
return '' if duration==nil
d = duration.to_f
return Time.at(d).gmtime.strftime("%X")
end
jittat
[web] added mode + access control, when sites started/finished...
r122 def read_textfile(fname,max_size=2048)
begin
File.open(fname).read(max_size)
rescue
nil
end
end
jittat
more styling...
r78
def user_title_bar(user)
jittat
[web] added mode + access control, when sites started/finished...
r122 header = ''
jittat
[web] site start/stop supports...
r123 time_left = ''
jittat
[web] added mode + access control, when sites started/finished...
r122
#
# if the contest is over
Jittat Fakcharoenphol
renamed model Configuration to GraderConfiguration, renamed rhtml views to erb, fixed other small errors
r320 if GraderConfiguration.time_limit_mode?
Jittat Fakcharoenphol
added individual contest mode
r217 if user.contest_finished?
jittat
[web] site start/stop supports...
r123 header = <<CONTEST_OVER
jittat
[web] added site and time out basic functionality...
r85 <tr><td colspan="2" align="center">
<span class="contest-over-msg">THE CONTEST IS OVER</span>
</td></tr>
CONTEST_OVER
jittat
[web] site start/stop supports...
r123 end
Jittat Fakcharoenphol
added individual contest mode
r217 if !user.contest_started?
jittat
MERGED 308:HEAD from http://theory.cpe.ku.ac.th/grader/web/branches/ytopc08-2/, removed some registration info...
r162 time_left = "&nbsp;&nbsp;" + (t 'title_bar.contest_not_started')
else
Jittat Fakcharoenphol
added individual contest mode
r217 time_left = "&nbsp;&nbsp;" + (t 'title_bar.remaining_time') +
" #{format_short_duration(user.contest_time_left)}"
jittat
[web] site start/stop supports...
r123 end
jittat
[web] added site and time out basic functionality...
r85 end
jittat
[web] added mode + access control, when sites started/finished...
r122
#
# if the contest is in the anaysis mode
Jittat Fakcharoenphol
renamed model Configuration to GraderConfiguration, renamed rhtml views to erb, fixed other small errors
r320 if GraderConfiguration.analysis_mode?
jittat
[web] added mode + access control, when sites started/finished...
r122 header = <<ANALYSISMODE
<tr><td colspan="2" align="center">
<span class="contest-over-msg">ANALYSIS MODE</span>
</td></tr>
ANALYSISMODE
end
Jittat Fakcharoenphol
renamed model Configuration to GraderConfiguration, renamed rhtml views to erb, fixed other small errors
r320 contest_name = GraderConfiguration['contest.name']
jittat
added contest.name to settings...
r141
jittat
[web] added mode + access control, when sites started/finished...
r122 #
# build real title bar
Jittat Fakcharoenphol
renamed model Configuration to GraderConfiguration, renamed rhtml views to erb, fixed other small errors
r320 result = <<TITLEBAR
jittat
more styling...
r78 <div class="title">
<table>
jittat
[web] added mode + access control, when sites started/finished...
r122 #{header}
jittat
more styling...
r78 <tr>
<td class="left-col">
#{user.full_name}<br/>
update Current time to properly use rails time
r351 #{t 'title_bar.current_time'} #{format_short_time(Time.zone.now)}
jittat
[web] site start/stop supports...
r123 #{time_left}
<br/>
jittat
more styling...
r78 </td>
jittat
added contest.name to settings...
r141 <td class="right-col">#{contest_name}</td>
jittat
more styling...
r78 </tr>
</table>
</div>
TITLEBAR
Jittat Fakcharoenphol
renamed model Configuration to GraderConfiguration, renamed rhtml views to erb, fixed other small errors
r320 result.html_safe
jittat
more styling...
r78 end
Jittat Fakcharoenphol
fixed javascript/css assets, fixed link_to_remote in problems page
r322 def markdown(text)
markdown = RDiscount.new(text)
markdown.to_html.html_safe
end
pramook
initial commit...
r0 end