Module: PdfParadise::EmbeddableInterface
- Included in:
- Sinatra
- Defined in:
- lib/pdf_paradise/sinatra/embeddable_interface.rb
Overview
PdfParadise::EmbeddableInterface
Constant Summary
collapse
- USE_THIS_UNIFORM_CSS_STYLE =
#
Designate a uniform CSS style to use:
#
'margin-left:3.5em; font-weight: bold;'
- RARROW =
'→'
- USE_THIS_PORT =
#
USE_THIS_PORT
Note that this constant, for the port, is only in use when we run the sinatra-specific part of PdfParadise in a standalone manner.
When we run from the main controller, which is part of the Roebe project, then this port is not relevant, as that main controller already handles that case.
#
'5200'
Class Method Summary
collapse
-
.route_name? ⇒ Boolean
# === PdfParadise::EmbeddableInterface.route_name? ========================================================================= #.
-
.set_route_name(i) ⇒ Object
# === PdfParadise::EmbeddableInterface.set_route_name ========================================================================= #.
-
.sub_routes? ⇒ Boolean
# === PdfParadise::EmbeddableInterface.sub_routes?.
Instance Method Summary
collapse
Class Method Details
.route_name? ⇒ Boolean
#
PdfParadise::EmbeddableInterface.route_name?
#
76
77
78
|
# File 'lib/pdf_paradise/sinatra/embeddable_interface.rb', line 76
def self.route_name?
@route_name
end
|
.set_route_name(i) ⇒ Object
#
PdfParadise::EmbeddableInterface.set_route_name
#
69
70
71
|
# File 'lib/pdf_paradise/sinatra/embeddable_interface.rb', line 69
def self.set_route_name(i)
@route_name = i
end
|
.sub_routes? ⇒ Boolean
#
PdfParadise::EmbeddableInterface.sub_routes?
List the available sub-routes that depend on the main route_name? defined above. All sub-routes must be defined here, because we may expose this Hash to other applications.
#
101
102
103
104
105
106
|
# File 'lib/pdf_paradise/sinatra/embeddable_interface.rb', line 101
def self.sub_routes?
{
view: route_name?+'/view',
n_pdf_pages: route_name?+'/n_pdf_pages'
}
end
|
Instance Method Details
#close_body ⇒ Object
273
274
275
|
# File 'lib/pdf_paradise/sinatra/embeddable_interface.rb', line 273
def close_body
'</body>'
end
|
#close_html ⇒ Object
252
253
254
|
# File 'lib/pdf_paradise/sinatra/embeddable_interface.rb', line 252
def close_html
'</html>'
end
|
#html_start_then_title ⇒ Object
Also known as:
html_then_title
#
html_start_then_title
#
307
308
309
310
|
# File 'lib/pdf_paradise/sinatra/embeddable_interface.rb', line 307
def html_start_then_title
html_start+
default_title
end
|
118
119
120
121
122
|
# File 'lib/pdf_paradise/sinatra/embeddable_interface.rb', line 118
def input_type_submit(
text_to_use = 'Search'
)
'<input type="submit" name="user_input_submit" value="'+text_to_use+'" class="default_submit">'
end
|
111
112
113
|
# File 'lib/pdf_paradise/sinatra/embeddable_interface.rb', line 111
def input_type_user_input
'<input type="text" name="user_input" style="border:3px solid slateblue; padding: 4px">'
end
|
#open_body ⇒ Object
127
128
129
|
# File 'lib/pdf_paradise/sinatra/embeddable_interface.rb', line 127
def open_body
'<body>'
end
|
#open_html ⇒ Object
Also known as:
html_start
259
260
261
|
# File 'lib/pdf_paradise/sinatra/embeddable_interface.rb', line 259
def open_html
'<html>'
end
|
#return_CSS_rules_to_use ⇒ Object
#
return_CSS_rules_to_use
#
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
|
# File 'lib/pdf_paradise/sinatra/embeddable_interface.rb', line 327
def return_CSS_rules_to_use
'<style>
body {
margin: 0.25em;
padding: 15px;
font-size: larger;
}
a {
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
</style>'
end
|
#return_div_for_manual_pdf_conversion ⇒ Object
#
return_div_for_manual_pdf_conversion
#
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
|
# File 'lib/pdf_paradise/sinatra/embeddable_interface.rb', line 219
def return_div_for_manual_pdf_conversion
route_to_this_action = '/convert_single_pdf_file/'
p("If you merely wish to convert a single .pdf file, you can use "\
"the following form for this:\n")+
div(css_style: 'padding: 0.2em') {
p(
'<b>Enter the name of the .pdf file that you wish to convert:</b>', css_style: 'padding:0.75em'
)+
form(action: route_to_this_action,
id: 'convert_single_pdf_file',
css_style: 'margin-left:2em; margin-top:2px') {
'<input type="text" name="user_input" style="border:3px solid slateblue; padding: 4px"><br>'\
'<b>Select a file</b>: <input type="file" name="this_file"><br>'\
'<input type="submit" name="user_input_submit" '\
'value="Click here to convert the .pdf file" style="2px dotted royalblue; '\
'color: white; background-color: olive; font-size: 1.50em;
margin:4px; padding: 4px; border: 1px solid black">'
}
}
end
|
#return_div_for_removing_the_first_page_of_this_pdf_file ⇒ Object
#
return_div_for_removing_the_first_page_of_this_pdf_file
#
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
|
# File 'lib/pdf_paradise/sinatra/embeddable_interface.rb', line 346
def return_div_for_removing_the_first_page_of_this_pdf_file
route_to_this_action = '/remove_the_first_page_of_this_pdf_file/'
div(css_style: 'padding: 0.2em') {
p(
'<b>Enter the name of the .pdf file whose first page should be removed:</b>',
css_style: 'padding:0.75em'
)+
form(action: route_to_this_action,
id: 'remove_the_first_page_of_this_pdf_file',
css_style: 'margin-left:2em; margin-top:2px') {
'<input type="text" name="user_input" style="border:3px solid slateblue; padding: 4px"><br>'\
'<b>Select a file</b>: <input type="file" name="this_file"><br>'\
'<input type="submit" name="user_input_submit" '\
'value="Click here to remove the first page of this .pdf file" style="2px dotted royalblue; '\
'color: white; background-color: olive; font-size: 1.50em;
margin:4px; padding: 4px; border: 1px solid black">'
}
}
end
|
#return_div_showing_all_available_books_if_we_are_on_a_roebe_system ⇒ Object
#
return_div_showing_all_available_books_if_we_are_on_a_roebe_system
#
205
206
207
208
209
210
211
212
213
214
|
# File 'lib/pdf_paradise/sinatra/embeddable_interface.rb', line 205
def return_div_showing_all_available_books_if_we_are_on_a_roebe_system
_ = ''.dup
if PdfParadise.is_on_roebe?
all_pdf_files = Dir['/home/x/books/**/*.pdf']
all_pdf_files.each {|this_pdf_file|
_ << this_pdf_file+"<br>"
}
end
return _
end
|
#return_full_title ⇒ Object
Also known as:
default_title
266
267
268
|
# File 'lib/pdf_paradise/sinatra/embeddable_interface.rb', line 266
def return_full_title
'<title>PDF-based operations</title>'
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 will be shown on the root-directory.
#
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
|
# File 'lib/pdf_paradise/sinatra/embeddable_interface.rb', line 164
def return_index_of_hyperlinks
hash = PdfParadise::EmbeddableInterface.sub_routes?
if Object.const_defined? :WebObject
cat_image = Cyberweb.base64_image(:cat)
else
cat_image = ''
end
a('/', content: cat_image+' /',
css_style: USE_THIS_UNIFORM_CSS_STYLE)+
'<br>'+
a(hash[:view], content: cat_image+' /view',
css_style: USE_THIS_UNIFORM_CSS_STYLE)+
'<br>'+
a(hash[:n_pdf_pages], content: cat_image+' /n_pdf_pages',
css_style: USE_THIS_UNIFORM_CSS_STYLE)+
'<br>'+
a('/title', content: cat_image+' /title',
css_style: USE_THIS_UNIFORM_CSS_STYLE)+
'<br>'+
p(
'Click on the <b>following link</b> to autoconvert all .pdf files '\
'in the directory called '\
'<b>'+PdfParadise.main_directory?.to_s+'</b>'
)+
a('/autoconvert', css_style: USE_THIS_UNIFORM_CSS_STYLE)+
'<br>'+
return_div_for_manual_pdf_conversion+
return_div_for_removing_the_first_page_of_this_pdf_file
end
|
#return_link_to_root ⇒ Object
296
297
298
299
300
301
302
|
# File 'lib/pdf_paradise/sinatra/embeddable_interface.rb', line 296
def return_link_to_root
abr(
'/',
content: :self,
css_style: USE_THIS_UNIFORM_CSS_STYLE
)
end
|
#return_n_pdf_pages ⇒ Object
280
281
282
283
284
285
286
287
288
289
290
291
|
# File 'lib/pdf_paradise/sinatra/embeddable_interface.rb', line 280
def return_n_pdf_pages
route_to_this_action = sub_routes?[:n_pdf_pages]
html_start_then_title+
p('Provide the path to a .pdf file:')+
form(action: route_to_this_action,
id: route_to_this_action.delete('/'),
css_style: 'margin-left:2em; margin-top:2px') {
input_type_user_input+
br+
input_type_submit('Submit')
}
end
|
#return_paragraph_of_hyperlinks ⇒ Object
Also known as:
#
return_paragraph_of_hyperlinks
#
135
136
137
138
139
140
141
142
143
|
# File 'lib/pdf_paradise/sinatra/embeddable_interface.rb', line 135
def return_paragraph_of_hyperlinks
p(
'The following entry-points are available for the '\
'<b>PdfParadise project</b>: (Version: '+PdfParadise::VERSION+',
Last Update: '+PdfParadise::LAST_UPDATE+')
<br><br>'+
return_index_of_hyperlinks
)
end
|
#return_root_string ⇒ Object
#
return_root_string (root tag)
#
315
316
317
318
319
320
321
322
|
# File 'lib/pdf_paradise/sinatra/embeddable_interface.rb', line 315
def return_root_string
html_then_title+
return_CSS_rules_to_use+
open_body+
return_paragraph_of_hyperlinks+
close_body+
close_html
end
|
#return_view_string ⇒ Object
Also known as:
view?
148
149
150
151
152
153
154
155
156
|
# File 'lib/pdf_paradise/sinatra/embeddable_interface.rb', line 148
def return_view_string
hash = PdfParadise::EmbeddableInterface.sub_routes?
h1('Pdf Options:', css_style: 'margin-left:0.25em;')+
p(
"The next link is to view all .pdf files at <b>"\
"#{PdfParadise.main_directory?}</b>"
)+
abr(hash[:view])
end
|