Class: ADIWG::Mdtranslator::Writers::Simple_html::Html_Body
- Inherits:
-
Object
- Object
- ADIWG::Mdtranslator::Writers::Simple_html::Html_Body
- Defined in:
- lib/adiwg/mdtranslator/writers/simple_html/sections/html_body.rb
Instance Method Summary collapse
-
#initialize(html) ⇒ Html_Body
constructor
A new instance of Html_Body.
- #writeHtml(version, intObj) ⇒ Object
Constructor Details
#initialize(html) ⇒ Html_Body
Returns a new instance of Html_Body.
31 32 33 |
# File 'lib/adiwg/mdtranslator/writers/simple_html/sections/html_body.rb', line 31 def initialize(html) @html = html end |
Instance Method Details
#writeHtml(version, intObj) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 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 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 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 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 |
# File 'lib/adiwg/mdtranslator/writers/simple_html/sections/html_body.rb', line 35 def writeHtml(version, intObj) @html.body do # classes used = Html_MetadataInfo.new(@html) contactClass = Html_Contact.new(@html) resourceClass = Html_ResourceInfo.new(@html) dataQualityClass = Html_DataQuality.new(@html) lineageClass = Html_Lineage.new(@html) distributionClass = Html_Distribution.new(@html) associatedClass = Html_AssociatedResource.new(@html) additionalClass = Html_AdditionalDocumentation.new(@html) fundingClass = Html_Funding.new(@html) dictionaryClass = Html_DataDictionary.new(@html) repositoryClass = Html_Repository.new(@html) # make sections of the internal data store convenient hSchema = intObj[:schema] aContacts = intObj[:contacts] hMetaInfo = intObj[:metadata][:metadataInfo] hResourceInfo = intObj[:metadata][:resourceInfo] aDataQuality = intObj[:metadata][:dataQuality] aLineage = intObj[:metadata][:lineageInfo] aDistribution = intObj[:metadata][:distributorInfo] aAssociated = intObj[:metadata][:associatedResources] aAdditional = intObj[:metadata][:additionalDocuments] aFunding = intObj[:metadata][:funding] aDictionaries = intObj[:dataDictionaries] aRepositories = intObj[:metadataRepositories] # set page title and logo # side navigation @html.div('id' => 'sideNav') do # add section buttons @html.a(' Top', {'href' => '#', 'class' => 'btn'}) @html.a(' Contacts', {'href' => '#body-contacts', 'class' => 'btn navBtn', 'id' => 'contactButton'}) @html.a(' Metadata', {'href' => '#body-metadataInfo', 'class' => 'btn navBtn', 'id' => 'metadataButton'}) @html.a(' Resource', {'href' => '#body-resourceInfo', 'class' => 'btn navBtn', 'id' => 'resourceButton'}) @html.a(' Lineage', {'href' => '#body-lineage', 'class' => 'btn navBtn', 'id' => 'lineageButton'}) @html.a(' Distribution', {'href' => '#body-distribution', 'class' => 'btn navBtn', 'id' => 'distributionButton'}) @html.a(' Associated', {'href' => '#body-associatedResource', 'class' => 'btn navBtn', 'id' => 'associatedButton'}) @html.a(' Additional', {'href' => '#body-additionalDocument', 'class' => 'btn navBtn', 'id' => 'additionalButton'}) @html.a(' Dictionary', {'href' => '#body-dataDictionary', 'class' => 'btn navBtn', 'id' => 'dictionaryButton'}) @html.a(' Funding', {'href' => '#body-funding', 'class' => 'btn navBtn', 'id' => 'fundingButton'}) @html.a(' Repository', {'href' => '#body-repository', 'class' => 'btn navBtn', 'id' => 'repositoryButton'}) # add open and close buttons @html.span(' Open', {'class' => 'btn icon-caret-down', 'id' => 'openAllButton'}) @html.span(' Close', {'class' => 'btn icon-caret-right', 'id' => 'closeAllButton'}) end # main header @html.h2('id' => 'mainHeader') do # added blank to span tag to force builder to create closing tag @html.span('', 'id' => 'logo') @html.span('Metadata Record') @html.span('HTML5', 'class' => 'version') end # report title # aShortVersion = version.split('.') # shortVersion = aShortVersion[0].to_s + '.' + aShortVersion[1].to_s @html.h1('mdTranslator ' + version + ' HTML Metadata Record', 'id' => 'mdtranslator-metadata-report') # resource citation title unless hResourceInfo.empty? unless hResourceInfo[:citation].empty? unless hResourceInfo[:citation][:title].nil? @html.h2(hResourceInfo[:citation][:title]) end end end # report date @html.div(:class => 'block') do @html.em('Report Generated:') @html.text!(Time.new.inspect) end # metadata source @html.h3('Metadata Source', 'id' => 'metadataSource') @html.div(:class => 'block') do @html.em('Metadata schema:') @html.text!(hSchema[:name]) @html.br @html.em('Schema version:') @html.text!(hSchema[:version]) end @html.hr # contacts [] section unless aContacts.empty? @html.div do @html.h2('Contacts', {'id' => 'body-contacts', 'class' => 'h2'}) @html.div(:class => 'block') do aContacts.each do |hContact| @html.div(:class => 'block') do contactClass.writeHtml(hContact) end end @html.hr end end end # metadata information section unless hMetaInfo.empty? @html.div do @html.h2('Metadata Information', {'id' => 'body-metadataInfo', 'class' => 'h2'}) @html.div(:class => 'block') do @html.div(:class => 'block') do .writeHtml(hMetaInfo) end end @html.hr end end # resource information section unless hResourceInfo.empty? @html.div do @html.h2('Resource Information', {'id' => 'body-resourceInfo', 'class' => 'h2'}) @html.div(:class => 'block') do resourceClass.writeHtml(hResourceInfo) end @html.hr end end unless aDataQuality.nil? || aDataQuality.empty? @html.div do @html.h2('Data Quality', {'id' => 'body-dataQuality', 'class' => 'h2'}) aDataQuality.each do |hDataQuality| @html.div(:class => 'block') do dataQualityClass.writeHtml(hDataQuality) end end end end # lineage section unless aLineage.empty? @html.div do @html.h2('Resource Lineage', {'id' => 'body-lineage', 'class' => 'h2'}) @html.div(:class => 'block') do aLineage.each do |hLineage| @html.div do @html.h3('Lineage', {'class' => 'h3'}) @html.div(:class => 'block') do lineageClass.writeHtml(hLineage) end end end end @html.hr end end # distribution section unless aDistribution.empty? @html.div do @html.h2('Resource Distribution', {'id' => 'body-distribution', 'class' => 'h2'}) @html.div(:class => 'block') do aDistribution.each do |hDistribution| @html.div do @html.h3('Distribution', {'class' => 'h3'}) @html.div(:class => 'block') do distributionClass.writeHtml(hDistribution) end end end end @html.hr end end # associated resource section unless aAssociated.empty? @html.div do @html.h2('Associated Resources', {'id' => 'body-associatedResource', 'class' => 'h2'}) @html.div(:class => 'block') do aAssociated.each do |hAssociated| @html.div do @html.h3('Resource', {'class' => 'h3'}) @html.div(:class => 'block') do associatedClass.writeHtml(hAssociated) end end end end @html.hr end end # additional documentation section unless aAdditional.empty? @html.div do @html.h2('Additional Documentation', {'id' => 'body-additionalDocument', 'class' => 'h2'}) @html.div(:class => 'block') do aAdditional.each do |hAdditional| @html.div do @html.h3('Document', {'class' => 'h3'}) @html.div(:class => 'block') do additionalClass.writeHtml(hAdditional) end end end end @html.hr end end # data dictionary section unless aDictionaries.empty? @html.div do @html.h2('Data Dictionaries', {'id' => 'body-dataDictionary', 'class' => 'h2'}) @html.div(:class => 'block') do aDictionaries.each do |hDictionary| @html.div do @html.h3('Dictionary', {'class' => 'h3'}) @html.div(:class => 'block') do dictionaryClass.writeHtml(hDictionary) end end end end end end # funding section unless aFunding.empty? @html.div do @html.h2('Funding', {'id' => 'body-funding', 'class' => 'h2'}) @html.div(:class => 'block') do aFunding.each do |hFunding| @html.div do @html.h3('Funds', {'class' => 'h3'}) @html.div(:class => 'block') do fundingClass.writeHtml(hFunding) end end end end end end # metadata repository section unless aRepositories.empty? @html.div do @html.h2('Metadata Repositories', {'id' => 'body-repository', 'class' => 'h2'}) @html.div(:class => 'block') do aRepositories.each do |hRepository| @html.div do @html.h3('Repository', {'class' => 'h3'}) @html.div(:class => 'block') do repositoryClass.writeHtml(hRepository) end end end end end end # load leaflet @html.link( :rel => 'stylesheet', :href => 'https://unpkg.com/[email protected]/dist/leaflet.css') @html.script('', :src => 'https://unpkg.com/[email protected]/dist/leaflet.js') @html.script('', :src => 'https://stamen-maps.a.ssl.fastly.net/js/tile.stamen.js') # add inline javascript # read javascript from file path = File.join(File.dirname(__FILE__), 'html_bodyScript.js') file = File.open(path, 'r') bodyJS = file.read file.close @html.script('type'=>'text/javascript') do @html << bodyJS end end # body end |