diff --git a/app/assets/stylesheets/web_resources_front.css.scss b/app/assets/stylesheets/web_resources_front.css.scss new file mode 100644 index 0000000..dbe2785 --- /dev/null +++ b/app/assets/stylesheets/web_resources_front.css.scss @@ -0,0 +1,32 @@ +// Place all the styles related to the act controller here. +// They will automatically be included in application.css. +// You can use Sass (SCSS) here: http://sass-lang.com/ +.index-link.index2 li.col-md-4{ + float: left; + .link-img-wrap { + overflow: hidden; + height: 12.5em; + img { + max-height: 100%; + max-width: 100%; + height: auto; + width: auto; + } + } + a:hover .link-title{ + color: #0032b2; + font-size: 1.15em; + } + @media (min-width: 992px){ + width: 33.3333%; + } + @media (min-width: 577px) and (max-width: 991px){ + width: 50%; + } + @media (max-width: 576px){ + width: 100%; + .alink-img-wrap { + height: auto; + } + } +} \ No newline at end of file diff --git a/app/controllers/web_resources_controller.rb b/app/controllers/web_resources_controller.rb index a21bbdd..c7fd44a 100644 --- a/app/controllers/web_resources_controller.rb +++ b/app/controllers/web_resources_controller.rb @@ -1,6 +1,7 @@ class WebResourcesController < ApplicationController require 'nokogiri' def index + OrbitHelper.render_css_in_head(["web_resources_front"]) links = WebLink.where(:title.ne => "").can_display.filter_by_categories web_link = links.collect do |link| statuses = link.statuses_with_classname.collect do |status| @@ -19,10 +20,14 @@ class WebResourcesController < ApplicationController if text.blank? && doc.css("img").count != 0 text = doc.css("img").map{|img| img.attr("alt") rescue ""}.select{|t| t.present?}.first end + desc = link.image_description + desc = (desc.blank? ? "web resource image" : desc) { "title" => link.title, "title_text" => text, - "context" => link.context, + "img_src" => link.image.thumb.url || "/assets/announcement-default.jpg", + "img_description" => desc, + "context" => nl2br(link.context.to_s), "statuses" => statuses, "category" => link.category.title, "link_to_show" => link.url, @@ -60,7 +65,7 @@ class WebResourcesController < ApplicationController { "title" => link.title, "title_text" => text, - "context" => link.context, + "context" => nl2br(link.context.to_s), "statuses" => statuses, "link_to_show" => link.url, "target" => target @@ -71,5 +76,8 @@ class WebResourcesController < ApplicationController "extras" => {"widget-title"=>t(:web_resource),"more_url" => OrbitHelper.widget_more_url} } end - + + def nl2br(val) + val.gsub(/\r\n/, '
').html_safe + end end diff --git a/app/models/web_link.rb b/app/models/web_link.rb index 383fbca..3853ccb 100644 --- a/app/models/web_link.rb +++ b/app/models/web_link.rb @@ -8,6 +8,9 @@ class WebLink include OrbitTag::Taggable include OrbitCategory::Categorizable + + field :image_description, type: String, localize: true + mount_uploader :image, ImageUploader field :title, localize: true field :context, localize: true field :order_position, type: Integer, default: -1 diff --git a/app/views/admin/web_resources/_form.html.erb b/app/views/admin/web_resources/_form.html.erb index d52f62c..9625c70 100644 --- a/app/views/admin/web_resources/_form.html.erb +++ b/app/views/admin/web_resources/_form.html.erb @@ -1,5 +1,7 @@ <% content_for :page_specific_css do %> <%= stylesheet_link_tag "lib/main-forms" %> + <%= stylesheet_link_tag "lib/fileupload" %> + <%= stylesheet_link_tag "lib/main-list" %> <% end %> <% content_for :page_specific_javascript do %> <%= javascript_include_tag "lib/bootstrap-fileupload" %> @@ -15,6 +17,7 @@
  • <%= t(:basic) %>
  • <%= t(:status) %>
  • <%= t(:tags) %>
  • +
  • <%= t('web_link.image') %>
  • @@ -65,6 +68,51 @@ + + +
    + + +
    + +
    +
    +
    + <% if @link.image.file %> + <%= image_tag @link.image %> + <% else %> + + <% end %> +
    +
    + + <%= t(:select_image) %> + <%= t(:change) %> + <%= f.file_field :image %> + + <%= t(:cancel) %> +
    + +
    +
    +
    +
    + <% @site_in_use_locales.each do |locale| %> + <%= f.fields_for :image_description_translations do |f| %> +
    + +
    + <%= f.text_field locale, value: (@link.image_description_translations[locale.to_s] rescue nil) %> +
    +
    + <% end %> + <% end %> + +
    + + @@ -91,7 +139,7 @@
    <%= f.fields_for :title_translations do |f| %> - <%= f.text_area locale, class: "input-block-level ckeditor", placeholder: t(:title), value: (@link.title_translations[locale] rescue nil) %> + <%= f.text_area locale, class: "input-block-level ckeditor_reduce", placeholder: t(:title), value: (@link.title_translations[locale] rescue nil) %> <% end %>
    @@ -101,7 +149,7 @@
    <%= f.fields_for :context_translations do |f| %> - <%= f.text_area locale, rows: 5, class: "input-block-level", value: (@link.context_translations[locale] rescue nil) %> + <%= f.text_area locale, rows: 5, class: "input-block-level ckeditor", value: (nl2br(@link.context_translations[locale]) rescue nil) %> <% end %>
    @@ -137,5 +185,65 @@ <%= f.submit t('submit'), class: 'btn btn-primary' %> <%= link_to t('cancel'), admin_web_resources_path, :class=>"btn" %> + \ No newline at end of file diff --git a/config/locales/en.yml b/config/locales/en.yml index 8bfa4dd..9d53131 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -4,6 +4,7 @@ en: restful_actions: order: Order web_link: + image: Cover Image local: Open In Current page new_window: Open In New window type: Link Open Type diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index e58a7a3..7456497 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -4,6 +4,7 @@ zh_tw: restful_actions: order: 排序 web_link: + image: 封面圖片 local: 當前視窗開啟 new_window: 新視窗開啟 type: 開啟方式 diff --git a/modules/web_resource/_web_res_widget1.html.erb b/modules/web_resource/_web_res_widget1.html.erb index 5b3ef48..89c6815 100644 --- a/modules/web_resource/_web_res_widget1.html.erb +++ b/modules/web_resource/_web_res_widget1.html.erb @@ -4,6 +4,9 @@