htmlcom 0.1.1 → 0.2.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 661f23ca4451ee0385d659f70b7e53ae9d43e7d30d75928ce4c4b7e0feb6e309
4
- data.tar.gz: f9cc43dc228fbc06cc53bc25595961030578bf5fb66503114a461be7629f4ab8
3
+ metadata.gz: 8d7960f5340eeea39252bf10f7b8c916c0b88877d86cea08064a132043602a45
4
+ data.tar.gz: 1d6d0f6e7ec0bf4508f77e611e7301925cc791744ff84ae58ed32debd058e3fb
5
5
  SHA512:
6
- metadata.gz: e763b428c839e7efa19a230150f6fcbd81a1e57bf9f51ff37b524b3f964210dbd7ad9938b4f67b4bc0de50242197208b37d2789ecead0b5cab189d58a764742c
7
- data.tar.gz: 0b6ead14425a9261d4ffbd1677ba9da9ac62ef458d012af8404aa1bfadfb8db9869e7d3211084f1a4dabbef5855e3e4d0e8667d2b6cdea5b73a2b1b8d91dffc2
6
+ metadata.gz: 91ef20411c97b6b4dfbe8cec05547b4f38adfa4247d21b20db78f05c5880dcaa449543d17d4056b2a647998bb0318df46e35d1268fa4f42aa7e189f6930d135f
7
+ data.tar.gz: b39f2b7c0f1385577fe682c10fca9073a8f28c9a8babe10436d0dd9d99443e8fd46f8088fe8c0fe13022540e38a16b8a1fe3a7fe1b34edeaae9aa4a9594d6da3
checksums.yaml.gz.sig CHANGED
Binary file
data/lib/htmlcom.rb CHANGED
@@ -4,10 +4,83 @@
4
4
 
5
5
  # description: Generates HTML components and is designed for rendering dynamic web pages from a web server.
6
6
 
7
+ require 'nokogiri'
8
+ require 'xml_to_sliml'
9
+ require 'jsajax_wizard'
7
10
  require 'jsmenubuilder'
8
11
 
9
12
 
10
- module HtmlCom
13
+ module HtmlCom
14
+
15
+ class Accordion
16
+
17
+ attr_reader :to_html
18
+
19
+ def initialize(xml, debug: false)
20
+
21
+ xml, @debug = xml, debug
22
+
23
+ # transform the accordion XML to tags XML
24
+ tags = Nokogiri::XSLT(xsl()).transform(Nokogiri::XML(xml))\
25
+ .to_xhtml(indent: 0)
26
+ jmb = JsMenuBuilder.new(tags, debug: debug)
27
+
28
+ # apply the AJAX
29
+ @to_html = JsAjaxWizard.new(jmb.to_webpage).to_html
30
+
31
+ end
32
+
33
+
34
+ private
35
+
36
+ def xsl()
37
+
38
+ xsl= %q(
39
+ <xsl:stylesheet xmlns:xsl='http://www.w3.org/1999/XSL/Transform' version='1.0'>
40
+
41
+ <xsl:template match='accordion'>
42
+
43
+ <xsl:element name='tags'>
44
+ <xsl:attribute name='mode'>accordion</xsl:attribute>
45
+ <xsl:apply-templates select='panel' />
46
+ </xsl:element>
47
+
48
+ </xsl:template>
49
+
50
+ <xsl:template match='panel'>
51
+
52
+ <xsl:element name='tag'>
53
+ <xsl:attribute name='title'>
54
+ <xsl:value-of select='@title'/>
55
+ </xsl:attribute>
56
+
57
+ <xsl:element name="input">
58
+ <xsl:attribute name="type">hidden</xsl:attribute>
59
+
60
+ <xsl:if test='@onopen!=""'>
61
+ <xsl:attribute name="onclick"><xsl:value-of select="@onopen"/></xsl:attribute>
62
+ </xsl:if>
63
+ <xsl:if test='@onclose!=""'>
64
+ <xsl:attribute name="ondblclick"><xsl:value-of select="@onclose"/></xsl:attribute>
65
+ </xsl:if>
66
+ </xsl:element>
67
+
68
+ <xsl:copy-of select="*"/>
69
+ <xsl:if test='@ajaxid!=""'> <!-- used with onopen -->
70
+ <div id='{@ajaxid}'>$<xsl:value-of select="@ajaxid"/></div>
71
+ </xsl:if>
72
+
73
+ </xsl:element>
74
+
75
+ </xsl:template>
76
+
77
+
78
+ </xsl:stylesheet>
79
+ )
80
+
81
+ end
82
+
83
+ end
11
84
 
12
85
  class Tabs
13
86
 
@@ -45,7 +118,7 @@ module HtmlCom
45
118
  # current options for type:
46
119
  # :tabs, :full_page_tabs
47
120
 
48
- def initialize(type=:tabs, headings: %w(tab1 tab2 tab3))
121
+ def initialize(type=:tabs, headings: [], xml: nil)
49
122
 
50
123
  @type = type
51
124
  @build = JsMenuBuilder.new(type, headings: headings)
@@ -54,6 +127,10 @@ module HtmlCom
54
127
  Tab.new heading, content: "<h3>#{heading}</h3>", callback: self
55
128
  end
56
129
 
130
+ if xml then
131
+ @build.import(xml)
132
+ end
133
+
57
134
  end
58
135
 
59
136
  def active=(tabnum)
@@ -96,10 +173,18 @@ module HtmlCom
96
173
  @build.to_html
97
174
  end
98
175
 
176
+
177
+ # not yet working properly
178
+ def to_bangtag()
179
+ XmlToSliml.new(@build.to_xml, spacer: '!')\
180
+ .to_s.lines.map {|x| '!' + x }.join
181
+ end
182
+
99
183
  def to_webpage()
100
184
  @build.to_webpage
101
185
  end
102
186
 
103
187
  end
188
+
104
189
 
105
190
  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.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - James Robertson
@@ -35,7 +35,7 @@ cert_chain:
35
35
  WiRgzz3/21eCm7N/8s5UGa7uDJXDDxf/i/QsEUJn1VcorDbODN3DbcPYph26bgQm
36
36
  vY6P53Z8DPcEft++oI9aZl1n
37
37
  -----END CERTIFICATE-----
38
- date: 2019-07-13 00:00:00.000000000 Z
38
+ date: 2019-12-07 00:00:00.000000000 Z
39
39
  dependencies:
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: jsmenubuilder
@@ -57,6 +57,66 @@ dependencies:
57
57
  - - "~>"
58
58
  - !ruby/object:Gem::Version
59
59
  version: '0.2'
60
+ - !ruby/object:Gem::Dependency
61
+ name: jsajax_wizard
62
+ requirement: !ruby/object:Gem::Requirement
63
+ requirements:
64
+ - - ">="
65
+ - !ruby/object:Gem::Version
66
+ version: 0.3.0
67
+ - - "~>"
68
+ - !ruby/object:Gem::Version
69
+ version: '0.3'
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - ">="
75
+ - !ruby/object:Gem::Version
76
+ version: 0.3.0
77
+ - - "~>"
78
+ - !ruby/object:Gem::Version
79
+ version: '0.3'
80
+ - !ruby/object:Gem::Dependency
81
+ name: xml_to_sliml
82
+ requirement: !ruby/object:Gem::Requirement
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ version: 0.1.0
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.1'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: 0.1.0
97
+ - - "~>"
98
+ - !ruby/object:Gem::Version
99
+ version: '0.1'
100
+ - !ruby/object:Gem::Dependency
101
+ name: nokogiri
102
+ requirement: !ruby/object:Gem::Requirement
103
+ requirements:
104
+ - - "~>"
105
+ - !ruby/object:Gem::Version
106
+ version: '1.10'
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: 1.10.7
110
+ type: :runtime
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - "~>"
115
+ - !ruby/object:Gem::Version
116
+ version: '1.10'
117
+ - - ">="
118
+ - !ruby/object:Gem::Version
119
+ version: 1.10.7
60
120
  description:
61
121
  email: james@jamesrobertson.eu
62
122
  executables: []
@@ -83,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
83
143
  - !ruby/object:Gem::Version
84
144
  version: '0'
85
145
  requirements: []
86
- rubygems_version: 3.0.1
146
+ rubygems_version: 3.0.3
87
147
  signing_key:
88
148
  specification_version: 4
89
149
  summary: Generates HTML components and is designed for rendering dynamic web pages
metadata.gz.sig CHANGED
Binary file