Merge: new `with` statement
[nit.git] / src / doc / html_templates / html_components.nit
index 5194e08..e65059b 100644 (file)
@@ -20,201 +20,10 @@ import doc_base
 import template
 import json::static
 
-# A documentation page
-redef class DocPage
-       super Template
-
-       # Page url
-       var url: String is writable, noinit
-
-       # Directory where css, js and other assets can be found
-       var shareurl: String is writable, noinit
-
-       # Attributes of the body tag element
-       var body_attrs = new Array[TagAttribute]
-
-       # Top menu template if any
-       var topmenu: TplTopMenu is writable, noinit
-
-       # Sidebar template if any
-       var sidebar: nullable TplSidebar = null is writable
-
-       # Content of the page in form a TplSection
-       var sections = new Array[TplSection]
-
-       # Footer content if any
-       var footer: nullable Writable = null is writable
-
-       # JS scripts to append at the end of the body
-       var scripts = new Array[TplScript]
-
-       # Add a section to this page
-       fun add_section(section: TplSection) do
-               sections.add section
-       end
-
-       # Render the html header
-       private fun render_head do
-               var css = (self.shareurl / "css").html_escape
-               var vendors = (self.shareurl / "vendors").html_escape
-
-               addn "<!DOCTYPE html>"
-               addn "<head>"
-               addn " <meta charset='utf-8'/>"
-               addn " <!--link rel='stylesheet' href='{css}/Nitdoc.UI.css' type='text/css'/-->"
-               addn " <link rel='stylesheet' href='{vendors}/bootstrap/css/bootstrap.min.css'/>"
-               addn " <link rel='stylesheet' href='{css}/nitdoc.bootstrap.css'/>"
-               addn " <link rel='stylesheet' href='{css}/nitdoc.css'/>"
-               addn " <link rel='stylesheet' href='{css}/Nitdoc.QuickSearch.css'/>"
-               addn " <link rel='stylesheet' href='{css}/Nitdoc.ModalBox.css'/>"
-               addn " <link rel='stylesheet' href='{css}/Nitdoc.GitHub.css'/>"
-               addn " <title>{title.html_escape}</title>"
-               addn "</head>"
-               add "<body"
-               for attr in body_attrs do add attr
-               addn ">"
-       end
-
-       # Render the topmenu template
-       private fun render_topmenu do
-               addn " <div class='row'>"
-               add topmenu
-               addn " </div>"
-       end
-
-       # Render the sidebar
-       # Sidebar is automatically populated with a summary of all sections
-       fun render_sidebar do
-               if sidebar == null then return
-               var summary = new TplSummary.with_order(0)
-               for section in sections do
-                       section.render_summary summary
-               end
-               sidebar.boxes.add summary
-               add sidebar.as(not null)
-       end
-       # Render the footer and content
-       private fun render_content do
-               for section in sections do add section
-               if footer != null then
-                       addn "<div class='well footer'>"
-                       add footer.as(not null)
-                       addn "</div>"
-               end
-       end
-
-       # Render JS scripts
-       private fun render_footer do
-               var vendors = (self.shareurl / "vendors").html_escape
-               var js = (self.shareurl / "js").html_escape
-
-               addn "<script src='{vendors}/jquery/jquery-1.11.1.min.js'></script>"
-               addn "<script src='{vendors}/jquery/jquery-ui-1.10.4.custom.min.js'></script>"
-               addn "<script src='{vendors}/bootstrap/js/bootstrap.min.js'></script>"
-               addn "<script data-main='{js}/nitdoc' src='{js}/lib/require.js'></script>"
-               for script in scripts do add script
-               addn """<script>
-                       $(function () {
-                               $("[data-toggle='tooltip']").tooltip();
-                               $("[data-toggle='popover']").popover();
-                       });
-               </script>"""
-               addn "</body>"
-               addn "</html>"
-       end
-
-       # Render the whole page
-       redef fun rendering do
-               render_head
-               addn "<div class='container-fluid'>"
-               render_topmenu
-               addn " <div class='row' id='content'>"
-               if sidebar != null then
-                       addn "<div class='col col-xs-3 col-lg-2'>"
-                       render_sidebar
-                       addn "</div>"
-                       addn "<div class='col col-xs-9 col-lg-10' data-spy='scroll' data-target='.summary'>"
-                       render_content
-                       addn "</div>"
-               else
-                       addn "<div class='col col-xs-12'>"
-                       render_content
-                       addn "</div>"
-               end
-               addn " </div>"
-               addn "</div>"
-               render_footer
-       end
-end
-
 #########################
 # general layout elements
 #########################
 
-# Top menu bar template
-class TplTopMenu
-       super Template
-
-       # Brand link to display in first position of the top menu
-       private var brand: nullable Writable = null is writable
-       # Elements of the topmenu
-       private var elts = new Array[Writable]
-
-       # The page url where the top menu is displayed.
-       #
-       # Used to select the active link.
-       private var current_url: String
-
-       # Add a new link to the menu.
-       fun add_link(content: TplLink) do
-               var is_active = content.href == current_url
-               add_item(content, is_active)
-       end
-
-       # Add a content between `<li>` tags
-       fun add_item(content: Writable, is_active: Bool) do
-               var tpl = new Template
-               tpl.add "<li"
-               if is_active then
-                       tpl.add " class='active'"
-               end
-               tpl.add ">"
-               tpl.add content
-               tpl.addn "</li>"
-               add_raw(tpl)
-       end
-
-       # Add a raw content to the menu
-       fun add_raw(content: Writable) do
-               elts.add content
-       end
-
-       redef fun rendering do
-               if brand == null and elts.is_empty then return
-               addn "<nav id='topmenu' class='navbar navbar-default navbar-fixed-top' role='navigation'>"
-               addn " <div class='container-fluid'>"
-               addn "  <div class='navbar-header'>"
-               add "   <button type='button' class='navbar-toggle' "
-               addn "       data-toggle='collapse' data-target='#topmenu-collapse'>"
-               addn "    <span class='sr-only'>Toggle menu</span>"
-               addn "    <span class='icon-bar'></span>"
-               addn "    <span class='icon-bar'></span>"
-               addn "    <span class='icon-bar'></span>"
-               addn "   </button>"
-               if brand != null then add brand.as(not null)
-               addn "  </div>"
-               addn "  <div class='collapse navbar-collapse' id='topmenu-collapse'>"
-               if not elts.is_empty then
-                       addn "<ul class='nav navbar-nav'>"
-                       for elt in elts do add elt
-                       addn "</ul>"
-               end
-               addn "  </div>"
-               addn " </div>"
-               addn "</nav>"
-       end
-end
-
 # A sidebar template
 class TplSidebar
        super Template