cgi-spa 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Manifest +13 -0
- data/README +6 -0
- data/cgi-spa.gemspec +17 -14
- data/lib/cgi-spa/environment.rb +24 -1
- data/lib/cgi-spa/html-methods.rb +22 -0
- data/lib/cgi-spa/version.rb +1 -1
- metadata +5 -5
data/Manifest
CHANGED
@@ -0,0 +1,13 @@
|
|
1
|
+
COPYING
|
2
|
+
Manifest
|
3
|
+
README
|
4
|
+
Rakefile
|
5
|
+
cgi-spa.gemspec
|
6
|
+
lib/cgi-spa.rb
|
7
|
+
lib/cgi-spa/builder.rb
|
8
|
+
lib/cgi-spa/cgi-methods.rb
|
9
|
+
lib/cgi-spa/environment.rb
|
10
|
+
lib/cgi-spa/html-methods.rb
|
11
|
+
lib/cgi-spa/installation.rb
|
12
|
+
lib/cgi-spa/job-control.rb
|
13
|
+
lib/cgi-spa/version.rb
|
data/README
CHANGED
@@ -7,6 +7,7 @@ scripts.
|
|
7
7
|
== Globals provided
|
8
8
|
* $cgi - Common Gateway Interface
|
9
9
|
* $param - Access to parameters (read-only OpenStruct like interface)
|
10
|
+
* $env - Access to environment variables (read-only OpenStruct like interface)
|
10
11
|
* $x - XmlBuilder instance
|
11
12
|
* $USER - Host user id
|
12
13
|
* $HOME - Home directory
|
@@ -25,7 +26,9 @@ scripts.
|
|
25
26
|
|
26
27
|
== HTML methods
|
27
28
|
* style! - argument is indented text/data
|
29
|
+
* system! - run command and capture output
|
28
30
|
* script! - argument is indented text/data
|
31
|
+
* body? - capture exceptions, and produce a stack traceback
|
29
32
|
|
30
33
|
== CGI methods
|
31
34
|
* json - produce JSON output using the block specified
|
@@ -38,6 +41,9 @@ scripts.
|
|
38
41
|
== Helper methods
|
39
42
|
* submit: runs command (or block) as a deamon process
|
40
43
|
|
44
|
+
== OpenStruct methods (for $params and $env)
|
45
|
+
* untaint_if_match: untaints value if it matches a regular expression
|
46
|
+
|
41
47
|
== Builder extensions
|
42
48
|
* indented_text: matches text indentation to markup
|
43
49
|
* indented_data: useful for script and styles in HTML syntax
|
data/cgi-spa.gemspec
CHANGED
@@ -1,22 +1,25 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
|
-
s.name =
|
5
|
-
s.version = "0.
|
4
|
+
s.name = %q{cgi-spa}
|
5
|
+
s.version = "0.5.0"
|
6
6
|
|
7
7
|
s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
|
8
|
-
s.authors = [
|
9
|
-
s.date =
|
10
|
-
s.description =
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
s.
|
15
|
-
s.
|
16
|
-
s.
|
17
|
-
s.
|
18
|
-
s.
|
19
|
-
s.
|
8
|
+
s.authors = [%q{Sam Ruby}]
|
9
|
+
s.date = %q{2011-12-24}
|
10
|
+
s.description = %q{ Provides a number of globals, helper methods, and monkey patches which
|
11
|
+
simplify the development of single page applications in the form of
|
12
|
+
CGI scripts.
|
13
|
+
}
|
14
|
+
s.email = %q{rubys@intertwingly.net}
|
15
|
+
s.extra_rdoc_files = [%q{COPYING}, %q{README}, %q{lib/cgi-spa.rb}, %q{lib/cgi-spa/builder.rb}, %q{lib/cgi-spa/cgi-methods.rb}, %q{lib/cgi-spa/environment.rb}, %q{lib/cgi-spa/html-methods.rb}, %q{lib/cgi-spa/installation.rb}, %q{lib/cgi-spa/job-control.rb}, %q{lib/cgi-spa/version.rb}]
|
16
|
+
s.files = [%q{COPYING}, %q{Manifest}, %q{README}, %q{Rakefile}, %q{cgi-spa.gemspec}, %q{lib/cgi-spa.rb}, %q{lib/cgi-spa/builder.rb}, %q{lib/cgi-spa/cgi-methods.rb}, %q{lib/cgi-spa/environment.rb}, %q{lib/cgi-spa/html-methods.rb}, %q{lib/cgi-spa/installation.rb}, %q{lib/cgi-spa/job-control.rb}, %q{lib/cgi-spa/version.rb}]
|
17
|
+
s.homepage = %q{http://github.com/rubys/cgi-spa}
|
18
|
+
s.rdoc_options = [%q{--line-numbers}, %q{--inline-source}, %q{--title}, %q{Cgi-spa}, %q{--main}, %q{README}]
|
19
|
+
s.require_paths = [%q{lib}]
|
20
|
+
s.rubyforge_project = %q{cgi-spa}
|
21
|
+
s.rubygems_version = %q{1.8.5}
|
22
|
+
s.summary = %q{CGI Single Page Applications}
|
20
23
|
|
21
24
|
if s.respond_to? :specification_version then
|
22
25
|
s.specification_version = 3
|
data/lib/cgi-spa/environment.rb
CHANGED
@@ -22,9 +22,32 @@ $XHTML ||= ($cgi.accept.to_s =~ /xhtml/)
|
|
22
22
|
# get arguments if CGI couldn't find any...
|
23
23
|
$param.merge!(CGI.parse(ARGV.join('&'))) if $param.empty?
|
24
24
|
|
25
|
+
module CgiSpa
|
26
|
+
module Untaint
|
27
|
+
def untaint_if_match regexp
|
28
|
+
self.untaint if regexp.match(self)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
25
33
|
# fast path for accessing CGI parameters
|
26
34
|
def $param.method_missing(name)
|
27
|
-
|
35
|
+
if has_key? name.to_s
|
36
|
+
if self[name.to_s].length == 1
|
37
|
+
self[name.to_s].first.extend(CgiSpa::Untaint)
|
38
|
+
else
|
39
|
+
self[name.to_s].join
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
$env = {}
|
45
|
+
def $env.method_missing(name)
|
46
|
+
delete name.to_s if ENV[name.to_s] != self[name.to_s]
|
47
|
+
unless has_key?(name.to_s)
|
48
|
+
self[name.to_s]=ENV[name.to_s].dup.extend(CgiSpa::Untaint)
|
49
|
+
end
|
50
|
+
self[name.to_s]
|
28
51
|
end
|
29
52
|
|
30
53
|
# quick access to request_uri
|
data/lib/cgi-spa/html-methods.rb
CHANGED
@@ -34,6 +34,7 @@ def $x.system!(command, opts={})
|
|
34
34
|
|
35
35
|
$x.pre command, :class=>stdin unless opts[:echo] == false
|
36
36
|
|
37
|
+
require 'thread'
|
37
38
|
semaphore = Mutex.new
|
38
39
|
Open3.popen3(command) do |pin, pout, perr|
|
39
40
|
[
|
@@ -63,3 +64,24 @@ def $x.system!(command, opts={})
|
|
63
64
|
].each {|thread| thread.join}
|
64
65
|
end
|
65
66
|
end
|
67
|
+
|
68
|
+
def $x.body? args={}
|
69
|
+
traceback_class = args.delete('traceback_class')
|
70
|
+
traceback_style = args.delete('traceback_style')
|
71
|
+
traceback_style ||= 'background-color:#ff0; margin: 1em 0; padding: 1em; ' +
|
72
|
+
'border: 4px solid red; border-radius: 1em'
|
73
|
+
$x.body(args) do
|
74
|
+
begin
|
75
|
+
yield
|
76
|
+
rescue Exception => exception
|
77
|
+
text = exception.inspect
|
78
|
+
exception.backtrace.each {|frame| text += "\n #{frame}"}
|
79
|
+
|
80
|
+
if traceback_class
|
81
|
+
$x.pre text, :class=>traceback_class
|
82
|
+
else
|
83
|
+
$x.pre text, :style=>traceback_style
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
data/lib/cgi-spa/version.rb
CHANGED
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cgi-spa
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 11
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 5
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.5.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Sam Ruby
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-12-24 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: builder
|
@@ -111,7 +111,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
111
111
|
requirements: []
|
112
112
|
|
113
113
|
rubyforge_project: cgi-spa
|
114
|
-
rubygems_version: 1.8.
|
114
|
+
rubygems_version: 1.8.5
|
115
115
|
signing_key:
|
116
116
|
specification_version: 3
|
117
117
|
summary: CGI Single Page Applications
|