component_library 0.0.1
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 +7 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +3 -0
- data/Rakefile +27 -0
- data/app/assets/javascripts/library.js +2 -0
- data/app/assets/javascripts/prism.js +3 -0
- data/app/assets/stylesheets/_prism.scss +137 -0
- data/app/assets/stylesheets/library.scss +63 -0
- data/app/controllers/library_controller.rb +16 -0
- data/app/models/library/component.rb +53 -0
- data/app/models/library/librarian.rb +19 -0
- data/app/views/layouts/component_library.html.erb +14 -0
- data/app/views/library/_componentpattern.html.erb +21 -0
- data/app/views/library/index.html.erb +6 -0
- data/app/views/library/show.html.erb +2 -0
- data/config/routes.rb +4 -0
- data/lib/component_library/engine.rb +11 -0
- data/lib/component_library/version.rb +3 -0
- data/lib/component_library.rb +13 -0
- data/lib/tasks/component_library_tasks.rake +4 -0
- metadata +125 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 076bb4712df8ac493fbcc2ac011b6b7d08eb5af2
|
|
4
|
+
data.tar.gz: 1187cdc589c7904f7f652f0009d230add30bf752
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 7be250f1d36667ba5f6ef4ac59121bb6b0e2875f7babb8675b9e0dd2b2ee04769926da67c0e9bc27632df1a6b8527e537d57267f34abac3920fe3713590ae231
|
|
7
|
+
data.tar.gz: 1b7b94c4a029cf25b13f268d5331ac7dc64c2f4a3f4ce1e70b27247ed0cf94e080f46cc9351a4da0aa8ebcee898413b84eacbb4fc45796865db3de8ba98bdd20
|
data/MIT-LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright 2016 Rich Archer
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
data/Rakefile
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
begin
|
|
2
|
+
require 'bundler/setup'
|
|
3
|
+
rescue LoadError
|
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
require 'rdoc/task'
|
|
8
|
+
|
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
|
11
|
+
rdoc.title = 'ComponentLibrary'
|
|
12
|
+
rdoc.options << '--line-numbers'
|
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
|
18
|
+
load 'rails/tasks/engine.rake'
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
load 'rails/tasks/statistics.rake'
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
Bundler::GemHelper.install_tasks
|
|
26
|
+
|
|
27
|
+
task default: :spec
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/* http://prismjs.com/download.html?themes=prism&languages=markup */
|
|
2
|
+
var _self="undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?self:{},Prism=function(){var e=/\blang(?:uage)?-(?!\*)(\w+)\b/i,t=_self.Prism={util:{encode:function(e){return e instanceof n?new n(e.type,t.util.encode(e.content),e.alias):"Array"===t.util.type(e)?e.map(t.util.encode):e.replace(/&/g,"&").replace(/</g,"<").replace(/\u00a0/g," ")},type:function(e){return Object.prototype.toString.call(e).match(/\[object (\w+)\]/)[1]},clone:function(e){var n=t.util.type(e);switch(n){case"Object":var a={};for(var r in e)e.hasOwnProperty(r)&&(a[r]=t.util.clone(e[r]));return a;case"Array":return e.map&&e.map(function(e){return t.util.clone(e)})}return e}},languages:{extend:function(e,n){var a=t.util.clone(t.languages[e]);for(var r in n)a[r]=n[r];return a},insertBefore:function(e,n,a,r){r=r||t.languages;var i=r[e];if(2==arguments.length){a=arguments[1];for(var l in a)a.hasOwnProperty(l)&&(i[l]=a[l]);return i}var o={};for(var s in i)if(i.hasOwnProperty(s)){if(s==n)for(var l in a)a.hasOwnProperty(l)&&(o[l]=a[l]);o[s]=i[s]}return t.languages.DFS(t.languages,function(t,n){n===r[e]&&t!=e&&(this[t]=o)}),r[e]=o},DFS:function(e,n,a){for(var r in e)e.hasOwnProperty(r)&&(n.call(e,r,e[r],a||r),"Object"===t.util.type(e[r])?t.languages.DFS(e[r],n):"Array"===t.util.type(e[r])&&t.languages.DFS(e[r],n,r))}},highlightAll:function(e,n){for(var a,r=document.querySelectorAll('code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code'),i=0;a=r[i++];)t.highlightElement(a,e===!0,n)},highlightElement:function(a,r,i){for(var l,o,s=a;s&&!e.test(s.className);)s=s.parentNode;s&&(l=(s.className.match(e)||[,""])[1],o=t.languages[l]),a.className=a.className.replace(e,"").replace(/\s+/g," ")+" language-"+l,s=a.parentNode,/pre/i.test(s.nodeName)&&(s.className=s.className.replace(e,"").replace(/\s+/g," ")+" language-"+l);var u=a.textContent,g={element:a,language:l,grammar:o,code:u};if(!u||!o)return t.hooks.run("complete",g),void 0;if(t.hooks.run("before-highlight",g),r&&_self.Worker){var c=new Worker(t.filename);c.onmessage=function(e){g.highlightedCode=n.stringify(JSON.parse(e.data),l),t.hooks.run("before-insert",g),g.element.innerHTML=g.highlightedCode,i&&i.call(g.element),t.hooks.run("after-highlight",g),t.hooks.run("complete",g)},c.postMessage(JSON.stringify({language:g.language,code:g.code}))}else g.highlightedCode=t.highlight(g.code,g.grammar,g.language),t.hooks.run("before-insert",g),g.element.innerHTML=g.highlightedCode,i&&i.call(a),t.hooks.run("after-highlight",g),t.hooks.run("complete",g)},highlight:function(e,a,r){var i=t.tokenize(e,a);return n.stringify(t.util.encode(i),r)},tokenize:function(e,n){var a=t.Token,r=[e],i=n.rest;if(i){for(var l in i)n[l]=i[l];delete n.rest}e:for(var l in n)if(n.hasOwnProperty(l)&&n[l]){var o=n[l];o="Array"===t.util.type(o)?o:[o];for(var s=0;s<o.length;++s){var u=o[s],g=u.inside,c=!!u.lookbehind,f=0,h=u.alias;u=u.pattern||u;for(var p=0;p<r.length;p++){var d=r[p];if(r.length>e.length)break e;if(!(d instanceof a)){u.lastIndex=0;var m=u.exec(d);if(m){c&&(f=m[1].length);var y=m.index-1+f,m=m[0].slice(f),v=m.length,k=y+v,b=d.slice(0,y+1),w=d.slice(k+1),N=[p,1];b&&N.push(b);var O=new a(l,g?t.tokenize(m,g):m,h);N.push(O),w&&N.push(w),Array.prototype.splice.apply(r,N)}}}}}return r},hooks:{all:{},add:function(e,n){var a=t.hooks.all;a[e]=a[e]||[],a[e].push(n)},run:function(e,n){var a=t.hooks.all[e];if(a&&a.length)for(var r,i=0;r=a[i++];)r(n)}}},n=t.Token=function(e,t,n){this.type=e,this.content=t,this.alias=n};if(n.stringify=function(e,a,r){if("string"==typeof e)return e;if("Array"===t.util.type(e))return e.map(function(t){return n.stringify(t,a,e)}).join("");var i={type:e.type,content:n.stringify(e.content,a,r),tag:"span",classes:["token",e.type],attributes:{},language:a,parent:r};if("comment"==i.type&&(i.attributes.spellcheck="true"),e.alias){var l="Array"===t.util.type(e.alias)?e.alias:[e.alias];Array.prototype.push.apply(i.classes,l)}t.hooks.run("wrap",i);var o="";for(var s in i.attributes)o+=s+'="'+(i.attributes[s]||"")+'"';return"<"+i.tag+' class="'+i.classes.join(" ")+'" '+o+">"+i.content+"</"+i.tag+">"},!_self.document)return _self.addEventListener?(_self.addEventListener("message",function(e){var n=JSON.parse(e.data),a=n.language,r=n.code;_self.postMessage(JSON.stringify(t.util.encode(t.tokenize(r,t.languages[a])))),_self.close()},!1),_self.Prism):_self.Prism;var a=document.getElementsByTagName("script");return a=a[a.length-1],a&&(t.filename=a.src,document.addEventListener&&!a.hasAttribute("data-manual")&&document.addEventListener("DOMContentLoaded",t.highlightAll)),_self.Prism}();"undefined"!=typeof module&&module.exports&&(module.exports=Prism);;
|
|
3
|
+
Prism.languages.markup={comment:/<!--[\w\W]*?-->/,prolog:/<\?[\w\W]+?\?>/,doctype:/<!DOCTYPE[\w\W]+?>/,cdata:/<!\[CDATA\[[\w\W]*?]]>/i,tag:{pattern:/<\/?[^\s>\/=]+(?:\s+[^\s>\/=]+(?:=(?:("|')(?:\\\1|\\?(?!\1)[\w\W])*\1|[^\s'">=]+))?)*\s*\/?>/i,inside:{tag:{pattern:/^<\/?[^\s>\/]+/i,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"attr-value":{pattern:/=(?:('|")[\w\W]*?(\1)|[^\s>]+)/i,inside:{punctuation:/[=>"']/}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:/&#?[\da-z]{1,8};/i},Prism.hooks.add("wrap",function(t){"entity"===t.type&&(t.attributes.title=t.content.replace(/&/,"&"))});;
|
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
/* http://prismjs.com/download.html?themes=prism&languages=markup */
|
|
2
|
+
/**
|
|
3
|
+
* prism.js default theme for JavaScript, CSS and HTML
|
|
4
|
+
* Based on dabblet (http://dabblet.com)
|
|
5
|
+
* @author Lea Verou
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
code[class*="language-"],
|
|
9
|
+
pre[class*="language-"] {
|
|
10
|
+
color: black;
|
|
11
|
+
text-shadow: 0 1px white;
|
|
12
|
+
font-family: Consolas, Monaco, 'Andale Mono', 'Ubuntu Mono', monospace;
|
|
13
|
+
direction: ltr;
|
|
14
|
+
text-align: left;
|
|
15
|
+
white-space: pre;
|
|
16
|
+
word-spacing: normal;
|
|
17
|
+
word-break: normal;
|
|
18
|
+
word-wrap: normal;
|
|
19
|
+
line-height: 1.5;
|
|
20
|
+
|
|
21
|
+
-moz-tab-size: 4;
|
|
22
|
+
-o-tab-size: 4;
|
|
23
|
+
tab-size: 4;
|
|
24
|
+
|
|
25
|
+
-webkit-hyphens: none;
|
|
26
|
+
-moz-hyphens: none;
|
|
27
|
+
-ms-hyphens: none;
|
|
28
|
+
hyphens: none;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
pre[class*="language-"]::-moz-selection, pre[class*="language-"] ::-moz-selection,
|
|
32
|
+
code[class*="language-"]::-moz-selection, code[class*="language-"] ::-moz-selection {
|
|
33
|
+
text-shadow: none;
|
|
34
|
+
background: #b3d4fc;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
pre[class*="language-"]::selection, pre[class*="language-"] ::selection,
|
|
38
|
+
code[class*="language-"]::selection, code[class*="language-"] ::selection {
|
|
39
|
+
text-shadow: none;
|
|
40
|
+
background: #b3d4fc;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@media print {
|
|
44
|
+
code[class*="language-"],
|
|
45
|
+
pre[class*="language-"] {
|
|
46
|
+
text-shadow: none;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/* Code blocks */
|
|
51
|
+
pre[class*="language-"] {
|
|
52
|
+
padding: 1em;
|
|
53
|
+
margin: .5em 0;
|
|
54
|
+
overflow: auto;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
:not(pre) > code[class*="language-"],
|
|
58
|
+
pre[class*="language-"] {
|
|
59
|
+
background: #f5f2f0;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/* Inline code */
|
|
63
|
+
:not(pre) > code[class*="language-"] {
|
|
64
|
+
padding: .1em;
|
|
65
|
+
border-radius: .3em;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.token.comment,
|
|
69
|
+
.token.prolog,
|
|
70
|
+
.token.doctype,
|
|
71
|
+
.token.cdata {
|
|
72
|
+
color: slategray;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.token.punctuation {
|
|
76
|
+
color: #999;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
.namespace {
|
|
80
|
+
opacity: .7;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.token.property,
|
|
84
|
+
.token.tag,
|
|
85
|
+
.token.boolean,
|
|
86
|
+
.token.number,
|
|
87
|
+
.token.constant,
|
|
88
|
+
.token.symbol,
|
|
89
|
+
.token.deleted {
|
|
90
|
+
color: #905;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
.token.selector,
|
|
94
|
+
.token.attr-name,
|
|
95
|
+
.token.string,
|
|
96
|
+
.token.char,
|
|
97
|
+
.token.builtin,
|
|
98
|
+
.token.inserted {
|
|
99
|
+
color: #690;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
.token.operator,
|
|
103
|
+
.token.entity,
|
|
104
|
+
.token.url,
|
|
105
|
+
.language-css .token.string,
|
|
106
|
+
.style .token.string {
|
|
107
|
+
color: #a67f59;
|
|
108
|
+
background: hsla(0, 0%, 100%, .5);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
.token.atrule,
|
|
112
|
+
.token.attr-value,
|
|
113
|
+
.token.keyword {
|
|
114
|
+
color: #07a;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.token.function {
|
|
118
|
+
color: #DD4A68;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.token.regex,
|
|
122
|
+
.token.important,
|
|
123
|
+
.token.variable {
|
|
124
|
+
color: #e90;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
.token.important,
|
|
128
|
+
.token.bold {
|
|
129
|
+
font-weight: bold;
|
|
130
|
+
}
|
|
131
|
+
.token.italic {
|
|
132
|
+
font-style: italic;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
.token.entity {
|
|
136
|
+
cursor: help;
|
|
137
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Place all the styles related to the matching controller here.
|
|
3
|
+
They will automatically be included in application.css.
|
|
4
|
+
*/
|
|
5
|
+
@import "prism";
|
|
6
|
+
|
|
7
|
+
.pattern {
|
|
8
|
+
margin-bottom: 3em;
|
|
9
|
+
& > * {
|
|
10
|
+
box-sizing: border-box;
|
|
11
|
+
display: block;
|
|
12
|
+
border: 1px solid;
|
|
13
|
+
border-color: #ccc;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
.pattern--code {
|
|
17
|
+
color: #333;
|
|
18
|
+
background-color: #eee;
|
|
19
|
+
padding: .5em 1%;
|
|
20
|
+
border-radius: 3px 3px 0 0;
|
|
21
|
+
}
|
|
22
|
+
.pattern--language-markup {
|
|
23
|
+
display: none;
|
|
24
|
+
padding: .5em 1em;
|
|
25
|
+
border: 1px solid #ccc;
|
|
26
|
+
margin: 1em 0;
|
|
27
|
+
overflow: auto;
|
|
28
|
+
}
|
|
29
|
+
.pattern--toggle-checkbox {
|
|
30
|
+
opacity: 0;
|
|
31
|
+
position: absolute;
|
|
32
|
+
&:checked ~ .pattern--language-markup {
|
|
33
|
+
display: block;
|
|
34
|
+
}
|
|
35
|
+
&:focus ~ .pattern--toggle-label {
|
|
36
|
+
text-decoration: underline;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
.pattern--toggle-label {
|
|
40
|
+
display: block;
|
|
41
|
+
cursor: pointer;
|
|
42
|
+
&:hover {
|
|
43
|
+
text-decoration: underline;
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
.pattern--preview {
|
|
47
|
+
background-image: -webkit-linear-gradient(-315deg, #eee 25%, transparent 25%, transparent 75%, #eee 75%, #eee), -webkit-linear-gradient(-315deg, #eee 25%, transparent 25%, transparent 75%, #eee 75%, #eee);
|
|
48
|
+
background-image: linear-gradient(45deg, #eee 25%, transparent 25%, transparent 75%, #eee 75%, #eee), linear-gradient(45deg, #eee 25%, transparent 25%, transparent 75%, #eee 75%, #eee);
|
|
49
|
+
background-size: 40px 40px;
|
|
50
|
+
background-position: 0 0, 20px 20px;
|
|
51
|
+
padding: 1em 1%;
|
|
52
|
+
border-radius: 0 0 3px 3px;
|
|
53
|
+
border-top-width: 0;
|
|
54
|
+
}
|
|
55
|
+
.pattern--layout {
|
|
56
|
+
position: relative;
|
|
57
|
+
&:after {
|
|
58
|
+
display: table;
|
|
59
|
+
line-height: 0;
|
|
60
|
+
content: "";
|
|
61
|
+
clear: both;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
class LibraryController < ApplicationController
|
|
2
|
+
layout "component_library"
|
|
3
|
+
|
|
4
|
+
def index
|
|
5
|
+
dir = Dir.glob("#{Rails.root}/app/views/#{ComponentLibrary.root_directory}/**/*.erb")
|
|
6
|
+
@library = Library::Librarian.new(dir, ComponentLibrary.root_directory)
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
def show
|
|
10
|
+
suffix = params[:format] == 'erb' ? ".erb" : "/**/*.erb"
|
|
11
|
+
dir = Dir.glob("#{Rails.root}/app/views/#{ComponentLibrary.root_directory}/#{params[:path]}#{suffix}")
|
|
12
|
+
@library = Library::Librarian.new(dir, ComponentLibrary.root_directory, params[:path])
|
|
13
|
+
raise ActionController::RoutingError.new('Not Found') if @library.components.empty?
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
end
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
module Library
|
|
2
|
+
class Component
|
|
3
|
+
def initialize(file, rootDirectory)
|
|
4
|
+
@file = file
|
|
5
|
+
@rootDirectory = rootDirectory
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def raw
|
|
9
|
+
File.open(@file).read
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def render
|
|
13
|
+
parseFile(@file, 'views')
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def paths
|
|
17
|
+
parseLinks(@file, @rootDirectory)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
|
|
22
|
+
def parseFile(file, trim)
|
|
23
|
+
fileArray = preparePath(file,trim)
|
|
24
|
+
fileArray[-1] = parseName(file)
|
|
25
|
+
fileArray.join('/')
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def parseName(file)
|
|
29
|
+
file.split('/').last[1..-1]
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
def parseLinks(file, trim)
|
|
33
|
+
response = []
|
|
34
|
+
fileArray = preparePath(file, trim)
|
|
35
|
+
while fileArray.length > 0 do
|
|
36
|
+
response.unshift prepareHash(fileArray)
|
|
37
|
+
end
|
|
38
|
+
h = {path: ".", name: "components"}
|
|
39
|
+
response.unshift h
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def preparePath(file, trim)
|
|
43
|
+
fileArray = file.split('/')
|
|
44
|
+
fileArray.shift( fileArray.index(trim) + 1 )
|
|
45
|
+
fileArray
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def prepareHash(fileArray)
|
|
49
|
+
|
|
50
|
+
{path: fileArray.join('/'), name: fileArray.pop}
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
module Library
|
|
2
|
+
class Librarian
|
|
3
|
+
|
|
4
|
+
def initialize(files, rootDirectory, title=nil)
|
|
5
|
+
@files = files
|
|
6
|
+
@rootDirectory = rootDirectory
|
|
7
|
+
@title = title
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def components
|
|
11
|
+
@files.map{ |file| Component.new(file, @rootDirectory) }
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def title
|
|
15
|
+
@title || ""
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>Component</title>
|
|
5
|
+
<%= stylesheet_link_tag 'library', 'application', media: 'all' %>
|
|
6
|
+
<%= javascript_include_tag 'prism' %>
|
|
7
|
+
<%= csrf_meta_tags %>
|
|
8
|
+
</head>
|
|
9
|
+
<body>
|
|
10
|
+
|
|
11
|
+
<%= yield %>
|
|
12
|
+
|
|
13
|
+
</body>
|
|
14
|
+
</html>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<% components.each do |component| %>
|
|
2
|
+
<p>
|
|
3
|
+
<% component.paths.each do |path| %>
|
|
4
|
+
/<%= link_to path[:name], component_path(path[:path]) %>
|
|
5
|
+
<% end %>
|
|
6
|
+
</p>
|
|
7
|
+
<div class="pattern" id="<%= component.render.parameterize %>">
|
|
8
|
+
<div class="pattern--code">
|
|
9
|
+
<input type="checkbox" id="view_html_<%= component.render.parameterize %>" class="pattern--toggle-checkbox">
|
|
10
|
+
<label for="view_html_<%= component.render.parameterize %>" class="pattern--toggle-label">View Source</labeL>
|
|
11
|
+
<div class="pattern--language-markup">
|
|
12
|
+
<code class="language-markup"><%= component.raw %></code>
|
|
13
|
+
</div>
|
|
14
|
+
</div>
|
|
15
|
+
<div class="pattern--preview">
|
|
16
|
+
<div class="pattern--layout">
|
|
17
|
+
<%= render component.render %>
|
|
18
|
+
</div>
|
|
19
|
+
</div>
|
|
20
|
+
</div>
|
|
21
|
+
<% end %>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
<h1>Component Library</h1>
|
|
2
|
+
<% if @library.components.any? %>
|
|
3
|
+
<%= render partial: "componentpattern", locals: { components: @library.components } %>
|
|
4
|
+
<% else %>
|
|
5
|
+
<p>No html components found at <code>/app/view/<%= ComponentLibrary.root_directory %></code></p>
|
|
6
|
+
<% end %>
|
data/config/routes.rb
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
module ComponentLibrary
|
|
2
|
+
class Engine < ::Rails::Engine
|
|
3
|
+
initializer "component_library.assets.precompile" do |app|
|
|
4
|
+
app.config.assets.precompile += %w(library.css library.js prism.js)
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
config.generators do |g|
|
|
8
|
+
g.test_framework :rspec
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: component_library
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Rich Archer
|
|
8
|
+
autorequire:
|
|
9
|
+
bindir: bin
|
|
10
|
+
cert_chain: []
|
|
11
|
+
date: 2016-03-09 00:00:00.000000000 Z
|
|
12
|
+
dependencies:
|
|
13
|
+
- !ruby/object:Gem::Dependency
|
|
14
|
+
name: rails
|
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
|
16
|
+
requirements:
|
|
17
|
+
- - "~>"
|
|
18
|
+
- !ruby/object:Gem::Version
|
|
19
|
+
version: 4.2.5.2
|
|
20
|
+
type: :development
|
|
21
|
+
prerelease: false
|
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
23
|
+
requirements:
|
|
24
|
+
- - "~>"
|
|
25
|
+
- !ruby/object:Gem::Version
|
|
26
|
+
version: 4.2.5.2
|
|
27
|
+
- !ruby/object:Gem::Dependency
|
|
28
|
+
name: sqlite3
|
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
|
30
|
+
requirements:
|
|
31
|
+
- - ">="
|
|
32
|
+
- !ruby/object:Gem::Version
|
|
33
|
+
version: '0'
|
|
34
|
+
type: :development
|
|
35
|
+
prerelease: false
|
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
37
|
+
requirements:
|
|
38
|
+
- - ">="
|
|
39
|
+
- !ruby/object:Gem::Version
|
|
40
|
+
version: '0'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: rspec-rails
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - "~>"
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '3.4'
|
|
48
|
+
type: :development
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - "~>"
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '3.4'
|
|
55
|
+
- !ruby/object:Gem::Dependency
|
|
56
|
+
name: sass
|
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
|
58
|
+
requirements:
|
|
59
|
+
- - "~>"
|
|
60
|
+
- !ruby/object:Gem::Version
|
|
61
|
+
version: '3.4'
|
|
62
|
+
- - ">="
|
|
63
|
+
- !ruby/object:Gem::Version
|
|
64
|
+
version: 3.4.21
|
|
65
|
+
type: :runtime
|
|
66
|
+
prerelease: false
|
|
67
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
68
|
+
requirements:
|
|
69
|
+
- - "~>"
|
|
70
|
+
- !ruby/object:Gem::Version
|
|
71
|
+
version: '3.4'
|
|
72
|
+
- - ">="
|
|
73
|
+
- !ruby/object:Gem::Version
|
|
74
|
+
version: 3.4.21
|
|
75
|
+
description: Description of ComponentLibrary.
|
|
76
|
+
email:
|
|
77
|
+
- rich.archer@unboxedconsulting.com
|
|
78
|
+
executables: []
|
|
79
|
+
extensions: []
|
|
80
|
+
extra_rdoc_files: []
|
|
81
|
+
files:
|
|
82
|
+
- MIT-LICENSE
|
|
83
|
+
- README.rdoc
|
|
84
|
+
- Rakefile
|
|
85
|
+
- app/assets/javascripts/library.js
|
|
86
|
+
- app/assets/javascripts/prism.js
|
|
87
|
+
- app/assets/stylesheets/_prism.scss
|
|
88
|
+
- app/assets/stylesheets/library.scss
|
|
89
|
+
- app/controllers/library_controller.rb
|
|
90
|
+
- app/models/library/component.rb
|
|
91
|
+
- app/models/library/librarian.rb
|
|
92
|
+
- app/views/layouts/component_library.html.erb
|
|
93
|
+
- app/views/library/_componentpattern.html.erb
|
|
94
|
+
- app/views/library/index.html.erb
|
|
95
|
+
- app/views/library/show.html.erb
|
|
96
|
+
- config/routes.rb
|
|
97
|
+
- lib/component_library.rb
|
|
98
|
+
- lib/component_library/engine.rb
|
|
99
|
+
- lib/component_library/version.rb
|
|
100
|
+
- lib/tasks/component_library_tasks.rake
|
|
101
|
+
homepage: https://github.com/richarcher/component_library
|
|
102
|
+
licenses:
|
|
103
|
+
- MIT
|
|
104
|
+
metadata: {}
|
|
105
|
+
post_install_message:
|
|
106
|
+
rdoc_options: []
|
|
107
|
+
require_paths:
|
|
108
|
+
- lib
|
|
109
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
110
|
+
requirements:
|
|
111
|
+
- - ">="
|
|
112
|
+
- !ruby/object:Gem::Version
|
|
113
|
+
version: '0'
|
|
114
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
115
|
+
requirements:
|
|
116
|
+
- - ">="
|
|
117
|
+
- !ruby/object:Gem::Version
|
|
118
|
+
version: '0'
|
|
119
|
+
requirements: []
|
|
120
|
+
rubyforge_project:
|
|
121
|
+
rubygems_version: 2.4.5.1
|
|
122
|
+
signing_key:
|
|
123
|
+
specification_version: 4
|
|
124
|
+
summary: Summary of ComponentLibrary.
|
|
125
|
+
test_files: []
|