stadtwiki-foo
parent
7b5bb895c4
commit
0cd7000356
@ -0,0 +1,35 @@
|
||||
#!/usr/bin/env ruby
|
||||
$:.unshift('vendor/ruby-mediawiki/lib')
|
||||
require 'mediawiki/dotfile'
|
||||
require 'http-access2'
|
||||
require 'vpim/icalendar'
|
||||
include Vpim
|
||||
|
||||
$ical_url = "http://www.google.com/calendar/ical/nsb7jkat2efmkfs85qcbvouk8g@group.calendar.google.com/public/basic.ics"
|
||||
$st = - 3*24*3600
|
||||
$en = +180*24*3600
|
||||
|
||||
def get_events()
|
||||
@client = HTTPAccess2::Client.new()
|
||||
ical = @client.get_content($ical_url)
|
||||
events = []
|
||||
Icalendar.decode(ical).each do |publish|
|
||||
publish.events.each do |event|
|
||||
if event.dtstart >= (Time.now+$st) and event.dtstart <= (Time.now+$en)
|
||||
events.push(event)
|
||||
end
|
||||
end
|
||||
end
|
||||
return events
|
||||
end
|
||||
|
||||
@wiki = MediaWiki.dotfile(nil,'stadtwiki')
|
||||
|
||||
body = "Folgende Termine stammen von #{$ical_url}:\n\n"
|
||||
get_events().sort {|x,y| x.dtstart <=> y.dtstart }.each do |event|
|
||||
body += "* #{event.dtstart.mday}.#{event.dtstart.month}. #{event.summary}\n"
|
||||
end
|
||||
|
||||
a = @wiki.article("Benutzer:Neingeist/Termine_aus_Google_Calendar")
|
||||
a.text = body
|
||||
a.submit("Import")
|
Reference in New Issue