diff --git a/commands/create-flyer.rb b/commands/create-flyer.rb new file mode 100644 index 00000000..78e563eb --- /dev/null +++ b/commands/create-flyer.rb @@ -0,0 +1,76 @@ +usage 'create-flyer eventnode outputdir' +aliases :cf +summary 'creates svg for flyer' +description 'Create SVG file with content of given event' + +class CreateFlyer < ::Nanoc::CLI::CommandRunner + def run + # Check arguments + if arguments.length!=2 + puts command.help + exit 1 + end + # Get node, check type + self.load_site + nodename = sanitize_path(arguments[0]) + event = self.site.items[nodename] + if !event + puts "Node #{nodename} not found" + exit 1 + end + if !event[:kind]=='event' + puts "Node #{nodename} is not an event" + exit 1 + end + # Collect data + merge_item_location_data(event[:location], self.site.items['/_data/locations/'].attributes) + self.site.compile + title = event[:title] + date = event[:startdate] + speakers = event[:speakers].map { |s| if s[:affiliation] then "#{s[:name]} (#{s[:affiliation]})" else s[:name] end } + text = Nokogiri::HTML(event.compiled_content) + text = text.content.gsub(/\n+/,"\n") + location_infos = [event[:location][:name]] + if (event[:location][:details]) + location_infos << event[:location][:details] + end + if (event[:location][:strasse]) + location_infos << event[:location][:strasse] + end + if (event[:location][:ort]) + if (event[:location][:plz]) + location_infos << "#{event[:location][:plz]} #{event[:location][:ort]}" + else + location_infos << event[:location][:ort] + end + end + if (event[:location][:lon]) + location_infos << "N #{event[:location][:lon]} E #{event[:location][:lat]}" + end + calendar_items = self.site.items.select do |i| + (i[:kind]=='event') && (i[:startdate].to_datetime>event[:startdate].to_datetime) && !i.identifier.start_with?('/_data/stammtisch/') + end.sort { |a,b| a[:startdate].to_datetime <=> b[:startdate].to_datetime } + calendar = calendar_items[0..5].map do |i| + if i[:startdate].instance_of?(Date) + "#{i[:startdate].strftime("%d.%m.%Y")} #{i[:title]}" + else + "#{i[:startdate].strftime("%d.%m.%Y, %H:%M")} #{i[:title]}" + end + end + # Read template + file = File.open(self.site.items['/_data/aushang/'].raw_filename(), "r:UTF-8") + template = file.read + file.close() + # Replace in template + template.gsub!('${title}', title) + template.gsub!('${date}', date.strftime("%d.%m.%Y, %H:%M")) + template.gsub!('${speakers}', speakers.join(', ')) + template.gsub!('${location}', location_infos.join(", ")) + template.gsub!('${calendar}', calendar.join(" \n")) + # Output + File.open("#{arguments[1]}/aushang.svg", 'w:UTF-8') {|f| f.write(template) } + end +end + +runner CreateFlyer + diff --git a/content/_data/aushang.svg b/content/_data/aushang.svg new file mode 100644 index 00000000..19f0ffad --- /dev/null +++ b/content/_data/aushang.svg @@ -0,0 +1,346 @@ + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + ChaosComputerClub Stuttgart e.V. und Stadtbibliothek am Mailänder Platz präsentieren: + + + + + VeranstalterChaosComputerClub Stuttgart e.V.www.cccs.deV.i.S.d.P.: Hanno Wagner, Neckarstraße 168B, 70190 Stuttgart + + + + ${date}${speakers}:${title} + Ort${location}Eintritt frei, um einen freiwilligen Unkostenbeitrag wird gebeten! + + Vortragsreihe des CCCS + TerminRegulär am zweiten Donnerstag im Monat.Ablauf19:30 Uhr Vortragsbeginn, bis max. 22 Uhr Diskussion im Anschluß an den Vortrag.KooperationWir danken der Stadtbücherei Stuttgart (http://www.stuttgart.de/stadtbuecherei/) fürdie Unterstützung! + + Weitere Termine${calendar} + + + QR-Code "Calendar Event" vonhttp://zxing.appspot.com/generator + + + diff --git a/lib/location.rb b/lib/location.rb index 23777b4b..a3299b93 100644 --- a/lib/location.rb +++ b/lib/location.rb @@ -1,6 +1,6 @@ -def merge_item_location_data(location) +def merge_item_location_data(location, templates) if (location && location[:location]) - templates = @items['/_data/locations/'].attributes + # templates = @items['/_data/locations/'].attributes if templates[location[:location].to_sym] location.merge!(templates[location[:location].to_sym]) end @@ -8,6 +8,6 @@ def merge_item_location_data(location) end def merge_location_data() - items.select { |i| i[:kind] == 'event' }.each { |e| merge_item_location_data(e[:location]) } + items.select { |i| i[:kind] == 'event' }.each { |e| merge_item_location_data(e[:location], @items['/_data/locations/'].attributes) } end