nus-mtp/cs-modify

View on GitHub
templates/base.html

Summary

Maintainability
Test Coverage
$def with (page)

$# This template serves as the base for all other pages, and renders other page contents within itself.

<html>
    <head>
        <title>$:page.title</title>
        <link rel="shortcut icon" href="static/favicon.ico" type="image/x-icon">
        <link rel="stylesheet" type="text/css" href="static/stylesheets/bootstrap.min.css">
        <link rel="stylesheet" type="text/css" href="static/stylesheets/bootstrap-theme.min.css">
        <link rel="stylesheet" type="text/css" href="static/stylesheets/dataTables.bootstrap.min.css">
        <link rel="stylesheet" type="text/css" href="static/stylesheets/csmodify.css">
        <script type="text/javascript" src="static/javascripts/jquery-2.2.4.min.js"></script>
        <script type="text/javascript" src="static/javascripts/bootstrap.min.js"></script>
        <script type="text/javascript" src="static/javascripts/jquery.dataTables.min.js"></script>
        <script type="text/javascript" src="static/javascripts/dataTables.bootstrap.min.js"></script>
        <script type="text/javascript" src="static/javascripts/jquery.easing.min.js"></script>
        <script type="text/javascript" src="static/javascripts/jquery.canvasjs.min.js"></script>
        <script type="text/javascript" src="static/javascripts/bootstrap3-typeahead.min.js"></script>
        <script type="text/javascript" src="static/javascripts/num-html.js"></script>
        <script type="text/javascript" src="static/javascripts/csmodify.js"></script>
    </head>

    <body>
        <script type="text/javascript">
            // Load list of module codes and names into the module search autocomplete
            var moduleSource = [];
            $$(document).ready(function(){
                var moduleCodeAndName = "";
                $for module in all_modules:
                    moduleCodeAndName = "$module[0]"+" - "+"$module[1]"
                    moduleSource.push(moduleCodeAndName);
                $$("input.findModule").typeahead({
                    minLength: 1,
                    source: moduleSource,
                    updater: function(selectedModule) {
                        var selectedModuleCode = selectedModule.split(" ")[0];
                        window.location = '/viewModule?code='+selectedModuleCode;
                    }
                })
            });
        </script>

        $if page.title == 'Login to CSModify' or page.title == 'Register for CSModify Account' or page.title == 'Validating...' or page.title == '404 Page Not Found':
            $# These pages do not have sidebar, therefore only the page element needs to be rendered
            $:page

        $else:
            <a class="btn btn-info back-to-top-btn page-scroll" href="#page-top"><span class="glyphicon glyphicon-chevron-up" id="back-to-top-btn"></span></a>
            <div id="page-top"></div>

            <nav class="navbar navbar-default">
                <div class="container-fluid">
                    <form class="navbar-form navbar-left" onsubmit="event.preventDefault();">
                        <a class="btn btn-lg btn-primary" href="/">
                            <span class="glyphicon glyphicon-home"></span>
                        </a>
                        <button type="button" class="btn btn-lg btn-primary" id="sidebar-button">
                               <span class="glyphicon glyphicon-menu-hamburger"></span>
                           </button>
                        <span id="magnifying-glass" class="glyphicon glyphicon-search"></span>
                        <input type="text" id="find-module" class="findModule" data-provide="typeahead" 
                        autocomplete="off" placeholder="&nbsp;Search for a module...">
                    </form>
                    <div class="navbar-form navbar-right">
                        <span class="well" id="id-well">
                            <span id="id-display-icon" class="glyphicon glyphicon-user"></span><span id="id-display">&nbsp;&nbsp;Logged in as: $web.cookies().get('user')</span>
                        </span>
                        <button class="btn btn-lg btn-danger" onclick="confirmLogout()">
                            <span class="glyphicon glyphicon-log-out"></span> Logout
                        </button>
                    </div>
                </div>
            </nav>

            <div id="sidebar" class="sidebar">
                <a href="javascript:void(0)" class="closebtn" onclick="closeSidebar()">&times;</a>
                <h3 id="sidebar"><span class="glyphicon glyphicon-align-left"></span>&nbsp;&nbsp;&nbsp;Module Views</h3>
                <ul id="sidebar">
                    <li><a id="sidebar" href="/oversubscribedModules">Oversubscribed Modules</a></li>
                    <li><a id="sidebar" href="/modules">Module Information</a></li>
                    <li><a id="sidebar" href="/modifiedModules">Modified Modules</a></li>
                    <li><a id="sidebar" href="/moduleSpecificSize">Modules with Specific Class Size</a></li>
                    <li><a id="sidebar" href="/starredModules">Starred Modules</a></li>
                    <li><a id="sidebar" href="/moduleMountingFixed">Module Mountings for Current AY</a></li>
                    <li><a id="sidebar" href="/moduleMountingTentative">Module Mountings for Other AYs</a></li>
                </ul>
                <h3 id="sidebar"><span class="glyphicon glyphicon-pencil"></span>&nbsp;&nbsp;&nbsp;Change Curriculum</h3>
                <ul id="sidebar">
                    <li><a id="sidebar" href="/editAll">Edit All Mountings and Quotas</a></li>
                    <li><a id="sidebar" href="/addModule">Add Module</a></li>
                    <li><a id="sidebar" href="/deleteModule">Delete Module</a></li>
                </ul>
                <h3 id="sidebar"><span class="glyphicon glyphicon-random"></span>&nbsp;&nbsp;&nbsp;Module Relations</h3>
                <ul id="sidebar">
                    <li><a id="sidebar" href="/overlappingModules">Overlapping Modules</a></li>
                    <li><a id="sidebar" href="/nonOverlappingModules">Non-Overlapping Modules</a></li>
                    <li><a class="inner-list-header" id="sidebar">Modules Taken Prior To:</a></li>
                    <ul id="sidebar">
                        <li><a id="sidebar" href="/moduleTakenPriorToOthers">Other Modules</a></li>
                        <li><a id="sidebar" href="/moduleTakenPriorToInternship">Internship</a></li>
                    </ul>
                </ul>
                <h3 id="sidebar"><span class="glyphicon glyphicon-education"></span>&nbsp;&nbsp;&nbsp;Student Statistics</h3>
                <ul id="sidebar">
                    <li><a id="sidebar" href="/studentEnrollment">Student Enrollment Info</a></li>
                </ul>
            </div>
            <div class="container">
                <ol class="breadcrumb">
                    $for entry in page.hierarchy:
                        $if entry[0] != '#':
                            <li><a href='$entry[0]'>$entry[1]</a></li>
                        $else:
                            <li class='active'>$entry[1]</li>
                </ol>
            </div>
            $:page
    </body>
</html>