Class: CS50::CalendarTag

Inherits:
Tag
  • Object
show all
Defined in:
lib/jekyll-theme-cs50.rb

Instance Method Summary collapse

Constructor Details

#initialize(tag_name, markup, options) ⇒ CalendarTag



199
200
201
202
# File 'lib/jekyll-theme-cs50.rb', line 199

def initialize(tag_name, markup, options)
  super

end

Instance Method Details

#render(context) ⇒ Object



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
# File 'lib/jekyll-theme-cs50.rb', line 204

def render(context)
  super

  # Deprecated @ctz
  if @kwargs.key?("ctz")
    Jekyll.logger.warn "CS50 warning: no need for @ctz anymore"
  end

  # Calendar's height
  height = @kwargs["height"] || "480"

  # Default components
  components = {
    height: height,
    hl: "en_US",
    mode: @kwargs["mode"] || "AGENDA",
    showCalendars: "0",
    showDate: "0",
    showNav: "0",
    showPrint: "0",
    showTabs: "0",
    showTitle: "0",
    showTz: "1",
    src: @args[0]
  }

  # Build URL
  src = URI::HTTPS.build(:host => "calendar.google.com", :path => "/calendar/embed", :query => URI.encode_www_form(components))

  # Render HTML
  "<iframe data-calendar='#{src}' #{@kwargs['ctz'] ? 'data-ctz' : ''} style='height: #{height}px;'></iframe>"
end