Commit dc15fefa authored by Zachary Seguin's avatar Zachary Seguin

Initial commit

parents
config.php
.DS_Store
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteRule ^(.*)$ ./index.php?request=$1
# UW Courses
List of courses offered at the University of Waterloo.
[https://zacharyseguin.ca/projects/uw-courses/](https://zacharyseguin.ca/projects/uw-courses/)
## Configuration
1. Copy `config.dist.php` to `config.php`
2. Update settings in `config.php`
Your webserver will be required to rewrite URLs.
\ No newline at end of file
<?php
/*
The MIT License (MIT)
Copyright (c) 2014 Zachary Seguin
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
class UWApi
{
private $key;
private $base;
public function __construct($key, $base = 'https://api.uwaterloo.ca/v2')
{
$this->key = $key;
$this->base = $base;
}// End of __construct function
private function performRequest($method, array $options = array())
{
$options['key'] = $this->key;
$response = json_decode(file_get_contents($this->base . $method . '?' . http_build_query($options)), true);
if (isset($response['meta']))
{
if (isset($response['meta']['status']))
{
if ($response['meta']['status'] === 200)
{
if (isset($response['data']))
{
return $response['data'];
}// End of if
}// End of if
}// End of if
}// End of if
return array();
}// End of performRequest function
public function subjects()
{
return $this->performRequest('/codes/subjects.json');
}// End of subjects function
public function courses($subject)
{
return $this->performRequest("/courses/$subject.json");
}// End of courses function
}// End of class
?>
\ No newline at end of file
<?php
/*
The MIT License (MIT)
Copyright (c) 2014 Zachary Seguin
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
/*
Application Base
*/
define('APP_BASE', 'https://zacharyseguin.ca/projects/uw-courses/');
/*
University of Waterloo OpenData API Key
https://api.uwaterloo.ca
*/
define('UW_API_KEY', 'INSERT_API_KEY_HERE');
\ No newline at end of file
<?php
/*
The MIT License (MIT)
Copyright (c) 2014 Zachary Seguin
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
require('lib/lightncandy.php');
require('classes/UWApi.php');
require('config.php');
function show_template($template, $data)
{
/* Load Template */
$template = file_get_contents('views/' . $template . '.tmpl');
$phpStr = LightnCandy::compile($template, Array(
'basedir' => 'partials',
'flags' => LightnCandy::FLAG_ERROR_EXCEPTION | LightnCandy::FLAG_PARENT
));
$renderer = LightnCandy::prepare($phpStr);
/* Render with Data */
$data['app_base'] = APP_BASE;
echo $renderer($data);
}
/* API */
$api = new UWApi(UW_API_KEY);
/* Path */
$request = explode('/', (isset($_GET['request']) ? $_GET['request'] : 'home'));
switch($request[0])
{
case 'home':
show_template('home', Array(
'page_title' => 'Subjects',
'subjects' => $api->subjects()
));
break;
case 'subject':
if (count($request) < 2) continue;
$subject = $request[1];
show_template('subject', Array(
'page_title' => "$subject Courses",
'courses' => $api->courses($subject)
));
break;
default:
show_template('not-found', Array(
'page_title' => 'Page Not Found'
));
}// End of switch
?>
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
</div><!-- End of content -->
</div><!-- End of content-container -->
<!-- Footer -->
<div id="footer-container">
<footer>
<p>Copyright &copy; 2014 &ndash; <a href="https://zacharyseguin.ca/">Zachary Seguin</a><br />All Rights Reserved.</p>
<p>Contains information provided by the Regional Municipality of Waterloo under licence.</p>
</footer>
</div><!-- End of footer-container -->
</body>
</html>
<!doctype html>
<!--
The MIT License (MIT)
Copyright (c) 2014 Zachary Seguin
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
-->
<html lang="en">
<head>
<base href="{{app_base}}" />
<!-- Meta Information -->
<meta charset="utf-8" />
<!-- Site/Page Information -->
<title>{{page_title}} &ndash; UW Courses &ndash; Zachary Seguin</title>
<link rel="icon" href="https://zacharyseguin.ca/favicon.png" />
<link href="https://zacharyseguin.ca/images/apple-touch-icon.png" rel="apple-touch-icon" />
<link href="https://zacharyseguin.ca/images/apple-touch-icon-76x76.png" rel="apple-touch-icon" sizes="76x76" />
<link href="https://zacharyseguin.ca/images/apple-touch-icon-120x120.png" rel="apple-touch-icon" sizes="120x120" />
<link href="https://zacharyseguin.ca/images/apple-touch-icon-152x152.png" rel="apple-touch-icon" sizes="152x152" />
<!-- Stylesheets -->
<link rel="stylesheet" href="resources/stylesheets/zacharyseguin.css" />
<!-- IE 8 and below -->
<!--[if lt IE 9]>
<script src="resources/javascript/html5shiv.js"></script>
<![endif]-->
</head>
<body>
<!-- Header -->
<div id="header-container">
<header>
<a href="https://zacharyseguin.ca/"><img src="https://zacharyseguin.ca/images/logo.png" alt="Zachary Seguin" /></a>
</header>
</div><!-- End of header-container -->
<!-- Navigation -->
<div id="navigation-container">
<div id="navigation-wrapper">
<!-- Left/Primary navigation -->
<nav>
<ul>
<li class="title">UW Courses</li>
</ul>
<ul>
<li><a href="">Home</a></li>
</ul>
</nav>
<!-- Right/Secondary navigation -->
<menu>
<ul>
</ul>
</menu>
</div> <!-- End of navigation-wrapper -->
</div><!-- End of navigation-container -->
<!-- Content -->
<div id="content-container">
<div id="content">
<h1 class="title">{{page_title}}</h1>
\ No newline at end of file
/**
* @preserve HTML5 Shiv 3.7.2 | @afarkas @jdalton @jon_neal @rem | MIT/GPL2 Licensed
*/
!function(a,b){function c(a,b){var c=a.createElement("p"),d=a.getElementsByTagName("head")[0]||a.documentElement;return c.innerHTML="x<style>"+b+"</style>",d.insertBefore(c.lastChild,d.firstChild)}function d(){var a=t.elements;return"string"==typeof a?a.split(" "):a}function e(a,b){var c=t.elements;"string"!=typeof c&&(c=c.join(" ")),"string"!=typeof a&&(a=a.join(" ")),t.elements=c+" "+a,j(b)}function f(a){var b=s[a[q]];return b||(b={},r++,a[q]=r,s[r]=b),b}function g(a,c,d){if(c||(c=b),l)return c.createElement(a);d||(d=f(c));var e;return e=d.cache[a]?d.cache[a].cloneNode():p.test(a)?(d.cache[a]=d.createElem(a)).cloneNode():d.createElem(a),!e.canHaveChildren||o.test(a)||e.tagUrn?e:d.frag.appendChild(e)}function h(a,c){if(a||(a=b),l)return a.createDocumentFragment();c=c||f(a);for(var e=c.frag.cloneNode(),g=0,h=d(),i=h.length;i>g;g++)e.createElement(h[g]);return e}function i(a,b){b.cache||(b.cache={},b.createElem=a.createElement,b.createFrag=a.createDocumentFragment,b.frag=b.createFrag()),a.createElement=function(c){return t.shivMethods?g(c,a,b):b.createElem(c)},a.createDocumentFragment=Function("h,f","return function(){var n=f.cloneNode(),c=n.createElement;h.shivMethods&&("+d().join().replace(/[\w\-:]+/g,function(a){return b.createElem(a),b.frag.createElement(a),'c("'+a+'")'})+");return n}")(t,b.frag)}function j(a){a||(a=b);var d=f(a);return!t.shivCSS||k||d.hasCSS||(d.hasCSS=!!c(a,"article,aside,dialog,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}mark{background:#FF0;color:#000}template{display:none}")),l||i(a,d),a}var k,l,m="3.7.2",n=a.html5||{},o=/^<|^(?:button|map|select|textarea|object|iframe|option|optgroup)$/i,p=/^(?:a|b|code|div|fieldset|h1|h2|h3|h4|h5|h6|i|label|li|ol|p|q|span|strong|style|table|tbody|td|th|tr|ul)$/i,q="_html5shiv",r=0,s={};!function(){try{var a=b.createElement("a");a.innerHTML="<xyz></xyz>",k="hidden"in a,l=1==a.childNodes.length||function(){b.createElement("a");var a=b.createDocumentFragment();return"undefined"==typeof a.cloneNode||"undefined"==typeof a.createDocumentFragment||"undefined"==typeof a.createElement}()}catch(c){k=!0,l=!0}}();var t={elements:n.elements||"abbr article aside audio bdi canvas data datalist details dialog figcaption figure footer header hgroup main mark meter nav output picture progress section summary template time video",version:m,shivCSS:n.shivCSS!==!1,supportsUnknownElements:l,shivMethods:n.shivMethods!==!1,type:"default",shivDocument:j,createElement:g,createDocumentFragment:h,addElements:e};a.html5=t,j(b)}(this,document);
/* http://meyerweb.com/eric/tools/css/reset/
v2.0 | 20110126
License: none (public domain)
*/
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
table, caption, tbody, tfoot, thead, tr, th, td,
article, aside, canvas, details, embed,
figure, figcaption, footer, header, hgroup,
menu, nav, output, ruby, section, summary,
time, mark, audio, video {
margin: 0;
padding: 0;
border: 0;
font-size: 100%;
font: inherit;
vertical-align: baseline;
-webkit-box-sizing: border-box;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
/* HTML5 display-role reset for older browsers */
article, aside, details, figcaption, figure,
footer, header, hgroup, menu, nav, section {
display: block;
}
body {
line-height: 1;
}
ol, ul {
list-style: none;
}
blockquote, q {
quotes: none;
}
blockquote:before, blockquote:after,
q:before, q:after {
content: '';
content: none;
}
table {
border-collapse: collapse;
border-spacing: 0;
}
/*
The MIT License (MIT)
Copyright (c) 2014 Zachary Seguin
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
/* Generic Styles */
body {
font-size: 16px;
}
/* Header */
#header-container {
}
#header-container header {
width: 980px;
margin: 0 auto;
}
#header-container header img {
height: 50px;
}
/* Navigation */
#navigation-container {
}
#navigation-container #navigation-wrapper {
width: 980px;
margin: 0 auto;
padding: 0 10px;
font-size: 0.9em;
overflow: hidden;
}
#navigation-container ul {
line-height: 20px;
padding: 10px 0;
}
#navigation-container ul li {
float: left;
padding: 0 6px;
border-right: 1px solid #aaa;
color: #555;
}
#navigation-container ul li.title {
font-weight: 400;
}
#navigation-container ul li:last-child {
border-right: none;
}
#navigation-container ul li a {
text-decoration: none;
color: #555;
}
#navigation-container nav ul {
float: left;
}
#navigation-container menu ul {
float: right;
}
/* Content */
#content-container {
}
#content-container #content {
width: 960px;
margin: 0 auto;
padding: 20px;
}
/* Footer */
#footer-container {
}
#footer-container footer {
width: 960px;
margin: 0 auto;
font-size: 0.85em;
line-height: 1.4em;
}
/*
The MIT License (MIT)
Copyright (c) 2014 Zachary Seguin
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
/* Import Required Styles */
@import url("reset.css");
@import url("zacharyseguin-normal.css"); /* TO BE RESPONSIVE */
@import url("//fonts.googleapis.com/css?family=Roboto:100,300,400");
/* Generic Styles */
body {
background: white;
font-family: 'Roboto', sans-serif;
font-weight: 300;
}
a {
outline: none;
border: none;
color: #aa0000;
text-decoration: none;
}
a:hover {
color: #880000;
}
a img {
outline: none;
border: none;
}
h1, h2, h3, h4, h5, h6 {
font-weight: 300;
}
/* Header */
#header-container {
background: #545454;
border-bottom: 1px solid #222;
}
#header-container header {
}
#header-container header img {
}
/* Navigation */
#navigation-container {
background: #eee;
border-bottom: 1px solid #aaa;
}
#navigation-container #navigation-wrapper {
}
/* Content */
#content-container {
}
#content-container #content {
line-height: 1.45em;
color: #555;
overflow: hidden;
}
#content-container #content h1,
#content-container #content h2,
#content-container #content h3,
#content-container #content h4,
#content-container #content h5,
#content-container #content h6 {
padding: 8px 4px;
}
#content-container #content h1 {
font-size: 30px;
padding: 8px 4px;
}
#content-container #content h1.title {
border-bottom: 2px solid #eee;
font-size: 35px;
font-weight: 100;
margin-bottom: 5px;
padding: 15px 8px;
}
#content-container #content h2 {
font-size: 22px;
}
#content-container #content h3 {
font-size: 20px;
}
#content-container #content h4 {
font-size: 18px;
}
#content-container #content h5 {
font-size: 16px;
}
#content-container #content h6 {
font-size: 14px;
}
#content-container #content p {
padding: 10px;
color: #666;
line-height: 1.5em;
}
#content-container #content header h1 {
background: #eee;
padding: 5px 10px;
font-size: 32px;
font-weight: 100;
line-height: 35px;
margin: 20px 0;
}
#content-container #content table {
width: 100%;
}
#content-container #content table thead {
border-bottom: 1px solid #ddd;
}
#content-container #content table thead th, #content-container #content table thead td {
font-weight: 400;
padding: 5px 0;
}
#content-container #content table tbody tr {
border-bottom: 1px solid #eee;
}
#content-container #content table tbody tr th {
font-weight: 400;
text-align: left;
padding: 5px 0;
}
#content-container #content table tbody tr td {
text-align: left;
padding: 5px 0;
}
#content-container #content ul, #content-container #content ol {
margin-left: 25px;
padding: 10px 5px;
}
#content-container #content ul {
list-style: square;
}
#content-container #content ol {
list-style: decimal;
}
#content-container #content dl {
padding: 10px 5px;
}
#content-container #content dl dt {
font-weight: 400;
margin-top: 10px;
}
#content-container #content .master, #content-container #content .detail {
margin-top: 25px;
}
#content-container #content .master {
float: left;
width: 250px;
margin-right: 10px;
border: 1px solid #eee;
}
#content-container #content .detail {
float: left;
width: 660px;
}
/* Footer */
#footer-container {
margin: 20px 0;
}
#footer-container footer {
text-align: center;
color: #aaa;
border-top: 2px solid #eee;
padding-top: 10px;
}
{{> template_start}}
<section id="subjects">
<ul>
{{#each subjects}}
<li><a href="subject/{{subject}}">{{subject}} &ndash; {{description}}</a></li>
{{/each}}
</ul>
</section>
{{> template_end}}
\ No newline at end of file
{{> template_start}}
<p>Sorry, the requested page could not be found.</p>
{{> template_end}}
\ No newline at end of file