Property definitions

nitc $ CardMetadata :: defaultinit
# A card that displays the metadata about a package in the Nit catalog
class CardMetadata
	super CardMEntity
	autoinit(mentity, metadata, stats, deps, clients)

	# Package metadata to display
	var metadata: MPackageMetadata is writable

	# Package stats
	var stats: MPackageStats is writable

	# Package dependencies
	var deps: Array[MPackage] is writable

	# Package clients
	var clients: Array[MPackage] is writable

	redef var id = "metadata_{super}" is lazy
	redef var title = "Metadata"

	redef fun rendering do
		for maintainer in metadata.maintainers do
			addn """
				<p class='lead'>
					{{{maintainer.to_html}}}
				</p>"""
		end
		var license = metadata.license
		if license != null then
			addn """
				<span class='text-muted'>
					<a href='http://opensource.org/licenses/{{{license}}}'>{{{license}}}</a>
					license
				</span>"""
		end

		var homepage = metadata.homepage
		var browse = metadata.browse
		var issues = metadata.issues
		if homepage != null or browse != null or issues != null then
			addn """
				<h4>Links</h4>
				<ul class='list-unstyled'>"""
			if homepage != null then addn "<li><a href='{homepage}'>Homepage</a></li>"
			if browse != null then addn "<li><a href='{browse}'>Source Code</a></li>"
			if issues != null then addn "<li><a href='{issues}'>Issues</a></li>"
			addn "</ul>"
		end

		var git = metadata.git
		var last_date = metadata.last_date
		var first_date = metadata.first_date
		if git != null then
			addn """
				<h4>Git</h4>
				<ul class='list-unstyled'>
					<li><a href='{{{git}}}'>{{{git}}}</a></li>
				</ul>
				<span class='text-muted'><b>{{{stats.commits}}}</b> commits</span>
				<br>"""
			if last_date != null then
				addn """<b class=text-muted>Last:</b> {{{last_date}}}<br>"""
			end
			if first_date != null then
				addn """<b class=text-muted>First:</b> {{{first_date}}}"""
			end
		end

		addn """
			<h4>Quality</h4>
			<ul class='list-unstyled'>
				<li>{{{stats.documentation_score}}}% documented</li>
			</ul>"""

		if metadata.tags.not_empty then
			addn "<h4>Tags</h4>"
			for tag in metadata.tags do
				addn " <a href='tag_{tag.to_cmangle}.html'>{tag}</a>"
				if tag != metadata.tags.last then add ", "
			end
		end

		if deps.not_empty then
			addn "<h4>Dependencies</h4>"
			for dep in deps do
				add dep.html_link
				if dep != deps.last then add ", "
			end
		end

		if clients.not_empty then
			addn "<h4>Clients</h4>"
			for client in clients do
				add client.html_link
				if client != clients.last then add ", "
			end
		end

		if metadata.contributors.not_empty then
			addn """
				<h4>Contributors</h4>
				<ul class='list-unstyled'>"""
			for contrib in metadata.contributors do
				addn """<li>{{{contrib.to_html}}}</li>"""
			end
			addn "</ul>"
		end

		addn """
			<h4>Stats</h4>
			<ul class='list-unstyled'>
				<li>{{{stats.mmodules}}} modules</li>
				<li>{{{stats.mclasses}}} classes</li>
				<li>{{{stats.mmethods}}} methods</li>
				<li>{{{stats.loc}}} loc</li>
			</ul>"""
	end
end
src/doc/static/static_cards.nit:558,1--675,3