added external link option

This commit is contained in:
Harry Bomrah 2017-06-20 15:04:05 +08:00
parent d6cb086a4a
commit c06e87fb05
5 changed files with 42 additions and 4 deletions

View File

@ -65,6 +65,8 @@ class AnnouncementsController < ApplicationController
author = User.find(a.create_user_id).member_profile.name rescue "" author = User.find(a.create_user_id).member_profile.name rescue ""
desc = a.image_description desc = a.image_description
desc = (desc.nil? || desc == "" ? "announcement image" : desc) desc = (desc.nil? || desc == "" ? "announcement image" : desc)
link_to_show = a.is_external_link ? a.external_link : OrbitHelper.url_to_show(a.to_param)
target = a.is_external_link ? "_blank" : "_self"
anns << { anns << {
"bulletin_links" => links, "bulletin_links" => links,
"bulletin_files" => files, "bulletin_files" => files,
@ -78,7 +80,8 @@ class AnnouncementsController < ApplicationController
"postdate" => a.postdate, "postdate" => a.postdate,
"author" => author, "author" => author,
"is_top" => (a.is_top? ? 1 : 0), "is_top" => (a.is_top? ? 1 : 0),
"link_to_show" => OrbitHelper.url_to_show(a.to_param), "link_to_show" => link_to_show,
"target" => target,
"img_src" => a.image.thumb.url || "/assets/announcement-default.jpg", "img_src" => a.image.thumb.url || "/assets/announcement-default.jpg",
"img_description" => desc, "img_description" => desc,
"more" => t(:more_plus), "more" => t(:more_plus),
@ -144,6 +147,7 @@ class AnnouncementsController < ApplicationController
"source-site-title" => fa["source-site-title"], "source-site-title" => fa["source-site-title"],
"source-site-link" => fa["source-site"], "source-site-link" => fa["source-site"],
"link_to_show" => OrbitHelper.url_to_show(fa["params"]), "link_to_show" => OrbitHelper.url_to_show(fa["params"]),
"target" => "_self",
"img_src" => fa["image"]["thumb"] || "/assets/announcement-default.jpg", "img_src" => fa["image"]["thumb"] || "/assets/announcement-default.jpg",
"img_description" => fa["image_description_translations"][locale], "img_description" => fa["image_description_translations"][locale],
"more" => t(:more_plus), "more" => t(:more_plus),
@ -201,7 +205,9 @@ class AnnouncementsController < ApplicationController
author = User.find(a.create_user_id).member_profile.name rescue "" author = User.find(a.create_user_id).member_profile.name rescue ""
desc = a.image_description desc = a.image_description
desc = (desc.nil? || desc == "" ? "announcement image" : desc) desc = (desc.nil? || desc == "" ? "announcement image" : desc)
anns << { link_to_show = a.is_external_link ? a.external_link : OrbitHelper.url_to_show(a.to_param)
target = a.is_external_link ? "_blank" : "_self"
anns << {
"bulletin_links" => links, "bulletin_links" => links,
"bulletin_files" => files, "bulletin_files" => files,
"title" => a.title, "title" => a.title,
@ -213,7 +219,8 @@ class AnnouncementsController < ApplicationController
"category" => a.category.title, "category" => a.category.title,
"postdate" => a.postdate, "postdate" => a.postdate,
"author" => author, "author" => author,
"link_to_show" => OrbitHelper.widget_item_url(a.to_param), "link_to_show" => link_to_show,
"target" => target,
"img_src" => a.image.thumb.url || "/assets/announcement-default.jpg", "img_src" => a.image.thumb.url || "/assets/announcement-default.jpg",
"img_description" => desc "img_description" => desc
} }

View File

@ -24,6 +24,8 @@ class Bulletin
field :rejected, :type => Boolean, :default => false field :rejected, :type => Boolean, :default => false
field :reapproval, :type => Boolean, :default => false field :reapproval, :type => Boolean, :default => false
field :rejection_reason field :rejection_reason
field :is_external_link, :type => Boolean, :default => false
field :external_link
field :email_id field :email_id
field :email_sent, :type => Boolean, :default => false field :email_sent, :type => Boolean, :default => false

View File

@ -52,6 +52,21 @@
</div> </div>
</div> </div>
<div class="control-group">
<%= f.label :is_external_link, t("announcement.is_external_link"), :class => "control-label muted" %>
<div class="controls">
<%= f.check_box :is_external_link %>
</div>
</div>
<div class="control-group" style="display: none;" id="external_link_box">
<%= f.label :external_link, t("announcement.external_link"), :class => "control-label muted" %>
<div class="controls">
<%= f.text_field :external_link %>
<div class="hint"><%= t("announcement.external_link_hint") %></div>
</div>
</div>
</div> </div>
<!-- Status Module --> <!-- Status Module -->
@ -441,6 +456,14 @@
},100) },100)
}) })
$("#bulletin_is_external_link").on("click",function(){
if($(this).is(":checked")){
$("#external_link_box").show();
}else{
$("#external_link_box").hide();
}
})
}); });
</script> </script>
<% end %> <% end %>

View File

@ -75,4 +75,7 @@ en:
mail_source: Source mail_source: Source
mail_time: Time mail_time: Time
image_upload_size_note: The following recommendations %{image_upload_size} upload size image_upload_size_note: The following recommendations %{image_upload_size} upload size
resend_mail: Re-send Email resend_mail: Re-send Email
is_external_link: Enable External Link
external_link: External Link
external_link_hint: "Make sure URL starts with http://"

View File

@ -79,3 +79,6 @@ zh_tw:
mail_time: 時間 mail_time: 時間
image_upload_size_note: 建議檔案小於%{image_upload_size} image_upload_size_note: 建議檔案小於%{image_upload_size}
resend_mail: 重新寄送提醒 resend_mail: 重新寄送提醒
is_external_link: 開啟內部連結
external_link: 外部連結
external_link_hint: "確定連結開頭為http://"