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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5efc7a653779c9512a8d0e280f41f2e95bfedfd09eb242ff755a3cfdb5c7ac7e
|
4
|
+
data.tar.gz: 8d1503bd4bc148b966abd4f662153015130d9297210f1a2eab5ea5ee6f9cd602
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
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
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
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
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
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
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
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
|
-
|
84
|
-
|
85
|
-
|
90
|
+
rescue => error
|
91
|
+
puts error
|
92
|
+
end
|
86
93
|
|
87
94
|
end
|
88
95
|
|
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.
|
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.
|
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
|