{# 
# TITLE
#}
{% macro titleBlock (printer, report, iconUrl) -%}
{%- set title = default(report.manifest.bundleName,report.commonInfo.name) -%}
{%- set title = default(title,report.manifest.bundleSymbolicName.symbolicName) -%}
{%- set title = default(title,report.fileName) -%}
{%- block beforeTitle %}{% endblock -%}
{{ printer.printTitle(title,1,iconUrl) }}
{%- endmacro %}

{# 
# OVERVIEW
#}
{% macro overviewBlock (printer, report) -%}
{%- set description = default(report.manifest.bundleDescription,report.commonInfo.description) -%}
{%- if not empty(description) -%}
{{ '\n\n' }}
{%- block beforeOverview %}{% endblock -%}
{{ description }}
{%- endif -%}
{%- endmacro %}

{# 
# LINKS
#}
{% macro linksBlock (printer, report, iconUrl) -%}
{%- set docUrl = default(report.manifest.bundleDocURL,report.commonInfo.docURL) -%}
{%- set codeBrowse = default(report.manifest.bundleSCM.url,report.commonInfo.scm.url) -%}
{%- set codeDev = default(report.manifest.bundleSCM.developerConnection,report.commonInfo.scm.developerConnection) -%}
{%- set download = default(report.manifest.bundleUpdateLocation,report.commonInfo.updateLocation) -%}
{%- if not empty(docUrl) or not empty(codeBrowse) or not empty(codeDev) or not empty(download) -%}
{{ '\n\n' }}{{ printer.printTitle('Links', 2, iconUrl) }}{{ '\n' }}
{%- block beforeLinks %}{% endblock -%}
{%- if not empty(docUrl) -%}
{{ '\n' }}* [Documentation]({{ docUrl }})
{%- endif -%}
{%- if not empty(codeBrowse) and not empty(codeDev) -%}
{{ '\n' }}* [Source Code]({{ codeBrowse }}) (clone with `{{ codeDev }}`)
{%- elseif not empty(codeBrowse) -%}
{{ '\n' }}* [Source Code]({{ codeBrowse }})
{%- else -%}
{{ '\n' }}* Clone source code with `{{ codeDev }}`
{%- endif -%}
{%- if not empty(download) -%}
{{ '\n' }}* [Artifact(s)]({{ download }})
{%- endif -%}
{%- endif -%}
{%- endmacro %}

{# 
# COORDINATES
#}
{% macro coordinatesBlock (printer, report, iconUrl) -%}
{%- if not empty(report.mavenCoordinate) or not empty(report.manifest) -%}
{{ '\n\n' }}{{ printer.printTitle('Coordinates',2, iconUrl) }}
{%- block beforeCoordinates %}{% endblock -%}
{%- if not empty(report.mavenCoordinate) -%}
{{ '\n\n' }}{{ printer.printTitle('Maven',3) }}

{{ printer.printMavenCoordinate(report.mavenCoordinate) }}
{%- endif -%}
{%- if not empty(report.manifest) -%}
{{ '\n\n' }}{{ printer.printTitle('OSGi',3) }}

{{ printer.printOsgiCoordinate(report.manifest.bundleSymbolicName.symbolicName,report.manifest.bundleVersion) }}
{%- endif -%}
{%- endif -%}
{%- endmacro %}

{# 
# DEVELOPERS
#}
{% macro developersBlock (printer, report, iconUrl) -%}
{% set developers = default(report.manifest.bundleDevelopers,report.commonInfo.developers) -%}
{%- if not empty(developers) -%}
{{ '\n\n' }}{{ printer.printTitle('Developers',2, iconUrl) }}

{% block beforeDevelopers %}{% endblock -%}
{{ printer.printDevelopers(developers) }}
{%- endif -%}
{%- endmacro %}

{# 
# LICENSE
#}
{% macro licensesBlock (printer, report, iconUrl) -%}
{%- set licenses = default(report.manifest.bundleLicenses,report.commonInfo.licenses) -%}
{%- if not empty(licenses) -%}
{{ '\n\n' }}{{ printer.printTitle('Licenses',2, iconUrl) }}

{% block beforeLicenses %}{% endblock -%}
{{ printer.printLicenses(licenses) }}
{%- endif -%}
{%- endmacro %}

{# 
# COPYRIGHT
#}
{% macro copyrightBlock (printer, report, iconUrl) -%}
{%- set copyright = default(report.manifest.bundleCopyright,report.commonInfo.copyright) -%}
{%- if not empty(copyright) -%}
{{ '\n\n' }}{{ printer.printTitle('Copyright',2, iconUrl) }}

{% block beforeCopyright %}{% endblock -%}
{{ copyright }}
{%- endif -%}
{% endmacro %}

{# 
# VENDOR
#}
{% macro vendorBlock (printer, report, iconUrl) -%}
{%- set vendor = default(report.manifest.bundleVendor,report.commonInfo.vendor) -%}
{%- set address = default(report.manifest.bundleContactAddress,report.commonInfo.contactAddress) -%}
{%- if not empty(vendor) or not empty(address) -%}
{{ '\n\n' }}---
{% block beforeVendor %}{% endblock -%}
{{ printer.printVendor(vendor, address) }}
{%- endif -%}
{%- endmacro %}

{# 
# ARTIFACTS
#}
{% macro artifactsBlock (printer, report, iconUrl) -%}
{% if not empty(report.projects) or length(report.bundles) > 1 -%}
{{ '\n\n' }}{{ printer.printTitle('Built Artifacts',2, iconUrl) }}

{% block beforeArtifacts %}{% endblock -%}
{{ printer.printArtifacts(report) }}
{%- endif -%}
{%- endmacro %}

{# 
# CODE USAGE
#}
{% macro codeUsageBlock (printer, report, iconUrl) -%}
{%- if not empty(report.codeSnippets) -%}
{{ '\n\n' }}{{ printer.printTitle('Code Usage',2, iconUrl) }}

{% block beforeCodeUsage %}{% endblock -%}
{{ printer.printCodeSnippets(report.codeSnippets) }}
{%- endif -%}
{%- endmacro %}

{# 
# COMPONENTS
#}
{% macro componentsBlock (printer, report, iconUrl) -%}
{%- if not empty(report.components) -%}
{{ '\n\n' }}{{ printer.printTitle('Components',2, iconUrl) }}

{% block beforeComponents %}{% endblock -%}
{{ printer.printComponents(report.components, report.metatypes) }}
{%- endif -%}
{%- endmacro %}


