vebdew 0.0.2 → 0.0.3
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.
- data/README.md +70 -42
- data/VERSION +1 -1
- data/lib/template/css/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/lib/template/css/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/lib/template/css/images/ui-bg_gloss-wave_16_121212_500x100.png +0 -0
- data/lib/template/css/images/ui-bg_highlight-hard_15_888888_1x100.png +0 -0
- data/lib/template/css/images/ui-bg_highlight-hard_55_555555_1x100.png +0 -0
- data/lib/template/css/images/ui-bg_highlight-soft_35_adadad_1x100.png +0 -0
- data/lib/template/css/images/ui-bg_highlight-soft_60_dddddd_1x100.png +0 -0
- data/lib/template/css/images/ui-bg_inset-soft_15_121212_1x100.png +0 -0
- data/lib/template/css/images/ui-icons_666666_256x240.png +0 -0
- data/lib/template/css/images/ui-icons_aaaaaa_256x240.png +0 -0
- data/lib/template/css/images/ui-icons_bbbbbb_256x240.png +0 -0
- data/lib/template/css/images/ui-icons_c98000_256x240.png +0 -0
- data/lib/template/css/images/ui-icons_cccccc_256x240.png +0 -0
- data/lib/template/css/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/lib/template/css/images/ui-icons_f29a00_256x240.png +0 -0
- data/lib/template/css/jquery-ui.css +306 -0
- data/lib/template/css/main.css +800 -0
- data/lib/template/css/reset.css +57 -0
- data/lib/template/css/ruler.css +34 -0
- data/lib/template/css/sample.css +128 -0
- data/lib/template/css/styles.css +102 -0
- data/lib/template/js/index.js +57 -0
- data/lib/template/js/init.js +6 -0
- data/lib/template/js/jquery-ui.min.js +76 -0
- data/lib/template/js/jquery.min.js +4 -0
- data/lib/template/js/reveal.js +705 -0
- data/lib/template/js/ruler.js +9 -0
- data/lib/template/js/sample.js +120 -0
- data/lib/template/vew/sample.vew +1 -1
- data/lib/vebdew/parser.rb +5 -1
- data/vebdew.gemspec +29 -1
- metadata +40 -12
@@ -0,0 +1,120 @@
|
|
1
|
+
/*global CodeMirror, hljs */
|
2
|
+
(function($, undefined){
|
3
|
+
"use strict";
|
4
|
+
|
5
|
+
// cached DOM elements
|
6
|
+
var $sampleContainerSrc = $('<div class="sample-container"></div>'),
|
7
|
+
$codeSrc = $('<code contenteditable></code>'),
|
8
|
+
$preSrc = $('<pre></pre>'),
|
9
|
+
$iframeSrc = $('<div class="iframe"><iframe></iframe></div>'),
|
10
|
+
$updateBtnSrc = $('<button>»</button>'),
|
11
|
+
|
12
|
+
updateIframe = function(iframe, $pre, wrapper){
|
13
|
+
var doc = iframe.contentDocument, newiframe,
|
14
|
+
height = $pre.height() || 200;
|
15
|
+
if(!doc){ // if cannot get iframe content, create a new one
|
16
|
+
newiframe = $('<iframe></iframe>').insertBefore(iframe).get(0);
|
17
|
+
$(iframe).remove();
|
18
|
+
iframe = newiframe; doc = iframe.contentDocument;
|
19
|
+
}
|
20
|
+
doc.open(); doc.writeln( wrapper($pre.text()) ); doc.close();
|
21
|
+
$(iframe).height(height);
|
22
|
+
|
23
|
+
// highligt the code
|
24
|
+
var $code = $pre.find('code'), // get $code to get unhighlighted text
|
25
|
+
ret = hljs.highlightAuto($code.text());
|
26
|
+
$code.html(ret.value);
|
27
|
+
$code.addClass(ret.language)
|
28
|
+
|
29
|
+
return iframe; // return the (possibly new) iframe
|
30
|
+
};
|
31
|
+
|
32
|
+
// example usage:
|
33
|
+
// $('script[type=text/x-sample]').sample();
|
34
|
+
//
|
35
|
+
$.fn.sample = function(options){
|
36
|
+
// 'this' should be <script> jQuery object
|
37
|
+
//
|
38
|
+
|
39
|
+
// method invocation
|
40
|
+
if(typeof arguments[0] === 'string'){
|
41
|
+
var args = arguments;
|
42
|
+
this.each(function(){
|
43
|
+
var method = $(this).data('sample')[options];
|
44
|
+
method.apply(this, Array.prototype.slice.call(args,1));
|
45
|
+
});
|
46
|
+
return; // do not execute the init part below
|
47
|
+
}
|
48
|
+
|
49
|
+
options = $.extend({
|
50
|
+
wrapper: function(lines){ // default wrapper: no-op
|
51
|
+
return lines;
|
52
|
+
}
|
53
|
+
}, options);
|
54
|
+
|
55
|
+
this.each(function(){
|
56
|
+
var
|
57
|
+
indent = 100, // shortest indent
|
58
|
+
lines = $(this).html().split('\n'); // lines of code
|
59
|
+
|
60
|
+
// finding indent
|
61
|
+
$.each(lines, function(){
|
62
|
+
var space = this.search(/[^ ]/);
|
63
|
+
if(space>0){
|
64
|
+
indent = Math.min(space, indent);
|
65
|
+
}
|
66
|
+
});
|
67
|
+
|
68
|
+
// removing indent & empty lines
|
69
|
+
lines = $.map(lines, function(l){
|
70
|
+
return l.substr(indent);
|
71
|
+
});
|
72
|
+
|
73
|
+
// remove leading & trailing empty lines
|
74
|
+
while(lines[0] === ''){
|
75
|
+
lines.shift();
|
76
|
+
}
|
77
|
+
while(lines[lines.length-1] === ''){
|
78
|
+
lines.pop();
|
79
|
+
}
|
80
|
+
|
81
|
+
// join lines
|
82
|
+
lines = lines.join('\n');
|
83
|
+
|
84
|
+
|
85
|
+
// output stage
|
86
|
+
//
|
87
|
+
// the container of all the elements, and
|
88
|
+
// insert the container below the script tag.
|
89
|
+
var $sampleContainer = $sampleContainerSrc.clone()
|
90
|
+
.addClass(this.className)
|
91
|
+
.insertAfter(this);
|
92
|
+
|
93
|
+
// append the code and append it to the container.
|
94
|
+
var $code = $codeSrc.clone().text(lines),
|
95
|
+
$pre = $preSrc.clone().append($code).appendTo($sampleContainer);
|
96
|
+
|
97
|
+
|
98
|
+
// previewing iframe
|
99
|
+
var iframe = $iframeSrc.clone().appendTo($sampleContainer).find('iframe').get(0);
|
100
|
+
$(iframe).ready(function(){
|
101
|
+
updateIframe(iframe, $pre, options.wrapper);
|
102
|
+
});
|
103
|
+
|
104
|
+
// update button
|
105
|
+
var $updateBtn = $updateBtnSrc.clone().insertAfter($pre);
|
106
|
+
$updateBtn.click(function(){
|
107
|
+
// updating iframe and highlight the $pre again
|
108
|
+
iframe = updateIframe(iframe, $pre, options.wrapper);
|
109
|
+
});
|
110
|
+
|
111
|
+
|
112
|
+
// install methods to data('sample')
|
113
|
+
$(this).data('sample', {
|
114
|
+
update: function(){
|
115
|
+
iframe = updateIframe(iframe, $pre, options.wrapper);
|
116
|
+
}
|
117
|
+
});
|
118
|
+
});
|
119
|
+
}
|
120
|
+
}(jQuery));
|
data/lib/template/vew/sample.vew
CHANGED
@@ -10,7 +10,7 @@
|
|
10
10
|
:javascript_include_tag js/jquery.min.js
|
11
11
|
:javascript_include_tag https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js
|
12
12
|
:javascript_include_tag js/reveal.js, lib/highlight.js, js/ruler.js, js/sample.js
|
13
|
-
:javascript_include_tag js/index.js
|
13
|
+
:javascript_include_tag js/init.js, js/index.js
|
14
14
|
|
15
15
|
!SLIDE
|
16
16
|
|
data/lib/vebdew/parser.rb
CHANGED
@@ -152,6 +152,10 @@ module Vebdew
|
|
152
152
|
str
|
153
153
|
end
|
154
154
|
|
155
|
+
def escape_html str
|
156
|
+
str.gsub(/>/, ">").gsub(/</, "<")
|
157
|
+
end
|
158
|
+
|
155
159
|
def format_buffer
|
156
160
|
@buffer.map! do |buf|
|
157
161
|
"<p#{append}>#{format_content(buf)}</p>"
|
@@ -160,7 +164,7 @@ module Vebdew
|
|
160
164
|
|
161
165
|
def format_content str
|
162
166
|
str.strip!
|
163
|
-
str.gsub!
|
167
|
+
str.gsub!(/`(([^\\`]|\\.)*)`/) {%Q{<code>#{escape_html($1)}</code>}}
|
164
168
|
str.gsub! /\!\[([^\]]+)\]\(([^\)]+)\)/, %q{<img src='\1' alt='\2'>}
|
165
169
|
str.gsub! /\!\[([^\]]+)\]/, %q{<img src='\1'>}
|
166
170
|
str.gsub! /\[([^\]]+)\]\(([^\)]+)\)/, %q{<a href='\1'>\2</a>}
|
data/vebdew.gemspec
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = "vebdew"
|
8
|
-
s.version = "0.0.
|
8
|
+
s.version = "0.0.3"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Andrew Liu"]
|
@@ -26,6 +26,34 @@ Gem::Specification.new do |s|
|
|
26
26
|
"Rakefile",
|
27
27
|
"VERSION",
|
28
28
|
"bin/vebdew",
|
29
|
+
"lib/template/css/images/ui-bg_flat_0_aaaaaa_40x100.png",
|
30
|
+
"lib/template/css/images/ui-bg_glass_95_fef1ec_1x400.png",
|
31
|
+
"lib/template/css/images/ui-bg_gloss-wave_16_121212_500x100.png",
|
32
|
+
"lib/template/css/images/ui-bg_highlight-hard_15_888888_1x100.png",
|
33
|
+
"lib/template/css/images/ui-bg_highlight-hard_55_555555_1x100.png",
|
34
|
+
"lib/template/css/images/ui-bg_highlight-soft_35_adadad_1x100.png",
|
35
|
+
"lib/template/css/images/ui-bg_highlight-soft_60_dddddd_1x100.png",
|
36
|
+
"lib/template/css/images/ui-bg_inset-soft_15_121212_1x100.png",
|
37
|
+
"lib/template/css/images/ui-icons_666666_256x240.png",
|
38
|
+
"lib/template/css/images/ui-icons_aaaaaa_256x240.png",
|
39
|
+
"lib/template/css/images/ui-icons_bbbbbb_256x240.png",
|
40
|
+
"lib/template/css/images/ui-icons_c98000_256x240.png",
|
41
|
+
"lib/template/css/images/ui-icons_cccccc_256x240.png",
|
42
|
+
"lib/template/css/images/ui-icons_cd0a0a_256x240.png",
|
43
|
+
"lib/template/css/images/ui-icons_f29a00_256x240.png",
|
44
|
+
"lib/template/css/jquery-ui.css",
|
45
|
+
"lib/template/css/main.css",
|
46
|
+
"lib/template/css/reset.css",
|
47
|
+
"lib/template/css/ruler.css",
|
48
|
+
"lib/template/css/sample.css",
|
49
|
+
"lib/template/css/styles.css",
|
50
|
+
"lib/template/js/index.js",
|
51
|
+
"lib/template/js/init.js",
|
52
|
+
"lib/template/js/jquery-ui.min.js",
|
53
|
+
"lib/template/js/jquery.min.js",
|
54
|
+
"lib/template/js/reveal.js",
|
55
|
+
"lib/template/js/ruler.js",
|
56
|
+
"lib/template/js/sample.js",
|
29
57
|
"lib/template/vew/sample.vew",
|
30
58
|
"lib/template/vew/template.erb",
|
31
59
|
"lib/vebdew.rb",
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vebdew
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -13,7 +13,7 @@ date: 2012-03-10 00:00:00.000000000Z
|
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: erubis
|
16
|
-
requirement: &
|
16
|
+
requirement: &2154113200 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: '0'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *2154113200
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: shoulda
|
27
|
-
requirement: &
|
27
|
+
requirement: &2154112480 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *2154112480
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: rdoc
|
38
|
-
requirement: &
|
38
|
+
requirement: &2154111680 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: '3.12'
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *2154111680
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: bundler
|
49
|
-
requirement: &
|
49
|
+
requirement: &2154110680 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,10 +54,10 @@ dependencies:
|
|
54
54
|
version: 1.0.0
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *2154110680
|
58
58
|
- !ruby/object:Gem::Dependency
|
59
59
|
name: jeweler
|
60
|
-
requirement: &
|
60
|
+
requirement: &2154109620 !ruby/object:Gem::Requirement
|
61
61
|
none: false
|
62
62
|
requirements:
|
63
63
|
- - ~>
|
@@ -65,7 +65,7 @@ dependencies:
|
|
65
65
|
version: 1.8.3
|
66
66
|
type: :development
|
67
67
|
prerelease: false
|
68
|
-
version_requirements: *
|
68
|
+
version_requirements: *2154109620
|
69
69
|
description: Generate HTML5 slides
|
70
70
|
email: andrewliu33@gmail.com
|
71
71
|
executables:
|
@@ -83,6 +83,34 @@ files:
|
|
83
83
|
- Rakefile
|
84
84
|
- VERSION
|
85
85
|
- bin/vebdew
|
86
|
+
- lib/template/css/images/ui-bg_flat_0_aaaaaa_40x100.png
|
87
|
+
- lib/template/css/images/ui-bg_glass_95_fef1ec_1x400.png
|
88
|
+
- lib/template/css/images/ui-bg_gloss-wave_16_121212_500x100.png
|
89
|
+
- lib/template/css/images/ui-bg_highlight-hard_15_888888_1x100.png
|
90
|
+
- lib/template/css/images/ui-bg_highlight-hard_55_555555_1x100.png
|
91
|
+
- lib/template/css/images/ui-bg_highlight-soft_35_adadad_1x100.png
|
92
|
+
- lib/template/css/images/ui-bg_highlight-soft_60_dddddd_1x100.png
|
93
|
+
- lib/template/css/images/ui-bg_inset-soft_15_121212_1x100.png
|
94
|
+
- lib/template/css/images/ui-icons_666666_256x240.png
|
95
|
+
- lib/template/css/images/ui-icons_aaaaaa_256x240.png
|
96
|
+
- lib/template/css/images/ui-icons_bbbbbb_256x240.png
|
97
|
+
- lib/template/css/images/ui-icons_c98000_256x240.png
|
98
|
+
- lib/template/css/images/ui-icons_cccccc_256x240.png
|
99
|
+
- lib/template/css/images/ui-icons_cd0a0a_256x240.png
|
100
|
+
- lib/template/css/images/ui-icons_f29a00_256x240.png
|
101
|
+
- lib/template/css/jquery-ui.css
|
102
|
+
- lib/template/css/main.css
|
103
|
+
- lib/template/css/reset.css
|
104
|
+
- lib/template/css/ruler.css
|
105
|
+
- lib/template/css/sample.css
|
106
|
+
- lib/template/css/styles.css
|
107
|
+
- lib/template/js/index.js
|
108
|
+
- lib/template/js/init.js
|
109
|
+
- lib/template/js/jquery-ui.min.js
|
110
|
+
- lib/template/js/jquery.min.js
|
111
|
+
- lib/template/js/reveal.js
|
112
|
+
- lib/template/js/ruler.js
|
113
|
+
- lib/template/js/sample.js
|
86
114
|
- lib/template/vew/sample.vew
|
87
115
|
- lib/template/vew/template.erb
|
88
116
|
- lib/vebdew.rb
|
@@ -107,7 +135,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
107
135
|
version: '0'
|
108
136
|
segments:
|
109
137
|
- 0
|
110
|
-
hash:
|
138
|
+
hash: 2574970994430618005
|
111
139
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
112
140
|
none: false
|
113
141
|
requirements:
|