Skip to content

Commit b46d46b

Browse files
committed
Add final project showcase
1 parent 7da5ead commit b46d46b

File tree

5 files changed

+110
-1
lines changed

5 files changed

+110
-1
lines changed

.DS_Store

0 Bytes
Binary file not shown.

index.html

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,33 @@ <h3 class="text-muted">the <span class="text-primary">python</span> programming
9999
<div class="tab-content">
100100
<!-- Overview Tab -->
101101
<div role="tabpanel" class="tab-pane fade in active" id="overview">
102+
103+
<!-- Start of the Final Project Showcase -->
104+
<!--
105+
<div class="row">
106+
<div>
107+
<div class="projects">
108+
<h4 class="text-primary">Final Project Showcase</h4>
109+
<table class="table table-striped table-hover table-bordered">
110+
<thead>
111+
<tr>
112+
<th style="width:40%">Project</th>
113+
<th style="width:40%"></th>
114+
115+
</tr>
116+
</thead>
117+
<tbody>
118+
<!-- Showcase inserted here by resources.js TODO - add closing
119+
comment to this when uncommenting the final project showcase
120+
since HTML comments don't nest
121+
</tbody>
122+
</table>
123+
</div>
124+
<div>
125+
</div>
126+
-->
127+
<!-- End of the Final Project Showcase -->
128+
102129
<div class="row">
103130
<!-- Left Column -->
104131
<div class="col-md-4">

js/gtag_helper.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,15 @@ var gtag_trackAssignmentHandout = function(url) {
124124
});
125125
}
126126

127+
var gtag_trackShowcaseLink = function(url) {
128+
gtag('event', 'click', {
129+
'event_category': 'resource:showcase',
130+
'event_label': url,
131+
'transport_type': DEFAULT_TRANSPORT_TYPE,
132+
// 'event_callback': function(){document.location = url;}
133+
});
134+
}
135+
127136
var gtag_trackAssignmentStarterCode = function(url) {
128137
gtag('event', 'click', {
129138
'event_category': 'assignment:starter_code',

js/resources.js

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,45 @@ function create_handout_tr(ho) {
205205
return $tr;
206206
}
207207

208+
function create_showcase_tr(project) {
209+
/*
210+
<tr>
211+
<td scope="row">
212+
<b>Sample Project Title</b> <br>
213+
Sample Project Authors <br>
214+
<a href="link_to_project"> [Check it Out!] </a>
215+
</td>
216+
<td> (Image, if applicable) </td>
217+
</tr>
218+
*/
219+
var $tr = $('<tr>').append(
220+
$('<td>').append(
221+
// $('<center>').attr('scope', 'row').append(
222+
$('<b>').append(
223+
project.Title.concat("<br>"))).append(
224+
project.Authors.concat("<br>")).append(
225+
create_anchor(project.href, project.DemoType, "None", gtag_trackShowcaseLink)
226+
// )
227+
));
228+
229+
// Add images if they're applicable
230+
if (project.img.length > 0){
231+
$tr.append(
232+
$('<td>').append(
233+
'<img src="'.concat(project.img, '"">')
234+
));
235+
}
236+
else {
237+
// Occupy the right hand column with something.
238+
$tr.append(
239+
$('<td>').append(
240+
""
241+
));
242+
}
243+
244+
return $tr;
245+
}
246+
208247
function create_announcement(announcement) {
209248
/*
210249
<div class="panel panel-default">
@@ -286,7 +325,7 @@ function create_week_heading_tr(week) {
286325
}
287326

288327
// Actually fetch all the resources
289-
var RESOURCES_DIR = 'https://stanfordpython.com/res'
328+
var RESOURCES_DIR = 'http://localhost:8000/res'
290329

291330
$.when(
292331
// Before we can do anything, make sure we have the proper data!
@@ -310,6 +349,9 @@ $.when(
310349
}),
311350
$.getJSON(RESOURCES_DIR + '/schedule.json', function(data) {
312351
schedule = data;
352+
}),
353+
$.getJSON(RESOURCES_DIR + '/projects.json', function(data) {
354+
projects = data;
313355
})
314356
).then(function() {
315357

@@ -353,6 +395,14 @@ $.when(
353395
}
354396
}
355397

398+
for (var i = 0; i < projects.length; i++) {
399+
var proj = projects[i];
400+
var markup = create_showcase_tr(proj);
401+
if (markup !== null) {
402+
$(".projects tbody").append(markup);
403+
}
404+
}
405+
356406
for (var i = 0; i < schedule.length; i++) {
357407
var week = schedule[i];
358408
var markup = create_week_heading_tr(week);

res/projects.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
[
2+
{
3+
"uid": "4d4fd06d-adf8-4161-8fb0-27a9590231c2",
4+
"Title": "Project Title",
5+
"Authors": "Author1, Author2",
6+
"DemoType": "GitHub",
7+
"href": "https://google.com",
8+
"img": "",
9+
"imgAlt": "altText",
10+
"ext": ""
11+
},
12+
{
13+
"uid": "4d4fd06d-adf8-4161-8fb0-27a9590231c2",
14+
"Title": "Project Title2",
15+
"Authors": "Author1, Author2",
16+
"DemoType": "GitHub",
17+
"href": "https://google.com",
18+
"img": "https://www.python.org/static/community_logos/python-logo.png",
19+
"imgAlt": "altText",
20+
"ext": ""
21+
22+
}
23+
]

0 commit comments

Comments
 (0)