Class: Cyberweb::Sinatra
- Inherits:
-
Sinatra::Base
- Object
- Sinatra::Base
- Cyberweb::Sinatra
show all
- Includes:
- CustomExtensions
- Defined in:
- lib/cyberweb/sinatra/base.rb,
lib/cyberweb/sinatra/custom_extensions.rb,
lib/cyberweb/sinatra/base/use_this_port.rb,
lib/cyberweb/sinatra/base/set_use_this_port.rb
Defined Under Namespace
Modules: CustomExtensions
Constant Summary
collapse
- DEFAULT_PORT_TO_USE =
'4567'
Class Method Summary
collapse
Instance Method Summary
collapse
#abr, #are_we_using_sinatra?, #escape_html, #merge_interface, #not_yet_implemented, #query_string?, #temp_dir?, #web_params?
Constructor Details
#initialize(i = ARGV, use_this_port = ::Cyberweb::Sinatra.use_this_port?, shall_we_open_in_the_browser = true) ⇒ Sinatra
#
initialize
The second argument is the port.
#
38
39
40
41
42
43
44
45
46
|
# File 'lib/cyberweb/sinatra/base.rb', line 38
def initialize(
i = ARGV,
use_this_port = ::Cyberweb::Sinatra.use_this_port?,
shall_we_open_in_the_browser = true
)
super()
reset
consider_opening_on_this_port(use_this_port) if shall_we_open_in_the_browser
end
|
Class Method Details
.set_use_this_port(i = ::Cyberweb::Sinatra.use_this_port?) ⇒ Object
#
Cyberweb::Sinatra.set_use_this_port
#
23
24
25
26
27
28
|
# File 'lib/cyberweb/sinatra/base/set_use_this_port.rb', line 23
def self.set_use_this_port(
i = ::Cyberweb::Sinatra.use_this_port?
)
@use_this_port = i
Sinatra.set(:port, i)
end
|
.start_sinatra_interface ⇒ Object
#
Cyberweb::Sinatra.start_sinatra_interface
#
150
151
152
|
# File 'lib/cyberweb/sinatra/base.rb', line 150
def self.start_sinatra_interface
::Cyberweb::Sinatra.run!
end
|
.use_this_port? ⇒ Boolean
#
Cyberweb::Sinatra.use_this_port?
#
36
37
38
|
# File 'lib/cyberweb/sinatra/base/use_this_port.rb', line 36
def self.use_this_port?
@use_this_port
end
|
Instance Method Details
#consider_opening_on_this_port(use_this_port) ⇒ Object
#
consider_opening_on_this_port
#
142
143
144
|
# File 'lib/cyberweb/sinatra/base.rb', line 142
def input_type_submit
'<input type="submit" name="user_input_submit" value="Search" class="default_submit">'
end
|
135
136
137
|
# File 'lib/cyberweb/sinatra/base.rb', line 135
def input_type_user_input
'<input type="text" name="user_input" style="border:3px solid slateblue; padding: 4px">'
end
|
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
|
# File 'lib/cyberweb/sinatra/base.rb', line 51
def reset
@index_of_hyperlinks = ''.dup
@root_string = '<html><head>'\
'<title>Hello world!</title>'\
'<body>'\
'<h1>Hello world</h1>'\
'</body>'\
'</html>'.dup
end
|
#return_index_of_hyperlinks ⇒ Object
Also known as:
return_the_hyperlinks
#
return_index_of_hyperlinks
This method will bundle together the different indices containing the hyperlinks that may/will be shown on the root-directory.
#
97
98
99
|
# File 'lib/cyberweb/sinatra/base.rb', line 97
def return_index_of_hyperlinks
@index_of_hyperlinks
end
|
#return_root_string ⇒ Object
#
return_root_string
The root-string will contain the main index that is displayed when the user visits the page initially.
#
119
120
121
|
# File 'lib/cyberweb/sinatra/base.rb', line 119
def return_root_string
@root_string
end
|
#set_port(i = USE_THIS_PORT) ⇒ Object
#
set_port
This unfortunately does not work right now. The idea was to call the set-method on the toplevel.
#
107
108
109
110
111
|
# File 'lib/cyberweb/sinatra/base.rb', line 107
def set_port(
i = USE_THIS_PORT
)
set(:port, USE_THIS_PORT) end
|