Skip to content
This repository has been archived by the owner on Mar 12, 2018. It is now read-only.

Commit

Permalink
Events of the Week functionality
Browse files Browse the repository at this point in the history
#2
Also added some temporary test events to see it in action.
  • Loading branch information
ofShard committed Nov 5, 2013
1 parent 08e3cc8 commit ee7780c
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 18 deletions.
14 changes: 13 additions & 1 deletion docpad.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,18 @@ docpadConfig = {
# Merge the document keywords with the site keywords
@site.keywords.concat(@document.keywords or []).join(', ')

# Get the next four events from this week's Sunday.
getEventsFromSunday: (limit=4) ->
now = new Date()
o = now.getDay() * 24 * 60 * 60 * 1000
temp = new Date(now - o)
lastSunday = new Date(temp.getFullYear(), temp.getMonth(), temp.getDate())

events = @getCollection('events').findAll({event:{$gte:lastSunday}}).toJSON()
if events.length > limit then events.length = limit

return events


# =================================
# Collections
Expand Down Expand Up @@ -102,7 +114,7 @@ docpadConfig = {
database.findAllLive({video: $exists: true}, [video:1,title:1])

events: (database) ->
database.findAllLive({event: $exists: true}, [event:1,title:1])
database.findAllLive({event: $exists: true}, [event:1])

news: (database) ->
database.findAllLive({tags:$has:'news'}, [date:-1])
Expand Down
17 changes: 1 addition & 16 deletions src/documents/pages/news-events.html.eco
Original file line number Diff line number Diff line change
Expand Up @@ -31,22 +31,7 @@ tags: ['page','left_sidebar_menu-item']
<br>

<h4 id="casestudies">Events</h4>
<nav class="linklist">
<% for document in @getCollection('events').toJSON(): %>
<li>
<a href="<%= document.url %>"><%= document.title %></a>
<% if document.postDate: %>
&raquo;
<span><%= document.postDate %></span>
<% end %>
<% if document.desc: %>
<br>
<sub><%= document.desc %></sub>
<% end %>
</li>
<br>
<% end %>
</nav>
<%- @partial('events.html.eco') %>

<br>

2 changes: 1 addition & 1 deletion src/documents/pages/news_events/HETT.html.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Healthcare Efficiency through Technology Oct 2013
layout: page
tags: ['events']
event: 1
event: 2013-10-08
postDate: 2013-10-08
desc: Visit us at Booth 21.
```
Expand Down
11 changes: 11 additions & 0 deletions src/documents/pages/news_events/event1.html.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
```
title: Does this show this week
layout: page
tags: ['events']
postDate: 2013-11-8
event: 2013-11-8
pdf:
desc: This should show w/c 28 Oct
```

# This should show w/c 28 Oct.
11 changes: 11 additions & 0 deletions src/documents/pages/news_events/event2.html.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
```
title: Does this show this week
layout: page
tags: ['events']
postDate: 2013-11-11
event: 2013-11-11
pdf:
desc: This should show w/c 28 Oct
```

# This should show w/c 28 Oct.
11 changes: 11 additions & 0 deletions src/documents/pages/news_events/event3.html.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
```
title: Does this show this week
layout: page
tags: ['events']
postDate: 2013-11-19
event: 2013-11-19
pdf:
desc: This should show w/c 28 Oct
```

# This should show w/c 28 Oct.
16 changes: 16 additions & 0 deletions src/partials/events.html.eco
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<nav class="linklist">
<% for document in @getEventsFromSunday(4): %>
<li>
<a href="<%= document.url %>"><%= document.title %></a>
<% if document.postDate: %>
&raquo;
<span><%= document.postDate %></span>
<% end %>
<% if document.desc: %>
<br>
<sub><%= document.desc %></sub>
<% end %>
</li>
<br>
<% end %>
</nav>

0 comments on commit ee7780c

Please sign in to comment.