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 @@