Class: Cyberweb::Sinatra
- Inherits:
-
Sinatra::Base
- Object
- Sinatra::Base
- Cyberweb::Sinatra
- 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 =
#
DEFAULT_PORT_TO_USE
#
'4567'
Class Method Summary collapse
-
.set_use_this_port(i = ::Cyberweb::Sinatra.use_this_port?) ⇒ Object
# === Cyberweb::Sinatra.set_use_this_port ========================================================================= #.
-
.start_sinatra_interface ⇒ Object
# === Cyberweb::Sinatra.start_sinatra_interface ========================================================================= #.
-
.use_this_port? ⇒ Boolean
# === Cyberweb::Sinatra.use_this_port? ========================================================================= #.
Instance Method Summary collapse
-
#consider_opening_on_this_port(use_this_port) ⇒ Object
# === consider_opening_on_this_port ========================================================================= #.
-
#initialize(i = ARGV, use_this_port = ::Cyberweb::Sinatra.use_this_port?, shall_we_open_in_the_browser = true) ⇒ Sinatra
constructor
# === initialize.
-
#input_type_submit ⇒ Object
# === input_type_submit ========================================================================= #.
-
#input_type_user_input ⇒ Object
# === input_type_user_input ========================================================================= #.
-
#reset ⇒ Object
# === reset ========================================================================= #.
-
#return_index_of_hyperlinks ⇒ Object
(also: #return_the_hyperlinks)
# === return_index_of_hyperlinks.
-
#return_root_string ⇒ Object
# === return_root_string.
-
#set_port(i = USE_THIS_PORT) ⇒ Object
# === set_port.
Methods included from CustomExtensions
#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
#
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/cyberweb/sinatra/base.rb', line 70 def consider_opening_on_this_port( use_this_port ) case use_this_port # ======================================================================= # # === :default # ======================================================================= # when :default use_this_port = ::Cyberweb::Sinatra.use_this_port? end if ::Cyberweb.is_on_roebe? and !use_this_port.nil? and use_this_port # Check for false here. # ===================================================================== # # Tell us which port will be used: # ===================================================================== # target = "http://localhost:#{use_this_port}/" Cyberweb.try_to_open_this_URL_via_the_browser(target, use_this_port) end end |
#input_type_submit ⇒ Object
#
input_type_submit
#
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 |
#input_type_user_input ⇒ Object
#
input_type_user_input
#
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 |
#reset ⇒ Object
#
reset
#
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 # ======================================================================= # @index_of_hyperlinks = ''.dup # ======================================================================= # # === @root_string # ======================================================================= # @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) # Delegate towards Sinatra::Base here. end |