Commit 1a0849c5 authored by Jay Wilson's avatar Jay Wilson 🎤
Browse files

Merge branch '18-port-to-js' into 'master'

Resolve "Port to JS"

Closes #18

See merge request !1
parents b02cfb9a f5ef664e
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link href="https://srct.gmu.io/masonstrap/css/masonstrap.min.css" rel="stylesheet">
{% block extra_head %}
{% endblock %}
<title>{% block title %}{% endblock %} - MapMason</title>
</head>
<body>
{% block content %}{% endblock %}
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script>
<script src="https://srct.gmu.io/masonstrap/js/masonstrap.min.js"></script>
{% block extra_js %}{% endblock %}
</body>
</html>
\ No newline at end of file
{% extends 'base.html' %}
{% block extra_head %}
<link rel="stylesheet" href="https://unpkg.com/leaflet@1.3.1/dist/leaflet.css"
integrity="sha512-Rksm5RenBEKSKFjgI3a41vrjkw4EVPlJ3+OiI65vTjIdo9brlAacEuKOiQ5OFh7cOI1bkDwLqdLw3Zg0cRJAAQ=="
crossorigin=""/>
<link rel="stylesheet" href="{{ url_for('static', filename='titatoggle-dist-min.css') }}">
<style>
#map {
height: 100%;
width: 100%;
margin: 0;
padding: 0;
}
html, body {
height: 100%;
width: 100%;
}
#page-content {
height: 100%;
}
#map-container {
padding: 0;
margin: 0;
}
</style>
{% endblock %}
{% block extra_js %}
<script src="https://unpkg.com/leaflet@1.3.1/dist/leaflet.js"
integrity="sha512-/Nsx9X4HebavoBvEBuyp3I7od5tA0UzAxs+j83KgC8PU0kgB4XiK4Lfe4y4cgBtaRJQEIFCW+oC506aPT2L1zw=="
crossorigin=""></script>
<script type="text/javascript">
// GMU Decimal Latitude and Decimal Longitude
const gmuLatitude = 38.8322871;
const gmuLongitude = -77.3080912;
const defaultZoom = 16;
var map = L.map('map', {
minZoom: 0,
maxZoom: 20,
zoomSnap: 0,
zoomDelta: 0.25
});
var cartodbAttribution = '&copy; <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors, &copy; <a href="http://cartodb.com/attributions">CartoDB</a>';
var tileUrl = 'http://{s}.tile.osm.org/{z}/{x}/{y}.png';
// 'http://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png'
var positron = L.tileLayer(tileUrl, {
attribution: cartodbAttribution
}).addTo(map);
map.setView([gmuLatitude, gmuLongitude], defaultZoom);
</script>
{% endblock %}
{% block content %}
<div class="container-fluid" id="page-content">
<div class="row" style="height: 100%;">
<nav class="col-sm-3 col-md-2 d-none d-sm-block navbar-inverse navbar-dark bg-dark sidebar">
<h1 class="navbar-brand navbar-dark bg-dark">MapMason</h1>
<p>
<h3 class="text-primary">Search</h3>
<form class="form-inline mt-2 mt-md-0">
<small class="form-text text-light">Search via Name or Keyword</small>
<input class="form-control mr-sm-2" type="text" placeholder="Search" aria-label="Name or Keyword">
</form>
</p>
<p>
<h3 class="text-primary">Filter Locations</h3>
<div class="nav flex-column text-light">
<div class="form-check checkbox-slider--b-flat">
<label>
<input type="checkbox"><span>Parking</span>
</label>
</div>
<div class="form-check checkbox-slider--b-flat">
<label>
<input type="checkbox"><span>Residence Halls</span>
</label>
</div>
<div class="form-check checkbox-slider--b-flat">
<label>
<input type="checkbox"><span>Dining Halls</span>
</label>
</div>
</div>
</p>
<p class="text-light">Having problems? <a href="mailto:srct@gmu.edu">Submit feedback</a></p>
<p class="text-muted">A service of <a href="http://srct.gmu.edu">Mason SRCT</a>. Licensed under the <a href="http://opensource.org/licenses/Apache-2.0">Apache License, Version 2.0</a>.</p>
</nav>
<main role="main" class="col-sm-9 ml-sm-auto col-md-10" id="map-container">
<div id="map"></div>
</main>
</div>
</div>
{% endblock %}
from flask import render_template
from map_mason import app
@app.route('/')
def index():
# app.logger.warning('Hit index')
return render_template('index.html')
from setuptools import setup, find_packages
setup(
name='map_mason',
version='1.0',
long_description=__doc__,
packages=find_packages(),
include_package_data=True,
zip_safe=False,
install_requires=[
'flask',
],
)
import unittest
import map_mason
class Map_masonTestCase(unittest.TestCase):
def setUp(self):
self.app = map_mason.app.test_client()
def test_index(self):
rv = self.app.get('/')
self.assertIn('Welcome to MapMason', rv.data.decode())
if __name__ == '__main__':
unittest.main()
{
"name": "map_mason",
"version": "0.1.0",
"description": "Map mason",
"repository": {
"type": "git",
"url": "https://git.gmu.edu/srct/where/"
},
"author": "Kunal Sarkhel",
"license": "Apache-2.0",
"scripts": {
"start": "npm run serve",
"build": "npm run build-sass && npm run build-ts && npm run tslint && npm run copy-static-assets",
"serve": "node dist/server.js",
"watch-node": "nodemon dist/server.js",
"watch": "concurrently -k -p \"[{name}]\" -n \"Sass,TypeScript,Node\" -c \"yellow.bold,cyan.bold,green.bold\" \"npm run watch-sass\" \"npm run watch-ts\" \"npm run watch-node\"",
"test": "jest --forceExit --coverage --verbose",
"watch-test": "npm run test -- --watchAll",
"build-ts": "tsc",
"watch-ts": "tsc -w",
"build-sass": "node-sass src/public/css/main.scss dist/public/css/main.css",
"watch-sass": "node-sass -w src/public/css/main.scss dist/public/css/main.css",
"tslint": "tslint -c tslint.json -p tsconfig.json",
"copy-static-assets": "ts-node copyStaticAssets.ts",
"debug": "npm run build && npm run watch-debug",
"serve-debug": "nodemon --inspect dist/server.js",
"watch-debug": "concurrently -k -p \"[{name}]\" -n \"Sass,TypeScript,Node\" -c \"yellow.bold,cyan.bold,green.bold\" \"npm run watch-sass\" \"npm run watch-ts\" \"npm run serve-debug\""
},
"dependencies": {
"async": "^2.6.0",
"bcrypt-nodejs": "^0.0.3",
"bluebird": "^3.5.1",
"body-parser": "^1.18.2",
"compression": "^1.7.1",
"dotenv": "^4.0.0",
"errorhandler": "^1.5.0",
"express": "^4.16.2",
"express-validator": "^4.3.0",
"fbgraph": "^1.4.1",
"lodash": "^4.17.5",
"lusca": "^1.5.2",
"nodemailer": "^4.4.1",
"pug": "^2.0.0-rc.4",
"request": "^2.83.0",
"request-promise": "^4.2.2",
"titatoggle": "^2.1.2",
"winston": "^2.4.0"
},
"devDependencies": {
"@types/async": "^2.0.45",
"@types/bcrypt-nodejs": "^0.0.30",
"@types/bluebird": "^3.5.20",
"@types/body-parser": "^1.16.8",
"@types/compression": "^0.0.35",
"@types/dotenv": "^4.0.3",
"@types/errorhandler": "^0.0.32",
"@types/express": "^4.11.1",
"@types/jest": "^22.1.3",
"@types/jquery": "^3.2.17",
"@types/lodash": "^4.14.91",
"@types/lusca": "^1.5.0",
"@types/morgan": "^1.7.35",
"@types/node": "^9.4.6",
"@types/nodemailer": "^4.3.4",
"@types/request": "^2.47.0",
"@types/shelljs": "^0.7.8",
"@types/supertest": "^2.0.4",
"chai": "^4.1.2",
"concurrently": "^3.5.1",
"jest": "^22.0.4",
"node-sass": "^4.7.2",
"nodemon": "^1.13.0",
"shelljs": "^0.8.1",
"supertest": "^3.0.0",
"ts-jest": "^22.0.4",
"ts-node": "^5.0.0",
"tslint": "^5.9.1",
"typescript": "^2.7.2"
}
}
import express from "express";
import compression from "compression"; // compresses requests
import bodyParser from "body-parser";
import logger from "./util/logger";
import lusca from "lusca";
import dotenv from "dotenv";
import path from "path";
import expressValidator from "express-validator";
import bluebird from "bluebird";
// Load environment variables from .env file, where API keys and passwords are configured
dotenv.config({path: ".env.example"});
// Controllers (route handlers)
import * as homeController from "./controllers/home";
import * as apiController from "./controllers/api";
// Create Express server
const app = express();
// Express configuration
app.set("port", process.env.PORT || 3000);
app.set("views", path.join(__dirname, "../views"));
app.set("view engine", "pug");
app.use(compression());
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: true}));
app.use(expressValidator());
app.use(lusca.xframe("SAMEORIGIN"));
app.use(lusca.xssProtection(true));
app.use(
express.static(path.join(__dirname, "public"), {maxAge: 31557600000})
);
/**
* Primary app routes.
*/
app.get("/", homeController.index);
/**
* API examples routes.
*/
app.get("/api", apiController.getApi);
export default app;
"use strict";
import async from "async";
import request from "request";
import { Response, Request, NextFunction } from "express";
/**
* GET /api
* List of API examples.
*/
export let getApi = (req: Request, res: Response) => {
res.render("api/index", {
title: "API Examples"
});
};
import { Request, Response } from "express";
/**
* GET /
* Home page.
*/
export let index = (req: Request, res: Response) => {
res.render("home", {
title: "Home"
});
};
This source diff could not be displayed because it is too large. You can view the blob instead.
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment