nitc :: CatalogPage
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.
nitc :: CatalogPage :: _catalog
The associated catalog, used to groups options and other global datanitc :: CatalogPage :: _more_head
Placeholder to include additional things before the</head>
.
nitc :: CatalogPage :: _rootpath
Relative path to the root directory (with the index file).nitc :: CatalogPage :: catalog
The associated catalog, used to groups options and other global datanitc :: CatalogPage :: catalog=
The associated catalog, used to groups options and other global datanitc :: CatalogPage :: defaultinit
nitc :: CatalogPage :: more_head
Placeholder to include additional things before the</head>
.
nitc :: CatalogPage :: more_head=
Placeholder to include additional things before the</head>
.
nitc :: CatalogPage :: rootpath
Relative path to the root directory (with the index file).nitc :: CatalogPage :: rootpath=
Relative path to the root directory (with the index file).nitc $ CatalogPage :: SELF
Type of this instance, automatically specialized in every classnitc $ CatalogPage :: init
nitc $ CatalogPage :: rendering
Service used to render the content of the template.nitc :: CatalogPage :: _catalog
The associated catalog, used to groups options and other global datatemplate :: Template :: _is_frozen
Is the template allowing more modification (add
)
template :: Template :: _is_writing
Flag to avoid infinite recursivity if a template contains itselfnitc :: CatalogPage :: _more_head
Placeholder to include additional things before the</head>
.
template :: Template :: _render_done
Flag to avoid multiple renderingnitc :: CatalogPage :: _rootpath
Relative path to the root directory (with the index file).nitc :: CatalogPage :: catalog
The associated catalog, used to groups options and other global datanitc :: CatalogPage :: catalog=
The associated catalog, used to groups options and other global datacore :: Object :: class_factory
Implementation used byget_class
to create the specific class.
nitc :: CatalogPage :: defaultinit
core :: Object :: defaultinit
template :: Template :: defaultinit
core :: Writable :: defaultinit
template :: Template :: is_frozen=
Is the template allowing more modification (add
)
core :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
template :: Template :: is_writing
Flag to avoid infinite recursivity if a template contains itselftemplate :: Template :: is_writing=
Flag to avoid infinite recursivity if a template contains itselfnitc :: CatalogPage :: more_head
Placeholder to include additional things before the</head>
.
nitc :: CatalogPage :: more_head=
Placeholder to include additional things before the</head>
.
core :: Object :: native_class_name
The class name of the object in CString format.core :: Object :: output_class_name
Display class name on stdout (debug only).template :: Template :: render_done=
Flag to avoid multiple renderingnitc :: CatalogPage :: rootpath
Relative path to the root directory (with the index file).nitc :: CatalogPage :: rootpath=
Relative path to the root directory (with the index file).core :: Writable :: write_to_bytes
Likewrite_to
but return a new Bytes (may be quite large)
core :: Writable :: write_to_file
Likewrite_to
but take care of creating the file
core :: Writable :: write_to_string
Likewrite_to
but return a new String (may be quite large).
# 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