wbzyl-rack-codehighlighter 0.1.6 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +2 -0
- data/VERSION.yml +1 -1
- data/examples/app.rb +2 -6
- data/examples/config.ru +12 -8
- data/examples/public/stylesheets/censor.css +4 -0
- data/examples/views/index.erb +81 -0
- data/examples/views/{layout.rdiscount → layout.erb} +3 -1
- data/lib/rack/codehighlighter.rb +1 -1
- metadata +4 -3
- data/examples/views/index.rdiscount +0 -75
data/README.markdown
CHANGED
data/VERSION.yml
CHANGED
data/examples/app.rb
CHANGED
@@ -5,17 +5,13 @@ $:.unshift(path) unless $:.include?(path)
|
|
5
5
|
|
6
6
|
require 'rubygems'
|
7
7
|
require 'sinatra'
|
8
|
-
require 'rdiscount'
|
9
8
|
|
10
|
-
|
11
|
-
require 'sinatra/rdiscount'
|
12
|
-
|
13
|
-
require 'codehighlighter-middleware'
|
9
|
+
require 'rack/codehighlighter'
|
14
10
|
|
15
11
|
require 'coderay' # Coderay
|
16
12
|
require 'syntax/convertors/html' # Syntax
|
17
13
|
require 'uv' # Ultraviolet
|
18
14
|
|
19
15
|
get "/" do
|
20
|
-
|
16
|
+
erb :index
|
21
17
|
end
|
data/examples/config.ru
CHANGED
@@ -1,15 +1,19 @@
|
|
1
|
-
# run with: thin --rackup config.ru -p 4567 start
|
2
|
-
|
3
|
-
#use Rack::Static, :urls => ["/stylesheets"], :root => "public"
|
4
|
-
|
5
1
|
require 'app'
|
6
2
|
|
3
|
+
use Rack::ShowExceptions
|
7
4
|
use Rack::Lint
|
8
|
-
#use Rack::Codehighlighter, :prettify, :logging => true
|
9
5
|
|
10
|
-
#use
|
11
|
-
|
6
|
+
# use default options
|
7
|
+
|
8
|
+
#use Rack::Codehighlighter, :prettify, :element => "//pre", :pattern => /\A:::(\w+)\s*\n/, :logging => true
|
9
|
+
|
10
|
+
use Rack::Codehighlighter, :coderay, :element => "//pre", :pattern => /\A:::(\w+)\s*\n/, :logging => true
|
11
|
+
|
12
|
+
#use Rack::Codehighlighter, :syntax, :element => "//pre", :pattern => /\A:::(\w+)\s*\n/, :logging => true
|
13
|
+
|
14
|
+
#use Rack::Codehighlighter, :ultraviolet, :theme => 'dawn',
|
15
|
+
# :element => "//pre", :pattern => /\A:::(\w+)\s*\n/, :logging => true
|
12
16
|
|
13
|
-
use Rack::Codehighlighter, :
|
17
|
+
#use Rack::Codehighlighter, :censor, :reason => '[[-- removed ugly code --]]'
|
14
18
|
|
15
19
|
run Sinatra::Application
|
@@ -0,0 +1,81 @@
|
|
1
|
+
<h3>C</h3>
|
2
|
+
|
3
|
+
<pre>:::c
|
4
|
+
int a, b;
|
5
|
+
int main(int argc, char *argv[]) {
|
6
|
+
hello();
|
7
|
+
return 0;
|
8
|
+
}
|
9
|
+
void hello(void) {
|
10
|
+
printf("hello world\n");
|
11
|
+
}
|
12
|
+
</pre>
|
13
|
+
|
14
|
+
<h3>html</h3>
|
15
|
+
|
16
|
+
<pre>:::html
|
17
|
+
<html>
|
18
|
+
<head>
|
19
|
+
<title>hello world</title>
|
20
|
+
</head>
|
21
|
+
<body>
|
22
|
+
<h1>hello world</h1>
|
23
|
+
</body>
|
24
|
+
</html>
|
25
|
+
</pre>
|
26
|
+
|
27
|
+
<h3>ruby </h3>
|
28
|
+
|
29
|
+
<pre>:::ruby
|
30
|
+
def hello
|
31
|
+
puts 'hello world'
|
32
|
+
end
|
33
|
+
</pre>
|
34
|
+
|
35
|
+
<h3>css21</h3>
|
36
|
+
|
37
|
+
<pre>:::css
|
38
|
+
html {
|
39
|
+
margin: 0;
|
40
|
+
padding: 0;
|
41
|
+
background-color: #0C7D85;
|
42
|
+
line-height: 1.6;
|
43
|
+
}
|
44
|
+
body {
|
45
|
+
margin: 1em auto 1em auto;
|
46
|
+
padding: 1em 2em 2em 1em;
|
47
|
+
width: 760px;
|
48
|
+
border: 1px solid black;
|
49
|
+
background-color: #E8DDCB;
|
50
|
+
}
|
51
|
+
</pre>
|
52
|
+
|
53
|
+
<h3>sqlite</h3>
|
54
|
+
|
55
|
+
<pre>:::sql
|
56
|
+
drop table if exists exams;
|
57
|
+
create table exams (
|
58
|
+
id integer primary key autoincrement,
|
59
|
+
student_id integer not null, -- foreign key
|
60
|
+
result integer default 0 collate nocase,
|
61
|
+
when datetime
|
62
|
+
);
|
63
|
+
</pre>
|
64
|
+
|
65
|
+
<h3>javascript</h3>
|
66
|
+
|
67
|
+
<pre>:::javascript
|
68
|
+
for (var i = 0, length = properties.length; i < length; i++) {
|
69
|
+
var property = properties[i], value = source[property];
|
70
|
+
if (ancestor && Object.isFunction(value) &&
|
71
|
+
value.argumentNames().first() == "$super") {
|
72
|
+
var method = value, value = Object.extend((function(m) {
|
73
|
+
return function() { return ancestor[m].apply(this, arguments) };
|
74
|
+
})(property).wrap(method), {
|
75
|
+
valueOf: function() { return method },
|
76
|
+
toString: function() { return method.toString() }
|
77
|
+
});
|
78
|
+
}
|
79
|
+
this.prototype[property] = value;
|
80
|
+
}
|
81
|
+
</pre>
|
@@ -10,6 +10,8 @@
|
|
10
10
|
type="text/css" media="screen" charset="utf-8">
|
11
11
|
<link rel="stylesheet" href="/stylesheets/uv.css"
|
12
12
|
type="text/css" media="screen" charset="utf-8">
|
13
|
+
<link rel="stylesheet" href="/stylesheets/censor.css"
|
14
|
+
type="text/css" media="screen" charset="utf-8"/>
|
13
15
|
|
14
16
|
<link rel="stylesheet" href="/stylesheets/prettify.css"
|
15
17
|
type="text/css" media="screen" charset="utf-8"/>
|
@@ -30,7 +32,7 @@
|
|
30
32
|
|
31
33
|
<body>
|
32
34
|
|
33
|
-
|
35
|
+
<%= yield %>
|
34
36
|
|
35
37
|
</body>
|
36
38
|
</html>
|
data/lib/rack/codehighlighter.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wbzyl-rack-codehighlighter
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wlodek Bzyl
|
@@ -69,6 +69,7 @@ files:
|
|
69
69
|
- examples/public/javascripts/lang-wiki.js
|
70
70
|
- examples/public/javascripts/prettify.js
|
71
71
|
- examples/public/stylesheets/application.css
|
72
|
+
- examples/public/stylesheets/censor.css
|
72
73
|
- examples/public/stylesheets/coderay.css
|
73
74
|
- examples/public/stylesheets/prettify.css
|
74
75
|
- examples/public/stylesheets/syntax.css
|
@@ -81,8 +82,8 @@ files:
|
|
81
82
|
- examples/public/stylesheets/uv/sunburst.css
|
82
83
|
- examples/public/stylesheets/uv/twilight.css
|
83
84
|
- examples/public/stylesheets/uv/zenburnesque.css
|
84
|
-
- examples/views/index.
|
85
|
-
- examples/views/layout.
|
85
|
+
- examples/views/index.erb
|
86
|
+
- examples/views/layout.erb
|
86
87
|
- lib/rack/codehighlighter.rb
|
87
88
|
- README.markdown
|
88
89
|
has_rdoc: false
|
@@ -1,75 +0,0 @@
|
|
1
|
-
### C
|
2
|
-
|
3
|
-
:::c
|
4
|
-
int a, b;
|
5
|
-
int main(int argc, char *argv[]) {
|
6
|
-
hello();
|
7
|
-
return 0;
|
8
|
-
}
|
9
|
-
void hello(void) {
|
10
|
-
printf("hello world\n");
|
11
|
-
}
|
12
|
-
|
13
|
-
### html
|
14
|
-
|
15
|
-
:::html
|
16
|
-
<html>
|
17
|
-
<head>
|
18
|
-
<title>hello world</title>
|
19
|
-
</head>
|
20
|
-
<body>
|
21
|
-
<h1>hello world</h1>
|
22
|
-
</body>
|
23
|
-
</html>
|
24
|
-
|
25
|
-
### ruby
|
26
|
-
|
27
|
-
:::ruby
|
28
|
-
def hello
|
29
|
-
puts 'hello world'
|
30
|
-
end
|
31
|
-
|
32
|
-
### css21
|
33
|
-
|
34
|
-
:::css
|
35
|
-
html {
|
36
|
-
margin: 0;
|
37
|
-
padding: 0;
|
38
|
-
background-color: #0C7D85;
|
39
|
-
line-height: 1.6;
|
40
|
-
}
|
41
|
-
body {
|
42
|
-
margin: 1em auto 1em auto;
|
43
|
-
padding: 1em 2em 2em 1em;
|
44
|
-
width: 760px;
|
45
|
-
border: 1px solid black;
|
46
|
-
background-color: #E8DDCB;
|
47
|
-
}
|
48
|
-
|
49
|
-
### sqlite
|
50
|
-
|
51
|
-
:::sql
|
52
|
-
drop table if exists exams;
|
53
|
-
create table exams (
|
54
|
-
id integer primary key autoincrement,
|
55
|
-
student_id integer not null, -- foreign key
|
56
|
-
result integer default 0 collate nocase,
|
57
|
-
when datetime
|
58
|
-
);
|
59
|
-
|
60
|
-
### javascript
|
61
|
-
|
62
|
-
:::javascript
|
63
|
-
for (var i = 0, length = properties.length; i < length; i++) {
|
64
|
-
var property = properties[i], value = source[property];
|
65
|
-
if (ancestor && Object.isFunction(value) &&
|
66
|
-
value.argumentNames().first() == "$super") {
|
67
|
-
var method = value, value = Object.extend((function(m) {
|
68
|
-
return function() { return ancestor[m].apply(this, arguments) };
|
69
|
-
})(property).wrap(method), {
|
70
|
-
valueOf: function() { return method },
|
71
|
-
toString: function() { return method.toString() }
|
72
|
-
});
|
73
|
-
}
|
74
|
-
this.prototype[property] = value;
|
75
|
-
}
|