Create page with info (pictures, content, links, whatever) about past and future activities (workshops, talks, etc.)
Initial work:
_activities/workshop_unity3d.yml:
description:
VolumeZero was the first project of NeCG (hence the name) and the first one to be publicly available back in 2006. It features a set of board games like Go, Virus and Abalone.
They were all built using C++, OpenGL and Prolog.
image:
url: volume0_project_logo_2.png
title: VolumeZero Logo
alt: VolumeZero Logo
layout: project
published: true
short: A set of board games using OpenGL, C++ and Prolog.
title: VolumeZero
website: http://paginas.fe.up.pt/~necg/sites/VolumeZeroSite/
website_description:
You can download them in the following link:
authors: ["Marco Silva", "Susana Vilaça", "Filipe Costa", "Diogo Pinto", "Tomé Duarte", "Mário Freitas", "Fábio Oliveira", "Telmo Couto"]
_layouts/activities.html:
---
layout: base
title: Projects
---
<article class="container" id="content">
<div class="span16">
<p>Here you can check most of our projects!</p>
<p>If the information that we share here doesn’t satisfy your curiosity, please email us and we’ll provide you what is lacking.</p>
<li id="projects" class="row">
{% for project in page.projects %}
<ul class="project col-xs-6 col-md-3-5">
<a href="{{ site.baseurl }}projects/{{ project[0] }}">
<b>{{ project[1].title }}</b>
{% if project[1].image %}
<img src="{{ project[1].image.url | asset_path }}" title="{{ project[1].image.title }}" alt="{{ project[1].image.alt }}" />
{% endif %}
<p>{{ project[1].short }}</p>
</a>
</ul>
{% endfor %}
</li>
</div>
</article>
_layouts/activity.html:
---
layout: base
---
<article class="container" id="content">
{% if page.image %}
<div class="span5 logo" style="display: inline; float: left; margin-left: 20px; width: 200px">
<a href="{{ page.website }}">
<img src="{{ page.image.url | asset_path }}" title="{{ page.image.title }}" alt="{{ page.image.alt }}" style="border: 1px solid #eee;padding: 2px" />
</a>
</div>
{% endif %}
<div class="span10">
<h1>{{ page.title }}</h1>
{{ page.description | simple_format }}
{% if page.website_description %}
<br/><br/><p>{{ page.website_description }}</p>
{% endif %}
{% if page.website %}
<div class="website"><a href="{{ page.website }}">{{ page.website }}</a></div>
{% endif %}
</div>
{% if page.authors %}
<footer>
<address>
<br/><br/><p>Project by:<br>
{% for author in page.authors %}
<span class="muted"><strong>{{ author }}</strong></span>{% if forloop.last == false %}, {% endif %}
{% endfor %}
</p>
</address>
</footer>
{% endif %}
</article>
_layout/base.html:
diff --git a/_layouts/base.html b/_layouts/base.html
index 0013ff2..f6983b5 100644
--- a/_layouts/base.html
+++ b/_layouts/base.html
@@ -38,6 +38,7 @@
</a>
<a href="{{ site.baseurl }}" class="home">Home</a>
<a href="{{ site.baseurl }}projects" class="projects">Projects</a>
+ <a href="{{ site.baseurl }}activities" class="activities">Activities</a>
<a href="{{ site.baseurl }}members" class="members">Members</a>
<a href="{{ site.baseurl }}about" class="about">About</a>
</nav>
_plugins/activities.rb:
module Jekyll
class ActivitiesIndex < Page
def initialize(site, base, dir)
@site = site
@base = base
@dir = dir
@name = "index.html"
self.process(@name)
self.read_yaml(File.join(base, '_layouts'), 'activities.html')
self.data['activities'] = self.get_activities(site)
end
def get_activities(site)
{}.tap do |activities|
Dir['_activities/*.yml'].each do |path|
name = File.basename(path, '.yml')
config = YAML.load(File.read(File.join(@base, path)))
activities[name] = config if config['published']
end
end
end
end
class ActivityIndex < Page
def initialize(site, base, dir, path)
@site = site
@base = base
@dir = dir
@name = "index.html"
self.data = YAML.load(File.read(File.join(@base, path)))
self.process(@name) if self.data['published']
end
end
class GenerateActivities < Generator
safe true
priority :normal
def generate(site)
self.write_activities(site)
end
# Loops through the list of activity pages and processes each one.
def write_activities(site)
if Dir.exists?('_activities')
Dir.chdir('_activities')
Dir["*.yml"].each do |path|
name = File.basename(path, '.yml')
self.write_activity_index(site, "_activities/#{path}", name)
end
Dir.chdir(site.source)
self.write_activities_index(site)
end
end
def write_activities_index(site)
activities = ActivitiesIndex.new(site, site.source, "/activities")
activities.render(site.layouts, site.site_payload)
activities.write(site.dest)
site.pages << activities
site.static_files << activities
end
def write_activity_index(site, path, name)
activity = ActivityIndex.new(site, site.source, "/activities/#{name}", path)
if activity.data['published']
activity.render(site.layouts, site.site_payload)
activity.write(site.dest)
site.pages << activity
site.static_files << activity
end
end
end
end
Ref #4
Create page with info (pictures, content, links, whatever) about past and future activities (workshops, talks, etc.)
Initial work:
_activities/workshop_unity3d.yml:
_layouts/activities.html:
_layouts/activity.html:
_layout/base.html:
_plugins/activities.rb:
Ref #4