Class: Jekyll::AttendeasePlugin::BlockRendererTag
- Inherits:
-
Liquid::Tag
- Object
- Liquid::Tag
- Jekyll::AttendeasePlugin::BlockRendererTag
- Defined in:
- lib/jekyll/attendease_plugin/tags.rb
Instance Method Summary collapse
-
#initialize(tag_name, url_override, tokens) ⇒ BlockRendererTag
constructor
A new instance of BlockRendererTag.
- #render(context) ⇒ Object
Constructor Details
#initialize(tag_name, url_override, tokens) ⇒ BlockRendererTag
Returns a new instance of BlockRendererTag.
146 147 148 149 |
# File 'lib/jekyll/attendease_plugin/tags.rb', line 146 def initialize(tag_name, url_override, tokens) super @url_override = url_override end |
Instance Method Details
#render(context) ⇒ Object
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 |
# File 'lib/jekyll/attendease_plugin/tags.rb', line 151 def render(context) config = context.registers[:site].config['attendease'] site_settings = context.registers[:site].data['site_settings'].clone analytics = site_settings.delete 'analytics' site_settings.delete_if {|key, value| ['analytics', 'meta', 'general'].include? key } organization_site_settings = {} if context.registers[:site].data['organization_site_settings'] organization_site_settings = context.registers[:site].data['organization_site_settings'].clone organization_site_settings.delete_if {|key, value| ['analytics', 'meta', 'general'].include? key } end parent_pages_are_clickable = config['parent_pages_are_clickable'] pages = Helpers.public_pages(context.registers[:site].data['pages']) portal_pages = Helpers.public_pages(context.registers[:site].data['portal_pages']) || [] env = config['environment'] # IMPORTANT NOTE: The script variables below must NOT be changed without making sure that blockrenderer.js and other # related code in the platform is backwards-compatible. if config['mode'] == 'organization' constants = { 'locale' => 'en', 'siteName' => config['organization_name'], 'orgURL' => config['api_host'], 'orgId' => config['source_id'], 'privateSite' => config['private_site'], 'authApiEndpoint' => "#{config['auth_host']}api", 'orgLocales' => config['available_portal_locales'], 'features' => config['features'], 'pages' => pages, 'settings' => { parentPagesAreClickable: !!parent_pages_are_clickable }, 'siteSettings' => site_settings, 'analytics' => analytics, 'basePath' => config['base_path'] } else constants = { 'locale' => config['locale'], 'siteName' => config['data']['event_name'], 'eventApiEndpoint' => "#{config['api_host']}api", 'eventId' => config['source_id'], 'orgURL' => config['organization_url'], 'orgId' => config['organization_id'], 'privateSite' => config['private_site'], 'authApiEndpoint' => "#{config['auth_host']}api", 'features' => config['features'], 'pages' => pages, 'portalPages' => portal_pages, 'settings' => { parentPagesAreClickable: !!parent_pages_are_clickable }, 'siteSettings' => site_settings, 'organizationSiteSettings' => organization_site_settings, 'analytics' => analytics, 'basePath' => config['base_path'] } end script = <<_EOT <script type="text/javascript"> (function(w) { w.AttendeaseConstants = { #{ constants.map{ |k, v| " #{k}: #{v.to_json}," }.join("\n") } } })(window) </script> _EOT if @url_override.match(/^(https:)?\/\/.+/) url = @url_override else case env when 'development' url = '//dashboard.localhost.attendease.com/webpack_assets/blockrenderer.bundle.js' when 'prerelease' url = '//cdn.attendease.com/blockrenderer/prerelease-latest.js' when 'staging' url = '//cdn.attendease.com/blockrenderer/staging-latest.js' when 'preview' url = '//cdn.attendease.com/blockrenderer/ci-latest.js' else url = '//cdn.attendease.com/blockrenderer/latest.js' end end script << <<_EOT <script type="text/javascript" src="#{ url }"></script> _EOT script end |