lib/adiwg/mdtranslator/writers/html/sections/html_body.rb in adiwg-mdtranslator-1.2.1 vs lib/adiwg/mdtranslator/writers/html/sections/html_body.rb in adiwg-mdtranslator-1.3.0
- old
+ new
@@ -2,19 +2,19 @@
# html body
# History:
# Stan Smith 2015-03-23 original script
# Stan Smith 2014-04-10 add open and close buttons
+# Stan Smith 2015-07-16 refactored to remove global namespace $HtmlNS
+# Stan Smith 2015-07-20 moved mdTranslator logo to html_inlineCss.css
-require 'html_metadataInfo'
-require 'html_resourceInfo'
-require 'html_dataDictionary'
-require 'html_citation'
-require 'html_responsibleParty'
-require 'html_orderProcess'
-require 'html_format'
-require 'html_transferOption'
+require_relative 'html_metadataInfo'
+require_relative 'html_resourceInfo'
+require_relative 'html_dataDictionary'
+require_relative 'html_distributor'
+require_relative 'html_associatedResource'
+require_relative 'html_additionalDocumentation'
module ADIWG
module Mdtranslator
module Writers
module Html
@@ -26,34 +26,27 @@
def writeHtml(intObj)
@html.body do
# classes used
- htmlMetaInfo = $HtmlNS::MdHtmlMetadataInfo.new(@html)
- htmlResInfo = $HtmlNS::MdHtmlResourceInfo.new(@html)
- htmlDataD = $HtmlNS::MdHtmlDataDictionary.new(@html)
- htmlCitation = $HtmlNS::MdHtmlCitation.new(@html)
- htmlResParty = $HtmlNS::MdHtmlResponsibleParty.new(@html)
- htmlOrderProc = $HtmlNS::MdHtmlOrderProcess.new(@html)
- htmlFormat = $HtmlNS::MdHtmlFormat.new(@html)
- htmlTranOpt = $HtmlNS::MdHtmlTransferOption.new(@html)
+ htmlMetaInfo = MdHtmlMetadataInfo.new(@html)
+ htmlResInfo = MdHtmlResourceInfo.new(@html)
+ htmlDataD = MdHtmlDataDictionary.new(@html)
+ htmlDist = MdHtmlDistributor.new(@html)
+ htmlAssRes = MdHtmlAssociatedResource.new(@html)
+ htmlAddDoc = MdHtmlAdditionalDocumentation.new(@html)
# make sections of the internal data store more accessible
hMetadata = intObj[:metadata]
- hMetaInfo = hMetadata[:metadataInfo]
aDataDict = intObj[:dataDictionary]
+
+ hMetaInfo = intObj[:metadata][:metadataInfo]
aDistributor = intObj[:metadata][:distributorInfo]
aAssRes = intObj[:metadata][:associatedResources]
aAddDocs = intObj[:metadata][:additionalDocuments]
- # set page title with logo
- # read logo from file
- path = File.join(File.dirname(__FILE__), 'logo150.txt')
- file = File.open(path, 'r')
- logo = file.read
- file.close
-
+ # set page title and logo
# side navigation
@html.div('id'=>'sideNav') do
# add top anchor and button
@html.a(' Top', {'href'=>'#', 'class'=>'btn icon-caret-up'})
@@ -62,11 +55,12 @@
@html.span(' Close',{'class'=>'btn icon-caret-right', 'onclick'=>'closeAllDetails();'})
end
# main header
@html.h2('id'=>'mainHeader') do
- @html.img('width'=>'150', 'height'=>'39', 'title'=>'', 'alt'=>'', 'src'=>logo)
+ # added blank to span tag to force builder to create closing tag
+ @html.span('','id'=>'logo')
@html.span('Metadata Report')
@html.span('HTML','class'=>'version')
end
# report title
@@ -75,40 +69,70 @@
# section index
@html.section(:class=>'block') do
@html.h3('Page Index')
@html.a('Metadata Information Section','href'=>'#metadataInfo')
@html.section(:class=>'block') do
- @html.a('Metadata Identifier', 'href'=>'#metadata-identifier')
- @html.br
- @html.a('Metadata Record Information', 'href'=>'#metadata-recordInfo')
- @html.br
- @html.a('Parent Metadata Citation', 'href'=>'#metadata-parentInfo')
+ if !hMetaInfo.empty?
+ unless hMetaInfo[:metadataId].empty?
+ @html.a('Metadata Identifier', 'href'=>'#metadata-identifier')
+ @html.br
+ end
+ @html.a('Metadata Record Information', 'href'=>'#metadata-recordInfo')
+ unless hMetaInfo[:parentMetadata].empty?
+ @html.br
+ @html.a('Parent Metadata Citation', 'href'=>'#metadata-parentInfo')
+ end
+ end
end
- @html.br
@html.a('Resource Information Section','href'=>'#resourceInfo')
@html.section(:class=>'block') do
@html.a('Resource Identification', 'href'=>'#resourceInfo-general')
@html.br
@html.a('Contacts', 'href'=>'#resourceInfo-contacts')
+ unless hMetadata[:resourceInfo][:descriptiveKeywords].empty?
+ @html.br
+ @html.a('Keywords', 'href'=>'#resourceInfo-keywords')
+ end
+ unless hMetadata[:resourceInfo][:taxonomy].empty?
+ @html.br
+ @html.a('Taxonomy', 'href'=>'#resourceInfo-taxonomy')
+ end
+ unless hMetadata[:resourceInfo][:spatialReferenceSystem].empty? &&
+ hMetadata[:resourceInfo][:spatialRepresentationTypes].empty? &&
+ hMetadata[:resourceInfo][:spatialResolutions].empty?
+ @html.br
+ @html.a('Spatial Reference', 'href'=>'#resourceInfo-spatialRef')
+ end
+ unless hMetadata[:resourceInfo][:extents].empty?
+ @html.br
+ @html.a('Extents (Geographic, Temporal, & Vertical Space)', 'href'=>'#resourceInfo-extents')
+ end
+ unless hMetadata[:resourceInfo][:gridInfo].empty?
+ @html.br
+ @html.a('Grid Information', 'href'=>'#resourceInfo-gridInfo')
+ end
+ unless hMetadata[:resourceInfo][:coverageInfo].empty?
+ @html.br
+ @html.a('Coverage Information', 'href'=>'#resourceInfo-coverageInfo')
+ end
+ unless hMetadata[:resourceInfo][:dataQualityInfo].empty?
+ @html.br
+ @html.a('Data Quality', 'href'=>'#resourceInfo-dataQuality')
+ end
+ unless hMetadata[:resourceInfo][:useConstraints].empty? &&
+ hMetadata[:resourceInfo][:legalConstraints].empty? &&
+ hMetadata[:resourceInfo][:securityConstraints].empty?
+ @html.br
+ @html.a('Constraints', 'href'=>'#resourceInfo-constraints')
+ end
+ unless hMetadata[:resourceInfo][:resourceMaint].empty?
+ @html.br
+ @html.a('Maintenance Information', 'href'=>'#resourceInfo-maintInfo')
+ end
@html.br
- @html.a('Keywords', 'href'=>'#resourceInfo-keywords')
- @html.br
- @html.a('Taxonomy', 'href'=>'#resourceInfo-taxonomy')
- @html.br
- @html.a('Spatial Reference', 'href'=>'#resourceInfo-spatialRef')
- @html.br
- @html.a('Extents (Geographic, Temporal, & Vertical Space)', 'href'=>'#resourceInfo-extents')
- @html.br
- @html.a('Data Quality', 'href'=>'#resourceInfo-dataQuality')
- @html.br
- @html.a('Constraints', 'href'=>'#resourceInfo-constraints')
- @html.br
- @html.a('Maintenance Information', 'href'=>'#resourceInfo-maintInfo')
- @html.br
@html.a('Other Resource Information', 'href'=>'#resourceInfo-other')
end
- @html.br
@html.a('Data Dictionary Section','href'=>'#dataDictionary')
@html.br
@html.a('Resource Distribution Section','href'=>'#resourceDistribution')
@html.br
@html.a('Associated Resources Section','href'=>'#associatedResource')
@@ -131,16 +155,15 @@
# metadata information section
@html.h2('Metadata Information', 'id'=>'metadataInfo')
if !hMetaInfo.empty?
@html.section(:class=>'block') do
- htmlMetaInfo.writeHtml(hMetaInfo)
+ htmlMetaInfo.writeHtml(hMetaInfo)
end
end
@html.hr
-
# resource information section
@html.h2('Resource Information', 'id'=>'resourceInfo')
@html.section(:class=>'block') do
htmlResInfo.writeHtml(hMetadata[:resourceInfo])
end
@@ -166,41 +189,25 @@
# resource distribution section
@html.h2('Resource Distribution', 'id'=>'resourceDistribution')
aDistributor.each do |hDistributor|
@html.section(:class=>'block') do
+
+ # get distributor name from contact orgName
+ contId = hDistributor[:distContact][:contactId]
+ hCont = ADIWG::Mdtranslator::Writers::Html::MdHtmlWriter.getContact(contId)
+ distName = hCont[:orgName]
+ if distName.nil?
+ distName = 'Other'
+ end
@html.details do
- @html.summary('Distributor', {'class'=>'h4'})
+ @html.summary(distName, {'class'=>'h3'})
@html.section(:class=>'block') do
-
- # resource distribution - distributor - required
- @html.em('Distributor contact: ')
- hResParty = hDistributor[:distContact]
- @html.section(:class=>'block') do
- htmlResParty.writeHtml(hResParty)
- end
-
- # resource distribution - order process
- hDistributor[:distOrderProc].each do |hOrder|
- @html.em('Order Process: ')
- @html.section(:class=>'block') do
- htmlOrderProc.writeHtml(hOrder)
- end
- end
-
- # resource distribution - resource format
- hDistributor[:distFormat].each do |hFormat|
- htmlFormat.writeHtml(hFormat)
- end
-
- # resource distribution - transfer options
- hDistributor[:distTransOption].each do |hTransOption|
- htmlTranOpt.writeHtml(hTransOption)
- end
-
+ htmlDist.writeHtml(hDistributor)
end
end
+
end
end
@html.hr
# associated resource section
@@ -217,52 +224,11 @@
end
@html.details do
@html.summary(sTitle, {'class'=>'h4'})
@html.section(:class=>'block') do
-
- # associated resource - resource type
- s = hAssRes[:resourceType]
- if !s.nil?
- @html.em('Resource type: ')
- @html.text!(s)
- @html.br
- end
-
- # associated resource - association type
- s = hAssRes[:associationType]
- if !s.nil?
- @html.em('Association type: ')
- @html.text!(s)
- @html.br
- end
-
- # associated resource - initiative type
- s = hAssRes[:initiativeType]
- if !s.nil?
- @html.em('Initiative type: ')
- @html.text!(s)
- @html.br
- end
-
- # associated resource - citation
- if !hCitation.empty?
- @html.em('Resource citation: ')
- @html.section(:class=>'block') do
- htmlCitation.writeHtml(hCitation)
- end
- end
-
- # associated resource - metadata citation
- hCitation = hAssRes[:metadataCitation]
- if !hCitation.empty?
- @html.em('Metadata citation: ')
- @html.section(:class=>'block') do
- htmlCitation.writeHtml(hCitation)
- end
- end
-
+ htmlAssRes.writeHtml(hAssRes)
end
end
end
end
@@ -276,27 +242,10 @@
# get document title from the citation
sTitle = hAddDoc[:citation][:citTitle]
@html.details do
@html.summary(sTitle, {'class'=>'h4'})
@html.section(:class=>'block') do
-
- # additional documentation - resource type
- s = hAddDoc[:resourceType]
- if !s.nil?
- @html.em('Resource type: ')
- @html.text!(s)
- @html.br
- end
-
- # additional documentation - citation
- hCitation = hAddDoc[:citation]
- if !hCitation.empty?
- @html.em('Citation: ')
- @html.section(:class=>'block') do
- htmlCitation.writeHtml(hCitation)
- end
- end
-
+ htmlAddDoc.writeHtml(hAddDoc)
end
end
end
end