htmlcom 0.2.5 → 0.3.0

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.
Files changed (6) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/lib/htmlcom.rb +211 -39
  4. data.tar.gz.sig +0 -0
  5. metadata +35 -55
  6. metadata.gz.sig +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8004cbae029ee293b21479ba8848c1651f26f335b999d16c0ef8d81441b71f30
4
- data.tar.gz: 9cf701e4bb970992b648fd54b73e4e7a700716bbaa8c5a898fce1b43800ebad1
3
+ metadata.gz: 41f76e94774f2bfc83083ea47a7a47272f13dcb9c813100f3f5c688114faef6f
4
+ data.tar.gz: 1eec290b80a32ebfc3f976d0c35f2a2ffccee516da6c71aed20f110bc9fd412a
5
5
  SHA512:
6
- metadata.gz: 91c0da1574759668917fd20254b82babcdbfca8302a6019b4d2d13e6125c26fdf08b65299965debf497ad530f2fd8120851bd88e7aabccc27e40360386a9aa98
7
- data.tar.gz: 66e8aba374f7e41d4c9c01cc5820141c8ed03f823f1ec2dea5de68c5a6af8aac98308a3a1b37ea80422fdd75e88ac98b268f1183bff3ce53a7b576e0231a0923
6
+ metadata.gz: d431b683fd27995074a06a0ccb2726dc0dc8af57eae06514c7e57402c781c257f2a2f8e1210f8939afdff4a6c23013840ca2a42e0b0053eb9ae37f4a8adc95de
7
+ data.tar.gz: d63d7b19dae7e63d24d931a64ebebc2bfa904f1632ec30a7a07734e8325edb9a1db4441bcc7acce17826ecd02de1208282405a8c94894bcc464e0fe4231be5c4
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/htmlcom.rb CHANGED
@@ -9,73 +9,85 @@ require 'xml_to_sliml'
9
9
  require 'jsajax_wizard'
10
10
  require 'jsmenubuilder'
11
11
  require 'jstreebuilder'
12
+ require 'rexle'
13
+ require 'rexle-builder'
12
14
 
15
+ # classes:
16
+
17
+ # Accordion
18
+ # Tabs (:tabs, :full_page_tabs)
19
+ # Tree
20
+ # Menu (:vertical_menu, :fixed_menu, sticky_nav, breadcrumb)
21
+ # Element # used by the HTML element
22
+ # InputElement # used by the HTML input element
23
+ # Dropdown # an HTML element
24
+ # Textarea # an HTML element
25
+
26
+ module HtmlCom
13
27
 
14
- module HtmlCom
15
-
16
28
  class Accordion
17
-
29
+
18
30
  attr_reader :to_html, :to_css, :to_js, :to_tags
19
-
31
+
20
32
  def initialize(xml, debug: false)
21
-
33
+
22
34
  xml, @debug = xml, debug
23
-
35
+
24
36
  # transform the accordion XML to tags XML
25
37
  tags = Nokogiri::XSLT(xsl()).transform(Nokogiri::XML(xml))\
26
38
  .to_xhtml(indent: 0)
27
-
39
+
28
40
  @to_tags = tags # used for debugging the structure
29
-
41
+
30
42
  jmb = JsMenuBuilder.new(tags, debug: debug)
31
-
43
+
32
44
  pg = if Rexle.new(xml).root.attributes[:navbar] then
33
45
 
34
46
  a = jmb.to_h.keys.sort.map {|key, _| [key, '#' + key.downcase]}
35
47
 
36
- navbar = JsMenuBuilder.new(:sticky_navbar, {sticky_navbar: a,
48
+ navbar = JsMenuBuilder.new(:sticky_navbar, {sticky_navbar: a,
37
49
  debug: debug})
38
-
50
+
39
51
  @to_css = navbar.to_css + "\n" + jmb.to_css
40
52
  @to_js = navbar.to_js + "\n" + jmb.to_js
41
53
 
42
54
 
43
55
  jmb.to_webpage do |css, html, js|
44
-
56
+
45
57
  [
46
- navbar.to_css + "\n" + css,
47
- navbar.to_html + "\n" + html,
58
+ navbar.to_css + "\n" + css,
59
+ navbar.to_html + "\n" + html,
48
60
  navbar.to_js + "\n" + js
49
61
  ]
50
-
62
+
51
63
  end
52
-
64
+
53
65
  else
54
-
66
+
55
67
  @to_css = jmb.to_css
56
68
  @to_js = jmb.to_js
57
-
69
+
58
70
  jmb.to_webpage
59
-
71
+
60
72
  end
61
73
 
62
74
  # apply the AJAX
63
- @to_html = JsAjaxWizard.new(pg).to_html
75
+ @to_html = JsAjaxWizard.new(pg).to_html
64
76
 
65
77
  end
66
-
67
-
78
+
79
+
68
80
  private
69
81
 
70
82
  def xsl()
71
-
83
+
72
84
  xsl= %q(
73
85
  <xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>
74
86
 
75
87
  <xsl:template match='accordion'>
76
88
 
77
89
  <xsl:element name='tags'>
78
- <xsl:attribute name='mode'>accordion</xsl:attribute>
90
+ <xsl:attribute name='mode'>accordion</xsl:attribute>
79
91
  <xsl:apply-templates select='panel' />
80
92
  </xsl:element>
81
93
 
@@ -87,10 +99,10 @@ xsl= %q(
87
99
  <xsl:attribute name='title'>
88
100
  <xsl:value-of select='@title'/>
89
101
  </xsl:attribute>
90
-
102
+
91
103
  <xsl:attribute name='class'>
92
104
  <xsl:value-of select='@class'/>
93
- </xsl:attribute>
105
+ </xsl:attribute>
94
106
 
95
107
  <xsl:element name="input">
96
108
  <xsl:attribute name="type">hidden</xsl:attribute>
@@ -117,7 +129,7 @@ xsl= %q(
117
129
  )
118
130
 
119
131
  end
120
-
132
+
121
133
  end
122
134
 
123
135
  class Tabs
@@ -155,16 +167,16 @@ xsl= %q(
155
167
 
156
168
  # current options for type:
157
169
  # :tabs, :full_page_tabs
158
-
170
+
159
171
  def initialize(type=:tabs, headings: [], xml: nil, debug: false)
160
172
 
161
173
  @type, @debug = type, debug
162
174
  @build = JsMenuBuilder.new(type, headings: headings)
163
-
175
+
164
176
  @active_tab = 1
165
177
 
166
178
  @tab = headings.map do |heading|
167
- Tab.new heading, content: "<h3>#{heading}</h3>",
179
+ Tab.new heading, content: "<h3>#{heading}</h3>",
168
180
  callback: self, debug: debug
169
181
  end
170
182
 
@@ -203,23 +215,30 @@ xsl= %q(
203
215
  tabs = @tab.map do |tab|
204
216
  tab.title ? tab.to_a : nil
205
217
  end.compact.to_h
206
-
218
+
207
219
  if @debug then
208
- puts 'inside ping; tabs: ' + tabs.inspect
220
+ puts 'inside ping; tabs: ' + tabs.inspect
209
221
  puts '@active_tab: ' + @active_tab.inspect
210
222
  end
211
-
212
- @build = JsMenuBuilder.new(@type, tabs: tabs,
223
+
224
+ @build = JsMenuBuilder.new(@type, tabs: tabs,
213
225
  active: @active_tab, debug: @debug)
214
226
 
215
227
  end
216
228
 
217
229
  alias refresh ping
218
230
 
231
+ def to_css()
232
+ @build.to_css
233
+ end
234
+
219
235
  def to_html()
220
236
  @build.to_html
221
237
  end
222
238
 
239
+ def to_js()
240
+ @build.to_js
241
+ end
223
242
 
224
243
  # not yet working properly
225
244
  def to_bangtag()
@@ -232,18 +251,171 @@ xsl= %q(
232
251
  end
233
252
 
234
253
  end
235
-
254
+
236
255
  class Tree
237
-
256
+
257
+ # hn = heading number
238
258
  def initialize(s, debug: false, hn: 2)
239
259
  jtb = JsTreeBuilder.new(:sidebar, {src: s, hn: hn, debug: debug})
240
- @html = jtb.to_webpage
260
+ @html = jtb.to_webpage
241
261
  end
242
-
262
+
243
263
  def to_webpage()
244
264
  @html
245
265
  end
246
-
266
+
267
+ end
268
+
269
+ class Menu
270
+
271
+ # current options
272
+ # :vertical_menu, :fixed_menu, sticky_nav, breadcrumb
273
+ #
274
+ def initialize(type=:vertical_menu, links, debug: false)
275
+ @jtb = JsMenuBuilder.new(type, {items: links, debug: debug})
276
+ end
277
+
278
+ def to_css()
279
+ @jtb.to_css
280
+ end
281
+
282
+ def to_html()
283
+ @jtb.to_html
284
+ end
285
+
286
+ def to_js()
287
+ @jtb.to_js
288
+ end
289
+
290
+ def to_webpage()
291
+ @jtb.to_webpage
292
+ end
293
+
294
+ end
295
+
296
+ class MindWordsWidget
297
+
298
+ def initialize(attributes)
299
+
300
+ @attributes = {
301
+ content: '',
302
+ action: 'mwupdate',
303
+ target: 'icontent'
304
+ }.merge(attributes)
305
+
306
+ end
307
+
308
+ def input(params={})
309
+
310
+ h = @attributes.merge(params)
311
+ content = h[:content]
312
+ action = h[:action]
313
+ target = h[:target]
314
+
315
+ @html =<<EOF
316
+ <form action='#{action}' method='post' target='#{target}'>
317
+ <textarea name='content' cols='30' rows='19'>
318
+ #{content}
319
+ </textarea>
320
+ <input type='submit' value='Submit'/>
321
+ </form>
322
+ EOF
323
+ self
324
+
325
+ end
326
+
327
+ def to_html()
328
+ @html
329
+ end
330
+
331
+ end
332
+
333
+ class Element
334
+
335
+ def initialize(h)
336
+ @doc = build(h)
337
+ end
338
+
339
+ def to_doc()
340
+ @doc
341
+ end
342
+
343
+ def build(h)
344
+
345
+ puts 'h: ' + h.inspect
346
+ doc = Rexle.new(RexleBuilder.new(h).to_a)
347
+ puts doc.xml pretty: true
348
+ doc
349
+ end
350
+
351
+ end
352
+
353
+ class InputElement < Element
354
+
355
+ def initialize(rawobj)
356
+
357
+ if @label then
358
+
359
+ obj = [{label: @label}, rawobj]
360
+ super({@tag.to_sym => obj})
361
+ @doc.root.element(@tag + '/label').attributes[:for] = @id
362
+
363
+ else
364
+ super({@tag.to_sym => rawobj})
365
+ end
366
+
367
+ if @id then
368
+ elem = @doc.root.element(@tag + '/' + @htmltag)
369
+ elem.attributes[:name] = @id
370
+ elem.attributes[:id] = @id
371
+ end
372
+
373
+ end
374
+
375
+ end
376
+
377
+ class Dropdown < InputElement
378
+
379
+ def initialize(rawoptions=[], options: rawoptions, label: nil, id: nil)
380
+
381
+ @tag = 'dropdown'
382
+ @htmltag = 'select'
383
+ @id = id
384
+ @label = label
385
+
386
+ if options.is_a? Array then
387
+
388
+ list = options.map {|option| {option: option}}
389
+ super({_select: list})
390
+
391
+ elsif options.is_a? Hash then
392
+
393
+ list = options.values.map {|option| {option: option}}
394
+ values = options.keys
395
+ puts 'list: ' + list.inspect
396
+ super({_select: list})
397
+
398
+ @doc.root.xpath('dropdown/select/option').each.with_index do |e,i|
399
+ e.attributes[:value] = values[i]
400
+ end
401
+
402
+
403
+ end
404
+ end
405
+ end
406
+
407
+ class Textarea < InputElement
408
+
409
+ def initialize(value='', text: value, label: nil, id: nil)
410
+
411
+ @tag = 'textarea'
412
+ @htmltag = 'textarea'
413
+ @id = id
414
+ @label = label
415
+ super({@tag.to_sym => text})
416
+
417
+ end
418
+
247
419
  end
248
420
 
249
421
  end
data.tar.gz.sig CHANGED
Binary file
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: htmlcom
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -10,32 +10,33 @@ bindir: bin
10
10
  cert_chain:
11
11
  - |
12
12
  -----BEGIN CERTIFICATE-----
13
- MIIEXjCCAsagAwIBAgIBATANBgkqhkiG9w0BAQsFADAsMSowKAYDVQQDDCFnZW1t
14
- YXN0ZXIvREM9amFtZXNyb2JlcnRzb24vREM9ZXUwHhcNMjEwMTE3MTUzNjE1WhcN
15
- MjIwMTE3MTUzNjE1WjAsMSowKAYDVQQDDCFnZW1tYXN0ZXIvREM9amFtZXNyb2Jl
16
- cnRzb24vREM9ZXUwggGiMA0GCSqGSIb3DQEBAQUAA4IBjwAwggGKAoIBgQDTZ8f6
17
- 3hCg1WPZPVRqvFupR3GrNpUVmE7ly6PnuoAGxvAr5QrGUy4mcy3NRYaExgE2sPMv
18
- zesDm3LVRvSLKoXThlbkNf/c2P4X2RXQzdNTuRY4hp77B9/a0+gWeFwX+K8dB27e
19
- foPBNLGwzlXl28b18cm+ik5CFwQiLtDYZUJIo6XMjpIOZX6r3ppdjX6zhxP83SJR
20
- DNcXYesJS2CW/Jr1nXA2VtW454tZT/G1My7OROMb13tyNeLvrBFnq+x5/qBzMTn5
21
- RSy3V/n1Q0acNgepEGTEF26bPz+KQi+IYUR+0SR4NlQvxFI3s/EwhGREs7ebb2n4
22
- y5z1O4BQU1CTNTEBVPErYe40rCbPx2tl7UFjeMREynyxdSqIgpuu5QDw+oGIA/G5
23
- +6n7+MSCiuK3aPweVRG+Cdx6bYJBgzR2oBTpOSnQBGuP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KLx8ni
31
+ +yxPmNFdAoTCA+NtY/hK6QWHNKd9NamAVVlZeccVn5MPPU3rXfR95+bB6Nhn+wbh
32
+ 6WTQc/GXDluzOMLoPHyE61J5tFBYSsA6BJZI5mOMBHP3UpJsuHTl2CHmHGjj4twk
33
+ IBxUACAF1vCdlWkL053BQttlZB5Pwb0U/tqclBwiNvx+lgKmz7ET1Jozhc5MinMk
34
+ aYiDsjEUsuY+OedqmF5uCi5smx9JJRDOBTNwJbHBWvPRMYI2Ll0a2lROWM4kxEeg
35
+ uI6GFPYf4z/KAOyF8W2uHSc7Hyt8ZB4BK7QLKo2PqdGlFsXk9r+LEMFuK3e8zEbF
36
+ JNdZs/7/k4vQlgqYQ3HnoA6GgIanmCgNkediqllxv/epLyIkW2DSJGcYXM8QjSEk
37
+ +4RQ8UHDCOWHpFPlT5Pgc0wPc7KyXosRYHg=
37
38
  -----END CERTIFICATE-----
38
- date: 2021-01-17 00:00:00.000000000 Z
39
+ date: 2022-07-05 00:00:00.000000000 Z
39
40
  dependencies:
40
41
  - !ruby/object:Gem::Dependency
41
42
  name: jsmenubuilder
@@ -46,7 +47,7 @@ dependencies:
46
47
  version: '0.3'
47
48
  - - ">="
48
49
  - !ruby/object:Gem::Version
49
- version: 0.3.2
50
+ version: 0.3.6
50
51
  type: :runtime
51
52
  prerelease: false
52
53
  version_requirements: !ruby/object:Gem::Requirement
@@ -56,27 +57,27 @@ dependencies:
56
57
  version: '0.3'
57
58
  - - ">="
58
59
  - !ruby/object:Gem::Version
59
- version: 0.3.2
60
+ version: 0.3.6
60
61
  - !ruby/object:Gem::Dependency
61
62
  name: jstreebuilder
62
63
  requirement: !ruby/object:Gem::Requirement
63
64
  requirements:
64
65
  - - "~>"
65
66
  - !ruby/object:Gem::Version
66
- version: '0.2'
67
+ version: '0.3'
67
68
  - - ">="
68
69
  - !ruby/object:Gem::Version
69
- version: 0.2.4
70
+ version: 0.3.2
70
71
  type: :runtime
71
72
  prerelease: false
72
73
  version_requirements: !ruby/object:Gem::Requirement
73
74
  requirements:
74
75
  - - "~>"
75
76
  - !ruby/object:Gem::Version
76
- version: '0.2'
77
+ version: '0.3'
77
78
  - - ">="
78
79
  - !ruby/object:Gem::Version
79
- version: 0.2.4
80
+ version: 0.3.2
80
81
  - !ruby/object:Gem::Dependency
81
82
  name: jsajax_wizard
82
83
  requirement: !ruby/object:Gem::Requirement
@@ -117,28 +118,8 @@ dependencies:
117
118
  - - ">="
118
119
  - !ruby/object:Gem::Version
119
120
  version: 0.1.2
120
- - !ruby/object:Gem::Dependency
121
- name: nokogiri
122
- requirement: !ruby/object:Gem::Requirement
123
- requirements:
124
- - - "~>"
125
- - !ruby/object:Gem::Version
126
- version: '1.11'
127
- - - ">="
128
- - !ruby/object:Gem::Version
129
- version: 1.11.1
130
- type: :runtime
131
- prerelease: false
132
- version_requirements: !ruby/object:Gem::Requirement
133
- requirements:
134
- - - "~>"
135
- - !ruby/object:Gem::Version
136
- version: '1.11'
137
- - - ">="
138
- - !ruby/object:Gem::Version
139
- version: 1.11.1
140
121
  description:
141
- email: james@jamesrobertson.eu
122
+ email: digital.robertson@gmail.com
142
123
  executables: []
143
124
  extensions: []
144
125
  extra_rdoc_files: []
@@ -163,8 +144,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
163
144
  - !ruby/object:Gem::Version
164
145
  version: '0'
165
146
  requirements: []
166
- rubyforge_project:
167
- rubygems_version: 2.7.10
147
+ rubygems_version: 3.3.7
168
148
  signing_key:
169
149
  specification_version: 4
170
150
  summary: Generates HTML components and is designed for rendering dynamic web pages
metadata.gz.sig CHANGED
Binary file