editmode 0.0.9.14 → 0.0.9.37
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: 2ef8bb95a914ee4e0c030cb365bb2f2ae661be5e38a4c6638f1ed07e28f38714
|
4
|
+
data.tar.gz: 5ccaa0a98155e222241adf0f85b12c2975d832d912902776fd84a919d6a9d649
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4db8788bbcf384cb5e8d5e57fe494688a990f02b33850c4febd722b70d54739d283cb1411af7873eb15f75858ab48aab1745053fc2c20e766df245f8d1717f2a
|
7
|
+
data.tar.gz: f13ae77f68463f0b7650bdd07743f5eccb5b93132dcd42327b5268c1f3588f12e7ea47f2fd302910e1b23f47e4d260cc8646babc59f80853ebc96321e84fc947
|
data/config/routes.rb
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
Rails.application.routes.draw do
|
2
2
|
# Use a namespaced url because /:generic can easily be overwritten by app default routes
|
3
3
|
get "/editmode/clear_cache" => "editmode#clear_cache" , :as => :editmode_clear_cache
|
4
|
+
# Support older route structure. To be expired
|
5
|
+
get "/chunksapp/clear_cache" => "editmode#clear_cache" , :as => :chunksapp_clear_cache
|
4
6
|
end
|
@@ -3,6 +3,8 @@ module EditModeRails
|
|
3
3
|
module ActionViewExtensions
|
4
4
|
module EditModeHelper
|
5
5
|
|
6
|
+
require 'httparty'
|
7
|
+
|
6
8
|
def api_version
|
7
9
|
"v1"
|
8
10
|
end
|
@@ -15,12 +17,39 @@ module EditModeRails
|
|
15
17
|
"#{api_root_url}/#{api_version}"
|
16
18
|
end
|
17
19
|
|
18
|
-
def
|
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
|
+
|
27
|
+
end
|
19
28
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
29
|
+
def chunk_property(chunk_info,custom_field_identifier=nil,options={})
|
30
|
+
|
31
|
+
chunk_identifier = chunk_info["identifier"]
|
32
|
+
|
33
|
+
if custom_field_identifier
|
34
|
+
custom_field_info = chunk_info["custom_fields"].select{|custom_field| custom_field["custom_field_identifier"] == custom_field_identifier }[0]
|
35
|
+
if custom_field_info.present?
|
36
|
+
chunk_display("",chunk_identifier,options,custom_field_info)
|
37
|
+
end
|
38
|
+
else
|
39
|
+
chunk_display("",chunk_identifier,options)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def chunk_display(label,identifier,options={},custom_field_info={})
|
44
|
+
|
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']
|
52
|
+
end
|
24
53
|
end
|
25
54
|
|
26
55
|
display_type = options[:display_type] || "span"
|
@@ -30,7 +59,7 @@ module EditModeRails
|
|
30
59
|
# Simple check to see if returned chunk contains html. Regex will need to be improved
|
31
60
|
if /<[a-z][\s\S]*>/i.match(chunk_content)
|
32
61
|
content_type = "rich"
|
33
|
-
chunk_content = chunk_content.html_safe
|
62
|
+
chunk_content = sanitize chunk_content.html_safe
|
34
63
|
elsif chunk_content.include? "\n"
|
35
64
|
content_type = "rich"
|
36
65
|
renderer = Redcarpet::Render::HTML.new(no_links: true, hard_wrap: true)
|
@@ -38,14 +67,16 @@ module EditModeRails
|
|
38
67
|
chunk_content = markdown.render(chunk_content).html_safe
|
39
68
|
end
|
40
69
|
|
70
|
+
additional_data_properties = custom_field_info.present? ? { :custom_field_identifier => custom_field_info["custom_field_identifier"] } : {}
|
71
|
+
|
41
72
|
case display_type
|
42
73
|
when "span"
|
43
74
|
if content_type == "rich"
|
44
|
-
content_tag(:span, :class => css_class, :data => {:chunk => identifier, :chunk_editable => false
|
75
|
+
content_tag(:span, :class => css_class, :data => {:chunk => identifier, :chunk_editable => false}.merge(additional_data_properties) ) do
|
45
76
|
chunk_content
|
46
77
|
end
|
47
78
|
else
|
48
|
-
content_tag(:span, :class => css_class, :data => {:chunk => identifier, :chunk_editable => true
|
79
|
+
content_tag(:span, :class => css_class, :data => {:chunk => identifier, :chunk_editable => true}.merge(additional_data_properties)) do
|
49
80
|
chunk_content
|
50
81
|
end
|
51
82
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
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.37
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tony Ennis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-02-
|
11
|
+
date: 2020-02-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|