social_stream-linkser 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -15,6 +15,14 @@
15
15
  margin: auto;
16
16
  margin-top: 50px;
17
17
  }
18
+ #link_preview img.link_error{
19
+ margin: auto;
20
+ margin-top: 40px;
21
+ }
22
+ #link_preview div.link_error{
23
+ margin: auto;
24
+ margin-top: 5px;
25
+ }
18
26
  .link {
19
27
  position: relative;
20
28
  padding: 10px;
@@ -2,14 +2,19 @@ class LinkserController < ApplicationController
2
2
  def index
3
3
  if params[:url].present?
4
4
  url = params[:url]
5
- o = Linkser.parse url, {:max_images => 1}
6
- if o.is_a? Linkser::Objects::HTML
7
- link = Link.new
8
- link.fill o
9
- render :partial => "links/link_preview", :locals => {:link => link}
10
- return
5
+ begin
6
+ o = Linkser.parse url, {:max_images => 1}
7
+ if o.is_a? Linkser::Objects::HTML
8
+ link = Link.new
9
+ link.fill o
10
+ render :partial => "links/link_preview", :locals => {:link => link}
11
+ return
12
+ end
13
+ rescue
14
+ render :partial => "links/error", :locals => {:message => I18n.t("link.errors.loading") + " " + url.to_s}
15
+ return
11
16
  end
12
17
  end
13
- render :text => I18n.t("link.errors.only_web")
18
+ render :partial => "links/error", :locals => {:message => I18n.t("link.errors.only_webs")}
14
19
  end
15
20
  end
data/app/models/link.rb CHANGED
@@ -32,9 +32,12 @@ class Link < ActiveRecord::Base
32
32
 
33
33
  def check_loaded
34
34
  if !self.loaded.eql? "true" and self.title.nil? and self.description.nil? and self.image.nil?
35
- o = Linkser.parse self.url, {:max_images => 1}
36
- if o.is_a? Linkser::Objects::HTML
37
- self.fill o
35
+ begin
36
+ o = Linkser.parse self.url, {:max_images => 1}
37
+ if o.is_a? Linkser::Objects::HTML
38
+ self.fill o
39
+ end
40
+ rescue
38
41
  end
39
42
  end
40
43
  end
@@ -0,0 +1,4 @@
1
+ <%= image_tag "btn/error.png", :class => "link_error" %>
2
+ <div class="link_error">
3
+ <%= message %>
4
+ </div>
@@ -1,5 +1,5 @@
1
1
  module SocialStream
2
2
  module Linkser
3
- VERSION = "0.0.4".freeze
3
+ VERSION = "0.0.5".freeze
4
4
  end
5
5
  end
@@ -12,7 +12,7 @@ Gem::Specification.new do |s|
12
12
  s.files = `git ls-files`.split("\n")
13
13
 
14
14
  # Gem dependencies
15
- s.add_runtime_dependency('social_stream-base', '~> 0.10.7')
15
+ s.add_runtime_dependency('social_stream-base', '~> 0.10.8')
16
16
  s.add_runtime_dependency('linkser', '~> 0.0.7')
17
17
  # Development Gem dependencies
18
18
  s.add_development_dependency('sqlite3-ruby')
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: social_stream-linkser
3
3
  version: !ruby/object:Gem::Version
4
- hash: 23
4
+ hash: 21
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 4
10
- version: 0.0.4
9
+ - 5
10
+ version: 0.0.5
11
11
  platform: ruby
12
12
  authors:
13
13
  - Eduardo Casanova Cuesta
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-12-09 00:00:00 +01:00
19
+ date: 2011-12-13 00:00:00 +01:00
20
20
  default_executable:
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -27,12 +27,12 @@ dependencies:
27
27
  requirements:
28
28
  - - ~>
29
29
  - !ruby/object:Gem::Version
30
- hash: 57
30
+ hash: 39
31
31
  segments:
32
32
  - 0
33
33
  - 10
34
- - 7
35
- version: 0.10.7
34
+ - 8
35
+ version: 0.10.8
36
36
  type: :runtime
37
37
  version_requirements: *id001
38
38
  - !ruby/object:Gem::Dependency
@@ -167,6 +167,7 @@ files:
167
167
  - app/controllers/links_controller.rb
168
168
  - app/controllers/linkser_controller.rb
169
169
  - app/models/link.rb
170
+ - app/views/links/_error.html.erb
170
171
  - app/views/links/_link.html.erb
171
172
  - app/views/links/_link_preview.html.erb
172
173
  - app/views/links/create.js.erb