editmode 0.0.9.37 → 0.0.9.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2ef8bb95a914ee4e0c030cb365bb2f2ae661be5e38a4c6638f1ed07e28f38714
4
- data.tar.gz: 5ccaa0a98155e222241adf0f85b12c2975d832d912902776fd84a919d6a9d649
3
+ metadata.gz: 5efc7a653779c9512a8d0e280f41f2e95bfedfd09eb242ff755a3cfdb5c7ac7e
4
+ data.tar.gz: 8d1503bd4bc148b966abd4f662153015130d9297210f1a2eab5ea5ee6f9cd602
5
5
  SHA512:
6
- metadata.gz: 4db8788bbcf384cb5e8d5e57fe494688a990f02b33850c4febd722b70d54739d283cb1411af7873eb15f75858ab48aab1745053fc2c20e766df245f8d1717f2a
7
- data.tar.gz: f13ae77f68463f0b7650bdd07743f5eccb5b93132dcd42327b5268c1f3588f12e7ea47f2fd302910e1b23f47e4d260cc8646babc59f80853ebc96321e84fc947
6
+ metadata.gz: 58b77302710392b9fd1fd01d15e719e24cd1abbe21c38cd041050a479d5717c8a670024c0a0877719e72d5bba49e72aa56092523b2e1dfc23ec1040cca7aef66
7
+ data.tar.gz: 8cc0ca43f7a1de0e4719e962e5d52692e1f413561092853d675eb960487e08a8bd48125da3a3eab526925bbf0251c25ab9f4de56cade9d948e93ffa45a68a21d
@@ -18,12 +18,15 @@ module EditModeRails
18
18
  end
19
19
 
20
20
  def chunk_collection(collection_identifier,has_tags=[])
21
-
22
- url = "#{versioned_api_url}/chunks?collection_identifier=#{collection_identifier}"
23
- response = HTTParty.get(url)
24
- chunks = response["chunks"]
25
- return chunks
26
-
21
+ begin
22
+ url = "#{versioned_api_url}/chunks?collection_identifier=#{collection_identifier}"
23
+ response = HTTParty.get(url)
24
+ chunks = response["chunks"]
25
+ return chunks
26
+ rescue => error
27
+ puts error
28
+ []
29
+ end
27
30
  end
28
31
 
29
32
  def chunk_property(chunk_info,custom_field_identifier=nil,options={})
@@ -42,47 +45,51 @@ module EditModeRails
42
45
 
43
46
  def chunk_display(label,identifier,options={},custom_field_info={})
44
47
 
45
- if custom_field_info.present?
46
- chunk_content = custom_field_info["value"]
47
- else
48
- chunk_content = Rails.cache.fetch("bit_#{identifier}") do
49
- url = "#{versioned_api_url}/bits/#{identifier}"
50
- response = HTTParty.get(url)
51
- chunk_content = response['content']
48
+ begin
49
+ if custom_field_info.present?
50
+ chunk_content = custom_field_info["value"]
51
+ else
52
+ chunk_content = Rails.cache.fetch("bit_#{identifier}") do
53
+ url = "#{versioned_api_url}/bits/#{identifier}"
54
+ response = HTTParty.get(url)
55
+ chunk_content = response['content']
56
+ end
52
57
  end
53
- end
54
58
 
55
- display_type = options[:display_type] || "span"
56
- css_class = options[:css_class]
57
- content_type = "plain"
58
-
59
- # Simple check to see if returned chunk contains html. Regex will need to be improved
60
- if /<[a-z][\s\S]*>/i.match(chunk_content)
61
- content_type = "rich"
62
- chunk_content = sanitize chunk_content.html_safe
63
- elsif chunk_content.include? "\n"
64
- content_type = "rich"
65
- renderer = Redcarpet::Render::HTML.new(no_links: true, hard_wrap: true)
66
- markdown = Redcarpet::Markdown.new(renderer, extensions = {})
67
- chunk_content = markdown.render(chunk_content).html_safe
68
- end
69
-
70
- additional_data_properties = custom_field_info.present? ? { :custom_field_identifier => custom_field_info["custom_field_identifier"] } : {}
59
+ display_type = options[:display_type] || "span"
60
+ css_class = options[:css_class]
61
+ content_type = "plain"
62
+
63
+ # Simple check to see if returned chunk contains html. Regex will need to be improved
64
+ if /<[a-z][\s\S]*>/i.match(chunk_content)
65
+ content_type = "rich"
66
+ chunk_content = sanitize chunk_content.html_safe
67
+ elsif chunk_content.include? "\n"
68
+ content_type = "rich"
69
+ renderer = Redcarpet::Render::HTML.new(no_links: true, hard_wrap: true)
70
+ markdown = Redcarpet::Markdown.new(renderer, extensions = {})
71
+ chunk_content = markdown.render(chunk_content).html_safe
72
+ end
71
73
 
72
- case display_type
73
- when "span"
74
- if content_type == "rich"
75
- content_tag(:span, :class => css_class, :data => {:chunk => identifier, :chunk_editable => false}.merge(additional_data_properties) ) do
76
- chunk_content
77
- end
78
- else
79
- content_tag(:span, :class => css_class, :data => {:chunk => identifier, :chunk_editable => true}.merge(additional_data_properties)) do
80
- chunk_content
74
+ additional_data_properties = custom_field_info.present? ? { :custom_field_identifier => custom_field_info["custom_field_identifier"] } : {}
75
+
76
+ case display_type
77
+ when "span"
78
+ if content_type == "rich"
79
+ content_tag(:span, :class => css_class, :data => {:chunk => identifier, :chunk_editable => false}.merge(additional_data_properties) ) do
80
+ chunk_content
81
+ end
82
+ else
83
+ content_tag(:span, :class => css_class, :data => {:chunk => identifier, :chunk_editable => true}.merge(additional_data_properties)) do
84
+ chunk_content
85
+ end
81
86
  end
87
+ when "raw"
88
+ chunk_content
82
89
  end
83
- when "raw"
84
- chunk_content
85
- end
90
+ rescue => error
91
+ puts error
92
+ end
86
93
 
87
94
  end
88
95
 
@@ -1,3 +1,3 @@
1
1
  module EditModeRails
2
- VERSION = "0.0.9.37"
2
+ VERSION = "0.0.9.39"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: editmode
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9.37
4
+ version: 0.0.9.39
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tony Ennis
@@ -105,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
105
  - !ruby/object:Gem::Version
106
106
  version: '0'
107
107
  requirements: []
108
- rubygems_version: 3.0.6
108
+ rubygems_version: 3.0.3
109
109
  signing_key:
110
110
  specification_version: 4
111
111
  summary: Editmode allows you to turn plain text in your rails app into easily inline-editable