From 18f9611d0a3d895a7c363f253f67e643008bc147 Mon Sep 17 00:00:00 2001 From: manson Date: Fri, 12 Sep 2014 11:02:56 +0800 Subject: [PATCH] add more date format for index --- app/controllers/announcements_controller.rb | 42 ++++++++++++++++++-- app/views/admin/announcements/_form.html.erb | 3 +- 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/app/controllers/announcements_controller.rb b/app/controllers/announcements_controller.rb index 0548bb5..6828bd2 100644 --- a/app/controllers/announcements_controller.rb +++ b/app/controllers/announcements_controller.rb @@ -14,7 +14,20 @@ class AnnouncementsController < ApplicationController "title" => a.title, "subtitle" => a.subtitle, "statuses" => statuses, + "postdate" => a.postdate.strftime("%b %d, %Y at %I:%M %p"), + "date" => a.postdate.strftime("%F"), + "year" => a.postdate.strftime("%Y"), + "month" => a.postdate.strftime("%b"), + "month-num" => a.postdate.strftime("%m"), + "week" => a.postdate.strftime("%A"), + "week-num" => a.postdate.strftime("%u"), + "day" => a.postdate.strftime("%d"), + "hour" => a.postdate.strftime("%H"), + "minute" => a.postdate.strftime("%M"), + "second" => a.postdate.strftime("%S"), + "meridian" => a.postdate.strftime("%p"), + "link_to_show" => OrbitHelper.url_to_show(a.to_param), "img_src" => a.image.thumb.url || "http://placehold.it/100x100", "more" => t(:more_plus) @@ -44,7 +57,20 @@ class AnnouncementsController < ApplicationController "title" => a.title, "subtitle" => a.subtitle, "statuses" => statuses, + "postdate" => a.postdate.strftime("%d"), + "date" => a.postdate.strftime("%F"), + "year" => a.postdate.strftime("%Y"), + "month" => a.postdate.strftime("%b"), + "month-num" => a.postdate.strftime("%m"), + "week" => a.postdate.strftime("%A"), + "week-num" => a.postdate.strftime("%u"), + "day" => a.postdate.strftime("%d"), + "hour" => a.postdate.strftime("%H"), + "minute" => a.postdate.strftime("%M"), + "second" => a.postdate.strftime("%S"), + "meridian" => a.postdate.strftime("%p"), + "link_to_show" => OrbitHelper.widget_item_url(a.to_param), "img_src" => a.image.thumb.url || "http://placehold.it/100x100", } @@ -71,10 +97,20 @@ class AnnouncementsController < ApplicationController "title" => a.title, "subtitle" => a.subtitle, "statuses" => statuses, - "week" => a.postdate.strftime("%A"), - "day" => a.postdate.strftime("%d"), - "month" => a.postdate.strftime("%b"), + + "postdate" => a.postdate.strftime("%d"), + "date" => a.postdate.strftime("%F"), "year" => a.postdate.strftime("%Y"), + "month" => a.postdate.strftime("%b"), + "month-num" => a.postdate.strftime("%m"), + "week" => a.postdate.strftime("%A"), + "week-num" => a.postdate.strftime("%u"), + "day" => a.postdate.strftime("%d"), + "hour" => a.postdate.strftime("%H"), + "minute" => a.postdate.strftime("%M"), + "second" => a.postdate.strftime("%S"), + "meridian" => a.postdate.strftime("%p"), + "link_to_show" => OrbitHelper.widget_item_url(a.to_param), "img_src" => a.image.thumb.url || "http://placehold.it/100x100", } diff --git a/app/views/admin/announcements/_form.html.erb b/app/views/admin/announcements/_form.html.erb index 9623791..a6106d8 100644 --- a/app/views/admin/announcements/_form.html.erb +++ b/app/views/admin/announcements/_form.html.erb @@ -286,8 +286,9 @@
+ <%= get_referer_url[:action] rescue "" %> <%= f.submit t('submit'), class: 'btn btn-primary' %> - + <%= button_tag t("preview"), id: "button_for_preview", name: "commit", class: 'btn', type: :button %> <%= link_to t('cancel'), admin_announcements_path, :class=>"btn" %>