nitc :: CatalogPage :: defaultinit
# A HTML page in a catalog
#
# This is just a template with the header pre-filled and the footer injected at rendering.
# Therefore, once instantiated, the content can just be added to it.
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 `</head>`.
var more_head = new Template
# Relative path to the root directory (with the index file).
#
# Use "" for pages in the root directory
# Use ".." for pages in a subdirectory
var rootpath: String
redef init
do
add """
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" media="all" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/css/bootstrap.min.css">
<link rel="stylesheet" media="all" href="{{{rootpath / "style.css"}}}">
"""
add more_head
add """
</head>
<body>
<div class='container-fluid'>
<div class='row'>
<nav id='topmenu' class='navbar navbar-default navbar-fixed-top' role='navigation'>
<div class='container-fluid'>
<div class='navbar-header'>
<button type='button' class='navbar-toggle' data-toggle='collapse' data-target='#topmenu-collapse'>
<span class='sr-only'>Toggle menu</span>
<span class='icon-bar'></span>
<span class='icon-bar'></span>
<span class='icon-bar'></span>
</button>
<span class='navbar-brand'><a href="http://nitlanguage.org/">Nitlanguage.org</a></span>
</div>
<div class='collapse navbar-collapse' id='topmenu-collapse'>
<ul class='nav navbar-nav'>
<li><a href="{{{rootpath / "index.html"}}}">Catalog</a></li>
</ul>
</div>
</div>
</nav>
</div>
"""
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 """
<!-- Piwik -->
<script type="text/javascript">
var _paq = _paq || [];
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u=(("https:" == document.location.protocol) ? "https" : "http") + "://{{{tracker_url.escape_to_c}}}";
_paq.push(['setTrackerUrl', u+'piwik.php']);
_paq.push(['setSiteId', {{{site_id}}}]);
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; g.type='text/javascript';
g.defer=true; g.async=true; g.src=u+'piwik.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<noscript><p><img src="http://{{{tracker_url.html_escape}}}piwik.php?idsite={{{site_id}}}" style="border:0;" alt="" /></p></noscript>
<!-- End Piwik Code -->
"""
end
redef fun rendering
do
add """
</div> <!-- container-fluid -->
<script src='https://code.jquery.com/jquery-latest.min.js'></script>
<script src='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.1/js/bootstrap.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/bootstrap-table/1.8.1/bootstrap-table-all.min.js'></script>
"""
add_piwik
add """
</body>
</html>
"""
end
end
src/nitcatalog.nit:29,1--133,3