From 564620482ac8620a3907f3c56f646a1ef2602da7 Mon Sep 17 00:00:00 2001 From: bohung Date: Tue, 19 May 2020 14:10:12 +0800 Subject: [PATCH] Fix bug --- app/helpers/announcements_helper.rb | 8 ++++++++ app/views/announcements/show_widget.html.erb | 4 ++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/app/helpers/announcements_helper.rb b/app/helpers/announcements_helper.rb index 34b82a5..5d898bc 100644 --- a/app/helpers/announcements_helper.rb +++ b/app/helpers/announcements_helper.rb @@ -383,6 +383,14 @@ module AnnouncementsHelper end html = Nokogiri::HTML.parse(html) html.css('.i-annc__page-title').remove + dates = html.css("*[date-format]") + if !dates.blank? + dates.each do |d| + format = d.attributes["date-format"].value + date = DateTime.parse(d.inner_text) + d.inner_html = d.inner_html.gsub(d.inner_text.strip, " " + date.strftime(format)) + end + end html.css("body").to_html.html_safe end end diff --git a/app/views/announcements/show_widget.html.erb b/app/views/announcements/show_widget.html.erb index 5356bff..a02fe02 100644 --- a/app/views/announcements/show_widget.html.erb +++ b/app/views/announcements/show_widget.html.erb @@ -5,11 +5,11 @@ <%= stylesheet_link_tag "//cdnjs.cloudflare.com/ajax/libs/font-awesome/4.3.0/css/font-awesome.min.css"%> <%= stylesheet_link_tag "bootstrap/bootstrap.min.css"%> <%= stylesheet_link_tag "template/template"%> + <%= javascript_include_tag "jquery.min"%> <%= javascript_include_tag "bootstrap.min"%> - <% params = {:layout_type => 'annc_index1',:target_controller=>'announcements',:target_action=>'show_widget'} %> <% @target_action = "show_widget" %> - <%=render_view_for_annc((params[:layout_type].blank? ? params[:layout_type] : 'annc_index1'))%> + <%=render_view_for_annc((!params[:layout_type].blank? ? params[:layout_type] : 'annc_index1'))%> \ No newline at end of file