Add initial version
This commit is contained in:
parent
2497e92839
commit
cb985a2dbc
38
server.py
Normal file
38
server.py
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
from datetime import datetime
|
||||||
|
|
||||||
|
import requests
|
||||||
|
from flask import Flask, render_template, Response
|
||||||
|
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
EASTER_EGG_MESSAGE = "It's DAKA."
|
||||||
|
DAKA_MENU_XML_URL = ("http://campusdining.compass-usa.com/wpi/Pages/"
|
||||||
|
"SignageXML.aspx?location=Pulse+On+Dining+Marketplace")
|
||||||
|
|
||||||
|
|
||||||
|
def its_april_fools():
|
||||||
|
now = datetime.now()
|
||||||
|
return now.month == 4 and now.day == 1
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/')
|
||||||
|
def index():
|
||||||
|
xsl_header = ('<?xml version="1.0"?>'
|
||||||
|
'<?xml-stylesheet type="text/xsl" href="pod_menu.xsl"?>')
|
||||||
|
xml_file = requests.get(DAKA_MENU_XML_URL).text
|
||||||
|
return Response(xsl_header + xml_file, mimetype='text/xml')
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/pod_menu.xsl')
|
||||||
|
def pod_menu():
|
||||||
|
xsl = render_template("pod_menu.xsl",
|
||||||
|
easter_egg_message=EASTER_EGG_MESSAGE,
|
||||||
|
easter_egg=its_april_fools(),
|
||||||
|
date=datetime.now().strftime("%A, %B %d, %Y"))
|
||||||
|
return Response(xsl, mimetype='text/xsl')
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
app.run('0.0.0.0', port=5000, debug=True)
|
BIN
static/img/Dining-Services_Subranded_Print_black.png
Normal file
BIN
static/img/Dining-Services_Subranded_Print_black.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 17 KiB |
BIN
static/img/WPIEATS_SocialMediaBanner_WhiteBG_Blacktext.png
Normal file
BIN
static/img/WPIEATS_SocialMediaBanner_WhiteBG_Blacktext.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 39 KiB |
154
templates/pod_menu.xsl
Normal file
154
templates/pod_menu.xsl
Normal file
@ -0,0 +1,154 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
|
||||||
|
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
||||||
|
|
||||||
|
<xsl:template match="/Data/Venues/Venue[1]">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8"/>
|
||||||
|
<title>Document</title>
|
||||||
|
<style>
|
||||||
|
html, body {
|
||||||
|
display: flex;
|
||||||
|
flex-flow: column wrap;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
font-size: 1.1em;
|
||||||
|
font-family: sans-serif;
|
||||||
|
min-height: 100%;
|
||||||
|
max-width: 960px;
|
||||||
|
}
|
||||||
|
@media screen {
|
||||||
|
body {
|
||||||
|
padding: 32px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.vegetarian {
|
||||||
|
color: #ac2b37;
|
||||||
|
}
|
||||||
|
.vegan {
|
||||||
|
color: #ac2b37;
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
.header {
|
||||||
|
background-image: url('{{ url_for('static', filename='img/Dining-Services_Subranded_Print_black.png') }}');
|
||||||
|
background-origin: content-box;
|
||||||
|
background-position: top right;
|
||||||
|
background-repeat: no-repeat;
|
||||||
|
background-size: 30%;
|
||||||
|
border: 1px #000 solid;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
padding: 8px 8px 8px 8px;
|
||||||
|
text-align: center;
|
||||||
|
-webkit-print-color-adjust: exact;
|
||||||
|
}
|
||||||
|
.header:before {
|
||||||
|
content: '';
|
||||||
|
position: absolute;
|
||||||
|
background-size: 100%;
|
||||||
|
background-image: url('{{ url_for('static', filename='img/WPIEATS_SocialMediaBanner_WhiteBG_Blacktext.png') }}');
|
||||||
|
margin-left: -150px;
|
||||||
|
width: 300px;
|
||||||
|
height: 48px;
|
||||||
|
-webkit-print-color-adjust: exact;
|
||||||
|
}
|
||||||
|
.header h1 {
|
||||||
|
margin-top: 48px;
|
||||||
|
}
|
||||||
|
.meal-periods {
|
||||||
|
flex: 1;
|
||||||
|
display: flex;
|
||||||
|
align-items: stretch;
|
||||||
|
align-content: stretch;
|
||||||
|
}
|
||||||
|
.meal-period {
|
||||||
|
flex: 1;
|
||||||
|
border: 1px #000 solid;
|
||||||
|
margin-right: 16px;
|
||||||
|
margin-bottom: 16px;
|
||||||
|
padding: 8px;
|
||||||
|
float: left;
|
||||||
|
}
|
||||||
|
.meal-period:last-child {
|
||||||
|
margin-right: 0;
|
||||||
|
}
|
||||||
|
.footer {
|
||||||
|
clear: both;
|
||||||
|
line-height: .5em;
|
||||||
|
}
|
||||||
|
h2 {
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
h3 {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
.menu-item::after {
|
||||||
|
content: ', ';
|
||||||
|
}
|
||||||
|
.menu-item:last-child::after {
|
||||||
|
content: '';
|
||||||
|
}
|
||||||
|
.easter-egg {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
h1::before {
|
||||||
|
content: 'POD';
|
||||||
|
}
|
||||||
|
@media print {
|
||||||
|
.easter-egg {
|
||||||
|
display: block;
|
||||||
|
font-size: 8px;
|
||||||
|
color: #f8f8f8;
|
||||||
|
position: absolute;
|
||||||
|
right: 0;
|
||||||
|
bottom: 0;
|
||||||
|
-webkit-print-color-adjust: exact;
|
||||||
|
}
|
||||||
|
{% if easter_egg %}
|
||||||
|
h1::before {
|
||||||
|
content: 'DAKA';
|
||||||
|
}
|
||||||
|
{% endif %}
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="header">
|
||||||
|
<h1> Menu</h1>
|
||||||
|
<h2>{{ date }}</h2>
|
||||||
|
</div>
|
||||||
|
<div class="meal-periods">
|
||||||
|
<xsl:for-each select="MealPeriods/MealPeriod[@name='Lunch' or @name='Dinner']">
|
||||||
|
<div class="meal-period">
|
||||||
|
<h2><xsl:value-of select="@name" /></h2>
|
||||||
|
<xsl:for-each select="MealStation">
|
||||||
|
<div class="meal-station">
|
||||||
|
<h3><xsl:value-of select="@name" /></h3>
|
||||||
|
<xsl:for-each select="MenuItem">
|
||||||
|
<xsl:choose>
|
||||||
|
<xsl:when test="Categories/Category[text()[contains(.,'Vegetarian')]]">
|
||||||
|
<span class="menu-item vegetarian"><xsl:value-of select="@name" />*</span>
|
||||||
|
</xsl:when>
|
||||||
|
<xsl:when test="Categories/Category[text()[contains(.,'Vegan')]]">
|
||||||
|
<span class="menu-item vegan"><xsl:value-of select="@name" />**</span>
|
||||||
|
</xsl:when>
|
||||||
|
<xsl:otherwise>
|
||||||
|
<span class="menu-item"><xsl:value-of select="@name" /></span>
|
||||||
|
</xsl:otherwise>
|
||||||
|
</xsl:choose>
|
||||||
|
</xsl:for-each>
|
||||||
|
</div>
|
||||||
|
</xsl:for-each>
|
||||||
|
</div>
|
||||||
|
</xsl:for-each>
|
||||||
|
</div>
|
||||||
|
<div class="footer">
|
||||||
|
<p class="vegetarian">* Vegetarian</p>
|
||||||
|
<p class="vegan">** Vegan</p>
|
||||||
|
<p class="easter-egg">{{ easter_egg_message }}</p>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
</xsl:template>
|
||||||
|
|
||||||
|
</xsl:stylesheet>
|
Loading…
x
Reference in New Issue
Block a user