# HG changeset patch # User Nattee Niparnan # Date 2016-07-09 04:37:05 # Node ID cc292daee78f7efeb9e3db82b22e62ff93cf382a # Parent 46de378c3b60456f38ceff44d386fbfc21487aa3 - add front page toggle to announcement - cosmetic change in some pages / main diff --git a/app/assets/stylesheets/sources.css.scss b/app/assets/stylesheets/sources.css.scss --- a/app/assets/stylesheets/sources.css.scss +++ b/app/assets/stylesheets/sources.css.scss @@ -2,11 +2,3 @@ // They will automatically be included in application.css. // You can use Sass (SCSS) here: http://sass-lang.com/ -#editor { - position: absolute; - top: 0; - right: 0; - bottom: 0; - left: 0; -} - diff --git a/app/controllers/announcements_controller.rb b/app/controllers/announcements_controller.rb --- a/app/controllers/announcements_controller.rb +++ b/app/controllers/announcements_controller.rb @@ -88,6 +88,15 @@ end end + def toggle_front + @announcement = Announcement.find(params[:id]) + @announcement.update_attributes( frontpage: !@announcement.frontpage? ) + respond_to do |format| + format.js { render partial: 'toggle_button', + locals: {button_id: "#announcement_toggle_front_#{@announcement.id}",button_on: @announcement.frontpage? } } + end + end + # DELETE /announcements/1 # DELETE /announcements/1.xml def destroy diff --git a/app/views/announcements/index.html.haml b/app/views/announcements/index.html.haml --- a/app/views/announcements/index.html.haml +++ b/app/views/announcements/index.html.haml @@ -5,11 +5,12 @@ %br %table.table.table-striped - %tr + %thead %th Updated %th Announcement %th Author - %th Published + %th{style: 'width: 100px'} Published? + %th{style: 'width: 100px'}Front? %th %th - for announcement in @announcements @@ -28,7 +29,7 @@ = h announcement.body %td= h announcement.author %td= toggle_button(announcement.published?, toggle_announcement_url(@announcement), "announcement_toggle_#{@announcement.id}", {size: 'btn-sm'}) - //%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' } } + %td= toggle_button(announcement.frontpage?, toggle_front_announcement_url(@announcement), "announcement_toggle_front_#{@announcement.id}", {size: 'btn-sm'}) %td= link_to 'Edit', edit_announcement_path(announcement), class: 'btn btn-block btn-sm btn-info' %td= link_to 'Destroy', announcement, :confirm => 'Are you sure?', :method => :delete, class: "btn btn-block btn-sm btn-danger" %br diff --git a/app/views/main/_announcement.html.haml b/app/views/main/_announcement.html.haml --- a/app/views/main/_announcement.html.haml +++ b/app/views/main/_announcement.html.haml @@ -1,19 +1,13 @@ -.announcement{:id => "announcement-#{announcement.id}", :style => "#{'display: none; opacity: 0' if (defined? announcement_effect) and announcement_effect }"} - %div - .announcement-title - -# .toggles - -# %a{:href => '#', :onclick => "$(\"announcement-body-#{announcement.id}\").blindUp({duration: 0.2}); return false;"} - -# [hide] - -# %a{:href => '#', :onclick => "$(\"announcement-body-#{announcement.id}\").blindDown({duration: 0.2}); return false;"} - -# [show] - = announcement.title - .announcement-body{:id => "announcement-body-#{announcement.id}"} - = markdown(announcement.body) - -#.pub-info - -# %p= "#{announcement.author}, #{announcement.created_at}" +%li.list-group-item + %strong + = announcement.title + %small= "(updated #{time_ago_in_words(announcement.updated_at)} ago on #{announcement.updated_at})" + + %br + = markdown(announcement.body) + :javascript + Announcement.updateRecentId(#{announcement.id}); + - if (defined? announcement_effect) and announcement_effect :javascript - Announcement.updateRecentId(#{announcement.id}); - - if (defined? announcement_effect) and announcement_effect - :javascript - $("announcement-#{announcement.id}").blindDown({duration: 0.2}); - $("announcement-#{announcement.id}").appear({duration: 0.5, queue: 'end'}); + $("announcement-#{announcement.id}").blindDown({duration: 0.2}); + $("announcement-#{announcement.id}").appear({duration: 0.5, queue: 'end'}); diff --git a/app/views/main/_problem.html.haml b/app/views/main/_problem.html.haml --- a/app/views/main/_problem.html.haml +++ b/app/views/main/_problem.html.haml @@ -4,8 +4,11 @@ %td = "#{problem.full_name}" = link_to_description_if_any "[#{t 'main.problem_desc'}] ".html_safe, problem - %td{:align => "center"} + %td = @prob_submissions[problem.id][:count] + = link_to "[#{t 'main.submissions_link'}]", main_submission_path(problem.id) %td = render :partial => 'submission_short', :locals => {:submission => @prob_submissions[problem.id][:submission], :problem_name => problem.name } + %td + = link_to 'Edit', direct_edit_path(problem.id), class: 'btn btn-success' diff --git a/app/views/main/_submission_short.html.haml b/app/views/main/_submission_short.html.haml --- a/app/views/main/_submission_short.html.haml +++ b/app/views/main/_submission_short.html.haml @@ -22,5 +22,5 @@ = link_to("[#{t 'main.cmp_msg'}]", {:action => 'compiler_msg', :id => submission.id}, {:popup => true}) = " | " = link_to("[#{t 'main.src_link'}]",{:action => 'source', :id => submission.id}) - = " | " - = link_to "[#{t 'main.submissions_link'}]", main_submission_path(submission.problem.id) + //= " | " + //= link_to "[#{t 'main.submissions_link'}]", main_submission_path(submission.problem.id) diff --git a/app/views/main/list.html.haml b/app/views/main/list.html.haml --- a/app/views/main/list.html.haml +++ b/app/views/main/list.html.haml @@ -3,17 +3,17 @@ = user_title_bar(@user) -.announcementbox{:style => (@announcements.length==0 ? "display:none" : "")} - %span{:class => 'title'} - Announcements - #announcementbox-body +.panel.panel-info + .panel-heading + Announcement + %ul.list-group = render :partial => 'announcement', :collection => @announcements + - if GraderConfiguration.show_submitbox_to?(@user) .submitbox = render :partial => 'submission_box' - %hr/ - if (GraderConfiguration.contest_mode?) and (@user.site!=nil) and (@user.site.started!=true) @@ -23,11 +23,12 @@ - if not GraderConfiguration.multicontests? %table.table.table-striped.table-condensed %thead - %tr.info-head + %tr %th Task name %th Full name %th # of sub(s) %th Results + %th %tbody = render :partial => 'problem', :collection => @problems - else @@ -41,6 +42,7 @@ %th Full name %th # of sub(s) %th Results + %th = render :partial => 'problem', :collection => cp[:problems] %hr/ diff --git a/app/views/sources/direct_edit.html.haml b/app/views/sources/direct_edit.html.haml --- a/app/views/sources/direct_edit.html.haml +++ b/app/views/sources/direct_edit.html.haml @@ -4,6 +4,10 @@ %textarea#text_haha{style: "display:none"}~ @source .container .row + .col-md-12 + .alert.alert-info + Write your code in the following box, choose language, and click submit button when finished + .row .col-md-7 %div#editor{style: 'height: 500px; border-radius: 7px; font-size: 14px;'} .col-md-5 diff --git a/config/routes.rb b/config/routes.rb --- a/config/routes.rb +++ b/config/routes.rb @@ -10,7 +10,7 @@ resources :announcements do member do - get 'toggle' + get 'toggle','toggle_front' end end