Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamically create index.html and support user submitted slides #29

Merged
merged 1 commit into from
Aug 26, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
149 changes: 9 additions & 140 deletions dashboard/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,149 +12,18 @@
</div>

<div class="slides">
{% for slide in slides %}
{% if slide.stype == "WIDGET" %}
{% include "widget_slide.html" %}
{% endif %}

<div class="slide" id="landing-slide">

<!-- Clock Widget -->
<div class="panel2" id="time">
<div class="icon">
<div id="clock">
</div>
</div>
<div class="widget-content2">
<h1>N/A</h1></br>
<h2>N/A</h2>
</div>
</div>
<!-- End Clock Widget -->

<!-- Weather Widget-->
<div class="panel2" id="weather">
<div class="icon">
<img src="{{ STATIC_URL }}img/no_icon.png"></img>
</div>
<div class="widget-content2">
<h1 class="temp">N/A</h1><br />
<h2 class="description">Unavailable</h2>
</div>
</div>
<!-- End Weather Widget-->

<!-- Nextbus Widget -->
<div class="panel2" id="nextbus">
<div class="icon">
<img src="{{ STATIC_URL }}img/bus.png"></img>
</div>
<div class="widget-content2">
<h1 class="next">N/A</h1><br />
<h2><span class="second">N/A</span> <span class="third">N/A</span></h2>
</div>
</div>
<!-- End Nextbus Widget-->

<!-- Events Widget -->
<div class="panel3" id="events">
<div class="icon">
<img src="{{ STATIC_URL }}img/events.png"></img>
{% if slide.stype == "POSTER" %}
<div class="slide" id="res-event">
<img src="{{ slide.path }}"></img>
</div>
<div class="widget-content3">
<h2 class="title">Unavailable</h2><br/>
<h2 class="time">N/A</h2>
</div>
</div>
<!-- End Events Widget -->

<!-- News Widget -->
<div class="panel3" id="news">
<div class="icon">
<img src="{{ STATIC_URL }}img/BBC.png"></img>
</div>
<div class="widget-content3">
<h2 class="title">Unavailable</h2>
</div>
</div>
<!-- End News Widget -->

</div>

<div class="slide" id="res-event">
<img src="{{ STATIC_URL }}img/poster/Simmons_10th_Anniversary.jpg"></img>
</div>

<div class="slide" id="res-event1">
<img src="{{ STATIC_URL }}img/poster/Boston_Harbor_Cruise.jpg"></img>
</div>

<div class="slide" id="landing-slide2">

<!-- Clock Widget -->
<div class="panel2" id="time">
<div class="icon">
<div id="clock">
</div>
</div>
<div class="widget-content2">
<h1>N/A</h1></br>
<h2>N/A</h2>
</div>
</div>
<!-- End Clock Widget -->

<!-- Weather Widget-->
<div class="panel2" id="weather">
<div class="icon">
<img src="{{ STATIC_URL }}img/no_icon.png"></img>
</div>
<div class="widget-content2">
<h1 class="temp">N/A</h1><br />
<h2 class="description">Unavailable</h2>
</div>
</div>
<!-- End Weather Widget-->

<!-- Nextbus Widget -->
<div class="panel2" id="nextbus">
<div class="icon">
<img src="{{ STATIC_URL }}img/bus.png"></img>
</div>
<div class="widget-content2">
<h1 class="next">N/A</h1><br />
<h2><span class="second">N/A</span> <span class="third">N/A</span></h2>
</div>
</div>
<!-- End Nextbus Widget-->

<!-- Events Widget -->
<div class="panel3" id="events">
<div class="icon">
<img src="{{ STATIC_URL }}img/events.png"></img>
</div>
<div class="widget-content3">
<h2 class="title">Unavailable</h2><br/>
<h2 class="time">N/A</h2>
</div>
</div>
<!-- End Events Widget -->

<!-- News Widget -->
<div class="panel3" id="news">
<div class="icon">
<img src="{{ STATIC_URL }}img/BBC.png"></img>
</div>
<div class="widget-content3">
<h2 class="title">Unavailable</h2>
</div>
</div>
<!-- End News Widget -->

</div>

<div class="slide" id="res-event2">
<img src="{{ STATIC_URL }}img/poster/Bobby_Weber.jpg"></img>
</div>

{% endif %}
{% endfor %}
</div>

</div>

<!-- Standard scripts -->
Expand Down
62 changes: 62 additions & 0 deletions dashboard/templates/widget_slide.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
<div class="slide" id="landing-slide">
<!-- Clock Widget -->
<div class="panel2" id="time">
<div class="icon">
<div id="clock">
</div>
</div>
<div class="widget-content2">
<h1>N/A</h1></br>
<h2>N/A</h2>
</div>
</div>
<!-- End Clock Widget -->

<!-- Weather Widget-->
<div class="panel2" id="weather">
<div class="icon">
<img src="{{ STATIC_URL }}img/no_icon.png"></img>
</div>
<div class="widget-content2">
<h1 class="temp">N/A</h1><br />
<h2 class="description">Unavailable</h2>
</div>
</div>
<!-- End Weather Widget-->

<!-- Nextbus Widget -->
<div class="panel2" id="nextbus">
<div class="icon">
<img src="{{ STATIC_URL }}img/bus.png"></img>
</div>
<div class="widget-content2">
<h1 class="next">N/A</h1><br />
<h2><span class="second">N/A</span> <span class="third">N/A</span></h2>
</div>
</div>
<!-- End Nextbus Widget-->

<!-- Events Widget -->
<div class="panel3" id="events">
<div class="icon">
<img src="{{ STATIC_URL }}img/events.png"></img>
</div>
<div class="widget-content3">
<h2 class="title">Unavailable</h2><br/>
<h2 class="time">N/A</h2>
</div>
</div>
<!-- End Events Widget -->

<!-- News Widget -->
<div class="panel3" id="news">
<div class="icon">
<img src="{{ STATIC_URL }}img/BBC.png"></img>
</div>
<div class="widget-content3">
<h2 class="title">Unavailable</h2>
</div>
</div>
<!-- End News Widget -->

</div>
20 changes: 18 additions & 2 deletions dashboard/views.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
from django.template import RequestContext
from django.shortcuts import render_to_response
from django.shortcuts import render_to_response, render
import requests

def home(request):
return render_to_response('index.html', context_instance = RequestContext(request))
class Slide():
def __init__(self, slide_type, path="NA"):
# slide_type is of WIDGET or POSTER
self.stype = slide_type
self.path = path

slides = []
img_urls = requests.get("https://adat.scripts.mit.edu:444/www/dev/simmons/display/dashboard.php").json()

# naively insert a widget slide after every 2 images
for i in range(len(img_urls)):
if i % 2:
slides.append(Slide("WIDGET"))
slides.append(Slide("POSTER", img_urls[i]))

return render(request, "index.html", {"slides": slides})

def sevenk(request):
return render_to_response('sevenk.html', context_instance = RequestContext(request))