doctype html
html
    head
        meta charset="utf-8"
        meta http-equiv="X-UA-Compatible" content="IE=edge"
        meta content="width=device-width, initial-scale=1, maximum-scale=2.0, user-scalable=yes, minimal-ui=yes" name="viewport"
        title== self['title'] || "facil.io - a light web application framework in C, with support for HTTP, WebSockets and Pub/Sub out of the box."
        meta name="description" content=(self['title'] || SCHEMA_ABOUT)
        link href='https://fonts.googleapis.com/css?family=Montserrat|Quicksand|Karla' rel='stylesheet' type='text/css'
        / link href='/assets/javascripts/styles/monokai_sublime.css' rel='stylesheet' type='text/css'
        script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"

        / CSS
        link href='/assets/styles/main.css' rel='stylesheet' type='text/css'

        / script src="/assets/javascripts/websocket.js"


        / Schema.org data
        script type="application/ld+json" == SCHEMA_ORG
        / icons
        / link rel="mask-icon" href="/assets/facil-io-logo.svg" color="#ffffff"
        link rel="icon" type="image/svg" href="/assets/logo/facil-io-logo.svg" sizes="350x350"
        link rel="icon" type="image/png" href="/assets/logo/facil-io-logo.png" sizes="350x350"
        link rel="shortcut icon" type="image/svg" href="/assets/logo/facil-io-logo.svg" sizes="350x350"
        link rel="shortcut icon" type="image/png" href="/assets/logo/facil-io-logo.png" sizes="350x350"
        link rel="apple-touch-icon" type="image/svg" href="/assets/logo/facil-io-logo.svg" sizes="350x350"
        link rel="apple-touch-icon" type="image/png" href="/assets/logo/facil-io-logo.png" sizes="350x350"
        link rel="fluid-icon" type="image/svg" href="/assets/logo/facil-io-logo.svg" sizes="350x350"
        link rel="fluid-icon" type="image/png" href="/assets/logo/facil-io-logo.png" sizes="350x350"
        link rel="manifest" href="/manifest.json"
        meta name="apple-mobile-web-app-title" content="facil.io"
        meta name="application-name" content="facil.io - the C Web Application Framework"
        meta name="msapplication-TileColor" content="#b91d47"
        meta name="msapplication-TileImage" content="/mstile-144x144.png"
        meta name="theme-color" content="#ffffff"

    body
        a#logo href='/'
        input#show_nav type='checkbox'
        nav#top_nav
            ul
                li
                    a href='/0.7.x/index' Latest Docs
                li
                    a href='https://github.com/boazsegev/facil.io' target='_blank' Source Code
                li
                    a#theme href='javascript: change_themes();' Night Theme

        - if !self['sidebar']
           #md_container == yield
        - else
            input#show_sidebar type='checkbox'
            nav#side_bar == self['sidebar']
            #md_container
                == yield
            a#sign href='/'
        - if @flash && @flash[:notice]
            #notice
                a.notice_close onclick='hide_notice()' X
                div#notice_text
                    pre= @flash[:notice]
        - else
            #notice.hidden
                a.notice_close onclick='hide_notice()' X
                div#notice_text
        / Highlight code using JavaScript? (no, it's performed during rendering)
        / script src="/assets/javascripts/highlight.pack.js"
        javascript:
            function change_themes() {
                if(localStorage.getItem("theme") == 'dark') {
                    localStorage.setItem("theme", "light");
                } else {
                    localStorage.setItem("theme", "dark");
                }
                $('body')[0].className = localStorage.getItem("theme");
                set_theme_link();
                $('#show_nav').attr('checked', false);
            };
            function sidebar_name() { return window.location.pathname.slice(0, window.location.pathname.lastIndexOf("/")); }
            function on_sidebar_link(e) {
                sessionStorage.setItem("sidebar.expect", sidebar_name());
                sessionStorage.setItem("sidebar.pos", document.getElementById("side_bar").scrollTop);
            }
            function load_sidebar_pos() {
                var e = document.getElementById("side_bar");
                if(!e) {
                    console.warn("No sidebar detected");
                    return;
                }
                var expect = sidebar_name();
                if(sessionStorage.getItem("sidebar.expect") == expect) {
                    e.scrollTo(0, parseInt(sessionStorage.getItem("sidebar.pos")));
                } else {
                    sessionStorage.setItem("sidebar.expect", false);
                    sessionStorage.setItem("sidebar.pos", 0);
                }
                if(e) {
                    // add link callbacks
                    var links = document.links;
                    var count = links.length;
                    for (var i = 0; i < count; i++) {
                        var href = links[i].href;
                        if(href.startsWith(document.location.origin)) {
                            href = href.slice(document.location.origin.length);
                        }
                        if(href.startsWith(expect)) {
                            /* add link event */
                            links[i].addEventListener("click", on_sidebar_link);
                        }
                    }
                }

            };
            load_sidebar_pos();
            function set_theme_link() {
                $("#theme").html( ( (localStorage.getItem("theme") == 'dark') ? "Day" : "Night") + " Theme" );
                }
            $('body')[0].className = (localStorage.getItem("theme") == 'dark') ? "dark" : "light";
            set_theme_link();
            function show_notice() { document.getElementById("notice").classList.remove('hidden'); };
            function hide_notice() { document.getElementById("notice").classList.add('hidden'); };
            $('#toc').on("touchstart", function (e) { return true; } );
            $('#toc').on("hover", function (e) { return true; } );
            // hljs.initHighlighting();
            // Google Analytics
            // if(location.hostname != "localhost") {
            //     (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
            //         (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
            //         m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
            //         })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

            //     ga('create', 'UA-69931401-1', 'auto');
            //     ga('send', 'pageview');
            // }
