jekyll_patternbot 0.12.0

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.
Files changed (116) hide show
  1. checksums.yaml +7 -0
  2. data/.editorconfig +12 -0
  3. data/.gitattributes +13 -0
  4. data/.gitignore +73 -0
  5. data/CHANGELOG.md +68 -0
  6. data/Gemfile +16 -0
  7. data/LICENSE.txt +21 -0
  8. data/README.md +39 -0
  9. data/Rakefile +1 -0
  10. data/_config.yml +54 -0
  11. data/_data/locales/en-ca.yml +5 -0
  12. data/_includes/patternbot_icons.html +38 -0
  13. data/_includes/patternbot_pattern_brand_color_swatches.html +48 -0
  14. data/_includes/patternbot_pattern_brand_typeface.html +32 -0
  15. data/_includes/patternbot_pattern_brand_typeface_weight.html +15 -0
  16. data/_includes/patternbot_pattern_copy_script.html +22 -0
  17. data/_includes/patternbot_patternlib_pattern.html +241 -0
  18. data/_layouts/patternbot_pattern_internal.html +94 -0
  19. data/_layouts/patternbot_pattern_lib.html +214 -0
  20. data/_layouts/patternbot_pattern_user.html +27 -0
  21. data/_patterns/brand/colors.html +23 -0
  22. data/_patterns/brand/config.yml +22 -0
  23. data/_patterns/brand/logos.html +43 -0
  24. data/_patterns/brand/typefaces.html +18 -0
  25. data/_patterns/grid/config.yml +14 -0
  26. data/_patterns/grid/grid-sizes.html +47 -0
  27. data/_patterns/icons/config.yml +13 -0
  28. data/_patterns/icons/icons.html +91 -0
  29. data/_patterns/modules/config.yml +32 -0
  30. data/_patterns/modules/embed.html +23 -0
  31. data/_patterns/modules/list-groups.html +21 -0
  32. data/_patterns/modules/media-objects.html +16 -0
  33. data/_patterns/typography/config.yml +55 -0
  34. data/_patterns/typography/emphasis-and-edits.html +80 -0
  35. data/_patterns/typography/font-sizes.html +90 -0
  36. data/_patterns/typography/headings.html +31 -0
  37. data/_patterns/typography/horizontal-spacing.html +46 -0
  38. data/_patterns/typography/links.html +11 -0
  39. data/_patterns/typography/lists.html +43 -0
  40. data/_patterns/typography/quotations.html +17 -0
  41. data/_patterns/typography/size-adjustments.html +20 -0
  42. data/_patterns/typography/typesetting.html +32 -0
  43. data/_patterns/typography/vertical-spacing.html +55 -0
  44. data/_patterns/utilities/config.yml +11 -0
  45. data/_patterns/utilities/utilities.html +18 -0
  46. data/_plugins/jekyll_patternbot/config.rb +19 -0
  47. data/_plugins/jekyll_patternbot/filters/color.rb +87 -0
  48. data/_plugins/jekyll_patternbot/filters/number.rb +11 -0
  49. data/_plugins/jekyll_patternbot/filters/pattern.rb +15 -0
  50. data/_plugins/jekyll_patternbot/filters/text.rb +33 -0
  51. data/_plugins/jekyll_patternbot/finders/finder.rb +34 -0
  52. data/_plugins/jekyll_patternbot/finders/icons.rb +25 -0
  53. data/_plugins/jekyll_patternbot/finders/logos.rb +26 -0
  54. data/_plugins/jekyll_patternbot/finders/patterns.rb +69 -0
  55. data/_plugins/jekyll_patternbot/finders/sample_pages.rb +18 -0
  56. data/_plugins/jekyll_patternbot/generators/internal_patterns.rb +56 -0
  57. data/_plugins/jekyll_patternbot/generators/pattern_lib.rb +27 -0
  58. data/_plugins/jekyll_patternbot/generators/user_patterns.rb +57 -0
  59. data/_plugins/jekyll_patternbot/helpers/color.rb +26 -0
  60. data/_plugins/jekyll_patternbot/helpers/file.rb +17 -0
  61. data/_plugins/jekyll_patternbot/helpers/jekyll.rb +60 -0
  62. data/_plugins/jekyll_patternbot/helpers/pattern.rb +36 -0
  63. data/_plugins/jekyll_patternbot/hooks/pattern_lib.rb +57 -0
  64. data/_plugins/jekyll_patternbot/loggers/patternbot.rb +24 -0
  65. data/_plugins/jekyll_patternbot/parsers/css_color.rb +54 -0
  66. data/_plugins/jekyll_patternbot/parsers/css_font.rb +109 -0
  67. data/_plugins/jekyll_patternbot/parsers/css_utility.rb +27 -0
  68. data/_plugins/jekyll_patternbot/parsers/gridifier.rb +22 -0
  69. data/_plugins/jekyll_patternbot/parsers/icons.rb +27 -0
  70. data/_plugins/jekyll_patternbot/parsers/modulifier.rb +10 -0
  71. data/_plugins/jekyll_patternbot/parsers/theme.rb +39 -0
  72. data/_plugins/jekyll_patternbot/parsers/typografier.rb +21 -0
  73. data/_plugins/jekyll_patternbot/parsers/web_dev_tool.rb +41 -0
  74. data/_plugins/jekyll_patternbot/processors/brand.rb +22 -0
  75. data/_plugins/jekyll_patternbot/processors/modules.rb +35 -0
  76. data/_plugins/jekyll_patternbot/tags/pattern.rb +19 -0
  77. data/_plugins/jekyll_patternbot/tags/pattern_css.rb +27 -0
  78. data/_plugins/jekyll_patternbot/tags/pattern_js.rb +27 -0
  79. data/_plugins/jekyll_patternbot.rb +55 -0
  80. data/_sass/.gitignore +0 -0
  81. data/assets/.gitignore +0 -0
  82. data/assets/_patternbot/common/common.css +223 -0
  83. data/assets/_patternbot/common/common.min.css +1 -0
  84. data/assets/_patternbot/common/gridifier.css +1175 -0
  85. data/assets/_patternbot/common/gridifier.min.css +1 -0
  86. data/assets/_patternbot/common/modulifier.css +539 -0
  87. data/assets/_patternbot/common/modulifier.min.css +1 -0
  88. data/assets/_patternbot/common/typografier.css +1787 -0
  89. data/assets/_patternbot/common/typografier.min.css +1 -0
  90. data/assets/_patternbot/images/placeholder-16by9.svg +1 -0
  91. data/assets/_patternbot/images/placeholder-1by1.svg +1 -0
  92. data/assets/_patternbot/patterns/brand/brand.css +79 -0
  93. data/assets/_patternbot/patterns/brand/brand.min.css +1 -0
  94. data/assets/_patternbot/patterns/grid/grid.css +27 -0
  95. data/assets/_patternbot/patterns/grid/grid.min.css +1 -0
  96. data/assets/_patternbot/patterns/icons/icons.css +41 -0
  97. data/assets/_patternbot/patterns/icons/icons.min.css +1 -0
  98. data/assets/_patternbot/patterns/modules/modules.css +4 -0
  99. data/assets/_patternbot/patterns/modules/modules.min.css +1 -0
  100. data/assets/_patternbot/patterns/typography/typography.css +11 -0
  101. data/assets/_patternbot/patterns/typography/typography.min.css +1 -0
  102. data/assets/_patternbot/patterns/utilities/utilities.css +4 -0
  103. data/assets/_patternbot/patterns/utilities/utilities.min.css +1 -0
  104. data/assets/_patternbot/ui/gridifier.css +1175 -0
  105. data/assets/_patternbot/ui/main.css +513 -0
  106. data/assets/_patternbot/ui/main.js +301 -0
  107. data/assets/_patternbot/ui/modulifier.css +725 -0
  108. data/assets/_patternbot/ui/pattern-lib.css +4 -0
  109. data/assets/_patternbot/ui/pattern-lib.min.css +1 -0
  110. data/assets/_patternbot/ui/pattern-lib.min.js +1 -0
  111. data/assets/_patternbot/ui/typografier.css +1787 -0
  112. data/jekyll_patternbot.gemspec +34 -0
  113. data/package.json +35 -0
  114. data/version.rb +3 -0
  115. data/yarn.lock +2783 -0
  116. metadata +312 -0
@@ -0,0 +1,18 @@
1
+ <div class="patternbot-font-primary text-left milli">
2
+ <table class="patternbot-utilities-table">
3
+ <thead>
4
+ <tr>
5
+ <th scope="col" colspan="6">Class</th>
6
+ <th scope="col" colspan="18">Description</th>
7
+ </tr>
8
+ </thead>
9
+ <tbody>
10
+ {% for util in page._PatternbotData.css.theme.utilities %}
11
+ <tr>
12
+ <th class="valign-middle" scope="row" colspan="6"><code class="ib valign-middle">{{util.class}}</code></th>
13
+ <td class="valign-middle" scope="col" colspan="18"><span class="ib valign-middle">{{util.description | escape}}</span></td>
14
+ </tr>
15
+ {% endfor %}
16
+ </tbody>
17
+ </table>
18
+ </div>
@@ -0,0 +1,19 @@
1
+ module JekyllPatternbot
2
+ Config = YAML.load_file File.expand_path('../../_config.yml', __dir__)
3
+ class << self; attr_accessor :PatternbotLogger; end
4
+ class << self; attr_accessor :PatternbotCache; end
5
+ class << self; attr_accessor :PatternbotLocale; end
6
+ class << self; attr_accessor :PatternbotData; end
7
+
8
+ Jekyll::Hooks.register :site, :after_init do |site|
9
+ Config.deep_merge! site.config
10
+ Config['patternbot'][:version] = JekyllPatternbot::VERSION
11
+
12
+ locale_path = File.expand_path("../../_data/locales/#{Config['patternbot']['locale']}.yml", __dir__)
13
+ if File.file? locale_path
14
+ PatternbotLocale = YAML.load_file locale_path
15
+ else
16
+ PatternbotLocale = YAML.load_file File.expand_path("../../_data/locales/en-ca.yml", __dir__)
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,87 @@
1
+ module JekyllPatternbot
2
+ module ColorFilters
3
+
4
+ def get_interface_color(color)
5
+ fg = ColorContrastCalc.color_from('black')
6
+ bg = ColorHelper.color color
7
+ if fg.contrast_ratio_against(bg) < 4.5
8
+ fg = ColorContrastCalc.color_from('white')
9
+ end
10
+ fg.hex.downcase
11
+ end
12
+
13
+ def get_interface_color_opposite(color)
14
+ fg = get_interface_color(color)
15
+ if fg == '#ffffff'
16
+ return '#000000'
17
+ end
18
+ '#ffffff'
19
+ end
20
+
21
+ def as_hex(color)
22
+ ColorHelper.color(color).hex.downcase
23
+ end
24
+
25
+ def as_rgba(color, opacity=1)
26
+ "rgba(#{ColorHelper.color(color).rgb.join(',')},#{opacity})"
27
+ end
28
+
29
+ def as_rgb_digit(color)
30
+ ColorHelper.color(color).rgb[0]
31
+ end
32
+
33
+ def has_pattern_background_color(id, *namespaces)
34
+ namespaces.push(id)
35
+ unless Config['patternbot']['colors']['patterns'].nil?
36
+ return (Config['patternbot']['colors']['patterns'].is_a?(Hash) and Config['patternbot']['colors']['patterns'].key?(namespaces.join('.')))
37
+ end
38
+ return false
39
+ end
40
+
41
+ def get_pattern_background_color(id, *namespaces)
42
+ bg = ''
43
+ namespaces.push(id)
44
+ key = namespaces.join('.')
45
+ unless Config['patternbot']['colors']['patterns'].nil?
46
+ if Config['patternbot']['colors']['patterns'].is_a?(Hash) and Config['patternbot']['colors']['patterns'].key? key
47
+ bg = Config['patternbot']['colors']['patterns'][key]
48
+ end
49
+ end
50
+ ColorHelper.color(bg).hex.downcase
51
+ end
52
+
53
+ def get_pattern_interface_color(id, *namespaces)
54
+ get_interface_color get_pattern_background_color id, *namespaces
55
+ end
56
+
57
+ def get_pattern_interface_color_opposite(id, *namespaces)
58
+ get_interface_color_opposite get_pattern_background_color id, *namespaces
59
+ end
60
+
61
+ def get_var_colors(id, *namespaces)
62
+ var_colors = []
63
+ namespaces.push(id)
64
+ key_name = namespaces.join('.')
65
+ unless Config['patternbot']['colors']['patterns'].nil?
66
+ if Config['patternbot']['colors']['patterns'].is_a?(Hash)
67
+ Config['patternbot']['colors']['patterns'].each do |key, val|
68
+ if key.start_with?(key_name + '.')
69
+ var_colors.push({
70
+ 'key' => key.sub(key_name + '.', ''),
71
+ 'val' => val,
72
+ })
73
+ end
74
+ end
75
+ end
76
+ end
77
+ if var_colors.length > 0
78
+ return var_colors
79
+ else
80
+ return false
81
+ end
82
+ end
83
+
84
+ end
85
+ end
86
+
87
+ Liquid::Template.register_filter(JekyllPatternbot::ColorFilters)
@@ -0,0 +1,11 @@
1
+ module JekyllPatternbot
2
+ module NumberFilters
3
+
4
+ def strip_trailing_zero(n)
5
+ n.to_s.sub(/\.?0+$/, '')
6
+ end
7
+
8
+ end
9
+ end
10
+
11
+ Liquid::Template.register_filter(JekyllPatternbot::NumberFilters)
@@ -0,0 +1,15 @@
1
+ module JekyllPatternbot
2
+ module PatternFilters
3
+
4
+ def pattern_code(subpattern, pattern, subdata)
5
+ JekyllHelper.pattern_tag(pattern, subpattern, subdata.is_a?(Hash) ? subdata['fields'] : nil)
6
+ end
7
+
8
+ def normalize_filename(filename)
9
+ PatternHelper.normalize_filename filename
10
+ end
11
+
12
+ end
13
+ end
14
+
15
+ Liquid::Template.register_filter(JekyllPatternbot::PatternFilters)
@@ -0,0 +1,33 @@
1
+ module JekyllPatternbot
2
+ module TextFilters
3
+
4
+ def as_title(s)
5
+ PatternHelper.slug_to_words(s).unicode_titlecase
6
+ end
7
+
8
+ def has_pattern_rationale(id, *namespaces)
9
+ namespaces.push(id)
10
+ unless Config['patternbot']['rationales'].nil?
11
+ return (Config['patternbot']['rationales'].is_a?(Hash) and Config['patternbot']['rationales'].key?(namespaces.join('.')))
12
+ end
13
+ end
14
+
15
+ def get_pattern_rationale(id, *namespaces)
16
+ namespaces.push(id)
17
+ unless Config['patternbot']['rationales'].nil?
18
+ return Config['patternbot']['rationales'][namespaces.join('.')]
19
+ end
20
+ ''
21
+ end
22
+
23
+ def sub_web_dev_tool_urls(text)
24
+ text.gsub!(/\+\+modulifier\-settings\-url\+\+/, PatternbotData[:css][:modulifier][:url]) if PatternbotData[:css].key? :modulifier and PatternbotData[:css][:modulifier].key? :url
25
+ text.gsub!(/\+\+gridifier\-settings\-url\+\+/, PatternbotData[:css][:gridifier][:url]) if PatternbotData[:css].key? :gridifier and PatternbotData[:css][:gridifier].key? :url
26
+ text.gsub!(/\+\+typografier\-settings\-url\+\+/, PatternbotData[:css][:typografier][:url]) if PatternbotData[:css].key? :typografier and PatternbotData[:css][:typografier].key? :url
27
+ text
28
+ end
29
+
30
+ end
31
+ end
32
+
33
+ Liquid::Template.register_filter(JekyllPatternbot::TextFilters)
@@ -0,0 +1,34 @@
1
+ module JekyllPatternbot
2
+ class Finder
3
+
4
+ def initialize(config)
5
+ @config = config
6
+ @source = config['source']
7
+ end
8
+
9
+ def files_list
10
+ files = []
11
+ for ext in @config['extensions']
12
+ for file in @config['filenames']
13
+ files.push("#{file}#{ext}")
14
+ end
15
+ end
16
+ files
17
+ end
18
+
19
+ def files
20
+ if @files.nil?
21
+ @files = []
22
+ for file in files_list
23
+ @files.push(file) if File.file? File.expand_path file, @source
24
+ end
25
+ end
26
+ @files
27
+ end
28
+
29
+ def exists?
30
+ files.length > 0
31
+ end
32
+
33
+ end
34
+ end
@@ -0,0 +1,25 @@
1
+ module JekyllPatternbot
2
+ class IconsFinder < Finder
3
+
4
+ def base
5
+ {
6
+ :name => false,
7
+ :filename => false,
8
+ :icons => [],
9
+ }
10
+ end
11
+
12
+ def info
13
+ icons = []
14
+ for file in files
15
+ exts = Regexp.new '(' + Config['patternbot']['icons']['extensions'].join('|') + ')'
16
+ icon_file = base.clone
17
+ icon_file[:name] = file.gsub(exts, '')
18
+ icon_file[:filename] = file
19
+ icons.push(icon_file)
20
+ end
21
+ icons
22
+ end
23
+
24
+ end
25
+ end
@@ -0,0 +1,26 @@
1
+ module JekyllPatternbot
2
+ class LogosFinder < Finder
3
+
4
+ def base
5
+ {
6
+ :size_large => false,
7
+ :size_64 => false,
8
+ :size_32 => false,
9
+ :size_16 => false,
10
+ }
11
+ end
12
+
13
+ def info
14
+ logos = base.clone
15
+ for file in files
16
+ logos[:size_large] = file if file.match? /256/
17
+ logos[:size_large] = file if file.match? /^logo\./
18
+ logos[:size_64] = file if file.match? /64/
19
+ logos[:size_32] = file if file.match? /32/
20
+ logos[:size_16] = file if file.match? /16/
21
+ end
22
+ logos
23
+ end
24
+
25
+ end
26
+ end
@@ -0,0 +1,69 @@
1
+ module JekyllPatternbot
2
+ class PatternsFinder
3
+
4
+ def initialize
5
+ @internal_source = File.expand_path '../../../_patterns', __dir__
6
+ @internal_patterns = FileHelper.list_dirs @internal_source
7
+ @user_source = File.expand_path Config['patternbot']['source']
8
+ @user_patterns = FileHelper.list_dirs @user_source if File.directory? @user_source
9
+ end
10
+
11
+ def user_config(patternpath)
12
+ config_path = File.expand_path Config['patternbot']['config'], patternpath
13
+ return {} unless File.file? config_path
14
+ begin
15
+ config_data = YAML.load_file config_path
16
+ rescue
17
+ return {}
18
+ end
19
+ if config_data.nil? or config_data == false
20
+ return {}
21
+ else
22
+ return config_data
23
+ end
24
+ end
25
+
26
+ def html_files(patternpath)
27
+ files = {}
28
+ all_files = FileHelper.list_files_with_ext patternpath, 'html'
29
+ return files unless all_files
30
+ for file in all_files
31
+ files[File.basename(file, '.*')] = nil
32
+ end
33
+ files
34
+ end
35
+
36
+ def pattern_config(patternpath)
37
+ config_data = user_config(patternpath)
38
+ files_config = {
39
+ 'patterns' => html_files(patternpath)
40
+ }
41
+ config_data.deep_merge! files_config
42
+ config_data
43
+ end
44
+
45
+ def patterns_info(source, patterns_names)
46
+ patterns = {}
47
+ if patterns_names
48
+ for pattern in patterns_names
49
+ dir = File.expand_path pattern, source
50
+ patterns[pattern] = {
51
+ :name => pattern,
52
+ :source => dir,
53
+ :config => pattern_config(dir),
54
+ }
55
+ end
56
+ end
57
+ patterns
58
+ end
59
+
60
+ def internal_patterns_info
61
+ patterns_info @internal_source, @internal_patterns
62
+ end
63
+
64
+ def user_patterns_info
65
+ patterns_info @user_source, @user_patterns
66
+ end
67
+
68
+ end
69
+ end
@@ -0,0 +1,18 @@
1
+ module JekyllPatternbot
2
+ class SamplePagesFinder
3
+
4
+ def initialize
5
+ @user_source = File.expand_path Config['patternbot']['sample_pages']['source']
6
+ @user_pages = FileHelper.list_files_with_ext @user_source, 'html' if File.directory? @user_source
7
+ end
8
+
9
+ def info
10
+ if @user_pages
11
+ return @user_pages.map { |page| page.sub(@user_source, '').sub(/\//, '') }
12
+ else
13
+ return false
14
+ end
15
+ end
16
+
17
+ end
18
+ end
@@ -0,0 +1,56 @@
1
+ module JekyllPatternbot
2
+
3
+ class InternalPatternsGenerator < Jekyll::Generator
4
+ priority :normal
5
+
6
+ def initialize(site)
7
+ @site = site
8
+ end
9
+
10
+ def generate(site)
11
+ @site = site
12
+ @site.pages.concat patterns
13
+ end
14
+
15
+ def patterns
16
+ pats = []
17
+ PatternbotData[:patterns][:internal].each do |pattern, data|
18
+ pats.concat pattern_pages(pattern, data)
19
+ end
20
+ pats
21
+ end
22
+
23
+ def pattern_pages(pattern, data)
24
+ pages = []
25
+ return pages unless data[:config].key? 'patterns'
26
+ data[:config]['patterns'].each do |subpattern, subdata|
27
+ pages.push to_page pattern, data, subpattern, subdata
28
+ end
29
+ pages
30
+ end
31
+
32
+ def to_page(pattern, data, subpattern, subdata)
33
+ dir = Config['patternbot']['destination'] + '/patterns/' + pattern
34
+ html = Jekyll::PageWithoutAFile.new(@site, @site.source, dir, "#{subpattern}.html")
35
+ html.data['title'] = PatternHelper.title pattern, subpattern, data, subdata
36
+ html.data['layout'] = data[:config]['_layout']
37
+ html.data['_PatternbotConfig'] = Config.with_indifferent_access
38
+ html.data['_PatternbotLocale'] = PatternbotLocale.with_indifferent_access
39
+ html.data['_PatternbotData'] = PatternbotData.with_indifferent_access
40
+ html.data['_pattern'] = pattern
41
+ html.data['_pattern_data'] = data.is_a?(Hash) ? data.with_indifferent_access : {}
42
+ html.data['_subpattern'] = subpattern
43
+ html.data['_subpattern_data'] = subdata.is_a?(Hash) ? subdata.with_indifferent_access : {}
44
+
45
+ begin
46
+ html.content = File.read File.expand_path "#{subpattern}.html", data[:source]
47
+ rescue
48
+ PatternbotLogger.fatal "Patternbot cannot find the associated HTML file for the “#{subpattern}” pattern listed inside the “#{pattern}” config.yml file."
49
+ end
50
+
51
+ html
52
+ end
53
+
54
+ end
55
+
56
+ end
@@ -0,0 +1,27 @@
1
+ module JekyllPatternbot
2
+
3
+ class PatternLibGenerator < Jekyll::Generator
4
+ priority :normal
5
+
6
+ def initialize(site)
7
+ @site = site
8
+ end
9
+
10
+ def generate(site)
11
+ @site = site
12
+ @site.pages.concat [pattern_lib_page]
13
+ end
14
+
15
+ def pattern_lib_page()
16
+ html = Jekyll::PageWithoutAFile.new(@site, @site.source, Config['patternbot']['destination'], 'index.html')
17
+ html.data['layout'] = 'patternbot_pattern_lib'
18
+ html.data['_PatternbotConfig'] = Config.with_indifferent_access
19
+ html.data['_PatternbotLocale'] = PatternbotLocale.with_indifferent_access
20
+ html.data['_PatternbotData'] = PatternbotData.with_indifferent_access
21
+ html.content = ''
22
+ html
23
+ end
24
+
25
+ end
26
+
27
+ end