wcc-contentful-app 1.0.2 → 1.0.6

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
- SHA1:
3
- metadata.gz: b8221c3f35a6b968682342aa4a314d3635e7a3c3
4
- data.tar.gz: fb659970a1f2d87048b358b3a7e12072eea6ad30
2
+ SHA256:
3
+ metadata.gz: 222d97e2c5e468eb06480abd758461d38c47cff94d3ae3b66546ca4a2dc28270
4
+ data.tar.gz: c29432ed47e73ae1be706e1aef01ccc38b74d812ce354d39fc5c8d55d34f79b0
5
5
  SHA512:
6
- metadata.gz: 6c5de8c3966afbf61f6be61a34cc6fb989e90080d3b4531a79f897c2f66e4706ead1de3aa68222202fad56517694cccb4dbef33adab39042c8ded4ca9c37b5b5
7
- data.tar.gz: ee32babaab793e280cc74a39a99d7d76ea3b3d4eefc9481b42225bc85d5983bd27fa9cd420221b96aab4d276231a427d4335ce16847e74e8b5e6b80997a7f146
6
+ metadata.gz: 37edcae2cb5a0bb83ec1cce4f19f42965e3a95c6f47899408dfd53883641bff88c6736a3cd7fdfa0a5d6609c3f0d0824ee776dbad374a44b7e31c3c25dbafb88
7
+ data.tar.gz: fca724980ba8a2594f14b51df9f86765350520fda4baca57719df8a013d3d24fc9e1297dc4c086378e720002cc5d3c46ed37874068d3a045eec97a8c51223c12
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require 'redcarpet'
4
+ require '../wcc-contentful-app/lib/wcc/contentful/app/markdown_renderer'
4
5
 
5
6
  module WCC::Contentful::App::SectionHelper
6
7
  extend self
@@ -35,87 +36,13 @@ module WCC::Contentful::App::SectionHelper
35
36
  end
36
37
 
37
38
  def markdown(text)
38
- raise ArgumentError, 'markdown method requires text' unless text
39
-
40
- markdown_links = links_within_markdown(text)
41
- links_with_classes, raw_classes = gather_links_with_classes_data(markdown_links)
42
-
43
- options = {
44
- filter_html: true,
45
- hard_wrap: true,
46
- link_attributes: { target: '_blank' },
47
- space_after_headers: true,
48
- fenced_code_blocks: true,
49
- links_with_classes: links_with_classes
50
- }
51
-
52
- extensions = {
53
- autolink: true,
54
- superscript: true,
55
- disable_indented_code_blocks: true,
56
- tables: true
57
- }
58
-
59
- renderer = ::WCC::Contentful::App::CustomMarkdownRender.new(options)
60
- markdown = ::Redcarpet::Markdown.new(renderer, extensions)
61
- html_to_render = markdown.render(remove_markdown_href_class_syntax(raw_classes, text))
39
+ html_to_render = WCC::Contentful::App::MarkdownRenderer.new.markdown(text)
62
40
 
63
41
  content_tag(:div,
64
42
  CGI.unescapeHTML(html_to_render).html_safe,
65
43
  class: 'formatted-content')
66
44
  end
67
45
 
68
- def links_within_markdown(text)
69
- text.scan(/(\[(.*?)\]\((.*?)\)(\{\:.*?\})?)/)
70
- end
71
-
72
- def gather_links_with_classes_data(markdown_links)
73
- links_with_classes_arr = []
74
- raw_classes_arr = []
75
- markdown_links.each do |markdown_link_arr|
76
- next unless markdown_link_arr.last.present?
77
-
78
- raw_class = markdown_link_arr[3]
79
- url, title = url_and_title(markdown_link_arr[2])
80
- content = markdown_link_arr[1]
81
- classes = capture_individual_classes(raw_class)
82
- link_class = combine_individual_classes_to_one_string(classes)
83
-
84
- raw_classes_arr << raw_class
85
- links_with_classes_arr << [url, title, content, link_class]
86
- end
87
-
88
- [links_with_classes_arr, raw_classes_arr]
89
- end
90
-
91
- def remove_markdown_href_class_syntax(raw_classes, text)
92
- text_without_markdown_class_syntax = text.dup
93
- raw_classes.each { |klass| text_without_markdown_class_syntax.slice!(klass) }
94
- text_without_markdown_class_syntax
95
- end
96
-
97
- def url_and_title(markdown_link_and_title)
98
- match =
99
- markdown_link_and_title.scan(
100
- /(\s|^)(https?:\/\/\S*|^\/\S*\/*\S*|^#\S*|mailto:\S*)(?=\s|$)|(\".*?\")/
101
- )
102
- url = match[0][1]
103
- title = match[1] ? match[1][2] : nil
104
- [url, title]
105
- end
106
-
107
- def capture_individual_classes(classes)
108
- classes.scan(/\.[^\.\}\s]*/)
109
- end
110
-
111
- def combine_individual_classes_to_one_string(classes)
112
- class_string = ''
113
- classes.each do |klass|
114
- class_string += klass.tr('.', '') + ' '
115
- end
116
- class_string
117
- end
118
-
119
46
  def safe_line_break(text, options = {})
120
47
  return unless text.present?
121
48
 
@@ -0,0 +1,85 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative './custom_markdown_render'
4
+
5
+ class WCC::Contentful::App::MarkdownRenderer
6
+ def markdown(text)
7
+ raise ArgumentError, 'markdown method requires text' unless text
8
+
9
+ markdown_links = links_within_markdown(text)
10
+ links_with_classes, raw_classes = gather_links_with_classes_data(markdown_links)
11
+
12
+ options = {
13
+ filter_html: true,
14
+ hard_wrap: true,
15
+ link_attributes: { target: '_blank' },
16
+ space_after_headers: true,
17
+ fenced_code_blocks: true,
18
+ links_with_classes: links_with_classes
19
+ }
20
+
21
+ extensions = {
22
+ autolink: true,
23
+ superscript: true,
24
+ disable_indented_code_blocks: true,
25
+ tables: true
26
+ }
27
+
28
+ renderer = ::WCC::Contentful::App::CustomMarkdownRender.new(options)
29
+ markdown = ::Redcarpet::Markdown.new(renderer, extensions)
30
+ markdown.render(remove_markdown_href_class_syntax(raw_classes, text))
31
+ end
32
+
33
+ private
34
+
35
+ def remove_markdown_href_class_syntax(raw_classes, text)
36
+ text_without_markdown_class_syntax = text.dup
37
+ raw_classes.each { |klass| text_without_markdown_class_syntax.slice!(klass) }
38
+ text_without_markdown_class_syntax
39
+ end
40
+
41
+ def links_within_markdown(text)
42
+ text.scan(/(\[(.*?)\]\((.*?)\)(\{\:.*?\})?)/)
43
+ end
44
+
45
+ def gather_links_with_classes_data(markdown_links)
46
+ links_with_classes_arr = []
47
+ raw_classes_arr = []
48
+ markdown_links.each do |markdown_link_arr|
49
+ next unless markdown_link_arr.last.present?
50
+
51
+ raw_class = markdown_link_arr[3]
52
+ url, title = url_and_title(markdown_link_arr[2])
53
+ content = markdown_link_arr[1]
54
+ classes = capture_individual_classes(raw_class)
55
+ link_class = combine_individual_classes_to_one_string(classes)
56
+
57
+ raw_classes_arr << raw_class
58
+ links_with_classes_arr << [url, title, content, link_class]
59
+ end
60
+
61
+ [links_with_classes_arr, raw_classes_arr]
62
+ end
63
+
64
+ def url_and_title(markdown_link_and_title)
65
+ match =
66
+ markdown_link_and_title.scan(
67
+ /(\s|^)(https?:\/\/\S*|^\/\S*\/*\S*|^#\S*|mailto:\S*)(?=\s|$)|(\".*?\")/
68
+ )
69
+ url = match[0][1]
70
+ title = match[1] ? match[1][2] : nil
71
+ [url, title]
72
+ end
73
+
74
+ def capture_individual_classes(classes)
75
+ classes.scan(/\.[^\.\}\s]*/)
76
+ end
77
+
78
+ def combine_individual_classes_to_one_string(classes)
79
+ class_string = ''
80
+ classes.each do |klass|
81
+ class_string += klass.tr('.', '') + ' '
82
+ end
83
+ class_string
84
+ end
85
+ end
@@ -3,7 +3,7 @@
3
3
  module WCC
4
4
  module Contentful
5
5
  module App
6
- VERSION = '1.0.2'
6
+ VERSION = '1.0.6'
7
7
  end
8
8
  end
9
9
  end
@@ -2,9 +2,9 @@
2
2
 
3
3
  require 'wcc/contentful/rails'
4
4
 
5
- require_relative './app/rails'
6
5
  require_relative './app/exceptions'
7
6
  require_relative './app/configuration'
7
+ require_relative './app/markdown_renderer'
8
8
 
9
9
  module WCC::Contentful::App
10
10
  class << self
@@ -24,10 +24,8 @@ Gem::Specification.new do |spec|
24
24
 
25
25
  spec.required_ruby_version = '>= 2.3'
26
26
 
27
- spec.files =
28
- `git ls-files -z`.split("\x0").reject do |f|
29
- f.match(%r{^(test|spec|features)/})
30
- end
27
+ spec.files = Dir['app/**/*', 'config/**/*', 'lib/**/*'] +
28
+ %w[Rakefile README.md wcc-contentful-app.gemspec]
31
29
 
32
30
  spec.require_paths = ['lib']
33
31
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wcc-contentful-app
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Watermark Dev
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-11-17 00:00:00.000000000 Z
11
+ date: 2021-12-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: capybara
@@ -352,14 +352,14 @@ dependencies:
352
352
  requirements:
353
353
  - - "~>"
354
354
  - !ruby/object:Gem::Version
355
- version: 1.0.2
355
+ version: 1.0.6
356
356
  type: :runtime
357
357
  prerelease: false
358
358
  version_requirements: !ruby/object:Gem::Requirement
359
359
  requirements:
360
360
  - - "~>"
361
361
  - !ruby/object:Gem::Version
362
- version: 1.0.2
362
+ version: 1.0.6
363
363
  description: Models, Controllers, and Views common to Watermark Church apps
364
364
  email:
365
365
  - dev@watermark.org
@@ -367,8 +367,6 @@ executables: []
367
367
  extensions: []
368
368
  extra_rdoc_files: []
369
369
  files:
370
- - ".rspec"
371
- - Guardfile
372
370
  - README.md
373
371
  - Rakefile
374
372
  - app/assets/config/manifest.js
@@ -386,7 +384,6 @@ files:
386
384
  - app/mailers/wcc/contentful/app/contact_mailer.rb
387
385
  - app/models/concerns/wcc/contentful/app/preview_password.rb
388
386
  - app/models/wcc/contentful/app/contact_form_submission.rb
389
- - app/models/wcc/contentful/app/custom_markdown_render.rb
390
387
  - app/views/components/_faq_row.html.erb
391
388
  - app/views/components/_menu-item.html.erb
392
389
  - app/views/components/_other-menu-item.html.erb
@@ -404,12 +401,9 @@ files:
404
401
  - app/views/sections/_video.html.erb
405
402
  - app/views/sections/_video_highlight.html.erb
406
403
  - app/views/wcc/contentful/app/contact_mailer/contact_form_email.html.erb
407
- - bin/rails
408
404
  - config/routes.rb
409
- - doc
410
405
  - lib/generators/wcc/USAGE
411
406
  - lib/generators/wcc/model_generator.rb
412
- - lib/generators/wcc/templates/.keep
413
407
  - lib/generators/wcc/templates/Procfile
414
408
  - lib/generators/wcc/templates/contentful_shell_wrapper
415
409
  - lib/generators/wcc/templates/menu/migrations/generated_add_menus.ts
@@ -445,8 +439,10 @@ files:
445
439
  - lib/generators/wcc/templates/wcc_contentful.rb
446
440
  - lib/wcc/contentful/app.rb
447
441
  - lib/wcc/contentful/app/configuration.rb
442
+ - lib/wcc/contentful/app/custom_markdown_render.rb
448
443
  - lib/wcc/contentful/app/engine.rb
449
444
  - lib/wcc/contentful/app/exceptions.rb
445
+ - lib/wcc/contentful/app/markdown_renderer.rb
450
446
  - lib/wcc/contentful/app/rails.rb
451
447
  - lib/wcc/contentful/app/version.rb
452
448
  - lib/wcc/contentful/model/dropdown_menu.rb
@@ -463,7 +459,7 @@ licenses:
463
459
  - MIT
464
460
  metadata:
465
461
  documentation_uri: https://watermarkchurch.github.io/wcc-contentful/1.0/wcc-contentful-app
466
- post_install_message:
462
+ post_install_message:
467
463
  rdoc_options: []
468
464
  require_paths:
469
465
  - lib
@@ -478,9 +474,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
478
474
  - !ruby/object:Gem::Version
479
475
  version: '0'
480
476
  requirements: []
481
- rubyforge_project:
482
- rubygems_version: 2.6.11
483
- signing_key:
477
+ rubyforge_project:
478
+ rubygems_version: 2.7.6.2
479
+ signing_key:
484
480
  specification_version: 4
485
481
  summary: "[![Gem Version](https://badge.fury.io/rb/wcc-contentful-app.svg)](https://rubygems.org/gems/wcc-contentful-app)
486
482
  [![Build Status](https://circleci.com/gh/watermarkchurch/wcc-contentful.svg?style=svg)](https://circleci.com/gh/watermarkchurch/wcc-contentful)
data/.rspec DELETED
@@ -1,4 +0,0 @@
1
- --require spec_helper
2
- --format documentation
3
- --color
4
- --order rand
data/Guardfile DELETED
@@ -1 +0,0 @@
1
- ./../wcc-contentful/Guardfile
data/bin/rails DELETED
@@ -1,14 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # This command will automatically be run when you run "rails" with Rails gems
3
- # installed from the root of your application.
4
-
5
- ENGINE_ROOT = File.expand_path('..', __dir__)
6
- ENGINE_PATH = File.expand_path('../lib/wcc/contentful/app/engine', __dir__)
7
- APP_PATH = File.expand_path('../spec/dummy/config/application', __dir__)
8
-
9
- # Set up gems listed in the Gemfile.
10
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
11
- require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
12
-
13
- require 'rails/all'
14
- require 'rails/engine/commands'
data/doc DELETED
@@ -1 +0,0 @@
1
- ./../doc/wcc-contentful-app
File without changes