From b3ae80b798a48c4d3f291c32c9757735c3f59ba8 Mon Sep 17 00:00:00 2001 From: Alexandre Terrasa Date: Tue, 17 Jun 2014 11:55:37 -0400 Subject: [PATCH] nitdoc: topmenu responsive design for small resolutions Signed-off-by: Alexandre Terrasa --- Makefile | 7 ++++--- share/nitdoc/css/nitdoc.css | 5 +++++ share/nitdoc/js/plugins/quicksearch.js | 2 +- src/doc/doc_pages.nit | 36 +++++++++++++++++++------------- src/doc/doc_templates.nit | 25 ++++++++++++++++++---- 5 files changed, 52 insertions(+), 23 deletions(-) diff --git a/Makefile b/Makefile index a88d277..a6b4849 100644 --- a/Makefile +++ b/Makefile @@ -36,7 +36,7 @@ doc/stdlib/index.html: bin/nitdoc bin/nitls @echo '***************************************************************' bin/nitdoc $$(bin/nitls lib -r --path) -d doc/stdlib \ --custom-title "Nit Standard Library" \ - --custom-menu-items "
  • Nitlanguage.org
  • " \ + --custom-brand "Nitlanguage.org" \ --custom-overview-text "

    Documentation for the standard library of Nit
    Version $$(git describe)
    Date: $$(git show --format="%cd" | head -1)

    " \ --custom-footer-text "Nit standard library. Version $$(git describe)." \ --github-upstream "privat:nit:master" \ @@ -44,13 +44,14 @@ doc/stdlib/index.html: bin/nitdoc bin/nitls --github-gitdir "." \ --source "https://github.com/privat/nit/blob/$$(git rev-parse HEAD)/%f#L%l-%L" \ --piwik-tracker "pratchett.info.uqam.ca/piwik/" \ - --piwik-site-id "2" + --piwik-site-id "2" \ + --shareurl "../../share/nitdoc" doc/nitc/index.html: bin/nitdoc bin/nitdoc src/nit*.nit src/test_*.nit -d doc/nitc \ --private \ --custom-title "Nit Compilers and Tools" \ - --custom-menu-items "
  • Nitlanguage.org
  • " \ + --custom-brand "Nitlanguage.org" \ --custom-overview-text "

    Documentation for the Nit tools
    Version $$(git describe)
    Date: $$(git show --format="%cd" | head -1)

    " \ --custom-footer-text "Nit tools. Version $$(git describe)." \ --github-upstream "privat:nit:master" \ diff --git a/share/nitdoc/css/nitdoc.css b/share/nitdoc/css/nitdoc.css index dc7c855..de3cd83 100644 --- a/share/nitdoc/css/nitdoc.css +++ b/share/nitdoc/css/nitdoc.css @@ -19,6 +19,11 @@ ul li .label { font-family: monospace; } +.navbar-default .navbar-toggle { + margin-top: 2px; + padding: 5px 10px; +} + /* * Sidebar */ diff --git a/share/nitdoc/js/plugins/quicksearch.js b/share/nitdoc/js/plugins/quicksearch.js index 12c124a..13f500c 100644 --- a/share/nitdoc/js/plugins/quicksearch.js +++ b/share/nitdoc/js/plugins/quicksearch.js @@ -366,7 +366,7 @@ define([ placeholder: "Search..." }) - $("#topmenu>.container-fluid").append( + $("#topmenu-collapse").append( $("
    ") .addClass("navbar-form navbar-right") .append( diff --git a/src/doc/doc_pages.nit b/src/doc/doc_pages.nit index bb379e5..2d2c733 100644 --- a/src/doc/doc_pages.nit +++ b/src/doc/doc_pages.nit @@ -27,7 +27,7 @@ class NitdocContext private var opt_private = new OptionBool("also generate private API", "--private") private var opt_custom_title = new OptionString("custom title for homepage", "--custom-title") - private var opt_custom_menu = new OptionString("custom items added in top menu (each item must be enclosed in 'li' tags)", "--custom-menu-items") + private var opt_custom_brand = new OptionString("custom link to external site", "--custom-brand") private var opt_custom_intro = new OptionString("custom intro text for homepage", "--custom-overview-text") private var opt_custom_footer = new OptionString("custom footer text", "--custom-footer-text") @@ -47,7 +47,7 @@ class NitdocContext init do var opts = toolcontext.option_context opts.add_option(opt_dir, opt_source, opt_sharedir, opt_shareurl, opt_nodot, opt_private) - opts.add_option(opt_custom_title, opt_custom_footer, opt_custom_intro, opt_custom_menu) + opts.add_option(opt_custom_title, opt_custom_footer, opt_custom_intro, opt_custom_brand) opts.add_option(opt_github_upstream, opt_github_base_sha1, opt_github_gitdir) opts.add_option(opt_piwik_tracker, opt_piwik_site_id) @@ -280,8 +280,14 @@ abstract class NitdocPage # Build top menu template fun tpl_topmenu: TplTopMenu do var topmenu = new TplTopMenu - var custom_elt = ctx.opt_custom_menu.value - if custom_elt != null then topmenu.add_raw(custom_elt) + var brand = ctx.opt_custom_brand.value + if brand != null then + var tpl = new Template + tpl.add "" + tpl.add brand + tpl.add "" + topmenu.brand = tpl + end return topmenu end @@ -449,8 +455,8 @@ class NitdocOverview redef fun tpl_topmenu do var topmenu = super - topmenu.add_link("#", "Overview", true) - topmenu.add_link("search.html", "Index", false) + topmenu.add_item(new TplLink("#", "Overview"), true) + topmenu.add_item(new TplLink("search.html", "Index"), false) return topmenu end @@ -496,8 +502,8 @@ class NitdocSearch redef fun tpl_topmenu do var topmenu = super - topmenu.add_link("index.html", "Overview", false) - topmenu.add_link("#", "Index", true) + topmenu.add_item(new TplLink("index.html", "Overview"), false) + topmenu.add_item(new TplLink("#", "Index"), true) return topmenu end @@ -584,9 +590,9 @@ class NitdocModule redef fun tpl_topmenu do var topmenu = super - topmenu.add_link("index.html", "Overview", false) - topmenu.add_link("#", "{mmodule.nitdoc_name}", true) - topmenu.add_link("search.html", "Index", false) + topmenu.add_item(new TplLink("index.html", "Overview"), false) + topmenu.add_item(new TplLink("#", "{mmodule.nitdoc_name}"), true) + topmenu.add_item(new TplLink("search.html", "Index"), false) return topmenu end @@ -781,10 +787,10 @@ class NitdocClass else mmodule = mclass.public_owner.as(not null) end - topmenu.add_link("index.html", "Overview", false) - topmenu.add_link("{mmodule.nitdoc_url}", "{mmodule.nitdoc_name}", false) - topmenu.add_link("#", "{mclass.nitdoc_name}", true) - topmenu.add_link("search.html", "Index", false) + topmenu.add_item(new TplLink("index.html", "Overview"), false) + topmenu.add_item(new TplLink("{mmodule.nitdoc_url}", "{mmodule.nitdoc_name}"), false) + topmenu.add_item(new TplLink("#", "{mclass.nitdoc_name}"), true) + topmenu.add_item(new TplLink("search.html", "Index"), false) return topmenu end diff --git a/src/doc/doc_templates.nit b/src/doc/doc_templates.nit index 788cb85..ce4949b 100644 --- a/src/doc/doc_templates.nit +++ b/src/doc/doc_templates.nit @@ -149,18 +149,22 @@ end class TplTopMenu super Template + # Brand link to display in first position of the top menu + private var brand: nullable Streamable writable # Elements of the topmenu private var elts = new Array[Streamable] - # Add a new link to the menu - fun add_link(href, name: String, is_active: Bool) do + init do end + + # Add a content between `
  • ` tags + fun add_item(content: Streamable, is_active: Bool) do var tpl = new Template tpl.add "" - tpl.add new TplLink(href, name) + tpl.add content tpl.add "
  • " add_raw(tpl) end @@ -171,13 +175,26 @@ class TplTopMenu end redef fun rendering do + if brand == null and elts.is_empty then return add "" end -- 1.7.9.5