shibori 1.0.0.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (239) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +20 -0
  3. data/Gemfile +4 -0
  4. data/Gemfile.lock +27 -0
  5. data/Procfile +1 -0
  6. data/README.md +24 -0
  7. data/Rakefile +2 -0
  8. data/app.json +11 -0
  9. data/builder/lineage_hunter.js +80 -0
  10. data/builder/list_item_hunter.js +106 -0
  11. data/builder/media_hunter.js +51 -0
  12. data/builder/object_factory.js +60 -0
  13. data/builder/parameter_hunter.js +69 -0
  14. data/builder/pattern_assembler.js +258 -0
  15. data/builder/pattern_exporter.js +43 -0
  16. data/builder/patternlab.js +365 -0
  17. data/builder/patternlab_grunt.js +38 -0
  18. data/builder/patternlab_gulp.js +26 -0
  19. data/builder/pseudopattern_hunter.js +78 -0
  20. data/config.json +34 -0
  21. data/docs/Pattern Lab Node.md +225 -0
  22. data/favicon.ico +0 -0
  23. data/gulpfile.js +148 -0
  24. data/index.js +20 -0
  25. data/lib/shibori/version.rb +3 -0
  26. data/lib/shibori.rb +11 -0
  27. data/package.json +44 -0
  28. data/public/data/annotations.js +109 -0
  29. data/public/styleguide/css/static.css +458 -0
  30. data/public/styleguide/css/static.scss +404 -0
  31. data/public/styleguide/css/styleguide-specific.css +170 -0
  32. data/public/styleguide/css/styleguide-specific.scss +204 -0
  33. data/public/styleguide/css/styleguide.css +880 -0
  34. data/public/styleguide/css/styleguide.scss +950 -0
  35. data/public/styleguide/css/vendor/prism.css +112 -0
  36. data/public/styleguide/css/vendor/typeahead.css +66 -0
  37. data/public/styleguide/fonts/icomoon.eot +0 -0
  38. data/public/styleguide/fonts/icomoon.svg +22 -0
  39. data/public/styleguide/fonts/icomoon.ttf +0 -0
  40. data/public/styleguide/fonts/icomoon.woff +0 -0
  41. data/public/styleguide/html/README +1 -0
  42. data/public/styleguide/images/spinner.gif +0 -0
  43. data/public/styleguide/js/annotations-pattern.js +308 -0
  44. data/public/styleguide/js/annotations-viewer.js +289 -0
  45. data/public/styleguide/js/code-pattern.js +120 -0
  46. data/public/styleguide/js/code-viewer.js +443 -0
  47. data/public/styleguide/js/data-saver.js +169 -0
  48. data/public/styleguide/js/pattern-finder.js +114 -0
  49. data/public/styleguide/js/postmessage.js +127 -0
  50. data/public/styleguide/js/styleguide.js +600 -0
  51. data/public/styleguide/js/url-handler.js +182 -0
  52. data/public/styleguide/js/vendor/classlist-polyfill.js +176 -0
  53. data/public/styleguide/js/vendor/jquery.js +4 -0
  54. data/public/styleguide/js/vendor/jwerty.js +523 -0
  55. data/public/styleguide/js/vendor/prism.js +7 -0
  56. data/public/styleguide/js/vendor/typeahead.bundle.min.js +7 -0
  57. data/script/bootstrap +58 -0
  58. data/shibori.gemspec +18 -0
  59. data/shibori.jpg +0 -0
  60. data/source/_data/annotations.js +109 -0
  61. data/source/_data/data.json +93 -0
  62. data/source/_data/listitems.json +782 -0
  63. data/source/_patternlab-files/README +1 -0
  64. data/source/_patternlab-files/index.mustache +94 -0
  65. data/source/_patternlab-files/partials/ishControls.mustache +64 -0
  66. data/source/_patternlab-files/partials/patternNav.mustache +17 -0
  67. data/source/_patternlab-files/partials/patternPaths.mustache +3 -0
  68. data/source/_patternlab-files/partials/viewAllPaths.mustache +3 -0
  69. data/source/_patternlab-files/pattern-header-footer/README +1 -0
  70. data/source/_patternlab-files/pattern-header-footer/footer.html +34 -0
  71. data/source/_patternlab-files/pattern-header-footer/header.html +44 -0
  72. data/source/_patternlab-files/styleguide.mustache +75 -0
  73. data/source/_patternlab-files/viewall.mustache +75 -0
  74. data/source/_patterns/00-atoms/00-typography/00-headings.mustache +6 -0
  75. data/source/_patterns/00-atoms/00-typography/01-headings-options.mustache +7 -0
  76. data/source/_patterns/00-atoms/00-typography/02-body.mustache +2 -0
  77. data/source/_patterns/00-atoms/00-typography/03-text-manipulation.mustache +12 -0
  78. data/source/_patterns/00-atoms/00-typography/04-blockquotes.mustache +3 -0
  79. data/source/_patterns/00-atoms/00-typography/05-lists.mustache +64 -0
  80. data/source/_patterns/00-atoms/01-colors/00-colors-monochromatic.mustache +36 -0
  81. data/source/_patterns/00-atoms/01-colors/01-colors-brand.mustache +26 -0
  82. data/source/_patterns/00-atoms/01-colors/02-colors-gradients.mustache +38 -0
  83. data/source/_patterns/00-atoms/02-buttons/00-btn-lg.mustache +7 -0
  84. data/source/_patterns/00-atoms/02-buttons/01-btn-sm.mustache +7 -0
  85. data/source/_patterns/00-atoms/02-buttons/02-btn-xs.mustache +7 -0
  86. data/source/_patterns/00-atoms/02-buttons/03-btn-block.mustache +7 -0
  87. data/source/_patterns/00-atoms/02-buttons/04-btn-deploy.mustache +4 -0
  88. data/source/_patterns/00-atoms/03-forms/00-text-fields.mustache +24 -0
  89. data/source/_patterns/00-atoms/03-forms/01-select-menu.mustache +6 -0
  90. data/source/_patterns/00-atoms/03-forms/02-checkbox.mustache +10 -0
  91. data/source/_patterns/00-atoms/03-forms/03-radios.mustache +10 -0
  92. data/source/_patterns/00-atoms/03-forms/04-validation.mustache +14 -0
  93. data/source/_patterns/00-atoms/04-quote/00-pullquote.mustache +7 -0
  94. data/source/_patterns/00-atoms/04-quote/01-quote-small.mustache +7 -0
  95. data/source/_patterns/00-atoms/05-code/01-pre.mustache +11 -0
  96. data/source/_patterns/00-atoms/06-tooltips/00-text.mustache +3 -0
  97. data/source/_patterns/00-atoms/06-tooltips/01-diagram-callout.mustache +1 -0
  98. data/source/_patterns/00-atoms/07-loader/00-spinner.mustache +5 -0
  99. data/source/_patterns/00-atoms/08-readmore/00-readmore.mustache +3 -0
  100. data/source/_patterns/00-atoms/09-slider/00-dots.mustache +8 -0
  101. data/source/_patterns/00-atoms/10-tables/00-tables.mustache +26 -0
  102. data/source/_patterns/00-atoms/12-modal/00-modal.mustache +14 -0
  103. data/source/_patterns/00-atoms/13-panel/00-panel.mustache +3 -0
  104. data/source/_patterns/00-atoms/14-users/00-avatar.mustache +3 -0
  105. data/source/_patterns/00-atoms/15-icons/00-icons.mustache +333 -0
  106. data/source/_patterns/00-atoms/15-icons/04-icon-colors.mustache +38 -0
  107. data/source/_patterns/00-atoms/15-icons/05-icon-sizes.mustache +31 -0
  108. data/source/_patterns/00-atoms/15-icons/_02-languages.mustache +0 -0
  109. data/source/_patterns/00-atoms/15-icons/_03-social.mustache +0 -0
  110. data/source/_patterns/00-atoms/15-icons/_05-icon-containers.mustache +0 -0
  111. data/source/_patterns/00-atoms/16-video/01-video.mustache +3 -0
  112. data/source/_patterns/00-atoms/16-video/_00-play-button.mustache +0 -0
  113. data/source/_patterns/00-atoms/17-utilities/00-visibility.mustache +8 -0
  114. data/source/_patterns/00-atoms/17-utilities/01-ui-elements.mustache +3 -0
  115. data/source/_patterns/00-atoms/18-grid/_00-grid.mustache +0 -0
  116. data/source/_patterns/01-molecules/00-text/00-header-groups.mustache +4 -0
  117. data/source/_patterns/01-molecules/00-text/01-intro-text.mustache +5 -0
  118. data/source/_patterns/01-molecules/01-layout/00-one-up.mustache +8 -0
  119. data/source/_patterns/01-molecules/01-layout/01-two-up.mustache +9 -0
  120. data/source/_patterns/01-molecules/01-layout/02-three-up.mustache +10 -0
  121. data/source/_patterns/01-molecules/01-layout/03-four-up.mustache +11 -0
  122. data/source/_patterns/01-molecules/01-layout/04-masonary-2.mustache +24 -0
  123. data/source/_patterns/01-molecules/01-layout/05-masonary-3.mustache +24 -0
  124. data/source/_patterns/01-molecules/02-navigation/01-subnav.mustache +21 -0
  125. data/source/_patterns/01-molecules/02-navigation/02-breadcrumbs.mustache +25 -0
  126. data/source/_patterns/01-molecules/02-navigation/03-side-nav.mustache +11 -0
  127. data/source/_patterns/01-molecules/02-navigation/04-side-nav-small.mustache +32 -0
  128. data/source/_patterns/01-molecules/02-navigation/05-pagination.mustache +0 -0
  129. data/source/_patterns/01-molecules/02-navigation/06-tabs.mustache +46 -0
  130. data/source/_patterns/01-molecules/03-forms/_00-search.mustache +0 -0
  131. data/source/_patterns/01-molecules/04-slider/00-slider.mustache +8 -0
  132. data/source/_patterns/01-molecules/05-messages/00-alert.mustache +15 -0
  133. data/source/_patterns/01-molecules/06-components/_00-social-share.mustache +0 -0
  134. data/source/_patterns/01-molecules/07-Elements/01-Addons-Card.mustache +79 -0
  135. data/source/_patterns/01-molecules/07-Elements/02-Buttons-Card.mustache +131 -0
  136. data/source/_patterns/01-molecules/07-Elements/03-Buildpack-Card.mustache +109 -0
  137. data/source/_patterns/01-molecules/08-vertical-tabs/01-vertical-tabs.mustache +30 -0
  138. data/source/_patterns/02-organisms/03-sections/00-purple.mustache +11 -0
  139. data/source/_patterns/02-organisms/03-sections/01-purple-dark.mustache +12 -0
  140. data/source/_patterns/02-organisms/03-sections/03-gray-light.mustache +12 -0
  141. data/source/css/hk-icon-rails.scss +13 -0
  142. data/source/css/scss/base/_base.scss +62 -0
  143. data/source/css/scss/base/_fonts.scss +12 -0
  144. data/source/css/scss/base/_normalize.scss +431 -0
  145. data/source/css/scss/base/_type.scss +128 -0
  146. data/source/css/scss/base/_utilities.scss +78 -0
  147. data/source/css/scss/components/_alert.scss +38 -0
  148. data/source/css/scss/components/_animate.scss +3340 -0
  149. data/source/css/scss/components/_animation.scss +15 -0
  150. data/source/css/scss/components/_buttons.scss +175 -0
  151. data/source/css/scss/components/_code.scss +26 -0
  152. data/source/css/scss/components/_forms.scss +136 -0
  153. data/source/css/scss/components/_hero.scss +18 -0
  154. data/source/css/scss/components/_hr.scss +11 -0
  155. data/source/css/scss/components/_icons.scss +85 -0
  156. data/source/css/scss/components/_lists.scss +45 -0
  157. data/source/css/scss/components/_logos.scss +15 -0
  158. data/source/css/scss/components/_masonary.scss +46 -0
  159. data/source/css/scss/components/_modal.scss +218 -0
  160. data/source/css/scss/components/_owlCarousel.scss +270 -0
  161. data/source/css/scss/components/_panel.scss +11 -0
  162. data/source/css/scss/components/_pill-box.scss +38 -0
  163. data/source/css/scss/components/_quote.scss +96 -0
  164. data/source/css/scss/components/_readmore.scss +11 -0
  165. data/source/css/scss/components/_slider.scss +96 -0
  166. data/source/css/scss/components/_spinner.scss +64 -0
  167. data/source/css/scss/components/_sprites.scss +3 -0
  168. data/source/css/scss/components/_sr-only.scss +10 -0
  169. data/source/css/scss/components/_tables.scss +62 -0
  170. data/source/css/scss/components/_tooltips.scss +93 -0
  171. data/source/css/scss/components/_users.scss +11 -0
  172. data/source/css/scss/components/_vertical-tabs.scss +129 -0
  173. data/source/css/scss/components/_video.scss +7 -0
  174. data/source/css/scss/ecosystem/_addons-card.scss +3 -0
  175. data/source/css/scss/ecosystem/_cards.scss +369 -0
  176. data/source/css/scss/ecosystem/_elements-brand.scss +32 -0
  177. data/source/css/scss/ecosystem/_elements.scss +4 -0
  178. data/source/css/scss/globals/_colors.scss +189 -0
  179. data/source/css/scss/globals/_mixins.scss +45 -0
  180. data/source/css/scss/globals/_variables.scss +87 -0
  181. data/source/css/scss/layout/_grid-settings.scss +13 -0
  182. data/source/css/scss/layout/_layout.scss +95 -0
  183. data/source/css/scss/page-elements/_headers.scss +3 -0
  184. data/source/css/scss/page-elements/_navigation.scss +254 -0
  185. data/source/css/scss/page-elements/_sections.scss +66 -0
  186. data/source/css/scss/page-elements/_sidebar.scss +34 -0
  187. data/source/css/shibori.scss +63 -0
  188. data/source/fonts/bentonsans/bentonsans-book.eot +0 -0
  189. data/source/fonts/bentonsans/bentonsans-book.svg +400 -0
  190. data/source/fonts/bentonsans/bentonsans-book.ttf +0 -0
  191. data/source/fonts/bentonsans/bentonsans-book.woff +0 -0
  192. data/source/fonts/bentonsans/bentonsans-medium.eot +0 -0
  193. data/source/fonts/bentonsans/bentonsans-medium.svg +416 -0
  194. data/source/fonts/bentonsans/bentonsans-medium.ttf +0 -0
  195. data/source/fonts/bentonsans/bentonsans-medium.woff +0 -0
  196. data/source/fonts/bentonsans/bentonsans-regular.eot +0 -0
  197. data/source/fonts/bentonsans/bentonsans-regular.svg +416 -0
  198. data/source/fonts/bentonsans/bentonsans-regular.ttf +0 -0
  199. data/source/fonts/bentonsans/bentonsans-regular.woff +0 -0
  200. data/source/fonts/hk-icon/hk-icon.eot +0 -0
  201. data/source/fonts/hk-icon/hk-icon.svg +261 -0
  202. data/source/fonts/hk-icon/hk-icon.ttf +0 -0
  203. data/source/fonts/hk-icon/hk-icon.woff +0 -0
  204. data/source/fonts/inconsolata/inconsolata-bold.eot +0 -0
  205. data/source/fonts/inconsolata/inconsolata-bold.svg +239 -0
  206. data/source/fonts/inconsolata/inconsolata-bold.ttf +0 -0
  207. data/source/fonts/inconsolata/inconsolata-bold.woff +0 -0
  208. data/source/fonts/inconsolata/inconsolata-regular.eot +0 -0
  209. data/source/fonts/inconsolata/inconsolata-regular.svg +239 -0
  210. data/source/fonts/inconsolata/inconsolata-regular.ttf +0 -0
  211. data/source/fonts/inconsolata/inconsolata-regular.woff +0 -0
  212. data/source/images/blockquote/close-sm.png +0 -0
  213. data/source/images/blockquote/close.png +0 -0
  214. data/source/images/blockquote/close@2x.png +0 -0
  215. data/source/images/blockquote/open-sm.png +0 -0
  216. data/source/images/blockquote/open.png +0 -0
  217. data/source/images/blockquote/open@2x.png +0 -0
  218. data/source/images/elements/heroku_suported.svg +32 -0
  219. data/source/images/forms/select-input-arrows.svg +8 -0
  220. data/source/js/init.js +26 -0
  221. data/source/js/main.js +22 -0
  222. data/source/js/vendor/bourbon-modal.js +17 -0
  223. data/source/js/vendor/fitvids.js +77 -0
  224. data/source/js/vendor/fixto.js +719 -0
  225. data/source/js/vendor/jquery-2.0.0b2.js +8690 -0
  226. data/source/js/vendor/modernizr.js +4 -0
  227. data/source/js/vendor/owl.carousel.js +3069 -0
  228. data/source/js/vendor/readmore.js +11 -0
  229. data/source/js/vendor/unslider.js +1 -0
  230. data/source/js/vendor/vertical-tabs.js +34 -0
  231. data/test/files/test.css +19 -0
  232. data/test/lineage_hunter_tests.js +262 -0
  233. data/test/list_item_hunter_tests.js +167 -0
  234. data/test/media_hunter_tests.js +74 -0
  235. data/test/object_factory_tests.js +62 -0
  236. data/test/parameter_hunter_tests.js +298 -0
  237. data/test/pattern_assembler_tests.js +43 -0
  238. data/test/patternlab_tests.js +8 -0
  239. metadata +320 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4ca62cc5fc76a05afafe004462b6abd9a0b6135d
4
+ data.tar.gz: 5938d8d9776a90fe53f8948569981d4792e1c6ec
5
+ SHA512:
6
+ metadata.gz: c4e3c6a0a7581b46fb5dc2010523f1a9d690ea1e507e6ff5462c83892dea0c2adbf789e07928fac366a24b356018282a5e008310701cc9adced9a96cda2ccb9b
7
+ data.tar.gz: 42606bb007ce66b3145135e136b646e9ca1f05194f7568278b1007e8771f483618980baf9f42b4f8ecf95e4c6ff08c2ddcfaf9226f0690b6e14f9cc7b08e299a
data/.gitignore ADDED
@@ -0,0 +1,20 @@
1
+ node_modules/
2
+ .DS_Store
3
+ public/index.html
4
+ public/styleguide.html
5
+ public/styleguide/html/styleguide.html
6
+ public/css/*
7
+ public/fonts/*
8
+ public/js/*
9
+ public/images/*
10
+ public/patterns/*
11
+ config.ini
12
+ latest-change.txt
13
+ patternlab.json
14
+ .sass-cache/*
15
+ /sass-cache
16
+ source/images/Thumbs.db
17
+ public/styleguide/css/static.css.map
18
+ public/styleguide/css/styleguide-specific.css.map
19
+ public/styleguide/css/styleguide.css.map
20
+ source/css/shibori.css.map
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in shibori.gemspec
4
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,27 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ shibori (1.0.0.beta1)
5
+ bourbon (>= 3.1.8, < 5.0.0)
6
+ neat (~> 1.7, >= 1.7.2)
7
+
8
+ GEM
9
+ remote: https://rubygems.org/
10
+ specs:
11
+ bourbon (4.2.7)
12
+ sass (~> 3.4)
13
+ thor (~> 0.19)
14
+ neat (1.8.0)
15
+ sass (>= 3.3)
16
+ thor (~> 0.19)
17
+ sass (3.4.22)
18
+ thor (0.19.1)
19
+
20
+ PLATFORMS
21
+ ruby
22
+
23
+ DEPENDENCIES
24
+ shibori!
25
+
26
+ BUNDLED WITH
27
+ 1.12.5
data/Procfile ADDED
@@ -0,0 +1 @@
1
+ web: node index.js
data/README.md ADDED
@@ -0,0 +1,24 @@
1
+ # Shibori
2
+ #### She • bore • ee
3
+ Patterns for use on Heroku web properties. See the library at [shibori.herokuapp.com](http://shibori.herokuapp.com)
4
+
5
+ ![Shibori](shibori.jpg)
6
+
7
+ > [Shibori](https://en.wikipedia.org/wiki/Shibori) is a Japanese tie-dying technique, using a variety of techniques in different shapes to make different patterns.
8
+
9
+ ## Local setup
10
+ Run:
11
+ ```
12
+ script/bootstrap
13
+ ```
14
+
15
+ To watch for files:
16
+ ```
17
+ gulp serve
18
+ ```
19
+
20
+ ## Development alongside Rails
21
+ In the rails app, set up bundler to use the local copy of shibori you have: `bundle config local.shibori path/to/your/local/shibori`.
22
+
23
+ ## Pattern lab docs
24
+ Shibori uses the [node version](https://github.com/pattern-lab/patternlab-node) of [Pattern Lab](http://patternlab.io/). You can find documentation in this repo's [`docs`](/docs) directory.
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require 'bundler/gem_tasks'
2
+ require 'rubygems'
data/app.json ADDED
@@ -0,0 +1,11 @@
1
+ {
2
+ "name": "www-patterns",
3
+ "scripts": {},
4
+ "env": {},
5
+ "addons": [],
6
+ "buildpacks": [
7
+ {
8
+ "url": "urn:buildpack:heroku/nodejs"
9
+ }
10
+ ]
11
+ }
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Heroku-Patterns - v0.2.0 - 2016
3
+ *
4
+ * , and the web community.
5
+ * Licensed under the license.
6
+ *
7
+ * Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice.
8
+ *
9
+ **/(function () {
10
+ "use strict";
11
+
12
+ var lineage_hunter = function(){
13
+
14
+ function findlineage(pattern, patternlab){
15
+
16
+ var pa = require('./pattern_assembler');
17
+ var pattern_assembler = new pa();
18
+
19
+ //find the {{> template-name }} within patterns
20
+ var matches = pattern_assembler.find_pattern_partials(pattern);
21
+ if(matches !== null){
22
+ matches.forEach(function(match, index, matches){
23
+ //strip out the template cruft
24
+ var foundPattern = match.replace("{{> ", "").replace(" }}", "").replace("{{>", "").replace("}}", "");
25
+
26
+ // remove any potential pattern parameters. this and the above are rather brutish but I didn't want to do a regex at the time
27
+ if(foundPattern.indexOf('(') > 0){
28
+ foundPattern = foundPattern.substring(0, foundPattern.indexOf('('));
29
+ }
30
+
31
+ //add if it doesnt exist
32
+ if (pattern.lineageIndex.indexOf(foundPattern) === -1){
33
+
34
+ pattern.lineageIndex.push(foundPattern);
35
+
36
+ patternlab.patterns.forEach(function(ancestorPattern, index, patterns){
37
+
38
+ //find the pattern in question
39
+ var searchPattern = ancestorPattern.patternGroup + "-" + ancestorPattern.patternName;
40
+
41
+ if(searchPattern === foundPattern){
42
+ //create the more complex patternLineage object too
43
+ var l = {
44
+ "lineagePattern": foundPattern,
45
+ "lineagePath": "../../patterns/" + ancestorPattern.patternLink
46
+ };
47
+ pattern.lineage.push(JSON.stringify(l));
48
+
49
+ //also, add the lineageR entry if it doesn't exist
50
+ var patternLabel = pattern.patternGroup + "-" + pattern.patternName;
51
+ if (ancestorPattern.lineageRIndex.indexOf(patternLabel) === -1){
52
+ ancestorPattern.lineageRIndex.push(patternLabel);
53
+
54
+ //create the more complex patternLineage object in reverse
55
+ var lr = {
56
+ "lineagePattern": patternLabel,
57
+ "lineagePath": "../../patterns/" + pattern.patternLink
58
+ };
59
+ ancestorPattern.lineageR.push(JSON.stringify(lr));
60
+ }
61
+ }
62
+
63
+ });
64
+
65
+ }
66
+ });
67
+ }
68
+ }
69
+
70
+ return {
71
+ find_lineage: function(pattern, patternlab){
72
+ findlineage(pattern, patternlab);
73
+ }
74
+ };
75
+
76
+ };
77
+
78
+ module.exports = lineage_hunter;
79
+
80
+ }());
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Heroku-Patterns - v0.2.0 - 2016
3
+ *
4
+ * , and the web community.
5
+ * Licensed under the license.
6
+ *
7
+ * Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice.
8
+ *
9
+ **/(function () {
10
+ "use strict";
11
+
12
+ var list_item_hunter = function(){
13
+
14
+ var extend = require('util')._extend,
15
+ pa = require('./pattern_assembler'),
16
+ mustache = require('mustache'),
17
+ pattern_assembler = new pa(),
18
+ items = [ 'zero','one','two','three','four','five','six','seven','eight','nine','ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen','twenty'];
19
+
20
+ function processListItemPartials(pattern, patternlab){
21
+ //find any listitem blocks
22
+ var matches = pattern_assembler.find_list_items(pattern, patternlab);
23
+ if(matches !== null){
24
+ matches.forEach(function(liMatch, index, matches){
25
+
26
+ if(patternlab.config.debug){
27
+ console.log('found listItem of size ' + liMatch + ' inside ' + pattern.key);
28
+ }
29
+
30
+ //find the boundaries of the block
31
+ var loopNumberString = liMatch.split('.')[1].split('}')[0].trim();
32
+ var end = liMatch.replace('#', '/');
33
+ var patternBlock = pattern.template.substring(pattern.template.indexOf(liMatch) + liMatch.length, pattern.template.indexOf(end)).trim();
34
+
35
+ //build arrays that repeat the block, however large we need to
36
+ var repeatedBlockTemplate = [];
37
+ var repeatedBlockHtml = '';
38
+ for(var i = 0; i < items.indexOf(loopNumberString); i++){
39
+ repeatedBlockTemplate.push(patternBlock);
40
+ }
41
+
42
+ //check for a local listitems.json file
43
+ var listData = JSON.parse(JSON.stringify(patternlab.listitems));
44
+ listData = pattern_assembler.merge_data(listData, pattern.patternSpecificListJson);
45
+
46
+ //iterate over each copied block, rendering its contents along with pattenlab.listitems[i]
47
+ for(var i = 0; i < repeatedBlockTemplate.length; i++){
48
+
49
+ var thisBlockTemplate = repeatedBlockTemplate[i];
50
+ var thisBlockHTML = "";
51
+
52
+ //combine listItem data with pattern data with global data
53
+ var itemData = listData['' + items.indexOf(loopNumberString)]; //this is a property like "2"
54
+ var globalData = JSON.parse(JSON.stringify(patternlab.data));
55
+ var localData = JSON.parse(JSON.stringify(pattern.jsonFileData));
56
+
57
+ var allData = pattern_assembler.merge_data(globalData, localData);
58
+ allData = pattern_assembler.merge_data(allData, itemData[i]);
59
+ allData.link = extend({}, patternlab.data.link);
60
+
61
+ //check for partials within the repeated block
62
+ var foundPartials = pattern_assembler.find_pattern_partials({ 'template' : thisBlockTemplate });
63
+
64
+ if(foundPartials && foundPartials.length > 0){
65
+
66
+ for(var j = 0; j < foundPartials.length; j++){
67
+
68
+ //get the partial
69
+ var partialName = foundPartials[j].match(/([a-z-]+)/ig)[0];
70
+ var partialPattern = pattern_assembler.get_pattern_by_key(partialName, patternlab);
71
+
72
+ //replace its reference within the block with the extended template
73
+ thisBlockTemplate = thisBlockTemplate.replace(foundPartials[j], partialPattern.extendedTemplate);
74
+ }
75
+
76
+ //render with data
77
+ thisBlockHTML = pattern_assembler.renderPattern(thisBlockTemplate, allData, patternlab.partials);
78
+
79
+ } else{
80
+ //just render with mergedData
81
+ thisBlockHTML = pattern_assembler.renderPattern(thisBlockTemplate, allData, patternlab.partials);
82
+ }
83
+
84
+ //add the rendered HTML to our string
85
+ repeatedBlockHtml = repeatedBlockHtml + thisBlockHTML;
86
+ }
87
+
88
+ //replace the block with our generated HTML
89
+ var repeatingBlock = pattern.extendedTemplate.substring(pattern.extendedTemplate.indexOf(liMatch), pattern.extendedTemplate.indexOf(end) + end.length);
90
+ pattern.extendedTemplate = pattern.extendedTemplate.replace(repeatingBlock, repeatedBlockHtml);
91
+
92
+ });
93
+ }
94
+ }
95
+
96
+ return {
97
+ process_list_item_partials: function(pattern, patternlab){
98
+ processListItemPartials(pattern, patternlab);
99
+ }
100
+ };
101
+
102
+ };
103
+
104
+ module.exports = list_item_hunter;
105
+
106
+ }());
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Heroku-Patterns - v0.2.0 - 2016
3
+ *
4
+ * , and the web community.
5
+ * Licensed under the license.
6
+ *
7
+ * Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice.
8
+ *
9
+ **/(function () {
10
+ "use strict";
11
+
12
+ var diveSync = require('diveSync'),
13
+ path = require('path'),
14
+ fs = require('fs-extra');
15
+
16
+ var media_hunter = function(){
17
+
18
+ function findMediaQueries(dir, patternlab){
19
+ patternlab.mediaQueries = [];
20
+
21
+ diveSync(dir, function(err, file){
22
+ if(path.extname(file) === '.css'){
23
+ var contents = fs.readFileSync(file, 'utf8');
24
+ var safeContents = contents.replace("\r", " ").replace("\n", " ");
25
+ var matches = safeContents.match(/\((min|max)-width:([ ]+)?(([0-9]{1,5})(\.[0-9]{1,20}|)(px|em))/g);
26
+ for(var i = 0; i < matches.length; i++){
27
+ var breakpoint = matches[i].substring(matches[i].indexOf(':') + 1).trimLeft();
28
+ if(patternlab.mediaQueries.indexOf(breakpoint) === -1){
29
+ patternlab.mediaQueries.push(breakpoint);
30
+ }
31
+ }
32
+ }
33
+ });
34
+ patternlab.mediaQueries.sort(function(a,b){
35
+ var integerPartA = a.match(/(?:\d*\.)?\d+/g);
36
+ var integerPartB = b.match(/(?:\d*\.)?\d+/g);
37
+ return parseInt(a,10) > parseInt(b,10);
38
+ });
39
+ }
40
+
41
+ return {
42
+ find_media_queries: function(dir, patternlab){
43
+ findMediaQueries(dir, patternlab);
44
+ }
45
+ };
46
+
47
+ };
48
+
49
+ module.exports = media_hunter;
50
+
51
+ }());
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Heroku-Patterns - v0.2.0 - 2016
3
+ *
4
+ * , and the web community.
5
+ * Licensed under the license.
6
+ *
7
+ * Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice.
8
+ *
9
+ **/(function () {
10
+ "use strict";
11
+
12
+ var oPattern = function(subdir, filename, data){
13
+ this.fileName = filename.substring(0, filename.indexOf('.'));
14
+ this.subdir = subdir;
15
+ this.name = subdir.replace(/[\/\\]/g, '-') + '-' + this.fileName; //this is the unique name with the subDir
16
+ this.jsonFileData = data || {};
17
+ this.patternName = this.fileName.substring(this.fileName.indexOf('-') + 1); //this is the display name for the ui
18
+ this.patternLink = this.name + '/' + this.name + '.html';
19
+ this.patternGroup = this.name.substring(this.name.indexOf('-') + 1, this.name.indexOf('-', 4) + 1 - this.name.indexOf('-') + 1);
20
+ this.patternSubGroup = subdir.substring(subdir.indexOf('/') + 4);
21
+ this.flatPatternPath = subdir.replace(/[\/\\]/g, '-');
22
+ this.key = this.patternGroup + '-' + this.patternName;
23
+ this.template = '';
24
+ this.patternPartial = '';
25
+ this.lineage = [];
26
+ this.lineageIndex = [];
27
+ this.lineageR = [];
28
+ this.lineageRIndex = [];
29
+ };
30
+
31
+ var oBucket = function(name){
32
+ this.bucketNameLC = name;
33
+ this.bucketNameUC = name.charAt(0).toUpperCase() + name.slice(1);
34
+ this.navItems = [];
35
+ this.navItemsIndex = [];
36
+ this.patternItems = [];
37
+ this.patternItemsIndex = [];
38
+ };
39
+
40
+ var oNavItem = function(name){
41
+ this.sectionNameLC = name;
42
+ this.sectionNameUC = name.charAt(0).toUpperCase() + name.slice(1);
43
+ this.navSubItems = [];
44
+ this.navSubItemsIndex = [];
45
+ };
46
+
47
+ var oNavSubItem = function(name){
48
+ this.patternPath = '';
49
+ this.patternPartial = '';
50
+ this.patternName = name.charAt(0).toUpperCase() + name.slice(1);
51
+ };
52
+
53
+ module.exports = {
54
+ oPattern: oPattern,
55
+ oBucket: oBucket,
56
+ oNavItem: oNavItem,
57
+ oNavSubItem: oNavSubItem
58
+ };
59
+
60
+ }());
@@ -0,0 +1,69 @@
1
+ /**
2
+ * Heroku-Patterns - v0.2.0 - 2016
3
+ *
4
+ * , and the web community.
5
+ * Licensed under the license.
6
+ *
7
+ * Many thanks to Brad Frost and Dave Olsen for inspiration, encouragement, and advice.
8
+ *
9
+ **/(function () {
10
+ "use strict";
11
+
12
+ var parameter_hunter = function(){
13
+
14
+ var extend = require('util')._extend,
15
+ pa = require('./pattern_assembler'),
16
+ mustache = require('mustache'),
17
+ pattern_assembler = new pa();
18
+
19
+ function findparameters(pattern, patternlab){
20
+
21
+ //find the {{> template-name(*) }} within patterns
22
+ var matches = pattern.template.match(/{{>([ ]+)?([\w\-\.\/~]+)(\()(.+)(\))([ ]+)?}}/g);
23
+ if(matches !== null){
24
+ //compile this partial immeadiately, essentially consuming it.
25
+ matches.forEach(function(pMatch, index, matches){
26
+ //find the partial's name
27
+ var partialName = pMatch.match(/([\w\-\.\/~]+)/g)[0];
28
+
29
+ if(patternlab.config.debug){
30
+ console.log('found patternParameters for ' + partialName);
31
+ }
32
+
33
+ //strip out the additional data and eval
34
+ var leftParen = pMatch.indexOf('(');
35
+ var rightParen = pMatch.indexOf(')');
36
+ var paramString = '({' + pMatch.substring(leftParen + 1, rightParen) + '})';
37
+
38
+ //do no evil. there is no good way to do this that I can think of without using a split, which then makes commas and colons special characters and unusable within the pattern params
39
+ var paramData = eval(paramString);
40
+
41
+ var partialPattern = pattern_assembler.get_pattern_by_key(partialName, patternlab);
42
+ var globalData = JSON.parse(JSON.stringify(patternlab.data));
43
+ var localData = JSON.parse(JSON.stringify(pattern.jsonFileData));
44
+
45
+ var allData = pattern_assembler.merge_data(globalData, localData);
46
+ allData = pattern_assembler.merge_data(allData, paramData);
47
+
48
+ //extend pattern data links into link for pattern link shortcuts to work. we do this locally and globally
49
+ allData.link = extend({}, patternlab.data.link);
50
+
51
+ var renderedPartial = pattern_assembler.renderPattern(partialPattern.extendedTemplate, allData, patternlab.partials);
52
+
53
+ //remove the parameter from the partial and replace it with the rendered partial + paramData
54
+ pattern.extendedTemplate = pattern.extendedTemplate.replace(pMatch, renderedPartial);
55
+ });
56
+ }
57
+ }
58
+
59
+ return {
60
+ find_parameters: function(pattern, patternlab){
61
+ findparameters(pattern, patternlab);
62
+ }
63
+ };
64
+
65
+ };
66
+
67
+ module.exports = parameter_hunter;
68
+
69
+ }());