class Jekyll::AttendeasePlugin::EventTemplateGenerator
Public Instance Methods
generate(site)
click to toggle source
# File lib/jekyll/attendease_plugin/event_template_generator.rb, line 24 def generate(site) return false if site.config.cms_theme? Jekyll.logger.info "[Attendease] Generating theme templates..." # Generate the template files if they don't yet exist. %w{ schedule presenters venues sponsors pages }.each do |p| path = File.join(site.source, '_attendease', 'templates', p) FileUtils.mkdir_p(path) raise "Could not create #{path}." unless File.exists?(path) end template_path = File.expand_path(File.join(File.dirname(__FILE__), '..', '..', '..', 'templates', 'attendease')) # Precompiled layouts for attendease app and jekyll generated pages. base_layout = site.config['attendease']['base_layout'] || 'layout' front_matter = <<EOF --- layout: #{base_layout} --- EOF %w{ index schedule/index schedule/day schedule/sessions schedule/session presenters/index presenters/presenter venues/index venues/venue sponsors/index pages/default }.each do |page| destination_file = File.join(site.source, '_attendease', 'templates', "#{page}.html") unless File.exists?(destination_file) template_data = front_matter + File.read(File.join(template_path, "#{page}.html")) File.open(destination_file, 'w+') { |f| f.write(template_data) } end end # Schedule widget page = 'schedule/widget' destination_file = File.join(site.source, '_attendease', 'templates', "#{page}.html") unless File.exists?(destination_file) template_data = File.read(File.join(template_path, "#{page}.html")) File.open(destination_file, 'w+') { |f| f.write(template_data) } end end