caliber 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- checksums.yaml.gz.sig +0 -0
- data/LICENSE.adoc +214 -0
- data/README.adoc +117 -0
- data/caliber.gemspec +28 -21
- data/config/all.yml +5 -0
- data/config/performance.yml +42 -0
- data/config/rake.yml +1 -0
- data/config/rspec.yml +47 -0
- data/config/ruby.yml +388 -0
- data/lib/caliber.rb +4 -20
- data.tar.gz.sig +0 -0
- metadata +97 -50
- metadata.gz.sig +2 -0
- data/.gitignore +0 -11
- data/Gemfile +0 -17
- data/README.md +0 -35
- data/Rakefile +0 -33
- data/app/assets/javascripts/caliber/application.js +0 -1
- data/app/assets/javascripts/caliber/caliber.js +0 -28
- data/app/assets/javascripts/caliber/highlight.pack.js +0 -1
- data/app/assets/stylesheets/caliber/github.css +0 -125
- data/app/controllers/caliber/application_controller.rb +0 -4
- data/app/controllers/caliber/caliber_controller.rb +0 -56
- data/app/views/caliber/caliber/index.html.erb +0 -251
- data/app/views/layouts/caliber/application.html.erb +0 -22
- data/config/routes.rb +0 -4
- data/lib/caliber/engine.rb +0 -5
- data/lib/caliber/version.rb +0 -3
data/Rakefile
DELETED
@@ -1,33 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
require 'rubygems'
|
3
|
-
require 'bundler'
|
4
|
-
|
5
|
-
begin
|
6
|
-
Bundler.setup(:default, :development, :test)
|
7
|
-
rescue Bundler::BundlerError => e
|
8
|
-
$stderr.puts e.message
|
9
|
-
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
-
exit e.status_code
|
11
|
-
end
|
12
|
-
|
13
|
-
require 'rake'
|
14
|
-
require 'rdoc/task'
|
15
|
-
|
16
|
-
require 'rake/testtask'
|
17
|
-
|
18
|
-
Rake::TestTask.new(:test) do |t|
|
19
|
-
t.libs << 'lib'
|
20
|
-
t.libs << 'test'
|
21
|
-
t.pattern = 'test/**/*_test.rb'
|
22
|
-
t.verbose = false
|
23
|
-
end
|
24
|
-
|
25
|
-
task :default => :test
|
26
|
-
|
27
|
-
Rake::RDocTask.new(:rdoc) do |rdoc|
|
28
|
-
rdoc.rdoc_dir = 'rdoc'
|
29
|
-
rdoc.title = 'Caliber'
|
30
|
-
rdoc.options << '--line-numbers' << '--inline-source'
|
31
|
-
rdoc.rdoc_files.include('README.rdoc')
|
32
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
33
|
-
end
|
@@ -1 +0,0 @@
|
|
1
|
-
//= require_tree .
|
@@ -1,28 +0,0 @@
|
|
1
|
-
function each(elems, func) {
|
2
|
-
if (!elems instanceof Array) { elems = [elems]; }
|
3
|
-
for (var i = elems.length; i--; ) {
|
4
|
-
func(elems[i]);
|
5
|
-
}
|
6
|
-
}
|
7
|
-
|
8
|
-
function setValOn(elems, val) {
|
9
|
-
each(elems, function(elem) {
|
10
|
-
elem.innerHTML = val;
|
11
|
-
});
|
12
|
-
}
|
13
|
-
|
14
|
-
function onClick(elems, func) {
|
15
|
-
each(elems, function(elem) {
|
16
|
-
elem.onclick = func;
|
17
|
-
});
|
18
|
-
}
|
19
|
-
|
20
|
-
// Enables functionality to toggle between `_path` and `_url` helper suffixes
|
21
|
-
function setupRouteToggleHelperLinks() {
|
22
|
-
var toggleLinks = document.querySelectorAll('#route_table [data-route-helper]');
|
23
|
-
onClick(toggleLinks, function(){
|
24
|
-
var helperTxt = this.getAttribute("data-route-helper");
|
25
|
-
var helperElems = document.querySelectorAll('[data-route-name] span.helper');
|
26
|
-
setValOn(helperElems, helperTxt);
|
27
|
-
});
|
28
|
-
}
|
@@ -1 +0,0 @@
|
|
1
|
-
var hljs=new function(){function k(v){return v.replace(/&/gm,"&").replace(/</gm,"<").replace(/>/gm,">")}function t(v){return v.nodeName.toLowerCase()}function i(w,x){var v=w&&w.exec(x);return v&&v.index==0}function d(v){return Array.prototype.map.call(v.childNodes,function(w){if(w.nodeType==3){return b.useBR?w.nodeValue.replace(/\n/g,""):w.nodeValue}if(t(w)=="br"){return"\n"}return d(w)}).join("")}function r(w){var v=(w.className+" "+(w.parentNode?w.parentNode.className:"")).split(/\s+/);v=v.map(function(x){return x.replace(/^language-/,"")});return v.filter(function(x){return j(x)||x=="no-highlight"})[0]}function o(x,y){var v={};for(var w in x){v[w]=x[w]}if(y){for(var w in y){v[w]=y[w]}}return v}function u(x){var v=[];(function w(y,z){for(var A=y.firstChild;A;A=A.nextSibling){if(A.nodeType==3){z+=A.nodeValue.length}else{if(t(A)=="br"){z+=1}else{if(A.nodeType==1){v.push({event:"start",offset:z,node:A});z=w(A,z);v.push({event:"stop",offset:z,node:A})}}}}return z})(x,0);return v}function q(w,y,C){var x=0;var F="";var z=[];function B(){if(!w.length||!y.length){return w.length?w:y}if(w[0].offset!=y[0].offset){return(w[0].offset<y[0].offset)?w:y}return y[0].event=="start"?w:y}function A(H){function G(I){return" "+I.nodeName+'="'+k(I.value)+'"'}F+="<"+t(H)+Array.prototype.map.call(H.attributes,G).join("")+">"}function E(G){F+="</"+t(G)+">"}function v(G){(G.event=="start"?A:E)(G.node)}while(w.length||y.length){var D=B();F+=k(C.substr(x,D[0].offset-x));x=D[0].offset;if(D==w){z.reverse().forEach(E);do{v(D.splice(0,1)[0]);D=B()}while(D==w&&D.length&&D[0].offset==x);z.reverse().forEach(A)}else{if(D[0].event=="start"){z.push(D[0].node)}else{z.pop()}v(D.splice(0,1)[0])}}return F+k(C.substr(x))}function m(y){function v(z){return(z&&z.source)||z}function w(A,z){return RegExp(v(A),"m"+(y.cI?"i":"")+(z?"g":""))}function x(D,C){if(D.compiled){return}D.compiled=true;D.k=D.k||D.bK;if(D.k){var z={};function E(G,F){if(y.cI){F=F.toLowerCase()}F.split(" ").forEach(function(H){var I=H.split("|");z[I[0]]=[G,I[1]?Number(I[1]):1]})}if(typeof D.k=="string"){E("keyword",D.k)}else{Object.keys(D.k).forEach(function(F){E(F,D.k[F])})}D.k=z}D.lR=w(D.l||/\b[A-Za-z0-9_]+\b/,true);if(C){if(D.bK){D.b=D.bK.split(" ").join("|")}if(!D.b){D.b=/\B|\b/}D.bR=w(D.b);if(!D.e&&!D.eW){D.e=/\B|\b/}if(D.e){D.eR=w(D.e)}D.tE=v(D.e)||"";if(D.eW&&C.tE){D.tE+=(D.e?"|":"")+C.tE}}if(D.i){D.iR=w(D.i)}if(D.r===undefined){D.r=1}if(!D.c){D.c=[]}var B=[];D.c.forEach(function(F){if(F.v){F.v.forEach(function(G){B.push(o(F,G))})}else{B.push(F=="self"?D:F)}});D.c=B;D.c.forEach(function(F){x(F,D)});if(D.starts){x(D.starts,C)}var A=D.c.map(function(F){return F.bK?"\\.?\\b("+F.b+")\\b\\.?":F.b}).concat([D.tE]).concat([D.i]).map(v).filter(Boolean);D.t=A.length?w(A.join("|"),true):{exec:function(F){return null}};D.continuation={}}x(y)}function c(S,L,J,R){function v(U,V){for(var T=0;T<V.c.length;T++){if(i(V.c[T].bR,U)){return V.c[T]}}}function z(U,T){if(i(U.eR,T)){return U}if(U.eW){return z(U.parent,T)}}function A(T,U){return !J&&i(U.iR,T)}function E(V,T){var U=M.cI?T[0].toLowerCase():T[0];return V.k.hasOwnProperty(U)&&V.k[U]}function w(Z,X,W,V){var T=V?"":b.classPrefix,U='<span class="'+T,Y=W?"":"</span>";U+=Z+'">';return U+X+Y}function N(){var U=k(C);if(!I.k){return U}var T="";var X=0;I.lR.lastIndex=0;var V=I.lR.exec(U);while(V){T+=U.substr(X,V.index-X);var W=E(I,V);if(W){H+=W[1];T+=w(W[0],V[0])}else{T+=V[0]}X=I.lR.lastIndex;V=I.lR.exec(U)}return T+U.substr(X)}function F(){if(I.sL&&!f[I.sL]){return k(C)}var T=I.sL?c(I.sL,C,true,I.continuation.top):g(C);if(I.r>0){H+=T.r}if(I.subLanguageMode=="continuous"){I.continuation.top=T.top}return w(T.language,T.value,false,true)}function Q(){return I.sL!==undefined?F():N()}function P(V,U){var T=V.cN?w(V.cN,"",true):"";if(V.rB){D+=T;C=""}else{if(V.eB){D+=k(U)+T;C=""}else{D+=T;C=U}}I=Object.create(V,{parent:{value:I}})}function G(T,X){C+=T;if(X===undefined){D+=Q();return 0}var V=v(X,I);if(V){D+=Q();P(V,X);return V.rB?0:X.length}var W=z(I,X);if(W){var U=I;if(!(U.rE||U.eE)){C+=X}D+=Q();do{if(I.cN){D+="</span>"}H+=I.r;I=I.parent}while(I!=W.parent);if(U.eE){D+=k(X)}C="";if(W.starts){P(W.starts,"")}return U.rE?0:X.length}if(A(X,I)){throw new Error('Illegal lexeme "'+X+'" for mode "'+(I.cN||"<unnamed>")+'"')}C+=X;return X.length||1}var M=j(S);if(!M){throw new Error('Unknown language: "'+S+'"')}m(M);var I=R||M;var D="";for(var K=I;K!=M;K=K.parent){if(K.cN){D=w(K.cN,D,true)}}var C="";var H=0;try{var B,y,x=0;while(true){I.t.lastIndex=x;B=I.t.exec(L);if(!B){break}y=G(L.substr(x,B.index-x),B[0]);x=B.index+y}G(L.substr(x));for(var K=I;K.parent;K=K.parent){if(K.cN){D+="</span>"}}return{r:H,value:D,language:S,top:I}}catch(O){if(O.message.indexOf("Illegal")!=-1){return{r:0,value:k(L)}}else{throw O}}}function g(y,x){x=x||b.languages||Object.keys(f);var v={r:0,value:k(y)};var w=v;x.forEach(function(z){if(!j(z)){return}var A=c(z,y,false);A.language=z;if(A.r>w.r){w=A}if(A.r>v.r){w=v;v=A}});if(w.language){v.second_best=w}return v}function h(v){if(b.tabReplace){v=v.replace(/^((<[^>]+>|\t)+)/gm,function(w,z,y,x){return z.replace(/\t/g,b.tabReplace)})}if(b.useBR){v=v.replace(/\n/g,"<br>")}return v}function p(z){var y=d(z);var A=r(z);if(A=="no-highlight"){return}var v=A?c(A,y,true):g(y);var w=u(z);if(w.length){var x=document.createElementNS("http://www.w3.org/1999/xhtml","pre");x.innerHTML=v.value;v.value=q(w,u(x),y)}v.value=h(v.value);z.innerHTML=v.value;z.className+=" hljs "+(!A&&v.language||"");z.result={language:v.language,re:v.r};if(v.second_best){z.second_best={language:v.second_best.language,re:v.second_best.r}}}var b={classPrefix:"hljs-",tabReplace:null,useBR:false,languages:undefined};function s(v){b=o(b,v)}function l(){if(l.called){return}l.called=true;var v=document.querySelectorAll("pre code");Array.prototype.forEach.call(v,p)}function a(){addEventListener("DOMContentLoaded",l,false);addEventListener("load",l,false)}var f={};var n={};function e(v,x){var w=f[v]=x(this);if(w.aliases){w.aliases.forEach(function(y){n[y]=v})}}function j(v){return f[v]||f[n[v]]}this.highlight=c;this.highlightAuto=g;this.fixMarkup=h;this.highlightBlock=p;this.configure=s;this.initHighlighting=l;this.initHighlightingOnLoad=a;this.registerLanguage=e;this.getLanguage=j;this.inherit=o;this.IR="[a-zA-Z][a-zA-Z0-9_]*";this.UIR="[a-zA-Z_][a-zA-Z0-9_]*";this.NR="\\b\\d+(\\.\\d+)?";this.CNR="(\\b0[xX][a-fA-F0-9]+|(\\b\\d+(\\.\\d*)?|\\.\\d+)([eE][-+]?\\d+)?)";this.BNR="\\b(0b[01]+)";this.RSR="!|!=|!==|%|%=|&|&&|&=|\\*|\\*=|\\+|\\+=|,|-|-=|/=|/|:|;|<<|<<=|<=|<|===|==|=|>>>=|>>=|>=|>>>|>>|>|\\?|\\[|\\{|\\(|\\^|\\^=|\\||\\|=|\\|\\||~";this.BE={b:"\\\\[\\s\\S]",r:0};this.ASM={cN:"string",b:"'",e:"'",i:"\\n",c:[this.BE]};this.QSM={cN:"string",b:'"',e:'"',i:"\\n",c:[this.BE]};this.CLCM={cN:"comment",b:"//",e:"$"};this.CBLCLM={cN:"comment",b:"/\\*",e:"\\*/"};this.HCM={cN:"comment",b:"#",e:"$"};this.NM={cN:"number",b:this.NR,r:0};this.CNM={cN:"number",b:this.CNR,r:0};this.BNM={cN:"number",b:this.BNR,r:0};this.REGEXP_MODE={cN:"regexp",b:/\//,e:/\/[gim]*/,i:/\n/,c:[this.BE,{b:/\[/,e:/\]/,r:0,c:[this.BE]}]};this.TM={cN:"title",b:this.IR,r:0};this.UTM={cN:"title",b:this.UIR,r:0}}();hljs.registerLanguage("css",function(a){var b="[a-zA-Z-][a-zA-Z0-9_-]*";var c={cN:"function",b:b+"\\(",e:"\\)",c:["self",a.NM,a.ASM,a.QSM]};return{cI:true,i:"[=/|']",c:[a.CBLCLM,{cN:"id",b:"\\#[A-Za-z0-9_-]+"},{cN:"class",b:"\\.[A-Za-z0-9_-]+",r:0},{cN:"attr_selector",b:"\\[",e:"\\]",i:"$"},{cN:"pseudo",b:":(:)?[a-zA-Z0-9\\_\\-\\+\\(\\)\\\"\\']+"},{cN:"at_rule",b:"@(font-face|page)",l:"[a-z-]+",k:"font-face page"},{cN:"at_rule",b:"@",e:"[{;]",c:[{cN:"keyword",b:/\S+/},{b:/\s/,eW:true,eE:true,r:0,c:[c,a.ASM,a.QSM,a.NM]}]},{cN:"tag",b:b,r:0},{cN:"rules",b:"{",e:"}",i:"[^\\s]",r:0,c:[a.CBLCLM,{cN:"rule",b:"[^\\s]",rB:true,e:";",eW:true,c:[{cN:"attribute",b:"[A-Z\\_\\.\\-]+",e:":",eE:true,i:"[^\\s]",starts:{cN:"value",eW:true,eE:true,c:[c,a.NM,a.QSM,a.ASM,a.CBLCLM,{cN:"hexcolor",b:"#[0-9A-Fa-f]+"},{cN:"important",b:"!important"}]}}]}]}]}});
|
@@ -1,125 +0,0 @@
|
|
1
|
-
/*
|
2
|
-
|
3
|
-
github.com style (c) Vasily Polovnyov <vast@whiteants.net>
|
4
|
-
|
5
|
-
*/
|
6
|
-
|
7
|
-
.hljs {
|
8
|
-
display: block; padding: 0.5em;
|
9
|
-
color: #333;
|
10
|
-
background: #f8f8f8
|
11
|
-
}
|
12
|
-
|
13
|
-
.hljs-comment,
|
14
|
-
.hljs-template_comment,
|
15
|
-
.diff .hljs-header,
|
16
|
-
.hljs-javadoc {
|
17
|
-
color: #998;
|
18
|
-
font-style: italic
|
19
|
-
}
|
20
|
-
|
21
|
-
.hljs-keyword,
|
22
|
-
.css .rule .hljs-keyword,
|
23
|
-
.hljs-winutils,
|
24
|
-
.javascript .hljs-title,
|
25
|
-
.nginx .hljs-title,
|
26
|
-
.hljs-subst,
|
27
|
-
.hljs-request,
|
28
|
-
.hljs-status {
|
29
|
-
color: #333;
|
30
|
-
font-weight: bold
|
31
|
-
}
|
32
|
-
|
33
|
-
.hljs-number,
|
34
|
-
.hljs-hexcolor,
|
35
|
-
.ruby .hljs-constant {
|
36
|
-
color: #099;
|
37
|
-
}
|
38
|
-
|
39
|
-
.hljs-string,
|
40
|
-
.hljs-tag .hljs-value,
|
41
|
-
.hljs-phpdoc,
|
42
|
-
.tex .hljs-formula {
|
43
|
-
color: #d14
|
44
|
-
}
|
45
|
-
|
46
|
-
.hljs-title,
|
47
|
-
.hljs-id,
|
48
|
-
.coffeescript .hljs-params,
|
49
|
-
.scss .hljs-preprocessor {
|
50
|
-
color: #900;
|
51
|
-
font-weight: bold
|
52
|
-
}
|
53
|
-
|
54
|
-
.javascript .hljs-title,
|
55
|
-
.lisp .hljs-title,
|
56
|
-
.clojure .hljs-title,
|
57
|
-
.hljs-subst {
|
58
|
-
font-weight: normal
|
59
|
-
}
|
60
|
-
|
61
|
-
.hljs-class .hljs-title,
|
62
|
-
.haskell .hljs-type,
|
63
|
-
.vhdl .hljs-literal,
|
64
|
-
.tex .hljs-command {
|
65
|
-
color: #458;
|
66
|
-
font-weight: bold
|
67
|
-
}
|
68
|
-
|
69
|
-
.hljs-tag,
|
70
|
-
.hljs-tag .hljs-title,
|
71
|
-
.hljs-rules .hljs-property,
|
72
|
-
.django .hljs-tag .hljs-keyword {
|
73
|
-
color: #000080;
|
74
|
-
font-weight: normal
|
75
|
-
}
|
76
|
-
|
77
|
-
.hljs-attribute,
|
78
|
-
.hljs-variable,
|
79
|
-
.lisp .hljs-body {
|
80
|
-
color: #008080
|
81
|
-
}
|
82
|
-
|
83
|
-
.hljs-regexp {
|
84
|
-
color: #009926
|
85
|
-
}
|
86
|
-
|
87
|
-
.hljs-symbol,
|
88
|
-
.ruby .hljs-symbol .hljs-string,
|
89
|
-
.lisp .hljs-keyword,
|
90
|
-
.tex .hljs-special,
|
91
|
-
.hljs-prompt {
|
92
|
-
color: #990073
|
93
|
-
}
|
94
|
-
|
95
|
-
.hljs-built_in,
|
96
|
-
.lisp .hljs-title,
|
97
|
-
.clojure .hljs-built_in {
|
98
|
-
color: #0086b3
|
99
|
-
}
|
100
|
-
|
101
|
-
.hljs-preprocessor,
|
102
|
-
.hljs-pragma,
|
103
|
-
.hljs-pi,
|
104
|
-
.hljs-doctype,
|
105
|
-
.hljs-shebang,
|
106
|
-
.hljs-cdata {
|
107
|
-
color: #999;
|
108
|
-
font-weight: bold
|
109
|
-
}
|
110
|
-
|
111
|
-
.hljs-deletion {
|
112
|
-
background: #fdd
|
113
|
-
}
|
114
|
-
|
115
|
-
.hljs-addition {
|
116
|
-
background: #dfd
|
117
|
-
}
|
118
|
-
|
119
|
-
.diff .hljs-change {
|
120
|
-
background: #0086b3
|
121
|
-
}
|
122
|
-
|
123
|
-
.hljs-chunk {
|
124
|
-
color: #aaa
|
125
|
-
}
|
@@ -1,56 +0,0 @@
|
|
1
|
-
require 'css_parser'
|
2
|
-
|
3
|
-
module Caliber
|
4
|
-
class CaliberController < Caliber::ApplicationController
|
5
|
-
include ::CssParser
|
6
|
-
|
7
|
-
layout 'caliber/application'
|
8
|
-
|
9
|
-
before_filter :require_local!
|
10
|
-
|
11
|
-
def index
|
12
|
-
@css_selectors = []
|
13
|
-
|
14
|
-
Rails.application.assets.each_file do |pathname|
|
15
|
-
|
16
|
-
next unless Rails.application.assets.content_type_of(pathname) == 'text/css'
|
17
|
-
|
18
|
-
#next if @css_selectors.any?
|
19
|
-
|
20
|
-
parser = CssParser::Parser.new
|
21
|
-
|
22
|
-
begin
|
23
|
-
link = Rails.application.assets[pathname].to_s
|
24
|
-
parser.add_block! link
|
25
|
-
|
26
|
-
selectors = parser.to_enum(:each_selector).map do |selectors, declarations, specificity, media_types|
|
27
|
-
declarations = declarations.gsub ";", ";<br>"
|
28
|
-
{
|
29
|
-
pathname: pathname.to_s,
|
30
|
-
selector: selectors,
|
31
|
-
declarations: declarations,
|
32
|
-
specificity: specificity,
|
33
|
-
media_types: media_types
|
34
|
-
}
|
35
|
-
end
|
36
|
-
|
37
|
-
@css_selectors.concat selectors
|
38
|
-
rescue
|
39
|
-
end
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
private
|
44
|
-
def require_local!
|
45
|
-
unless local_request?
|
46
|
-
render :text => '<p>For security purposes, this information is only available to local requests.</p>', :status => :forbidden
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def local_request?
|
51
|
-
Rails.application.config.consider_all_requests_local || request.local?
|
52
|
-
end
|
53
|
-
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
@@ -1,251 +0,0 @@
|
|
1
|
-
<style type="text/css">
|
2
|
-
.result {
|
3
|
-
width: 500px;
|
4
|
-
padding: 10px;
|
5
|
-
}
|
6
|
-
|
7
|
-
.selector,
|
8
|
-
.selector > input {
|
9
|
-
font-size: 20px;
|
10
|
-
font-weight: bold;
|
11
|
-
}
|
12
|
-
|
13
|
-
.pathname,
|
14
|
-
.pathname > input {
|
15
|
-
color: grey;
|
16
|
-
font-size: 0.8em;
|
17
|
-
}
|
18
|
-
|
19
|
-
.mediatypes {
|
20
|
-
color: grey;
|
21
|
-
float: right;
|
22
|
-
}
|
23
|
-
|
24
|
-
.mediatypes input {
|
25
|
-
text-align: right;
|
26
|
-
}
|
27
|
-
|
28
|
-
.results-list {
|
29
|
-
list-style-type: none;
|
30
|
-
padding: 0;
|
31
|
-
float: left;
|
32
|
-
}
|
33
|
-
|
34
|
-
.results-list > li:hover {
|
35
|
-
background-color: lightgrey;
|
36
|
-
}
|
37
|
-
|
38
|
-
.results-list > li {
|
39
|
-
border-bottom: #C0C0C0 1px solid;
|
40
|
-
}
|
41
|
-
|
42
|
-
.filter {
|
43
|
-
border-right: black solid 1px;
|
44
|
-
float: left;
|
45
|
-
}
|
46
|
-
|
47
|
-
.filter input,
|
48
|
-
#rule-name {
|
49
|
-
border: none;
|
50
|
-
background-color: none;
|
51
|
-
color: black;
|
52
|
-
border-bottom-width: 1px;
|
53
|
-
border-bottom-style: dashed;
|
54
|
-
border-bottom-color: grey;
|
55
|
-
}
|
56
|
-
|
57
|
-
.rule-filter {
|
58
|
-
float: left;
|
59
|
-
}
|
60
|
-
|
61
|
-
.pathname > input {
|
62
|
-
width: 350px;
|
63
|
-
}
|
64
|
-
|
65
|
-
.selector > input {
|
66
|
-
width: 300px;
|
67
|
-
}
|
68
|
-
|
69
|
-
.top-header {
|
70
|
-
position: fixed;
|
71
|
-
top:0;
|
72
|
-
width: 100%;
|
73
|
-
border-bottom: black 1px solid;
|
74
|
-
background-color: white;;
|
75
|
-
}
|
76
|
-
|
77
|
-
.content {
|
78
|
-
margin-top: 70px;
|
79
|
-
}
|
80
|
-
|
81
|
-
.code-preview {
|
82
|
-
position: absolute;
|
83
|
-
bottom: 0;
|
84
|
-
top: 69px;
|
85
|
-
left:501px;
|
86
|
-
right:0;
|
87
|
-
}
|
88
|
-
|
89
|
-
.results-list-container {
|
90
|
-
overflow: auto;
|
91
|
-
width: 500px;
|
92
|
-
position: absolute;
|
93
|
-
bottom:0;
|
94
|
-
top:69px;
|
95
|
-
left:0;
|
96
|
-
}
|
97
|
-
|
98
|
-
pre {
|
99
|
-
padding: 0;
|
100
|
-
border: 0;
|
101
|
-
height: 100%
|
102
|
-
}
|
103
|
-
|
104
|
-
pre code {
|
105
|
-
height: 100%
|
106
|
-
}
|
107
|
-
|
108
|
-
#rule-name {
|
109
|
-
margin: 15px;
|
110
|
-
width: 300px;
|
111
|
-
}
|
112
|
-
|
113
|
-
</style>
|
114
|
-
|
115
|
-
<div class="top-header">
|
116
|
-
<div class="result filter">
|
117
|
-
<div class="mediatypes">
|
118
|
-
<input type="text" id='mediatype' value='' placeholder='media type'>
|
119
|
-
</div>
|
120
|
-
<div class="selector">
|
121
|
-
<input type="text" id='selector' value='' placeholder='css selector'>
|
122
|
-
</div>
|
123
|
-
<div class="pathname">
|
124
|
-
<input type="text" id='pathname' placeholder='css file path'>
|
125
|
-
</div>
|
126
|
-
</div>
|
127
|
-
|
128
|
-
<div class="rule-filter">
|
129
|
-
<input type="text" id='rule-name' placeholder='css rule'>
|
130
|
-
</div>
|
131
|
-
</div>
|
132
|
-
|
133
|
-
<div class="content">
|
134
|
-
<div class="results-list-container">
|
135
|
-
<ul class="results-list">
|
136
|
-
</ul>
|
137
|
-
</div>
|
138
|
-
<div class="code-preview">
|
139
|
-
|
140
|
-
</div>
|
141
|
-
</div>
|
142
|
-
|
143
|
-
<div class="template-result" style="display:none;">
|
144
|
-
<li class="result">
|
145
|
-
<div class="mediatypes"></div>
|
146
|
-
<div class="selector"></div>
|
147
|
-
<div class="pathname"></div>
|
148
|
-
</li>
|
149
|
-
</div>
|
150
|
-
|
151
|
-
<script type="text/javascript">
|
152
|
-
$(function () {
|
153
|
-
var data = <%= @css_selectors.to_json.html_safe %>;
|
154
|
-
|
155
|
-
window.gg = data;
|
156
|
-
|
157
|
-
function debounce(fn, delay) {
|
158
|
-
var timer = null;
|
159
|
-
return function () {
|
160
|
-
var context = this, args = arguments;
|
161
|
-
clearTimeout(timer);
|
162
|
-
timer = setTimeout(function () {
|
163
|
-
fn.apply(context, args);
|
164
|
-
}, delay);
|
165
|
-
};
|
166
|
-
}
|
167
|
-
|
168
|
-
var filterData = function () {
|
169
|
-
var filter_selector = $("#selector").val();
|
170
|
-
var filter_pathname = $("#pathname").val();
|
171
|
-
var filter_mediatype = $("#mediatype").val();
|
172
|
-
var filter_css = $("#rule-name").val();
|
173
|
-
var max_results = 200;
|
174
|
-
|
175
|
-
var result = [];
|
176
|
-
|
177
|
-
for (var i = 0; i < data.length; i++) {
|
178
|
-
if (result.length >= max_results) {
|
179
|
-
break;
|
180
|
-
}
|
181
|
-
var item = data[i];
|
182
|
-
if (item.selector.indexOf(filter_selector) != -1 &&
|
183
|
-
item.pathname.indexOf(filter_pathname) != -1 &&
|
184
|
-
item.declarations.indexOf(filter_css) != -1 ) {
|
185
|
-
|
186
|
-
var media_match = false;
|
187
|
-
for (var b = 0; b < item.media_types.length; b++) {
|
188
|
-
if (item.media_types[b].indexOf(filter_mediatype) != -1) {
|
189
|
-
media_match = true;
|
190
|
-
}
|
191
|
-
}
|
192
|
-
|
193
|
-
if (media_match || (item.media_types.length == 0 && filter_mediatype.length == 0)) {
|
194
|
-
item.index_id = i;
|
195
|
-
result.push(item);
|
196
|
-
}
|
197
|
-
}
|
198
|
-
}
|
199
|
-
|
200
|
-
return result;
|
201
|
-
}
|
202
|
-
|
203
|
-
var render = function (list) {
|
204
|
-
var results_list = $('.results-list');
|
205
|
-
var template = $('.template-result');
|
206
|
-
template = $(template.html());
|
207
|
-
|
208
|
-
results_list.html('');
|
209
|
-
for (var i = 0; i < list.length; i++) {
|
210
|
-
var item = list[i];
|
211
|
-
|
212
|
-
var html = template.clone();
|
213
|
-
html.data('index-id', item.index_id)
|
214
|
-
html.find('.selector').text(item.selector);
|
215
|
-
html.find('.pathname').text(item.pathname);
|
216
|
-
html.find('.mediatypes').text(item.media_types.join(','));
|
217
|
-
|
218
|
-
results_list.append(html);
|
219
|
-
}
|
220
|
-
|
221
|
-
}
|
222
|
-
|
223
|
-
var update = debounce(function () {
|
224
|
-
var filteredData = filterData();
|
225
|
-
render(filteredData);
|
226
|
-
}, 500);
|
227
|
-
|
228
|
-
$('.filter').on('keyup', 'input', update);
|
229
|
-
$('#rule-name').on('keyup', update);
|
230
|
-
|
231
|
-
$('.results-list').on('mouseenter', 'li', function (e) {
|
232
|
-
|
233
|
-
var elem = $(this);
|
234
|
-
var item = data[elem.data('index-id')];
|
235
|
-
|
236
|
-
var html = '<pre><code class="css">';
|
237
|
-
html += item.selector + ' {\n ';
|
238
|
-
html += item.declarations;
|
239
|
-
html += '};';
|
240
|
-
html += '</code></pre>';
|
241
|
-
|
242
|
-
$('.code-preview').html(html);
|
243
|
-
|
244
|
-
$('pre code').each(function (i, e) {
|
245
|
-
hljs.highlightBlock(e)
|
246
|
-
});
|
247
|
-
|
248
|
-
});
|
249
|
-
});
|
250
|
-
|
251
|
-
</script>
|
@@ -1,22 +0,0 @@
|
|
1
|
-
<!DOCTYPE html>
|
2
|
-
<html lang="en">
|
3
|
-
<head>
|
4
|
-
<meta charset="UTF-8" />
|
5
|
-
<title>Caliber of CSS rules</title>
|
6
|
-
|
7
|
-
<%= csrf_meta_tags %>
|
8
|
-
|
9
|
-
<%= javascript_include_tag 'http://code.jquery.com/jquery-1.11.0.min.js' %>
|
10
|
-
<%= javascript_include_tag "caliber/application" %>
|
11
|
-
<%= stylesheet_link_tag "caliber/github" %>
|
12
|
-
|
13
|
-
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.3/css/bootstrap.min.css" rel="stylesheet">
|
14
|
-
<!--<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>-->
|
15
|
-
|
16
|
-
</head>
|
17
|
-
<body>
|
18
|
-
|
19
|
-
<%= yield %>
|
20
|
-
|
21
|
-
</body>
|
22
|
-
</html>
|
data/config/routes.rb
DELETED
data/lib/caliber/engine.rb
DELETED
data/lib/caliber/version.rb
DELETED