wcc-contentful-app 1.0.3 → 1.0.7
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 +5 -5
- data/app/helpers/wcc/contentful/app/section_helper.rb +1 -75
- data/{app/models → lib}/wcc/contentful/app/custom_markdown_render.rb +2 -0
- data/lib/wcc/contentful/app/markdown_renderer.rb +85 -0
- data/lib/wcc/contentful/app/version.rb +1 -1
- data/lib/wcc/contentful/app.rb +1 -1
- data/wcc-contentful-app.gemspec +2 -4
- metadata +11 -15
- data/.rspec +0 -4
- data/Guardfile +0 -1
- data/bin/rails +0 -14
- data/doc +0 -1
- data/lib/generators/wcc/templates/.keep +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 847b51e62b8b74d6d2d41af8b69db98fc53341bb80423e84e586433398f5d151
|
4
|
+
data.tar.gz: 1fc55b4e5dac3db2e62ade4bc5abadb5cb5217bac8af0a225b67bd0157e81ede
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f93bb72ceb5ead8a965da22d9f5de330efd18243086e0f64684c38e8de3d1bd034dee6368473386eb9120554e617c77d60280566b7de28b6fe350c87eaa58d2
|
7
|
+
data.tar.gz: 8b0cf60b8f3d5374c1371f0684cc08896e6b05b82f0b30192e343be58c43c6f94b6a8f88dedfb4c31b8510e9634175836ae78615eae415a2c197e33ba439f85e
|
@@ -35,87 +35,13 @@ module WCC::Contentful::App::SectionHelper
|
|
35
35
|
end
|
36
36
|
|
37
37
|
def markdown(text)
|
38
|
-
|
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))
|
38
|
+
html_to_render = WCC::Contentful::App::MarkdownRenderer.new.markdown(text)
|
62
39
|
|
63
40
|
content_tag(:div,
|
64
41
|
CGI.unescapeHTML(html_to_render).html_safe,
|
65
42
|
class: 'formatted-content')
|
66
43
|
end
|
67
44
|
|
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
45
|
def safe_line_break(text, options = {})
|
120
46
|
return unless text.present?
|
121
47
|
|
@@ -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
|
data/lib/wcc/contentful/app.rb
CHANGED
data/wcc-contentful-app.gemspec
CHANGED
@@ -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
|
-
|
29
|
-
f.match(%r{^(test|spec|features|Guardfile)/})
|
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.
|
4
|
+
version: 1.0.7
|
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
|
+
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.
|
355
|
+
version: 1.0.7
|
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.
|
362
|
+
version: 1.0.7
|
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.
|
483
|
-
signing_key:
|
477
|
+
rubyforge_project:
|
478
|
+
rubygems_version: 2.7.6.2
|
479
|
+
signing_key:
|
484
480
|
specification_version: 4
|
485
481
|
summary: "[](https://rubygems.org/gems/wcc-contentful-app)
|
486
482
|
[](https://circleci.com/gh/watermarkchurch/wcc-contentful)
|
data/.rspec
DELETED
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'
|
File without changes
|