knjrbfw 0.0.100 → 0.0.101

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. data/VERSION +1 -1
  2. data/knjrbfw.gemspec +2 -2
  3. data/lib/knj/web.rb +27 -11
  4. metadata +23 -23
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.0.100
1
+ 0.0.101
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{knjrbfw}
8
- s.version = "0.0.100"
8
+ s.version = "0.0.101"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Kasper Johansen"]
12
- s.date = %q{2012-10-10}
12
+ s.date = %q{2012-10-12}
13
13
  s.description = %q{Including stuff for HTTP, SSH and much more.}
14
14
  s.email = %q{k@spernj.org}
15
15
  s.extra_rdoc_files = [
@@ -170,26 +170,42 @@ class Knj::Web
170
170
 
171
171
  def self.alert(string)
172
172
  require "#{$knjpath}strings"
173
+
174
+ begin
175
+ _httpsession.alert_sent = true
176
+ rescue NameError
177
+ #ignore.
178
+ end
179
+
173
180
  @alert_sent = true
181
+
174
182
  html = "<script type=\"text/javascript\">alert(\"#{Knj::Strings.js_safe(string.to_s)}\");</script>"
175
183
  print html
184
+
185
+ return self
176
186
  end
177
187
 
178
- def self.redirect(string, args = {})
179
- do_js = true
180
-
188
+ #Redirects to another URL.
189
+ #===Examples
190
+ # _hb.redirect("someotherpage.rhtml")
191
+ # _hb.redirect("newpage.rhtml", :perm => true)
192
+ def self.redirect(url, args = {})
181
193
  #Header way
182
- if !@alert_sent
183
- if args[:perm]
184
- Php4r.header("Status: 301 Moved Permanently")
185
- else
186
- Php4r.header("Status: 303 See Other")
194
+ begin
195
+ if !_httpsession.alert_sent and !_hb.headers_sent?
196
+ if args[:perm]
197
+ _httpsession.resp.status = 301 if !_hb.headers_sent?
198
+ else
199
+ _httpsession.resp.status = 303 if !_hb.headers_sent?
200
+ end
201
+
202
+ _hb.header("Location", url) if !_hb.headers_sent?
187
203
  end
188
-
189
- Php4r.header("Location: #{string}")
204
+ rescue NameError
205
+ #ignore.
190
206
  end
191
207
 
192
- print "<script type=\"text/javascript\">location.href=\"#{string}\";</script>" if do_js
208
+ print "<script type=\"text/javascript\">location.href=\"#{url}\";</script>"
193
209
  exit
194
210
  end
195
211
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knjrbfw
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.100
4
+ version: 0.0.101
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,12 +9,12 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-10 00:00:00.000000000 +02:00
12
+ date: 2012-10-12 00:00:00.000000000 +02:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: wref
17
- requirement: &22408120 !ruby/object:Gem::Requirement
17
+ requirement: &12911800 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: '0'
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *22408120
25
+ version_requirements: *12911800
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: tsafe
28
- requirement: &22407480 !ruby/object:Gem::Requirement
28
+ requirement: &12910660 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ! '>='
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: '0'
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *22407480
36
+ version_requirements: *12910660
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: datet
39
- requirement: &22406900 !ruby/object:Gem::Requirement
39
+ requirement: &12909520 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ! '>='
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: '0'
45
45
  type: :runtime
46
46
  prerelease: false
47
- version_requirements: *22406900
47
+ version_requirements: *12909520
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: http2
50
- requirement: &22406200 !ruby/object:Gem::Requirement
50
+ requirement: &12908320 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ! '>='
@@ -55,10 +55,10 @@ dependencies:
55
55
  version: '0'
56
56
  type: :runtime
57
57
  prerelease: false
58
- version_requirements: *22406200
58
+ version_requirements: *12908320
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: php4r
61
- requirement: &22405660 !ruby/object:Gem::Requirement
61
+ requirement: &12907140 !ruby/object:Gem::Requirement
62
62
  none: false
63
63
  requirements:
64
64
  - - ! '>='
@@ -66,10 +66,10 @@ dependencies:
66
66
  version: '0'
67
67
  type: :runtime
68
68
  prerelease: false
69
- version_requirements: *22405660
69
+ version_requirements: *12907140
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: rspec
72
- requirement: &22405000 !ruby/object:Gem::Requirement
72
+ requirement: &12902680 !ruby/object:Gem::Requirement
73
73
  none: false
74
74
  requirements:
75
75
  - - ~>
@@ -77,10 +77,10 @@ dependencies:
77
77
  version: 2.3.0
78
78
  type: :development
79
79
  prerelease: false
80
- version_requirements: *22405000
80
+ version_requirements: *12902680
81
81
  - !ruby/object:Gem::Dependency
82
82
  name: bundler
83
- requirement: &22404200 !ruby/object:Gem::Requirement
83
+ requirement: &12901220 !ruby/object:Gem::Requirement
84
84
  none: false
85
85
  requirements:
86
86
  - - ! '>='
@@ -88,10 +88,10 @@ dependencies:
88
88
  version: 1.0.0
89
89
  type: :development
90
90
  prerelease: false
91
- version_requirements: *22404200
91
+ version_requirements: *12901220
92
92
  - !ruby/object:Gem::Dependency
93
93
  name: jeweler
94
- requirement: &22403280 !ruby/object:Gem::Requirement
94
+ requirement: &12899660 !ruby/object:Gem::Requirement
95
95
  none: false
96
96
  requirements:
97
97
  - - ~>
@@ -99,10 +99,10 @@ dependencies:
99
99
  version: 1.6.3
100
100
  type: :development
101
101
  prerelease: false
102
- version_requirements: *22403280
102
+ version_requirements: *12899660
103
103
  - !ruby/object:Gem::Dependency
104
104
  name: sqlite3
105
- requirement: &22402560 !ruby/object:Gem::Requirement
105
+ requirement: &12898740 !ruby/object:Gem::Requirement
106
106
  none: false
107
107
  requirements:
108
108
  - - ! '>='
@@ -110,10 +110,10 @@ dependencies:
110
110
  version: '0'
111
111
  type: :development
112
112
  prerelease: false
113
- version_requirements: *22402560
113
+ version_requirements: *12898740
114
114
  - !ruby/object:Gem::Dependency
115
115
  name: rmagick
116
- requirement: &22399720 !ruby/object:Gem::Requirement
116
+ requirement: &12897700 !ruby/object:Gem::Requirement
117
117
  none: false
118
118
  requirements:
119
119
  - - ! '>='
@@ -121,7 +121,7 @@ dependencies:
121
121
  version: '0'
122
122
  type: :development
123
123
  prerelease: false
124
- version_requirements: *22399720
124
+ version_requirements: *12897700
125
125
  description: Including stuff for HTTP, SSH and much more.
126
126
  email: k@spernj.org
127
127
  executables: []
@@ -391,7 +391,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
391
391
  version: '0'
392
392
  segments:
393
393
  - 0
394
- hash: -3820029287983780012
394
+ hash: 3595874400943566572
395
395
  required_rubygems_version: !ruby/object:Gem::Requirement
396
396
  none: false
397
397
  requirements: