dictionaries 0.2.192

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of dictionaries might be problematic. Click here for more details.

Files changed (48) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +164 -0
  3. data/bin/dictionaries +7 -0
  4. data/bin/unique_words_in_this_file +7 -0
  5. data/dictionaries.gemspec +85 -0
  6. data/doc/README.gen +136 -0
  7. data/lib/dictionaries/ask_english_word.rb +141 -0
  8. data/lib/dictionaries/ask_italian_word.rb +84 -0
  9. data/lib/dictionaries/class/ask_word_from_dictionary.rb +693 -0
  10. data/lib/dictionaries/class/colours.rb +55 -0
  11. data/lib/dictionaries/class/constants.rb +16 -0
  12. data/lib/dictionaries/class/set_search_for_this_word.rb +163 -0
  13. data/lib/dictionaries/commandline/parse_commandline.rb +60 -0
  14. data/lib/dictionaries/constants.rb +133 -0
  15. data/lib/dictionaries/gui/gtk2/dictionary.rb +36 -0
  16. data/lib/dictionaries/gui/gtk3/dictionary/dictionary.rb +34 -0
  17. data/lib/dictionaries/gui/shared_code/dictionaries/dictionary_module.rb +393 -0
  18. data/lib/dictionaries/gui/tk/README.md +2 -0
  19. data/lib/dictionaries/gui/tk/dictionary.rb +85 -0
  20. data/lib/dictionaries/project/project_base_directory.rb +22 -0
  21. data/lib/dictionaries/project/project_yaml_directory.rb +25 -0
  22. data/lib/dictionaries/require_project/require_project.rb +11 -0
  23. data/lib/dictionaries/sinatra/app.rb +105 -0
  24. data/lib/dictionaries/sinatra/english_to_german.rb +82 -0
  25. data/lib/dictionaries/toplevel_methods/e.rb +16 -0
  26. data/lib/dictionaries/toplevel_methods/english_to_german.rb +31 -0
  27. data/lib/dictionaries/toplevel_methods/has_key.rb +32 -0
  28. data/lib/dictionaries/toplevel_methods/is_on_roebe.rb +16 -0
  29. data/lib/dictionaries/toplevel_methods/main_file.rb +88 -0
  30. data/lib/dictionaries/toplevel_methods/misc.rb +129 -0
  31. data/lib/dictionaries/toplevel_methods/module_methods.rb +9 -0
  32. data/lib/dictionaries/toplevel_methods/show_help.rb +30 -0
  33. data/lib/dictionaries/version/version.rb +17 -0
  34. data/lib/dictionaries/yaml/chinese.yml +21 -0
  35. data/lib/dictionaries/yaml/danish.yml +4 -0
  36. data/lib/dictionaries/yaml/deutsche_fremdwoerter.yml +1 -0
  37. data/lib/dictionaries/yaml/dutch.yml +3 -0
  38. data/lib/dictionaries/yaml/english.yml +2427 -0
  39. data/lib/dictionaries/yaml/farsi.yml +8 -0
  40. data/lib/dictionaries/yaml/finnish.yml +2 -0
  41. data/lib/dictionaries/yaml/italian.yml +499 -0
  42. data/lib/dictionaries/yaml/japanese.yml +15 -0
  43. data/lib/dictionaries/yaml/portugese.yml +42 -0
  44. data/lib/dictionaries/yaml/russian.yml +10 -0
  45. data/lib/dictionaries/yaml/spanish.yml +130 -0
  46. data/lib/dictionaries/yaml/swedish.yml +101 -0
  47. data/lib/dictionaries.rb +1 -0
  48. metadata +208 -0
@@ -0,0 +1,393 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # === Dictionaries::GUI::Gtk::DictionaryModule
6
+ # =========================================================================== #
7
+ # require 'dictionaries/gui/shared_code/dictionaries/dictionary_module.rb'
8
+ # include ::Dictionaries::GUI::Gtk::DictionaryModule
9
+ # =========================================================================== #
10
+ module Dictionaries
11
+
12
+ module GUI
13
+
14
+ module Gtk
15
+
16
+ module DictionaryModule
17
+
18
+ require 'dictionaries/toplevel_methods/e.rb'
19
+ require 'dictionaries/toplevel_methods/misc.rb'
20
+
21
+ require 'dictionaries/class/ask_word_from_dictionary.rb'
22
+
23
+ require 'gtk_paradise/requires/require_the_base_module.rb'
24
+ include ::Gtk::BaseModule
25
+
26
+ include ::Colours
27
+
28
+ # ========================================================================= #
29
+ # === NAMESPACE
30
+ # ========================================================================= #
31
+ NAMESPACE = inspect
32
+
33
+ # ========================================================================= #
34
+ # === TITLE
35
+ # ========================================================================= #
36
+ TITLE = 'Dictionary'
37
+
38
+ # ========================================================================= #
39
+ # === WIDTH
40
+ # ========================================================================= #
41
+ WIDTH = '60%'
42
+
43
+ # ========================================================================= #
44
+ # === HEIGHT
45
+ # ========================================================================= #
46
+ HEIGHT = '40%'
47
+
48
+ # ========================================================================= #
49
+ # === USE_THIS_FONT
50
+ # ========================================================================= #
51
+ USE_THIS_FONT = :dejavu_condensed_22
52
+
53
+ # ========================================================================= #
54
+ # === SMALLER_FONT
55
+ #
56
+ # This one should be relative to the font used above.
57
+ # ========================================================================= #
58
+ SMALLER_FONT = :dejavu_condensed_18
59
+
60
+ # ========================================================================= #
61
+ # === initialize
62
+ # ========================================================================= #
63
+ def initialize(
64
+ run_already = true
65
+ )
66
+ super(:vertical)
67
+ reset
68
+ run if run_already
69
+ end
70
+
71
+ # ========================================================================= #
72
+ # === reset
73
+ # ========================================================================= #
74
+ def reset
75
+ reset_the_internal_variables
76
+ set_use_this_font(USE_THIS_FONT)
77
+ # ======================================================================= #
78
+ # === @configuration
79
+ # ======================================================================= #
80
+ @configuration = [true, __dir__, NAMESPACE]
81
+ # ======================================================================= #
82
+ # === @title
83
+ # ======================================================================= #
84
+ set_title(TITLE)
85
+ # ======================================================================= #
86
+ # === @width
87
+ # ======================================================================= #
88
+ set_width(WIDTH)
89
+ # ======================================================================= #
90
+ # === @height
91
+ # ======================================================================= #
92
+ set_height(HEIGHT)
93
+ # ======================================================================= #
94
+ # === @dictionaries
95
+ # ======================================================================= #
96
+ @dictionaries = Dictionaries.new(:do_not_run_yet)
97
+ Dictionaries.set_main_file(:default)
98
+ @dictionaries.load_the_english_file
99
+ handle_CSS
100
+ end
101
+
102
+ # ========================================================================= #
103
+ # === handle_CSS
104
+ # ========================================================================= #
105
+ def handle_CSS
106
+ use_gtk_paradise_project_css_file
107
+ end
108
+
109
+ # ========================================================================= #
110
+ # === padding?
111
+ # ========================================================================= #
112
+ def padding?
113
+ 2
114
+ end
115
+
116
+ # ========================================================================= #
117
+ # === border_size?
118
+ # ========================================================================= #
119
+ def border_size?
120
+ 2
121
+ end
122
+
123
+ # ========================================================================= #
124
+ # === e
125
+ # ========================================================================= #
126
+ def e(i = '')
127
+ ::Dictionaries.e(i)
128
+ end
129
+
130
+ # ========================================================================= #
131
+ # === add_ask_the_question_button
132
+ # ========================================================================= #
133
+ def add_ask_the_question_button
134
+ button = bold_button('Translate into german')
135
+ button.bblack1
136
+ button.hint =
137
+ 'Click this button in order to <b>translate the english '\
138
+ 'word into the german equivalent word</b>.'
139
+ button.on_clicked {
140
+ button_pressed_so_try_to_convert_the_input
141
+ }
142
+ button.modify_background(:normal, :khaki) # ← default colour
143
+ button.modify_background(:prelight, :paleturquoise) # ← mouse-on-over events
144
+ button.modify_background(:active, :slategray) # ← colour on mouse-press-event
145
+ minimal(button, 0)
146
+ end
147
+
148
+ # ========================================================================= #
149
+ # === button_pressed_so_try_to_convert_the_input (click tag)
150
+ #
151
+ # This action is called when the user clicks on the button.
152
+ # ========================================================================= #
153
+ def button_pressed_so_try_to_convert_the_input
154
+ user_input = @input_field.return_input
155
+ unless user_input.empty? # We check whether the user did input something.
156
+ translated_word = @dictionaries.translate(user_input)
157
+ e "#{sfancy(user_input)} → #{simp(translated_word)}"
158
+ @answer_field.set_text(translated_word)
159
+ end
160
+ end
161
+
162
+ # ========================================================================= #
163
+ # === add_the_widget_for_remote_query_of_the_dictionary_at_leo (bottom tag)
164
+ #
165
+ # This is the bottom widget.
166
+ # ========================================================================= #
167
+ def add_the_widget_for_remote_query_of_the_dictionary_at_leo
168
+ bottom_vbox = gtk_vbox
169
+ bold_label = gtk_bold_label(
170
+ 'Query from a remote website instead (more entries available)'
171
+ )
172
+ bottom_vbox.minimal(bold_label, 15)
173
+ # This is the user-input entry at the bottom.
174
+ @entry_for_the_remote_query = gtk_entry
175
+ @entry_for_the_remote_query.center
176
+ @entry_for_the_remote_query.on_key_press_event { |widget, event|
177
+ case Gdk::Keyval.to_name(event.keyval)
178
+ when 'Return', 'KP_Enter'
179
+ do_perform_a_remote_query_to_the_leo_dictionary
180
+ end
181
+ }
182
+ bottom_vbox.minimal(@entry_for_the_remote_query)
183
+ button_for_the_remote_query = button(
184
+ 'Query from a remote dictionary'
185
+ )
186
+ button_for_the_remote_query.bblack1
187
+ button_for_the_remote_query.hint =
188
+ 'This will <b>query the remote dictionary</b> at leo instead. '\
189
+ 'The <b>advantage</b> here is that the dataset at leo will '\
190
+ 'contain many more entries than does the knowledgebase '\
191
+ 'distributed with the <b>dictionaries gem</b>.'
192
+ button_for_the_remote_query.on_clicked {
193
+ do_perform_a_remote_query_to_the_leo_dictionary
194
+ }
195
+ @entry_at_the_bottom_showing_the_result_from_online_leo = gtk_entry
196
+ @entry_at_the_bottom_showing_the_result_from_online_leo.center
197
+ bottom_vbox.minimal(
198
+ @entry_at_the_bottom_showing_the_result_from_online_leo, 2
199
+ )
200
+ bottom_vbox.minimal(
201
+ button_for_the_remote_query, 2
202
+ )
203
+ maximal(bottom_vbox, 2)
204
+ end
205
+
206
+ # ========================================================================= #
207
+ # === add_the_statistics_frame
208
+ # ========================================================================= #
209
+ def add_the_statistics_frame
210
+ maximal(@frame_statistics, 2)
211
+ end
212
+
213
+ # ========================================================================= #
214
+ # === update_the_statistics_frame (update tag)
215
+ # ========================================================================= #
216
+ def update_the_statistics_frame(i = return_currently_selected_file)
217
+ @label_currently_selected_file.set_text(i)
218
+ end
219
+
220
+ # ========================================================================= #
221
+ # === do_perform_a_remote_query_to_the_leo_dictionary
222
+ # ========================================================================= #
223
+ def do_perform_a_remote_query_to_the_leo_dictionary(
224
+ i = @entry_for_the_remote_query.text.to_s
225
+ )
226
+ if i and !i.empty?
227
+ array = ::Dictionaries.return_array_of_translated_words_from_online_leo(i)
228
+ result = array.first
229
+ @entry_at_the_bottom_showing_the_result_from_online_leo.set_text(result)
230
+ end
231
+ end
232
+
233
+ # ========================================================================= #
234
+ # === create_the_statistics_frame
235
+ # ========================================================================= #
236
+ def create_the_statistics_frame
237
+ @frame_statistics = gtk_frame(' Statistics ')
238
+ @frame_statistics.make_bold
239
+ @frame_statistics.use_this_font = smaller_font?
240
+ vbox = gtk_vbox
241
+ @label_currently_selected_file = gtk_label(return_currently_selected_file)
242
+ vbox.minimal(
243
+ @label_currently_selected_file, 0
244
+ )
245
+ @frame_statistics.add(vbox)
246
+ end
247
+
248
+ # ========================================================================= #
249
+ # === return_currently_selected_file
250
+ # ========================================================================= #
251
+ def return_currently_selected_file
252
+ 'Currently selected file: '+
253
+ File.basename(
254
+ @dictionaries.currently_selected_file?.to_s
255
+ )
256
+ end
257
+
258
+ # ========================================================================= #
259
+ # === create_skeleton
260
+ # ========================================================================= #
261
+ def create_skeleton
262
+ create_input_field_on_top
263
+ create_answer_field
264
+ create_the_statistics_frame
265
+ end
266
+
267
+ # ========================================================================= #
268
+ # === connect_skeleton (skeleton tag, connect tag)
269
+ # ========================================================================= #
270
+ def connect_skeleton
271
+ minimal(@answer_field) # ← Translation appears here.
272
+ add_ask_the_question_button
273
+ add_the_widget_for_remote_query_of_the_dictionary_at_leo
274
+ add_the_statistics_frame
275
+ end
276
+
277
+ # ========================================================================= #
278
+ # === create_answer_field
279
+ #
280
+ # This method builds up the "answer-widget".
281
+ # ========================================================================= #
282
+ def create_answer_field
283
+ @answer_field = gtk_input_field
284
+ @answer_field.center
285
+ @answer_field.hint = 'The translated string may appear here.'
286
+ @answer_field.very_light_yellow_background
287
+ end
288
+
289
+ # ========================================================================= #
290
+ # === create_input_field_on_top
291
+ #
292
+ # This is the main widget for user input. The user types in some
293
+ # words, and then hits the main button on the bottom, in order
294
+ # to translate the (english) word to german.
295
+ # ========================================================================= #
296
+ def create_input_field_on_top
297
+ text_for_the_label = 'Input an english word in the field below'
298
+ text = gtk_label(text_for_the_label)
299
+ text.css_class('slateblue')
300
+
301
+ if use_gtk2?
302
+ text.set_markup(
303
+ '<span size="x-large" weight="bold">'+text_for_the_label+'</span>',
304
+ true
305
+ )
306
+ else
307
+ text.set_markup(
308
+ '<span size="x-large" weight="bold">'+text_for_the_label+'</span>',
309
+ use_underline: true
310
+ )
311
+ end
312
+
313
+ # ======================================================================= #
314
+ # Add the "input field" next for the english word that is to
315
+ # be translated.
316
+ # ======================================================================= #
317
+ @input_field = gtk_input_field
318
+ @input_field.hint = 'Input the word that should be translated '\
319
+ 'here. Then, press the "enter" key or the button '\
320
+ '"Translate into german" below.'
321
+ @input_field.very_light_yellow_background
322
+ completion = gtk_entry_completion
323
+ @input_field.completion = completion # Assign the completion.
324
+ completion_model = gtk_list_store(String)
325
+ @dictionaries.array.each { |word|
326
+ iter = completion_model.append
327
+ iter[0] = word
328
+ }
329
+ completion.model = completion_model
330
+ # ======================================================================= #
331
+ # Use model column 0 as the text column
332
+ # ======================================================================= #
333
+ completion.text_column = 0
334
+ @input_field.center
335
+ @input_field.on_key_press_event { |widget, event|
336
+ case Gdk::Keyval.to_name(event.keyval)
337
+ when 'Return', 'KP_Enter'
338
+ button_pressed_so_try_to_convert_the_input
339
+ end
340
+ }
341
+ hbox_holding_label_and_input_field = gtk_vbox(
342
+ text, @input_field
343
+ )
344
+ minimal(hbox_holding_label_and_input_field, 2)
345
+ end
346
+
347
+ # ========================================================================= #
348
+ # === run
349
+ # ========================================================================= #
350
+ def run
351
+ create_skeleton
352
+ connect_skeleton
353
+ update_the_statistics_frame
354
+ show_all
355
+ end
356
+
357
+ # ========================================================================= #
358
+ # === smaller_font?
359
+ # ========================================================================= #
360
+ def smaller_font?
361
+ SMALLER_FONT
362
+ end
363
+
364
+ # ========================================================================= #
365
+ # === Dictionaries::GUI::Gtk::Dictionary.run
366
+ #
367
+ # Use this method if you wish to start a new gtk-application window.
368
+ # ========================================================================= #
369
+ def self.run
370
+ require 'gtk_paradise/run'
371
+ _ = Dictionaries::GUI::Gtk::Dictionary.new
372
+ r = ::Gtk.run
373
+ r << _
374
+ r.automatic_title
375
+ r.automatic_size
376
+ r.border_width = 12
377
+ r.top_left_then_run
378
+ end
379
+
380
+ end; end; end
381
+
382
+ # =========================================================================== #
383
+ # === Dictionaries.gtk_widget
384
+ #
385
+ # This toplevel-method can be used to return the gtk-widget, which
386
+ # can then be embedded by other ruby-gtk applications, in particular
387
+ # admin_panel.rb of the gtk_paradise project.
388
+ # =========================================================================== #
389
+ def self.gtk_widget
390
+ Dictionaries::GUI::Gtk::Dictionary.new
391
+ end
392
+
393
+ end
@@ -0,0 +1,2 @@
1
+ This directory includes experimental tk code. The main GUI is
2
+ ruby-gtk, so this is just a fallback.
@@ -0,0 +1,85 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # === Dictionaries::GUI::Tk::Dictionary
6
+ #
7
+ # This is a small TK-wrapper.
8
+ # =========================================================================== #
9
+ # require 'dictionaries/gui/tk/dictionary.rb'
10
+ # =========================================================================== #
11
+ begin
12
+ require 'tk'
13
+ rescue LoadError; end
14
+ require 'dictionaries/class/ask_word_from_dictionary.rb'
15
+ require 'dictionaries/toplevel_methods/e.rb'
16
+
17
+ module Dictionaries
18
+
19
+ module GUI
20
+
21
+ module Tk
22
+
23
+ class Dictionary < ::TkFrame # < Base === Dictionaries::GUI::Tk::Dictionary.new
24
+
25
+ include Colours::E
26
+
27
+ # ========================================================================= #
28
+ # === initialize
29
+ # ========================================================================= #
30
+ def initialize(
31
+ i = nil,
32
+ run_already = true
33
+ )
34
+ super()
35
+ reset
36
+ set_input(i)
37
+ title "TK wrapper for the Dictionaries project"
38
+ run if run_already
39
+ end
40
+
41
+ # ========================================================================= #
42
+ # === reset (reset tag)
43
+ # ========================================================================= #
44
+ def reset
45
+ end
46
+
47
+ # ========================================================================= #
48
+ # === set_input
49
+ # ========================================================================= #
50
+ def set_input(i = '')
51
+ i = i.first if i.is_a? Array
52
+ i = i.to_s.dup
53
+ @input = i
54
+ end
55
+
56
+ # ========================================================================= #
57
+ # === input?
58
+ # ========================================================================= #
59
+ def input?
60
+ @input
61
+ end
62
+
63
+ # ========================================================================= #
64
+ # === run (run tag)
65
+ # ========================================================================= #
66
+ def run
67
+ TkLabel.new(root) do
68
+ text 'Hello, World!'
69
+ pack { padx 15 ; pady 15; side 'left' }
70
+ end
71
+ end
72
+
73
+ # ========================================================================= #
74
+ # === Dictionaries::GUI:Tk::Dictionary[]
75
+ # ========================================================================= #
76
+ def self.[](i = '')
77
+ self.new(i)
78
+ end
79
+
80
+ end; end; end; end
81
+
82
+ if __FILE__ == $PROGRAM_NAME
83
+ Dictionaries::GUI:Tk::Dictionary.new(ARGV)
84
+ ::Tk.mainloop
85
+ end # dictionary.rb
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'dictionaries/project/project_base_directory.rb'
6
+ # =========================================================================== #
7
+ module Dictionaries
8
+
9
+ # ========================================================================= #
10
+ # === Dictionaries::PROJECT_BASE_DIRECTORY
11
+ # ========================================================================= #
12
+ PROJECT_BASE_DIRECTORY =
13
+ File.absolute_path("#{__dir__}/..")+'/'
14
+
15
+ # ========================================================================= #
16
+ # === Dictionaries.project_base_dir?
17
+ # ========================================================================= #
18
+ def self.project_base_dir?
19
+ PROJECT_BASE_DIRECTORY
20
+ end
21
+
22
+ end
@@ -0,0 +1,25 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # This file will point to the yaml directory of the Dictionaries project.
6
+ # =========================================================================== #
7
+ # require 'dictionaries/project/project_yaml_directory.rb'
8
+ # =========================================================================== #
9
+ require 'dictionaries/project/project_base_directory.rb'
10
+
11
+ module Dictionaries
12
+
13
+ # ========================================================================= #
14
+ # === PROJECT_YAML_DIRECTORY
15
+ # ========================================================================= #
16
+ PROJECT_YAML_DIRECTORY = "#{PROJECT_BASE_DIRECTORY}yaml/"
17
+
18
+ # ========================================================================= #
19
+ # === Dictionaries.project_yaml_dir?
20
+ # ========================================================================= #
21
+ def self.project_yaml_dir?
22
+ PROJECT_YAML_DIRECTORY
23
+ end; self.instance_eval { alias dictionary_directory? project_yaml_dir? } # === Dictionaries.dictionary_directory?
24
+
25
+ end
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # require 'dictionaries/require_project/require_project.rb'
6
+ # =========================================================================== #
7
+ require 'dictionaries/ask_italian_word.rb'
8
+ require 'dictionaries/toplevel_methods/has_key.rb' # This file requires the files above.
9
+ require 'dictionaries/toplevel_methods/module_methods.rb'
10
+ require 'dictionaries/toplevel_methods/english_to_german.rb'
11
+ require 'dictionaries/toplevel_methods/is_on_roebe.rb'
@@ -0,0 +1,105 @@
1
+ #!/usr/bin/ruby -w
2
+ # Encoding: UTF-8
3
+ # frozen_string_literal: true
4
+ # =========================================================================== #
5
+ # === Dictionaries::Sinatra
6
+ # =========================================================================== #
7
+ # require 'dictionaries/sinatra/app.rb'
8
+ # =========================================================================== #
9
+ require 'sinatra/base.rb'
10
+
11
+ module Dictionaries
12
+
13
+ class Sinatra < ::Sinatra::Base
14
+
15
+ require 'dictionaries/class/ask_word_from_dictionary.rb'
16
+ require 'dictionaries/toplevel_methods/is_on_roebe.rb'
17
+ require 'dictionaries/sinatra/english_to_german.rb'
18
+
19
+ include Colours
20
+ include Colours::E
21
+ begin
22
+ require 'html_tags'
23
+ include HtmlTags::BaseModule
24
+ rescue LoadError; end
25
+
26
+ # ========================================================================= #
27
+ # === USE_THIS_PORT
28
+ # ========================================================================= #
29
+ USE_THIS_PORT = '5252'
30
+
31
+ set :port, USE_THIS_PORT
32
+
33
+ # ========================================================================= #
34
+ # === initialize
35
+ # ========================================================================= #
36
+ def initialize
37
+ super()
38
+ reset
39
+ consider_opening_the_page_in_the_browser
40
+ end
41
+
42
+ # ========================================================================= #
43
+ # === reset
44
+ # ========================================================================= #
45
+ def reset
46
+ end
47
+
48
+ # ========================================================================= #
49
+ # === consider_opening_the_page_in_the_browser
50
+ # ========================================================================= #
51
+ def consider_opening_the_page_in_the_browser
52
+ if ::Dictionaries.is_on_roebe?
53
+ begin
54
+ require 'open'
55
+ rescue LoadError; end
56
+ # ===================================================================== #
57
+ # Tell us which port will be used:
58
+ # ===================================================================== #
59
+ target = "http://localhost:#{USE_THIS_PORT}/"
60
+ e sfancy(target)
61
+ Thread.new {
62
+ sleep 1.0
63
+ Open.in_browser(target)
64
+ }
65
+ end
66
+ end
67
+
68
+ # ========================================================================= #
69
+ # === / Entry point
70
+ #
71
+ # This is the root of our web-application.
72
+ # ========================================================================= #
73
+ get('/'){
74
+ html_header_default_title_and_start_of_the_body_tag+
75
+ p('Available translations:')+
76
+ a('/english_to_german')+
77
+ br+
78
+ a('/german_to_english')+
79
+ br
80
+ }
81
+
82
+ # ========================================================================= #
83
+ # === not_found
84
+ # ========================================================================= #
85
+ not_found {
86
+ p('This particular <b>API</b> was not found.')
87
+ }
88
+
89
+ end
90
+
91
+ # =========================================================================== #
92
+ # === Dictionaries.start_sinatra_interface
93
+ #
94
+ # This method can be used to start the sinatra interface.
95
+ # =========================================================================== #
96
+ def self.start_sinatra_interface
97
+ e 'Trying to start the sinatra-interface of the Dictionaries project.'
98
+ ::Dictionaries::Sinatra.run!
99
+ end
100
+
101
+ end
102
+
103
+ if __FILE__ == $PROGRAM_NAME
104
+ Dictionaries.start_sinatra_interface
105
+ end # dictionaries --sinatra