-
Notifications
You must be signed in to change notification settings - Fork 1
/
jmc_calendar.rb
55 lines (45 loc) · 1.14 KB
/
jmc_calendar.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# frozen_string_literal: true
require 'rubygems'
require 'sinatra'
require 'haml'
require 'sass'
require 'coffee-script'
require 'linguistics'
set :haml, format: :html5
Linguistics.use(:en)
# ----------------------------------
# Index - This uses the current date
# ----------------------------------
get '/' do
# TODO: use of GMT over server timezone; Localised timezone support
params[:tz] ||= 0
# /TODO
@today = Date.today
@year = @today.year
@start = @today
# Manage start and end of calendar
# Start
@start = if @today.month == 1
Date.new(@today.year - 1, 12, 1)
else
Date.new(@today.year, @today.month - 1, 1)
end
@end = @start >> 12
haml :index
end
# ----------------------------------
# Year - calendar for a particular year
# ----------------------------------
get %r{\/(\d+)} do
# TODO: use of GMT over server timezone; Localised timezone support
params[:tz] ||= 0
# /TODO
@year = params[:captures][0].to_i
haml :annual
end
# ----------------------------------
# SCSS Custom Styling
# ----------------------------------
get '/css/styles.css' do
sass :styles
end