jekyll-attendease 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/README.md +5 -0
  2. data/lib/jekyll-attendease.rb +98 -7
  3. metadata +1 -1
data/README.md CHANGED
@@ -34,10 +34,15 @@ You will need to configure by editing your `_config.yml`:
34
34
  #
35
35
  attendease:
36
36
  api_host: https://your-event-subdomain.attendease.com/
37
+ test_mode: true
37
38
  ```
38
39
 
39
40
  Remember to replace `https://your-event-subdomain.attendease.com/` with your actual event url, or crazy things will happen!
40
41
 
42
+ Setting `test_mode` will create pages for /register, /schedule and
43
+ /presenters. You may style these pages, but they are non-functional.
44
+ When the site is deployed to Attendease these will function.
45
+
41
46
  ## Usage
42
47
 
43
48
  Now the event name can easily be used in your site like so:
@@ -5,6 +5,8 @@ module Jekyll
5
5
  module Attendease
6
6
 
7
7
  class EventData < Generator
8
+ safe true
9
+
8
10
  def generate(site)
9
11
  if attendease_config = site.config['attendease']
10
12
 
@@ -36,12 +38,28 @@ module Jekyll
36
38
  event_data = HTTParty.get("#{attendease_config['api_host']}api/site.json")
37
39
 
38
40
  if !event_data['error']
39
- puts "Saving attendease event data..."
41
+ puts " [Attendease] Saving event data..."
40
42
 
41
43
  File.open("#{attendease_data_path}/site.json", 'w+') { |file| file.write(event_data.parsed_response.to_json) }
42
44
  else
43
45
  raise "Event data not found, is your Attendease api_host site properly in _config.yml?"
44
46
  end
47
+
48
+
49
+ # Registration test pages, so we can style the forms!
50
+ pages_to_fetch = ['choose_pass', 'checkout', 'dashboard']
51
+
52
+ pages_to_fetch.each do |page|
53
+ page_data = HTTParty.get("#{attendease_config['api_host']}attendease/preview/#{page}.html")
54
+
55
+ if page_data.response.code.to_i == 200
56
+ puts " [Attendease] Saving test data for register page (#{page})..."
57
+
58
+ File.open("#{attendease_data_path}/attendease_test_register_#{page}.html", 'w+') { |file| file.write(page_data.parsed_response) }
59
+ else
60
+ raise "Event data not found, is your Attendease api_host site properly in _config.yml?"
61
+ end
62
+ end
45
63
  end
46
64
 
47
65
  # Adding to site config so we can access these variables globally wihtout using a Liquid Tag so we can use if/else
@@ -53,15 +71,17 @@ module Jekyll
53
71
  end
54
72
 
55
73
  else
56
- raise "Please set the Attendease config in your _config.yml"
74
+ raise "Please set the Attendease event data in your _config.yml"
57
75
  end
58
76
  end
59
77
  end
60
78
 
61
79
 
62
80
  class EventThemes < Generator
81
+ safe true
82
+
63
83
  def generate(site)
64
- puts "Generating theme layout..."
84
+ puts " [Attendease] Generating theme layouts..."
65
85
 
66
86
  attendease_precompiled_theme_layouts_path = "#{site.config['source']}/attendease_layouts"
67
87
 
@@ -83,18 +103,89 @@ module Jekyll
83
103
  layout: layout
84
104
  ---
85
105
 
86
- {% raw %}
87
- {{ content }}
88
- {% endraw %}
106
+ {% attendease_content %}
89
107
  eos
90
108
 
91
109
  File.open("#{site.config['source']}/attendease_layouts/#{layout}.html", 'w+') { |file| file.write(theme_layout_content) }
110
+
92
111
  end
93
112
  end
94
113
  end
114
+ end
115
+ end
116
+
117
+
118
+ class TestPages < Generator
119
+ safe true
120
+
121
+ def generate(site)
122
+ if attendease_config = site.config['attendease']
123
+
124
+ if attendease_config['test_mode']
125
+ puts " [Attendease] Generating pages to test the layouts..."
126
+
127
+ puts " [Attendease] Generating /register/index.html"
128
+ site.pages << RegisterTestPage.new(site, site.source, File.join('register'), {:name => 'index.html', :liquid_tag => 'attendease_test_register_choose_pass'})
129
+
130
+ puts " [Attendease] Generating /register/checkout.html"
131
+ site.pages << RegisterTestPage.new(site, site.source, File.join('register'), {:name => 'checkout.html', :liquid_tag => 'attendease_test_register_checkout'})
132
+
133
+ puts " [Attendease] Generating /register/dashboard.html"
134
+ site.pages << RegisterTestPage.new(site, site.source, File.join('register'), {:name => 'dashboard.html', :liquid_tag => 'attendease_test_register_dashboard'})
135
+ end
136
+
137
+ end
138
+ end
139
+ end
140
+
141
+ class RegisterTestPage < Page
142
+ def initialize(site, base, dir, page_data)
143
+ @site = site
144
+ @base = base
145
+ @dir = dir
146
+ @name = page_data[:name]
147
+
148
+ self.process(@name)
149
+
150
+ if File.exists?(File.join(base, 'attendease_layouts', 'register.html'))
151
+ self.read_yaml(File.join(base, 'attendease_layouts'), 'register.html')
152
+ else
153
+ self.read_yaml(File.join(base, 'attendease_layouts'), 'layout.html')
154
+ end
155
+
156
+ self.content.gsub! /\{\% attendease_content \%\}/, "{% #{page_data[:liquid_tag]} %}"
157
+ end
158
+ end
159
+
160
+
161
+ class AttendeaseTest < Liquid::Tag
162
+ def initialize(tag_name, text, tokens)
163
+ super
164
+ @tag_name = tag_name
165
+ end
166
+
167
+ def render(context)
168
+ attendease_data_path = "#{context['site']['source']}/_attendease_data"
169
+
170
+ if File.exists?("#{attendease_data_path}/#{@tag_name}.html")
171
+ File.read("#{attendease_data_path}/#{@tag_name}.html")
172
+ else
173
+ raise "Please set the Attendease event data in your _config.yml or read documentation about how to use this tag."
174
+ end
175
+ end
176
+ end
95
177
 
178
+
179
+ class AttendeaseContent < Liquid::Tag
180
+ def render(context)
181
+ "{{ content }}"
96
182
  end
97
183
  end
98
184
 
99
185
  end
100
- end
186
+ end
187
+
188
+ Liquid::Template.register_tag('attendease_content', Jekyll::Attendease::AttendeaseContent)
189
+ Liquid::Template.register_tag('attendease_test_register_choose_pass', Jekyll::Attendease::AttendeaseTest)
190
+ Liquid::Template.register_tag('attendease_test_register_checkout', Jekyll::Attendease::AttendeaseTest)
191
+ Liquid::Template.register_tag('attendease_test_register_dashboard', Jekyll::Attendease::AttendeaseTest)
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: jekyll-attendease
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.0
5
+ version: 0.2.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Michael Wood