Description:
- add front page toggle to announcement - cosmetic change in some pages / main
Commit status:
[Not Reviewed]
References:
Comments:
0 Commit comments 0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
Add another comment

r567:cc292daee78f - - 9 files changed: 44 inserted, 39 deleted

@@ -1,12 +1,4
1 // Place all the styles related to the sources controller here.
1 // Place all the styles related to the sources controller here.
2 // They will automatically be included in application.css.
2 // They will automatically be included in application.css.
3 // You can use Sass (SCSS) here: http://sass-lang.com/
3 // You can use Sass (SCSS) here: http://sass-lang.com/
4
4
5 - #editor {
6 - position: absolute;
7 - top: 0;
8 - right: 0;
9 - bottom: 0;
10 - left: 0;
11 - }
12 -
@@ -85,12 +85,21
85 respond_to do |format|
85 respond_to do |format|
86 format.js { render partial: 'toggle_button',
86 format.js { render partial: 'toggle_button',
87 locals: {button_id: "#announcement_toggle_#{@announcement.id}",button_on: @announcement.published? } }
87 locals: {button_id: "#announcement_toggle_#{@announcement.id}",button_on: @announcement.published? } }
88 end
88 end
89 end
89 end
90
90
91 + def toggle_front
92 + @announcement = Announcement.find(params[:id])
93 + @announcement.update_attributes( frontpage: !@announcement.frontpage? )
94 + respond_to do |format|
95 + format.js { render partial: 'toggle_button',
96 + locals: {button_id: "#announcement_toggle_front_#{@announcement.id}",button_on: @announcement.frontpage? } }
97 + end
98 + end
99 +
91 # DELETE /announcements/1
100 # DELETE /announcements/1
92 # DELETE /announcements/1.xml
101 # DELETE /announcements/1.xml
93 def destroy
102 def destroy
94 @announcement = Announcement.find(params[:id])
103 @announcement = Announcement.find(params[:id])
95 @announcement.destroy
104 @announcement.destroy
96
105
@@ -2,17 +2,18
2
2
3 = link_to '+ Add announcement', new_announcement_path, class: 'btn btn-success'
3 = link_to '+ Add announcement', new_announcement_path, class: 'btn btn-success'
4 %br
4 %br
5 %br
5 %br
6
6
7 %table.table.table-striped
7 %table.table.table-striped
8 - %tr
8 + %thead
9 %th Updated
9 %th Updated
10 %th Announcement
10 %th Announcement
11 %th Author
11 %th Author
12 - %th Published
12 + %th{style: 'width: 100px'} Published?
13 + %th{style: 'width: 100px'}Front?
13 %th
14 %th
14 %th
15 %th
15 - for announcement in @announcements
16 - for announcement in @announcements
16 %tr
17 %tr
17 - @announcement = announcement
18 - @announcement = announcement
18 %td= time_ago_in_words announcement.updated_at
19 %td= time_ago_in_words announcement.updated_at
@@ -25,12 +26,12
25 %b
26 %b
26 Notes: #{h announcement.notes}
27 Notes: #{h announcement.notes}
27 %br/
28 %br/
28 = h announcement.body
29 = h announcement.body
29 %td= h announcement.author
30 %td= h announcement.author
30 %td= toggle_button(announcement.published?, toggle_announcement_url(@announcement), "announcement_toggle_#{@announcement.id}", {size: 'btn-sm'})
31 %td= toggle_button(announcement.published?, toggle_announcement_url(@announcement), "announcement_toggle_#{@announcement.id}", {size: 'btn-sm'})
31 - //%td= link_to (announcement.published? ? "Yes" : "No"), url_for(controller: :announcements, action: :toggle, id: announcement), { class: "btn btn-block btn-sm btn-#{(announcement.published? ? 'success' : 'default')} ajax-toggle", id: "published-#{announcement.id}", data: {remote: true, method: 'post' } }
32 + %td= toggle_button(announcement.frontpage?, toggle_front_announcement_url(@announcement), "announcement_toggle_front_#{@announcement.id}", {size: 'btn-sm'})
32 %td= link_to 'Edit', edit_announcement_path(announcement), class: 'btn btn-block btn-sm btn-info'
33 %td= link_to 'Edit', edit_announcement_path(announcement), class: 'btn btn-block btn-sm btn-info'
33 %td= link_to 'Destroy', announcement, :confirm => 'Are you sure?', :method => :delete, class: "btn btn-block btn-sm btn-danger"
34 %td= link_to 'Destroy', announcement, :confirm => 'Are you sure?', :method => :delete, class: "btn btn-block btn-sm btn-danger"
34 %br
35 %br
35
36
36 = link_to '+ Add announcement', new_announcement_path, class: 'btn btn-success'
37 = link_to '+ Add announcement', new_announcement_path, class: 'btn btn-success'
@@ -1,19 +1,13
1 - .announcement{:id => "announcement-#{announcement.id}", :style => "#{'display: none; opacity: 0' if (defined? announcement_effect) and announcement_effect }"}
1 + %li.list-group-item
2 - %div
2 + %strong
3 - .announcement-title
3 + = announcement.title
4 - -# .toggles
4 + %small= "(updated #{time_ago_in_words(announcement.updated_at)} ago on #{announcement.updated_at})"
5 - -# %a{:href => '#', :onclick => "$(\"announcement-body-#{announcement.id}\").blindUp({duration: 0.2}); return false;"}
5 +
6 - -# [hide]
6 + %br
7 - -# %a{:href => '#', :onclick => "$(\"announcement-body-#{announcement.id}\").blindDown({duration: 0.2}); return false;"}
7 + = markdown(announcement.body)
8 - -# [show]
8 + :javascript
9 - = announcement.title
9 + Announcement.updateRecentId(#{announcement.id});
10 - .announcement-body{:id => "announcement-body-#{announcement.id}"}
10 + - if (defined? announcement_effect) and announcement_effect
11 - = markdown(announcement.body)
12 - -#.pub-info
13 - -# %p= "#{announcement.author}, #{announcement.created_at}"
14 :javascript
11 :javascript
15 - Announcement.updateRecentId(#{announcement.id});
12 + $("announcement-#{announcement.id}").blindDown({duration: 0.2});
16 - - if (defined? announcement_effect) and announcement_effect
13 + $("announcement-#{announcement.id}").appear({duration: 0.5, queue: 'end'});
17 - :javascript
18 - $("announcement-#{announcement.id}").blindDown({duration: 0.2});
19 - $("announcement-#{announcement.id}").appear({duration: 0.5, queue: 'end'});
@@ -1,11 +1,14
1 %tr
1 %tr
2 %td
2 %td
3 = "#{problem.name}"
3 = "#{problem.name}"
4 %td
4 %td
5 = "#{problem.full_name}"
5 = "#{problem.full_name}"
6 = link_to_description_if_any "[#{t 'main.problem_desc'}] <span class='glyphicon glyphicon-file'></span>".html_safe, problem
6 = link_to_description_if_any "[#{t 'main.problem_desc'}] <span class='glyphicon glyphicon-file'></span>".html_safe, problem
7 - %td{:align => "center"}
7 + %td
8 = @prob_submissions[problem.id][:count]
8 = @prob_submissions[problem.id][:count]
9 + = link_to "[#{t 'main.submissions_link'}]", main_submission_path(problem.id)
9 %td
10 %td
10 = render :partial => 'submission_short',
11 = render :partial => 'submission_short',
11 :locals => {:submission => @prob_submissions[problem.id][:submission], :problem_name => problem.name }
12 :locals => {:submission => @prob_submissions[problem.id][:submission], :problem_name => problem.name }
13 + %td
14 + = link_to 'Edit', direct_edit_path(problem.id), class: 'btn btn-success'
@@ -19,8 +19,8
19 = " | "
19 = " | "
20 = link_to '[detailed result]', :action => 'result', :id => submission.id
20 = link_to '[detailed result]', :action => 'result', :id => submission.id
21 = " | "
21 = " | "
22 = link_to("[#{t 'main.cmp_msg'}]", {:action => 'compiler_msg', :id => submission.id}, {:popup => true})
22 = link_to("[#{t 'main.cmp_msg'}]", {:action => 'compiler_msg', :id => submission.id}, {:popup => true})
23 = " | "
23 = " | "
24 = link_to("[#{t 'main.src_link'}]",{:action => 'source', :id => submission.id})
24 = link_to("[#{t 'main.src_link'}]",{:action => 'source', :id => submission.id})
25 - = " | "
25 + //= " | "
26 - = link_to "[#{t 'main.submissions_link'}]", main_submission_path(submission.problem.id)
26 + //= link_to "[#{t 'main.submissions_link'}]", main_submission_path(submission.problem.id)
@@ -1,36 +1,37
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 + .panel.panel-info
7 - %span{:class => 'title'}
7 + .panel-heading
8 - Announcements
8 + Announcement
9 - #announcementbox-body
9 + %ul.list-group
10 = render :partial => 'announcement', :collection => @announcements
10 = render :partial => 'announcement', :collection => @announcements
11
11
12 +
12 - if GraderConfiguration.show_submitbox_to?(@user)
13 - if GraderConfiguration.show_submitbox_to?(@user)
13 .submitbox
14 .submitbox
14 = render :partial => 'submission_box'
15 = render :partial => 'submission_box'
15
16
16 -
17 %hr/
17 %hr/
18
18
19 - if (GraderConfiguration.contest_mode?) and (@user.site!=nil) and (@user.site.started!=true)
19 - if (GraderConfiguration.contest_mode?) and (@user.site!=nil) and (@user.site.started!=true)
20 %p=t 'main.start_soon'
20 %p=t 'main.start_soon'
21
21
22 - if GraderConfiguration.show_tasks_to?(@user)
22 - if GraderConfiguration.show_tasks_to?(@user)
23 - if not GraderConfiguration.multicontests?
23 - if not GraderConfiguration.multicontests?
24 %table.table.table-striped.table-condensed
24 %table.table.table-striped.table-condensed
25 %thead
25 %thead
26 - %tr.info-head
26 + %tr
27 %th Task name
27 %th Task name
28 %th Full name
28 %th Full name
29 %th # of sub(s)
29 %th # of sub(s)
30 %th Results
30 %th Results
31 + %th
31 %tbody
32 %tbody
32 = render :partial => 'problem', :collection => @problems
33 = render :partial => 'problem', :collection => @problems
33 - else
34 - else
34 - @contest_problems.each do |cp|
35 - @contest_problems.each do |cp|
35 - if cp[:problems].length > 0
36 - if cp[:problems].length > 0
36 %h2{:class =>'contest-title'}
37 %h2{:class =>'contest-title'}
@@ -38,12 +39,13
38 %table.info
39 %table.info
39 %tr.info-head
40 %tr.info-head
40 %th Task name
41 %th Task name
41 %th Full name
42 %th Full name
42 %th # of sub(s)
43 %th # of sub(s)
43 %th Results
44 %th Results
45 + %th
44 = render :partial => 'problem', :collection => cp[:problems]
46 = render :partial => 'problem', :collection => cp[:problems]
45
47
46 %hr/
48 %hr/
47
49
48 %script{:type => 'text/javascript'}
50 %script{:type => 'text/javascript'}
49 = "Announcement.refreshUrl = '#{url_for :controller => 'main', :action => 'announcements'}';"
51 = "Announcement.refreshUrl = '#{url_for :controller => 'main', :action => 'announcements'}';"
@@ -1,12 +1,16
1 %h2 Live submit
1 %h2 Live submit
2 %br
2 %br
3
3
4 %textarea#text_haha{style: "display:none"}~ @source
4 %textarea#text_haha{style: "display:none"}~ @source
5 .container
5 .container
6 .row
6 .row
7 + .col-md-12
8 + .alert.alert-info
9 + Write your code in the following box, choose language, and click submit button when finished
10 + .row
7 .col-md-7
11 .col-md-7
8 %div#editor{style: 'height: 500px; border-radius: 7px; font-size: 14px;'}
12 %div#editor{style: 'height: 500px; border-radius: 7px; font-size: 14px;'}
9 .col-md-5
13 .col-md-5
10 = form_tag({controller: :main, :action => 'submit'}, :multipart => true, class: 'form') do
14 = form_tag({controller: :main, :action => 'submit'}, :multipart => true, class: 'form') do
11
15
12 = hidden_field_tag 'editor_text', @source
16 = hidden_field_tag 'editor_text', @source
@@ -7,13 +7,13
7 resources :contests
7 resources :contests
8
8
9 resources :sites
9 resources :sites
10
10
11 resources :announcements do
11 resources :announcements do
12 member do
12 member do
13 - get 'toggle'
13 + get 'toggle','toggle_front'
14 end
14 end
15 end
15 end
16
16
17
17
18 resources :problems do
18 resources :problems do
19 member do
19 member do
You need to be logged in to leave comments. Login now