Permalink
Browse files

Merge pull request #14 - iCal generation, thanks to @nougad

  • Loading branch information...
Matthias Günther
Matthias Günther committed Aug 18, 2013
2 parents 0321116 + 50dab71 commit b04a467a945310c89095f73664c97e276c62c45e
View
@@ -10,3 +10,6 @@ gem 'rake' , '10.1.0'
gem 'rdiscount' , '2.1.6'
gem 'stringex' , '2.0.8'
gem 'sweetie' , '1.0.1'
gem 'ri_cal' , '0.8.8'
gem 'tzinfo' , '1.0.1'
gem 'nokogiri' , '1.6.0'
View
@@ -4,3 +4,35 @@ permalink: /:title
rdiscount:
extensions: [smart]
siteurl: http://vimberlin.de
locations:
launchco:
street: Warschauer Str. 70A
city: Berlin
postalcode: 10243
country: Germany
url: https://launchco.com/etc/#coworking
map: http://g.co/maps/k62eb
name: LAUNCH/CO
addition: 3rd floor
matthias:
street: Neue Straße 6
city: Berlin Tempelhof
postalcode: 12103
country: Germany
url:
map: http://bit.ly/To0yMf
name: Matthias@Home
addition:
intimes:
street: Boxhagener Str. 107
city: Berlin
postalcode: 10245
country: Germany
url:
map: http://goo.gl/maps/a4oqk
name: the bar Intimes
addition:
View
@@ -40,7 +40,7 @@ <h1>Vimberlin<small> a gathering for Vim-enthusiasts in Berlin.</small>
<aside class="three columns">
<div class="panel">
<h5>Next meetup:</h5>
<p><code>29th of August 6.30pm, 2013 3rd floor {% include launch_co_map.html %}</code></p>
<p>{% next_meetup %}</p>
</div>
</aside>
View
@@ -0,0 +1,44 @@
---
layout: base
---
<div id="post" itemscope itemtype="http://schema.org/Event">
<meta itemprop="url" content="{{page.url}}">
<header>
<h3 itemprop="name">{{page.title}}</h3>
</header>
<div itemprop="startDate" content="{{page.when}}">Starts: {{page.when | date: "%B, %eth %Y %l:%M %P"}}</div>
<div itemprop="endDate" content="{{page.ends}}">Ends: {{page.ends | date: "%B, %eth %Y %l:%M %P"}}</div>
at {% location %}
<div itemprop="description">
{{ content }}
</div>
</div>
<div class="whoring">
<h3>Discussion, links, and comments</h3>
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES: EDIT BEFORE PASTING INTO YOUR WEBPAGE * * */
var disqus_shortname = 'vimberlin'; // required: replace example with your forum shortname
/*var disqus_developer = 1;*/
/*var disqus_url = 'http://christophehamerling.com{{ page.url }}';*/
var disqus_identifier = '{{ page.title }}';
// The following are highly recommended additional parameters. Remove the slashes in front to use.
// var disqus_identifier = 'unique_dynamic_id_1234';
// var disqus_url = 'http://example.com/permalink-to-page.html';
/* * * DON'T EDIT BELOW THIS LINE * * */
(function() {
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = 'http://' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="http://disqus.com/?ref_noscript">comments powered by Disqus.</a></noscript>
</div>
View
@@ -0,0 +1,60 @@
require 'pathname'
require 'ri_cal'
require 'tzinfo'
require 'nokogiri'
module Jekyll
class StaticICalFile < StaticFile
def write(dest)
super(dest) rescue ArgumentError
true
end
end
class ICalGenerator < Generator
safe true
priority :low
def generate(site)
# Create the destination folder if necessary.
site_folder = site.config['destination']
unless File.directory?(site_folder)
p = Pathname.new(site_folder)
p.mkdir
end
calendar = RiCal.Calendar do |cal|
cal.default_tzid = "Europe/Berlin"
#cal.x_wr_calname = "VimBerlin"
site.site_payload['site']['posts'].each do |post|
if post.data['layout'] == "event" then
# XXX: is there no fucking way to get the rendered content of a site?
payload = {'page' => post.to_liquid }
info = { :filters => [Jekyll::Filters], :registers => { :site => site, :page => payload['page'] } }
content = Liquid::Template.parse(post.content).render!(payload, info)
loc = site.config['locations'][post.data['where']]
location = "#{loc["name"]}, #{loc["street"]}, #{loc["postalcode"]} #{loc["city"]}, #{loc["country"]}"
cal.event do |event|
event.summary = post.title
event.description = Nokogiri::HTML(content).text # ugly hack to textify html
event.dtstart = Time.parse post.data['when']
event.dtend = Time.parse post.data['ends']
event.location = location
event.url = site.config['siteurl'] + post.url
end
end
end
end
File.open(File.join(site_folder, 'vimberlin.ics'), 'w') do |f|
f.puts calendar.to_s
end
# Add a static file entry for the zip file, otherwise Site::cleanup will remove it.
site.static_files << Jekyll::StaticICalFile.new(site, site.dest, '/', 'vimberlin.ics')
end
end
end
View
@@ -0,0 +1,42 @@
module Jekyll
class RenderLocation < Liquid::Tag
def initialize(tag_name, text, tokens)
super
@addition_overwrite = text
end
def render(context)
# is there no pretty way to access the page?
page = context.environments.first["page"]
# is there no pretty way to access the config?
loc = context.registers[:site].config['locations'][page['where']]
addition = if @addition_overwrite != "" then @addition_overwrite else loc["addition"] end
# TODO: refactor to remove ugly strings
where = if loc["url"].nil? then
"<span itemprop='name'>#{loc["name"]}</span> #{addition}"
else
"<a itemprop='url' href='#{loc["url"]}'>
<span itemprop='name'>#{loc["name"]}</span>
</a> #{addition}"
end
<<DOC
<div itemprop="location" itemscope itemtype="http://schema.org/PostalAddress">
<div>#{where}</div>
<div itemprop="streetAddress">#{loc["street"]}</div>
<div>
<span itemprop="postalCode">#{loc["postalcode"]}</span>
<span itemprop="addressLocality">#{loc["city"]}</span>
</div>
<meta itemprop="addressCountry" content=#{loc["country"]} />
(<a href="#{loc["map"]}">map</a>)
</div>
DOC
end
end
end
Liquid::Template.register_tag('location', Jekyll::RenderLocation)
View
@@ -0,0 +1,28 @@
require 'date'
module Jekyll
class RenderNextMeetup < Liquid::Tag
def initialize(tag_name, text, tokens)
super
end
def render(context)
next_event = context.registers[:site].posts
.select do |page| page.data['layout'] == 'event' end
.select do |page| Time.parse(page.data['when']) >= Time.now end
.sort_by do |page| page.data['when'] end
.first
loc = context.registers[:site].config['locations'][next_event.data['where']]
time = Time.parse(next_event.data['when']).strftime("%B, %eth %Y %l:%M %P")
# it doesn't support templates here :(
result = ""
result += "<a href='#{next_event.url}'>#{next_event.title}</a>:"
result += " #{time}"
result += " at <a href='#{loc["url"]}'>#{loc["name"]}</a>"
end
end
end
Liquid::Template.register_tag('next_meetup', Jekyll::RenderNextMeetup)
@@ -1,11 +1,11 @@
---
layout: post
layout: event
title: January 2012 Meetup
when: 2012-01-26T20:00
ends: 2012-01-26T22:00
where: launchco
---
The first "Vimberlin User Group" meetup will take place on Thursday, 26th January, at 8:00 p.m at the [LAUNCH/CO coworking space](https://launchco.com/etc/#coworking "LAUNCH/CO coworking space") [(map)](https://plus.google.com/115820795011326627918/about?gl=US&hl=en "Map").
[Drew Neil](http://drewneil.com/ "Drew Neil") (aka [@nelstrom](https://twitter.com/nelstrom "@nelstrom"), the creator of the awesome [vimcasts](http://vimcasts.org/ "vimcasts"), agreed to give a talk.
We are very proud to have him at our very first meetup. The topic is yet to be announced. Further topics will be kind of organizational. We should briefly talk about:
@@ -1,12 +1,11 @@
---
layout: post
layout: event
title: March 2012 Meetup
when: 2012-03-22T20:00
ends: 2012-03-22T22:00
where: launchco
---
We will meet on:
<code>March, 22nd 2012 8:00 p.m{% include launch_co_map.html %}</code>
We currently have two talks on our agenda:
<ul>
@@ -1,12 +1,11 @@
---
layout: post
layout: event
title: May 2012 Meetup
when: 2012-05-24T20:00
ends: 2012-05-24T22:00
where: launchco
---
We will meet on:
<code>May, 24th 2012 8:00 p.m. {% include launch_co_map.html %}</code>
We currently have two talks on our agenda:
<ul>
@@ -1,12 +1,11 @@
---
layout: post
layout: event
title: July 2012 Meetup
when: 2012-07-26T20:00
ends: 2012-07-26T22:00
where: launchco
---
We will meet on:
<code>July, 26th 2012 8:00 p.m. {% include launch_co_map.html %}</code>
We currently have one talk on our agenda:
<ul>
@@ -1,9 +1,12 @@
---
layout: post
layout: event
title: August 2012 Workshop
when: 2012-08-29T19:00
ends: 2012-08-29T22:00
where: launchco
---
**Next meetup is something special: "VIM NOVICE - a beginners workshop for people new to Vim" 2012-08-29, 7 p.m. at LAUNCH/CO**
**Next meetup is something special: "VIM NOVICE - a beginners workshop for people new to Vim"**
After discussing with [@lucapette](https://twitter.com/lucapette) and [@guckes](https://twitter.com/guckes) on our last meetup, we brainstormed the ideas how we can teach Vim not only to basic users of the editor but as well to beginners who has never used a modal editor like Vim before.
@@ -1,12 +1,11 @@
---
layout: post
layout: event
title: September 2012 Meetup
when: 2012-09-27T20:00
ends: 2012-09-27T22:00
where: launchco
---
We will meet on:
<code> September, 27th 2012 8:00 p.m. {% include launch_co_map.html %}</code>
We currently have the following talks on our agenda:
<ul>
@@ -1,16 +1,16 @@
---
layout: post
layout: event
title: October 2012 Workshop
when: 2012-10-25T20:00
ends: 2012-10-25T23:00
where: launchco
---
![/images/workshop.png](/images/workshop.png "workshop")
Our first beginners workshop in [August 2012](/august-2012-workshop) was a huge success. Around twenty people were learning something new: Some of them learned the usage of the `vimrc`, others went through [vimtutor](http://linuxcommand.org/man_pages/vimtutor1.html), and some of them asked specific questions.
I'm happy to announce the second vimberlin beginners workshop. We will meet on:
<code>October, 25th 2012 8:00 p.m. {% include launch_co_map.html %}</code>
I'm happy to announce the second vimberlin beginners workshop.
### Registration
@@ -1,12 +1,11 @@
---
layout: post
layout: event
title: November 2012 Meetup
when: 2012-11-22T19:30
ends: 2012-11-22T22:00
where: launchco
---
We will meet on:
<code>November, 22th 2012 7:30 pm {% include launch_co_map.html %}</code>
We currently have the three talks on our agenda:
<ul>
@@ -1,12 +1,12 @@
---
layout: post
layout: event
title: Unusual December 2012 Meetup
when: 2012-12-20T19:30
ends: 2012-12-20T22:00
where: matthias
---
We discussed on our mail list that we will have no official meetup before X-mas starts. Due to lack of space, we will meet at the home of Matthias:
<code>December, 20th 2012 7:30 pm at Neue Straße 6, 12103 Berlin Tempelhof (<a
href="http://bit.ly/To0yMf">map</a>)</code>
We discussed on our mail list that we will have no official meetup before X-mas starts. Due to lack of space, we will meet at the home of Matthias.
I will provide some beer and a delicious cake. See you soon.
Oops, something went wrong.

0 comments on commit b04a467

Please sign in to comment.