From: Jean Privat Date: Tue, 10 Nov 2015 16:25:38 +0000 (-0500) Subject: Merge: add piwik to the nitcatalog X-Git-Tag: v0.8~95 X-Git-Url: http://nitlanguage.org?hp=-c Merge: add piwik to the nitcatalog Because you do not deserve privacy. Pull-Request: #1818 Reviewed-by: Alexis Laferrière --- 3e0ee8c3fe573a58435a61da09f8e9bb30443d66 diff --combined src/nitcatalog.nit index 33d1871,f629b4f..c604fa6 --- a/src/nitcatalog.nit +++ b/src/nitcatalog.nit @@@ -83,6 -83,9 +83,9 @@@ en class CatalogPage super Template + # The associated catalog, used to groups options and other global data + var catalog: Catalog + # Placeholder to include additional things before the ``. var more_head = new Template @@@ -131,6 -134,37 +134,37 @@@ """ end + # Inject piwik HTML code if required + private fun add_piwik + do + var tracker_url = catalog.piwik_tracker + if tracker_url == null then return + + var site_id = catalog.piwik_site_id + + tracker_url = tracker_url.trim + if tracker_url.chars.last != '/' then tracker_url += "/" + add """ + + + + + """ + + end + redef fun rendering do add """ @@@ -138,6 -172,10 +172,10 @@@ + """ + add_piwik + add """ + """ @@@ -191,6 -229,12 +229,12 @@@ class Catalo # The score is loosely computed using other metrics var score = new Counter[MPackage] + # Return a empty `CatalogPage`. + fun new_page(rootpath: String): CatalogPage + do + return new CatalogPage(self, rootpath) + end + # Scan, register and add a contributor to a package fun add_contrib(person: String, mpackage: MPackage, res: Template) do @@@ -273,7 -317,7 +317,7 @@@ # Compute information and generate a full HTML page for a package fun package_page(mpackage: MPackage): Writable do - var res = new CatalogPage("..") + var res = new_page("..") var score = score[mpackage].to_f var name = mpackage.name.html_escape res.more_head.add """{{{name}}}""" @@@ -447,12 -491,6 +491,12 @@@ end var contributors = mpackage.contributors + var more_contributors = mpackage.metadata("package.more_contributors") + if more_contributors != null then + for c in more_contributors.split(",") do + contributors.add c.trim + end + end if not contributors.is_empty then res.add "

Contributors

\n