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: ca0cf8b16aa5b0b0ac38337020ced29f5cc3e9c1251c55755cefd1f84ff68c1e
4
- data.tar.gz: 34cdb07294694a3fb0db501fe2e72f0555a8bfe43d24a584f89d7396c05ca876
3
+ metadata.gz: 2ef8bb95a914ee4e0c030cb365bb2f2ae661be5e38a4c6638f1ed07e28f38714
4
+ data.tar.gz: 5ccaa0a98155e222241adf0f85b12c2975d832d912902776fd84a919d6a9d649
5
5
  SHA512:
6
- metadata.gz: 884e0dbc8219b37b6b632a722626c5665192c0c6db0ddab202ea5f0da3b1943309dd08ada6531f2062e009becd40ae18ab441466e3b5787de493c0a519830b7b
7
- data.tar.gz: dc033fcea9c660de77b94cb317ec05cb17deebbbf590967a7759e1857aa6f1c9ea487fd11a0249fbc9ff19ca7e8545522926ea92396bc9150e67ffb0cce82e3b
6
+ metadata.gz: 4db8788bbcf384cb5e8d5e57fe494688a990f02b33850c4febd722b70d54739d283cb1411af7873eb15f75858ab48aab1745053fc2c20e766df245f8d1717f2a
7
+ data.tar.gz: f13ae77f68463f0b7650bdd07743f5eccb5b93132dcd42327b5268c1f3588f12e7ea47f2fd302910e1b23f47e4d260cc8646babc59f80853ebc96321e84fc947
@@ -1,4 +1,4 @@
1
- class EditModeController < ApplicationController
1
+ class EditmodeController < ApplicationController
2
2
 
3
3
  def clear_cache
4
4
 
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 chunk_display(label,identifier,options={})
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
- chunk_content = Rails.cache.fetch("bit_#{identifier}") do
21
- url = "#{versioned_api_url}/bits/#{identifier}"
22
- response = HTTParty.get(url)
23
- chunk_content = response['content']
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 }) do
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 }) do
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
@@ -4,7 +4,6 @@ module EditModeRails
4
4
 
5
5
  ActiveSupport.on_load :action_view do
6
6
  include EditModeRails::ActionViewExtensions::EditModeHelper
7
- Rails.logger.info("lkjlkjkljkl")
8
7
  end
9
8
  ActiveSupport.on_load :action_controller do
10
9
  include AutoInclude::Method
@@ -1,3 +1,3 @@
1
1
  module EditModeRails
2
- VERSION = "0.0.9.14"
2
+ VERSION = "0.0.9.37"
3
3
  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.14
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-25 00:00:00.000000000 Z
11
+ date: 2020-02-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler