Skip to content

Commit

Permalink
first poc for the talks
Browse files Browse the repository at this point in the history
  • Loading branch information
syarra committed Dec 18, 2017
1 parent cf48383 commit eb38cd1
Show file tree
Hide file tree
Showing 7 changed files with 708 additions and 3 deletions.
36 changes: 36 additions & 0 deletions 2018/talks/index.html
@@ -0,0 +1,36 @@
---
layout: default2018
---

{% include main_nav.html %}

<div class="u-vskip-3"></div>

<div class="container">
<div class="row masonry" data-masonry='{ "itemSelector": ".grid-item", "percentPosition": true }'>


{% for talk in site.data.talks %}
<div class="grid-item col-12 col-sm-12 col-md-6 col-lg-6 col-xl-6 mb-3">
<div class="red-box content-box">
<h2>{{talk.speaker}}</h2>
<p>{{talk.abstract}}</p>
<a href="{{ talk.speaker | datapage_url: '.' }}">more details</a>
</div>
</div>
{% endfor %}
</div>
</div>

<div class="u-vskip-3"></div>

<footer class="container-fluid" align="center">
<div class="container">
<div class="u-vskip"></div>
<div class="u-vskip"></div>
<div class="container">
{% include footer.html %}
</div>
<div class="u-vskip"></div>
</div>
</footer>
9 changes: 8 additions & 1 deletion _config.yml
@@ -1,3 +1,10 @@
name: JuliaCoq
kramdown:
input: GFM
input: GFM

page_gen-dirs: true
page_gen:
- data: 'talks'
template: 'profile'
name: 'speaker'
dir: '2018/talks'
472 changes: 472 additions & 0 deletions _data/talks.yml

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions _includes/main_nav.html
Expand Up @@ -15,7 +15,7 @@
<a class="nav-link" href="/{{current_folder}}">JuliaCon 2018</a>
</li>
<li class="nav-item">
<a class="nav-link" href="javascript:alert('coming soon');">talks & workshops</a>
<a class="nav-link" href="/{{current_folder}}/talks">talks & workshops</a>
</li>
<li class="nav-item">
<a class="nav-link" href="javascript:alert('coming soon');">schedule</a>
Expand All @@ -27,4 +27,4 @@
</div>
</nav>
</div>
</div>
</div>
47 changes: 47 additions & 0 deletions _layouts/2018speakers.html
@@ -0,0 +1,47 @@
---
layout: default2018
---

<div class="main-heading container-fluid">
<div class="u-futura heading-copy container">
<h1 align="center">JuliaCon is coming to London!</h1>
<div class="u-vskip"></div>
<h3 align="center">
<strong>7th to 11th August, 2018</strong> at University College London<br/>
Roberts Engineering Building, Torrington Place, WC1E 7JE, London, UK
</h3>
</div>
<div class="u-vskip-3"></div>
<div class="u-vskip-3"></div>
<div class="u-vskip-3"></div>
<div class="u-vskip-3"></div>
<div class="u-vskip-3"></div>
<div class="u-vskip-3"></div>
<div class="u-vskip-3"></div>
<div class="u-vskip-3"></div>
</div>

{% include main_nav.html %}

<div class="u-vskip-3"></div>

{% include content.html %}

<ul>
{% for person in site.data.talks %}
<li><a href="{{ person.speaker | datapage_url: 'talks' }}">{{person.speaker}}</a></li>
{% endfor %}
</ul>

<div class="u-vskip-3"></div>

<footer class="container-fluid" align="center">
<div class="container">
<div class="u-vskip"></div>
<div class="u-vskip"></div>
<div class="container">
{% include footer.html %}
</div>
<div class="u-vskip"></div>
</div>
</footer>
18 changes: 18 additions & 0 deletions _layouts/profile.html
@@ -0,0 +1,18 @@



<h1>{{page.speaker}}</h1>

<p>This page is automatically generated by the <tt>data_page_generator.rb</tt> plugin, based on the <tt>_layouts/profile.html</tt> template.</p>

<p>Use the <tt>_config.yml</tt> to specify the rules for generating pages like this one (including name and template).</p>

<p>In the template, you have access to all the fields defined in <tt>data</tt> for the record, like, for instance:</p>

<ul>
<li><tt>page.speaker</tt>: {{page.speaker}}</li>
<li><tt>page.affiliation</tt>: {{page.affiliation}}</li>
<li><tt>page.bio</tt>: {{page.bio}}</li>
</ul>

Additionally, you also have access to <tt>page.speaker</tt>, which is the filename of the page, that is: {{page.speaker}}.
125 changes: 125 additions & 0 deletions _plugins/data_page_generator.rb
@@ -0,0 +1,125 @@
# Generate pages from individual records in yml files
# (c) 2014-2016 Adolfo Villafiorita
# Distributed under the conditions of the MIT License

module Jekyll

module Sanitizer
# strip characters and whitespace to create valid filenames, also lowercase
def sanitize_filename(name)
if(name.is_a? Integer)
return name.to_s
end
return name.tr(
"ÀÁÂÃÄÅàáâãäåĀāĂ㥹ÇçĆćĈĉĊċČčÐðĎďĐđÈÉÊËèéêëĒēĔĕĖėĘęĚěĜĝĞğĠġĢģĤĥĦħÌÍÎÏìíîïĨĩĪīĬĭĮįİıĴĵĶķĸĹĺĻļĽľĿŀŁłÑñŃńŅņŇňʼnŊŋÑñÒÓÔÕÖØòóôõöøŌōŎŏŐőŔŕŖŗŘřŚśŜŝŞşŠšſŢţŤťŦŧÙÚÛÜùúûüŨũŪūŬŭŮůŰűŲųŴŵÝýÿŶŷŸŹźŻżŽž",
"AAAAAAaaaaaaAaAaAaCcCcCcCcCcDdDdDdEEEEeeeeEeEeEeEeEeGgGgGgGgHhHhIIIIiiiiIiIiIiIiIiJjKkkLlLlLlLlLlNnNnNnNnnNnNnOOOOOOooooooOoOoOoRrRrRrSsSsSsSssTtTtTtUUUUuuuuUuUuUuUuUuUuWwYyyYyYZzZzZz"
).downcase.strip.gsub(' ', '-').gsub(/[^\w.-]/, '')
end
end

# this class is used to tell Jekyll to generate a page
class DataPage < Page
include Sanitizer

# - site and base are copied from other plugins: to be honest, I am not sure what they do
#
# - `index_files` specifies if we want to generate named folders (true) or not (false)
# - `dir` is the default output directory
# - `data` is the data defined in `_data.yml` of the record for which we are generating a page
# - `name` is the key in `data` which determines the output filename
# - `template` is the name of the template for generating the page
# - `extension` is the extension for the generated file
def initialize(site, base, index_files, dir, data, name, template, extension)
@site = site
@base = base

# @dir is the directory where we want to output the page
# @name is the name of the page to generate
#
# the value of these variables changes according to whether we
# want to generate named folders or not
filename = sanitize_filename(data[name]).to_s
@dir = dir + (index_files ? "/" + filename + "/" : "")
@name = (index_files ? "index" : filename) + "." + extension.to_s

self.process(@name)
self.read_yaml(File.join(base, '_layouts'), template + ".html")
self.data['title'] = data[name]
# add all the information defined in _data for the current record to the
# current page (so that we can access it with liquid tags)
self.data.merge!(data)
end
end

class DataPagesGenerator < Generator
safe true

# generate loops over _config.yml/page_gen invoking the DataPage
# constructor for each record for which we want to generate a page

def generate(site)
# page_gen_dirs determines whether we want to generate index pages
# (name/index.html) or standard files (name.html). This information
# is passed to the DataPage constructor, which sets the @dir variable
# as required by this directive
index_files = site.config['page_gen-dirs'] == true

# data contains the specification of the data for which we want to generate
# the pages (look at the README file for its specification)
data = site.config['page_gen']
if data
data.each do |data_spec|
template = data_spec['template'] || data_spec['data']
name = data_spec['name']
dir = data_spec['dir'] || data_spec['data']
extension = data_spec['extension'] || "html"

if site.layouts.key? template
# records is the list of records defined in _data.yml
# for which we want to generate different pages
records = nil
puts "#{data_spec['data']}"

data_spec['data'].split('.').each do |level|
if records.nil?
records = site.data[level]
else
records = records[level]
end
end
records = records.select { |r| r[data_spec['filter']] } if data_spec['filter']
puts "Let's talk about #{records}."
records.each do |record|
site.pages << DataPage.new(site, site.source, index_files, dir, record, name, template, extension)
end
else
puts "error. could not find template #{template}" if not site.layouts.key? template
end
end
end
end
end

module DataPageLinkGenerator
include Sanitizer

# use it like this: {{input | datapage_url: dir}}
# to generate a link to a data_page.
#
# the filter is smart enough to generate different link styles
# according to the data_page-dirs directive ...
#
# ... however, the filter is not smart enough to support different
# extensions for filenames.
#
# Thus, if you use the `extension` feature of this plugin, you
# need to generate the links by hand
def datapage_url(input, dir)
extension = Jekyll.configuration({})['page_gen-dirs'] ? '/' : '.html'
"#{dir}/#{sanitize_filename(input)}#{extension}"
end
end

end

Liquid::Template.register_filter(Jekyll::DataPageLinkGenerator)

0 comments on commit eb38cd1

Please sign in to comment.