imagine_cms 3.0.17 → 3.0.18

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.
@@ -822,10 +822,12 @@ function scanForPageObjects(page_id, parent_key, version) {
822
822
  var matches = $A($('page_objects_' + parent_key).value.match(regex));
823
823
 
824
824
  matches.each(function (match) {
825
- if (regex.test(match)) {
826
- name = match.replace(regex, "$1");
827
- type = match.replace(regex, "$2");
828
- opts = match.replace(regex, "$3");
825
+ // regex2 should be exactly the same as regex. Global regexes have a lastIndex which is not reset.
826
+ var regex2 = /<%=\s*insert_object\(?\s*['"]([-\w\s\d]+)['"],\s*:(\w+)\s*(.*?)\)?\s*%>/gm;
827
+ if (regex2.test(match)) {
828
+ name = match.replace(regex2, "$1");
829
+ type = match.replace(regex2, "$2");
830
+ opts = match.replace(regex2, "$3");
829
831
  found[name] = type;
830
832
  }
831
833
  });
@@ -0,0 +1,61 @@
1
+ module ActionView::Helpers::TextHelper
2
+
3
+ # Turns all email addresses into clickable links. If a block is given,
4
+ # each email is yielded and the result is used as the link text.
5
+ # Example:
6
+ # auto_link_email_addresses(post.body) do |text|
7
+ # truncate(text, 15)
8
+ # end
9
+ def auto_link_email_addresses(content)
10
+ re = %r{
11
+ (<\w+[^\<\>]*?\>|[\s[:punct:]]|mailto:|^) # leading text
12
+ (
13
+ [\w\.\!\#\$\%\-\+\.]+ # username
14
+ \@
15
+ [-\w]+ # subdomain or domain
16
+ (?:\.[-\w]+)+ # remaining subdomains or domain
17
+ )
18
+ ([[:punct:]]|\s|\<|$) # trailing text
19
+ }x
20
+
21
+ content.gsub(re) do |all|
22
+ # this seems incredibly stupid, but $1, $2, $3 weren't being set
23
+ re.match(all)
24
+
25
+ a, b, c = $1, $2, $3
26
+
27
+ if a =~ /\<a\s|[='"]$/i
28
+ all
29
+ elsif a =~ /mailto:/i
30
+ url_src = b
31
+
32
+ url = ''
33
+ url_src.length.times do |i|
34
+ url << (i % 2 == 0 ? sprintf("%%%x", url_src[i].ord) : url_src[i])
35
+ end
36
+
37
+ "#{a}#{url}#{c}"
38
+ else
39
+ url_src = b
40
+ text_src = b
41
+ text_src = yield(text_src) if block_given?
42
+
43
+ unless url_src && text_src
44
+ all
45
+ else
46
+ url = ''
47
+ text = ''
48
+ url_src.length.times do |i|
49
+ url << (i % 2 == 0 ? sprintf("%%%x", url_src[i].ord) : url_src[i])
50
+ end
51
+ text_src.length.times do |i|
52
+ text << (i % 4 == 0 ? '<span>' << text_src[i] << '</span>' : text_src[i])
53
+ end
54
+
55
+ "#{a}<a href=\"mailto:#{url}\">#{text}</a>#{c}"
56
+ end
57
+ end
58
+ end.html_safe
59
+ end
60
+
61
+ end
@@ -48,12 +48,14 @@ module ActionControllerExtensions
48
48
  when :string
49
49
  content = substitute_placeholders(@page_objects[key] || '', @pg)
50
50
  content = erb_render(content)
51
- content = auto_link(content, :all, :target => '_blank') unless options[:disable_auto_link]
51
+ content = auto_link(content, :urls, :target => '_blank') unless options[:disable_auto_link]
52
+ content = auto_link_email_addresses(content) unless options[:disable_auto_link]
52
53
  content_tag :span, content, html_options
53
54
  when :text
54
55
  content = substitute_placeholders(@page_objects[key] || '', @pg)
55
56
  content = erb_render(content)
56
- # content = auto_link(content, :all, :target => '_blank') unless options[:disable_auto_link]
57
+ content = auto_link(content, :urls, :target => '_blank') unless options[:disable_auto_link]
58
+ content = auto_link_email_addresses(content) unless options[:disable_auto_link]
57
59
  content_tag :div, content, html_options
58
60
  when :page_list
59
61
  @rss_feeds ||= []
@@ -44,6 +44,8 @@ module ImagineCms
44
44
  require 'upload_progress/lib/upload_progress'
45
45
  require 'upload_progress/lib/upload_progress_helper'
46
46
 
47
+ require 'auto_link_email_addresses'
48
+
47
49
  #
48
50
  # load provided classes
49
51
  #
@@ -1,3 +1,3 @@
1
1
  module ImagineCms
2
- VERSION = "3.0.17"
2
+ VERSION = "3.0.18"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imagine_cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.17
4
+ version: 3.0.18
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-04-10 00:00:00.000000000 Z
12
+ date: 2013-04-12 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -453,6 +453,7 @@ files:
453
453
  - lib/acts_as_versioned/test/migration_test.rb
454
454
  - lib/acts_as_versioned/test/schema.rb
455
455
  - lib/acts_as_versioned/test/versioned_test.rb
456
+ - lib/auto_link_email_addresses.rb
456
457
  - lib/dynamic_methods.rb
457
458
  - lib/extensions/action_controller.rb
458
459
  - lib/extensions/array.rb