Class: CGI
Overview
Constant Summary
collapse
- ENV =
::ENV.to_hash
Instance Method Summary
collapse
#mobile_agent?, #smartphone?
Instance Method Details
#base_url ⇒ Object
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
|
# File 'lib/tdiary/core_ext.rb', line 90
def base_url
return '' unless script_name
begin
script_dirname = script_name.empty? ? '' : File::dirname(script_name)
if https?
port = (server_port == 443) ? '' : ':' + server_port.to_s
"https://#{server_name}#{port}#{script_dirname}/"
else
port = (server_port == 80) ? '' : ':' + server_port.to_s
"http://#{server_name}#{port}#{script_dirname}/"
end.sub(%r|/+$|, '/')
rescue SecurityError
''
end
end
|
#env_table_rack ⇒ Object
Also known as:
env_table
8
9
10
|
# File 'lib/tdiary/application.rb', line 8
def env_table_rack
$RACK_ENV || ENV
end
|
#https? ⇒ Boolean
65
66
67
68
69
|
# File 'lib/tdiary/core_ext.rb', line 65
def https?
return true if env_table['HTTP_X_FORWARDED_PROTO'] == 'https'
return false if env_table['HTTPS'].nil? or /off/i =~ env_table['HTTPS'] or env_table['HTTPS'] == ''
true
end
|
#redirect_url ⇒ Object
86
87
88
|
# File 'lib/tdiary/core_ext.rb', line 86
def redirect_url
env_table['REDIRECT_URL']
end
|
#request_uri ⇒ Object
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
# File 'lib/tdiary/core_ext.rb', line 71
def request_uri
_request_uri = env_table['REQUEST_URI']
_script_name = env_table['SCRIPT_NAME']
if !_request_uri || _request_uri == '' || _request_uri == _script_name then
_path_info = env_table['PATH_INFO'] || ''
_query_string = env_table['QUERY_STRING'] || ''
_request_uri = _path_info.include?(_script_name) ? '' : _script_name.dup
_request_uri << _path_info
_request_uri << '?' + _query_string if _query_string != ''
end
_request_uri
end
|
#valid?(param, idx = 0) ⇒ Boolean
61
62
63
|
# File 'lib/tdiary/core_ext.rb', line 61
def valid?( param, idx = 0 )
self.params[param] and self.params[param][idx] and self.params[param][idx].length > 0
end
|