+ file.write("],")
+ end
+ file.write(" \};")
+ file.close
+ end
+
+end
+
+# Nitdoc base page
+abstract class NitdocPage
+
+ var dot_dir: nullable String
+ var source: nullable String
+ var ctx: NitdocContext
+
+ init(ctx: NitdocContext) do
+ self.ctx = ctx
+ end
+
+ protected fun head do
+ append("<meta charset='utf-8'/>")
+ append("<script type='text/javascript' src='scripts/jquery-1.7.1.min.js'></script>")
+ append("<script type='text/javascript' src='quicksearch-list.js'></script>")
+ append("<script type='text/javascript' src='scripts/js-facilities.js'></script>")
+ append("<link rel='stylesheet' href='styles/main.css' type='text/css' media='screen'/>")
+ var title = ""
+ if ctx.opt_custom_title.value != null then
+ title = " | {ctx.opt_custom_title.value.to_s}"
+ end
+ append("<title>{self.title}{title}</title>")
+ end
+
+ protected fun menu do
+ if ctx.opt_custom_menu_items.value != null then
+ append(ctx.opt_custom_menu_items.value.to_s)
+ end
+ end
+
+ protected fun title: String is abstract
+
+ protected fun header do
+ append("<header>")
+ append("<nav class='main'>")
+ append("<ul>")
+ menu
+ append("<li id='liGitHub'>")
+ append("<a class='btn' id='logGitHub'>")
+ append("<img id='imgGitHub' src='resources/icons/github-icon.png' alt='GitHub'/>")
+ append("</a>")
+ append("<div class='popover bottom'>")
+ append("<div class='arrow'> </div>")
+ append("<div class='githubTitle'>")
+ append("<h3>Github Sign In</h3>")
+ append("</div>")
+ append("<div>")
+ append("<label id='lbloginGit'>Username</label>")
+ append("<input id='loginGit' name='login' type='text'/>")
+ append("<label id='logginMessage'>Hello ")
+ append("<a id='githubAccount'><strong id='nickName'></strong></a>")
+ append("</label>")
+ append("</div>")
+ append("<div>")
+ append("<label id='lbpasswordGit'>Password</label>")
+ append("<input id='passwordGit' name='password' type='password'/>")
+ append("<div id='listBranches'>")
+ append("<label id='lbBranches'>Branch</label>")
+ append("<select class='dropdown' id='dropBranches' name='dropBranches' tabindex='1'></select>")
+ append("</div>")
+ append("</div>")
+ append("<div>")
+ append("<label id='lbrepositoryGit'>Repository</label>")
+ append("<input id='repositoryGit' name='repository' type='text'/>")
+ append("</div>")
+ append("<div>")
+ append("<label id='lbbranchGit'>Branch</label>")
+ append("<input id='branchGit' name='branch' type='text'/>")
+ append("</div>")
+ append("<div>")
+ append("<a id='signIn'>Sign In</a>")
+ append("</div>")
+ append("</div>")
+ append("</li>")
+ append("</ul>")
+ append("</nav>")
+ append("</header>")
+ end
+
+ protected fun content is abstract
+
+ protected fun footer do
+ if ctx.opt_custom_footer_text.value != null then
+ append("<footer>{ctx.opt_custom_footer_text.value.to_s}</footer>")
+ end
+ end
+
+ # Generate a clickable graphviz image using a dot content
+ protected fun generate_dot(dot: String, name: String, alt: String) do
+ var output_dir = dot_dir
+ if output_dir == null then return
+ var file = new OFStream.open("{output_dir}/{name}.dot")
+ file.write(dot)
+ file.close
+ sys.system("\{ test -f {output_dir}/{name}.png && test -f {output_dir}/{name}.s.dot && diff {output_dir}/{name}.dot {output_dir}/{name}.s.dot >/dev/null 2>&1 ; \} || \{ cp {output_dir}/{name}.dot {output_dir}/{name}.s.dot && dot -Tpng -o{output_dir}/{name}.png -Tcmapx -o{output_dir}/{name}.map {output_dir}/{name}.s.dot ; \}")
+ append("<article class='graph'>")
+ append("<img src='{name}.png' usemap='#{name}' style='margin:auto' alt='{alt}'/>")
+ append("</article>")
+ var fmap = new IFStream.open("{output_dir}/{name}.map")
+ append(fmap.read_all)
+ fmap.close
+ end
+
+ # Add a (source) link for a given location
+ protected fun show_source(l: Location): String
+ do
+ if source == null then
+ return "({l.file.filename.simplify_path})"
+ else
+ # THIS IS JUST UGLY ! (but there is no replace yet)
+ var x = source.split_with("%f")
+ source = x.join(l.file.filename.simplify_path)
+ x = source.split_with("%l")
+ source = x.join(l.line_start.to_s)
+ x = source.split_with("%L")
+ source = x.join(l.line_end.to_s)
+ return " (<a href=\"{source.to_s}\">source</a>)"