jsmenubuilder 0.2.12 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/jsmenubuilder.rb +111 -27
- metadata +28 -27
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 316d2335263826ac8c815f29eb8c992cc60addc471a125a2ab5d56d38178e8f0
|
|
4
|
+
data.tar.gz: cd745cc90c562fce91026cfc18d0ab93ff7ea1d2f137f9b915f7c3a7285e6cec
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 17f2d295f6e593f29c6f318e0a212ec49390f060aed6fda3f653437fc9a7c25a4e31745d449d8363e88829ad8bdb2fe282d04c3957005a5b4bbb7dad9791de53
|
|
7
|
+
data.tar.gz: 8ed6769c73d838c5bcf24764efd0fa36eacdf2008f8d2476986c4b04ddb75d0e1827d7dc87d47c7bc4b596e4449e1e6fe9d95f6b558f1effa32d0f4dcb0bb92e
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data.tar.gz.sig
CHANGED
|
Binary file
|
data/lib/jsmenubuilder.rb
CHANGED
|
@@ -6,6 +6,7 @@ require 'rexle'
|
|
|
6
6
|
require 'rxfhelper'
|
|
7
7
|
require 'rexle-builder'
|
|
8
8
|
|
|
9
|
+
|
|
9
10
|
class JsMenuBuilder
|
|
10
11
|
using ColouredText
|
|
11
12
|
|
|
@@ -189,7 +190,43 @@ STICKY_NAVBAR_CSS =<<EOF
|
|
|
189
190
|
.sticky + .content {
|
|
190
191
|
padding-top: 60px;
|
|
191
192
|
}
|
|
193
|
+
/* see https://stackoverflow.com/questions/10732690/offsetting-an-html-anchor-to-adjust-for-fixed-header */
|
|
194
|
+
.anchor {
|
|
195
|
+
background-color: transparent;
|
|
196
|
+
padding-top: 70px;
|
|
197
|
+
margin-top: -70px;
|
|
198
|
+
display: block;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
h2.anchor {
|
|
202
|
+
background-color: transparent;
|
|
203
|
+
padding-top: 60px;
|
|
204
|
+
margin-top: 0px;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
EOF
|
|
208
|
+
|
|
209
|
+
VERTICAL_MENU_CSS =<<EOF
|
|
210
|
+
.vertical-menu {
|
|
211
|
+
width: 200px; /* Set a width if you like */
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
.vertical-menu a {
|
|
215
|
+
background-color: #eee; /* Grey background color */
|
|
216
|
+
color: black; /* Black text color */
|
|
217
|
+
display: block; /* Make the links appear below each other */
|
|
218
|
+
padding: 12px; /* Add some padding */
|
|
219
|
+
text-decoration: none; /* Remove underline from links */
|
|
220
|
+
}
|
|
192
221
|
|
|
222
|
+
.vertical-menu a:hover {
|
|
223
|
+
background-color: #ccc; /* Dark grey background on mouse-over */
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
.vertical-menu a.active {
|
|
227
|
+
background-color: #4CAF50; /* Add a green color to the "active/current" link */
|
|
228
|
+
color: white;
|
|
229
|
+
}
|
|
193
230
|
EOF
|
|
194
231
|
|
|
195
232
|
FULL_PAGE_TABS_JS =<<EOF
|
|
@@ -266,6 +303,10 @@ function myFunction() {
|
|
|
266
303
|
}
|
|
267
304
|
EOF
|
|
268
305
|
|
|
306
|
+
VERTICAL_MENU_JS = ''
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
|
|
269
310
|
attr_reader :html, :css, :js
|
|
270
311
|
|
|
271
312
|
def initialize(unknown=nil, options={})
|
|
@@ -290,7 +331,7 @@ EOF
|
|
|
290
331
|
options = unknown
|
|
291
332
|
end
|
|
292
333
|
|
|
293
|
-
@types = %i(tabs full_page_tabs accordion sticky_navbar)
|
|
334
|
+
@types = %i(tabs full_page_tabs accordion sticky_navbar vertical_menu)
|
|
294
335
|
|
|
295
336
|
build(type, options) if type
|
|
296
337
|
|
|
@@ -331,6 +372,10 @@ EOF
|
|
|
331
372
|
@css
|
|
332
373
|
end
|
|
333
374
|
|
|
375
|
+
def to_h()
|
|
376
|
+
@h
|
|
377
|
+
end
|
|
378
|
+
|
|
334
379
|
def to_html()
|
|
335
380
|
@html
|
|
336
381
|
end
|
|
@@ -341,25 +386,29 @@ EOF
|
|
|
341
386
|
|
|
342
387
|
def to_webpage()
|
|
343
388
|
|
|
389
|
+
r = block_given? ? yield(@css, @html, @js) : @css, @html, @js
|
|
390
|
+
css, html, js = *r.flatten
|
|
391
|
+
puts 'css: ' + css.inspect if @debug
|
|
392
|
+
|
|
344
393
|
a = RexleBuilder.build do |xml|
|
|
345
394
|
xml.html do
|
|
346
395
|
xml.head do
|
|
347
396
|
xml.meta name: "viewport", content: \
|
|
348
397
|
"width=device-width, initial-scale=1"
|
|
349
|
-
xml.style "\nbody {font-family: Arial;}\n\n" +
|
|
398
|
+
xml.style "\nbody {font-family: Arial;}\n\n" + css
|
|
350
399
|
end
|
|
351
400
|
xml.body
|
|
352
401
|
end
|
|
353
402
|
end
|
|
354
403
|
|
|
355
404
|
doc = Rexle.new(a)
|
|
356
|
-
e = Rexle.new("<html>%s</html>" %
|
|
405
|
+
e = Rexle.new("<html>%s</html>" % html).root
|
|
357
406
|
|
|
358
407
|
e.children.each {|child| doc.root.element('body').add child }
|
|
359
408
|
|
|
360
409
|
doc.root.element('body').add \
|
|
361
410
|
Rexle::Element.new('script').add_text "\n" +
|
|
362
|
-
|
|
411
|
+
js.gsub(/^ +\/\/[^\n]+\n/,'')
|
|
363
412
|
|
|
364
413
|
"<!DOCTYPE html>\n" + doc.xml(pretty: true, declaration: false)\
|
|
365
414
|
.gsub(/<\/div>/,'\0' + "\n").gsub(/\n *<!--[^>]+>/,'')
|
|
@@ -401,7 +450,7 @@ EOF
|
|
|
401
450
|
puts 'inside build_h'.info if @debug
|
|
402
451
|
|
|
403
452
|
h = doc.root.xpath('tag').inject({}) do |r,e|
|
|
404
|
-
r.merge(e.attributes[:title] => e.children.join.strip)
|
|
453
|
+
r.merge(e.attributes[:title] => [e.children.join.strip, e.attributes[:class].join(' ')])
|
|
405
454
|
end
|
|
406
455
|
|
|
407
456
|
puts ('build_h: ' + h.inspect).debug if @debug
|
|
@@ -433,8 +482,9 @@ EOF
|
|
|
433
482
|
|
|
434
483
|
a = RexleBuilder.build do |xml|
|
|
435
484
|
xml.tags({mode: type}) do
|
|
436
|
-
entries.each do |heading,
|
|
437
|
-
|
|
485
|
+
entries.each do |heading, value|
|
|
486
|
+
content, klass = value
|
|
487
|
+
xml.tag({title: heading, class: klass}, content )
|
|
438
488
|
end
|
|
439
489
|
end
|
|
440
490
|
end
|
|
@@ -537,7 +587,7 @@ EOF
|
|
|
537
587
|
|
|
538
588
|
panels = opt[:accordion]
|
|
539
589
|
|
|
540
|
-
h = panels.group_by {|key, value| key.upcase[0]}
|
|
590
|
+
@h = h = panels.group_by {|key, value| key.upcase[0]}
|
|
541
591
|
|
|
542
592
|
debug = @debug
|
|
543
593
|
|
|
@@ -546,25 +596,24 @@ EOF
|
|
|
546
596
|
a = RexleBuilder.build do |xml|
|
|
547
597
|
|
|
548
598
|
xml.html do
|
|
549
|
-
|
|
550
|
-
|
|
599
|
+
|
|
600
|
+
h.sort.each do |char, rows|
|
|
551
601
|
|
|
552
|
-
|
|
553
|
-
xml.a({href: '#' + char.downcase}, char)
|
|
554
|
-
end
|
|
602
|
+
xml.h2({class: 'anchor', id: char.downcase}, char)
|
|
555
603
|
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
rows.each do |heading, inner_html|
|
|
604
|
+
rows.each do |heading, value|
|
|
605
|
+
|
|
606
|
+
puts 'value: ' + value.inspect if @debug
|
|
607
|
+
inner_html, attrclass = value
|
|
608
|
+
|
|
563
609
|
puts 'inner_html: ' + inner_html.inspect if debug
|
|
564
|
-
xml.a({name: heading.downcase.gsub(/\W/,'-')
|
|
565
|
-
|
|
610
|
+
xml.a({class: 'anchor', name: heading.downcase.gsub(/\W/,'-')\
|
|
611
|
+
.gsub(/-{2,}/,'-').gsub(/^-|-$/,'')})
|
|
566
612
|
xml.button({class:'accordion'}, heading.to_s)
|
|
567
|
-
|
|
613
|
+
|
|
614
|
+
s = 'panel'
|
|
615
|
+
s += ' ' + attrclass if attrclass
|
|
616
|
+
xml.div({class: s}, inner_html)
|
|
568
617
|
|
|
569
618
|
end
|
|
570
619
|
end
|
|
@@ -580,7 +629,8 @@ EOF
|
|
|
580
629
|
|
|
581
630
|
def sticky_navbar(opt={})
|
|
582
631
|
|
|
583
|
-
|
|
632
|
+
puts 'inside sticky_navbar' if @debug
|
|
633
|
+
|
|
584
634
|
navhtml = if opt[:html] then
|
|
585
635
|
|
|
586
636
|
opt[:html]
|
|
@@ -593,8 +643,8 @@ EOF
|
|
|
593
643
|
|
|
594
644
|
xml.div(id: 'navbar') do
|
|
595
645
|
|
|
596
|
-
|
|
597
|
-
xml.a({href:
|
|
646
|
+
opt[:sticky_navbar].each do |title, href|
|
|
647
|
+
xml.a({href: href}, title)
|
|
598
648
|
end
|
|
599
649
|
|
|
600
650
|
end
|
|
@@ -609,6 +659,40 @@ EOF
|
|
|
609
659
|
return doc
|
|
610
660
|
|
|
611
661
|
|
|
612
|
-
end
|
|
662
|
+
end
|
|
663
|
+
|
|
664
|
+
def vertical_menu(opt={})
|
|
665
|
+
|
|
666
|
+
puts 'inside vertical_navbar' if @debug
|
|
667
|
+
|
|
668
|
+
navhtml = if opt[:html] then
|
|
669
|
+
|
|
670
|
+
opt[:html]
|
|
671
|
+
|
|
672
|
+
elsif opt[:items]
|
|
673
|
+
|
|
674
|
+
RexleBuilder.build do |xml|
|
|
675
|
+
|
|
676
|
+
xml.html do
|
|
677
|
+
|
|
678
|
+
xml.div(class: 'vertical-menu') do
|
|
679
|
+
|
|
680
|
+
opt[:items].each do |title, href|
|
|
681
|
+
xml.a({href: href}, title)
|
|
682
|
+
end
|
|
683
|
+
|
|
684
|
+
end
|
|
685
|
+
|
|
686
|
+
end
|
|
687
|
+
end
|
|
688
|
+
end
|
|
689
|
+
|
|
690
|
+
doc = Rexle.new(navhtml)
|
|
691
|
+
puts 'doc: ' + doc.xml.inspect if @debug
|
|
692
|
+
|
|
693
|
+
return doc
|
|
694
|
+
|
|
695
|
+
|
|
696
|
+
end
|
|
613
697
|
|
|
614
698
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: jsmenubuilder
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.3.4
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- James Robertson
|
|
@@ -11,31 +11,31 @@ cert_chain:
|
|
|
11
11
|
- |
|
|
12
12
|
-----BEGIN CERTIFICATE-----
|
|
13
13
|
MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDDCFnZW1t
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
14
|
+
YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMjEwMTE3MjAxMDI3WhcN
|
|
15
|
+
MjIwMTE3MjAxMDI3WjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
|
|
16
|
+
cnRzb24vREM9ZXUwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQC2UBXg
|
|
17
|
+
dSeJqcBwxeYBSbb4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nVnhi8tBU5+0bwqR2USL9LKVoeDCyd6sxOlkffVqYZFRGQB3/K3o9
|
|
31
|
+
XaAfiwiXOcq1hYBPh76N/rcNUvjlON4WpoJbwGiREKsLgFXpExXloeUUo8EhCVs5
|
|
32
|
+
g5n20V75pNW/1y8jOxbrKq/M4uaJkyvFMc96ms/NO5Av1OO/GfFJmecuupUvi80E
|
|
33
|
+
yD+/vvvKT8C6A+7Luv70eCEqNC2kmI5k2FKlfkkfaHacRtDz4Ntzw+W216u2ewBB
|
|
34
|
+
4DzeVtqMQq2g7T4xVjQRRwdBJkdERbyx4TD/2HNa6VNC/V8R5aVlKNyjjglPSC3P
|
|
35
|
+
stR9WM2Qrn9oxHHjgt05mQb9lgp7uGqcCvQoP82U8lJawp7oLLsO25kTe4Hj28T1
|
|
36
|
+
+BcAGJd5hR/dFCHvJ6rtQss3
|
|
37
37
|
-----END CERTIFICATE-----
|
|
38
|
-
date:
|
|
38
|
+
date: 2021-01-17 00:00:00.000000000 Z
|
|
39
39
|
dependencies:
|
|
40
40
|
- !ruby/object:Gem::Dependency
|
|
41
41
|
name: rexle
|
|
@@ -46,7 +46,7 @@ dependencies:
|
|
|
46
46
|
version: '1.5'
|
|
47
47
|
- - ">="
|
|
48
48
|
- !ruby/object:Gem::Version
|
|
49
|
-
version: 1.5.
|
|
49
|
+
version: 1.5.9
|
|
50
50
|
type: :runtime
|
|
51
51
|
prerelease: false
|
|
52
52
|
version_requirements: !ruby/object:Gem::Requirement
|
|
@@ -56,7 +56,7 @@ dependencies:
|
|
|
56
56
|
version: '1.5'
|
|
57
57
|
- - ">="
|
|
58
58
|
- !ruby/object:Gem::Version
|
|
59
|
-
version: 1.5.
|
|
59
|
+
version: 1.5.9
|
|
60
60
|
description:
|
|
61
61
|
email: james@jamesrobertson.eu
|
|
62
62
|
executables: []
|
|
@@ -83,7 +83,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
83
83
|
- !ruby/object:Gem::Version
|
|
84
84
|
version: '0'
|
|
85
85
|
requirements: []
|
|
86
|
-
|
|
86
|
+
rubyforge_project:
|
|
87
|
+
rubygems_version: 2.7.10
|
|
87
88
|
signing_key:
|
|
88
89
|
specification_version: 4
|
|
89
90
|
summary: Generates HTML based tabs using HTML, CSS, and JavaScript.
|
metadata.gz.sig
CHANGED
|
Binary file
|