almanack 0.0.1.alpha2 → 0.0.1.alpha3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 67e9e2f5df00888819b42e0af733cf662fb60a4f
4
- data.tar.gz: cd05e1944b3dd5e0670de6d9e378c6964e90972a
3
+ metadata.gz: 0d73adf865b8f26fc09b7964c10617ff54d6b381
4
+ data.tar.gz: c9835f0434bf1821619eb22d86a0396c156860c3
5
5
  SHA512:
6
- metadata.gz: 45140da76420d78031824b8e7ac8c079e01dda68dad3bf67a977da43b93aeca2d9111eab2eb865bc324a3cd671ec74d9965b2f6d3349c866006c110970e61b8b
7
- data.tar.gz: e4497e0852a86bf0ea21b18926eb2f215698f5858c60d3330fad90c0e0107dba2c4cc1a0d0f623dc7bd6e6cf96ab886b337c45875ba5ed017ead0f755e8d4028
6
+ metadata.gz: 64d23b956709c3127395f09e774f7acc6ec4761222c085d6b86bc3cfd4e49c77bc578c7ee93abc007dc6dcba762f4eabff9b24d43ec5705b086cc620df858b31
7
+ data.tar.gz: 164eb43910f561b1fd46e154e460dff36e70cd392cd1311e08f3ad78ae63b5afe179f3f89beb1181cc064260a393dcefe2b64c48aae5e84efa2267a413a27cc8
data/.travis.yml CHANGED
@@ -1,7 +1,7 @@
1
1
  language: ruby
2
2
  cache: bundler
3
3
  rvm:
4
- - 2.1.1
4
+ - 2.1.2
5
5
  addons:
6
6
  code_climate:
7
7
  repo_token:
data/Rakefile CHANGED
@@ -4,18 +4,3 @@ require "rspec/core/rake_task"
4
4
  RSpec::Core::RakeTask.new(:spec)
5
5
 
6
6
  task :default => :spec
7
-
8
- desc 'Run a dummy server'
9
- task :server do
10
- require "almanack"
11
-
12
- today = DateTime.now
13
-
14
- Almanack.config.add_events [
15
- { title: "Hogswatch", start_date: today },
16
- { title: "Soul Cake Tuesday", start_date: today + 10 },
17
- { title: "Eve of Small Gods", start_date: today + 30 },
18
- ]
19
-
20
- Rack::Handler::WEBrick.run(Almanack::Server)
21
- end
data/almanac.gemspec CHANGED
@@ -18,6 +18,8 @@ Gem::Specification.new do |spec|
18
18
  spec.require_paths = ["lib"]
19
19
 
20
20
  spec.add_dependency "sinatra"
21
+ spec.add_dependency "sinatra-contrib"
22
+ spec.add_dependency "sass"
21
23
  spec.add_dependency "ri_cal"
22
24
  spec.add_dependency "addressable"
23
25
 
data/example.ru ADDED
@@ -0,0 +1,20 @@
1
+ require "bundler/setup"
2
+ require "rack/reloader"
3
+ require "almanack"
4
+
5
+ today = DateTime.now
6
+
7
+ Almanack.config.title = 'Discworld Holidays'
8
+
9
+ Almanack.config.add_events [
10
+ {
11
+ title: "Hogswatch",
12
+ start_date: today,
13
+ description: 'The sausages have been strung, the wreaths of oakleaves hung and the stockings dangled. The pork pie, the sherry and the all-important turnip await their festive guests. The poker lent against the fireplace may or may not have been bent over the head of some nightmare creature.',
14
+ location: 'Castle of Bones'
15
+ },
16
+ { title: "Soul Cake Tuesday", start_date: today + 10 },
17
+ { title: "Eve of Small Gods", start_date: today + 30 },
18
+ ]
19
+
20
+ run Almanack::Server
@@ -1,21 +1,25 @@
1
+ require 'forwardable'
2
+
1
3
  module Almanack
2
4
  class Calendar
5
+ extend Forwardable
6
+ def_delegators :@config, :event_sources, :title
7
+
3
8
  def initialize(config)
4
9
  @config = config
5
10
  end
6
11
 
7
- def event_sources
8
- @config.event_sources
9
- end
10
-
11
- def events
12
- days_lookahead = 30
12
+ def events
13
13
  from_date = DateTime.now
14
14
  to_date = DateTime.now + days_lookahead
15
-
15
+
16
16
  event_sources.map do |event_source|
17
17
  event_source.events_between(from_date..to_date)
18
18
  end.flatten.sort_by(&:start_date)
19
19
  end
20
+
21
+ def days_lookahead
22
+ 30
23
+ end
20
24
  end
21
- end
25
+ end
@@ -5,6 +5,7 @@ require 'ri_cal'
5
5
  module Almanack
6
6
  class Configuration
7
7
  attr_reader :event_sources
8
+ attr_accessor :title
8
9
 
9
10
  def initialize
10
11
  reset!
@@ -26,4 +27,4 @@ module Almanack
26
27
  @event_sources << MeetupGroup.new(options)
27
28
  end
28
29
  end
29
- end
30
+ end
@@ -2,12 +2,17 @@ require "sinatra"
2
2
 
3
3
  module Almanack
4
4
  class Server < Sinatra::Base
5
- set :theme, 'origami'
5
+ set :theme, 'legacy'
6
6
  set :root, Pathname(settings.root).join('themes', settings.theme)
7
+ set :protection, except: :frame_options
7
8
 
8
9
  get "/" do
9
10
  @calendar = Almanack.calendar
10
11
  erb :events
11
12
  end
13
+
14
+ get "/stylesheets/:name" do
15
+ sass :"stylesheets/#{params[:name]}"
16
+ end
12
17
  end
13
- end
18
+ end
@@ -0,0 +1,29 @@
1
+ <div class="events">
2
+ <% @calendar.events.each do |event| %>
3
+ <div class="event">
4
+ <div class="date">
5
+ <div class="month"><%= event.start_date.strftime('%a') %></div>
6
+ <div class="day"><%= event.start_date.strftime('%d') %></div>
7
+ </div>
8
+ <div class="details">
9
+ <h3 class="title"><%= event.title %></h3>
10
+
11
+ <% if event.description %>
12
+ <div class="description">
13
+ <%= event.description %>
14
+ </div>
15
+ <% end %>
16
+
17
+ <dl>
18
+ <% if event.location %>
19
+ <dt>Where</dt>
20
+ <dd><%= event.location %></dd>
21
+ <% end %>
22
+
23
+ <dt>When</dt>
24
+ <dd><%= event.start_date.strftime('%l:%M%P, %-d %b %Y') %></dd>
25
+ </dl>
26
+ </div>
27
+ </div>
28
+ <% end %>
29
+ </div>
@@ -0,0 +1,25 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>Upcoming events</title>
6
+ <link rel="stylesheet" type="text/css" href="/stylesheets/legacy.css">
7
+ </head>
8
+ <body>
9
+
10
+ <header>
11
+ <h1><%= @calendar.title %></h1>
12
+ <h2>The Next <%= @calendar.days_lookahead %> Days</h2>
13
+ </header>
14
+
15
+ <%= yield %>
16
+
17
+ <footer>
18
+ <div class="fork">
19
+ Powered by <a href="http://github.com/Aupajo/sinatra-gcal">Almanack</a>.
20
+ <a href="http://github.com/Aupajo/sinatra-gcal/issues">Bugs? Features?</a>
21
+ </div>
22
+ </footer>
23
+
24
+ </body>
25
+ </html>
@@ -0,0 +1,119 @@
1
+ =border-radius($size)
2
+ border-radius: $size
3
+ -webkit-border-radius: $size
4
+ -moz-border-radius: $size
5
+
6
+ =box-shadow($x, $y, $size, $colour)
7
+ -webkit-box-shadow: $x $y $size $colour
8
+ -moz-box-shadow: $x $y $size $colour
9
+
10
+ body
11
+ background-color: #e3e3e3
12
+ color: #595959
13
+ font: 12pt / 1.6em "Helvetica Neue", Helvetica, sans-serif
14
+ margin: 2em auto
15
+ width: 600px
16
+
17
+ a
18
+ text-decoration: none
19
+ &:link, &:visited
20
+ color: #2960AA
21
+
22
+ em
23
+ font-style: italic
24
+
25
+ strong
26
+ font-weight: bold
27
+
28
+ .event
29
+ background-color: #efefef
30
+ background: -webkit-gradient(linear, left top, left bottom, from(#f9f9f9), to(#efefef))
31
+ background: -moz-linear-gradient(top, #f9f9f9, #efefef)
32
+ border-top: 1px solid white
33
+ +border-radius(4px)
34
+ overflow: hidden
35
+ padding: 20px
36
+ margin-bottom: 1em
37
+ +box-shadow(0, 1px, 3px, rgba(0, 0, 0, 0.3))
38
+ &.today
39
+ background-color: #ebe4de
40
+ background: -webkit-gradient(linear, left top, left bottom, from(#f3ebe3), to(#e9d6c1))
41
+ .details
42
+ float: right
43
+ width: 480px
44
+ dl
45
+ color: #777777
46
+ font-size: 0.9em
47
+ dt
48
+ font-weight: bold
49
+ float: left
50
+ dd
51
+ float: right
52
+ margin: 0
53
+ width: 420px
54
+
55
+ header, footer
56
+ // display: block for browsers with poor HTML5 support
57
+ display: block
58
+
59
+ header
60
+ border-bottom: 1px solid #cccccc
61
+ overflow: hidden
62
+ padding-bottom: 0.5em
63
+ margin-bottom: 1em
64
+ +box-shadow(0, 1px, 0, #f6f6f6)
65
+
66
+ footer
67
+ border-top: 1px solid #cccccc
68
+ color: #999999
69
+ font-size: 0.9em
70
+ padding: 1em
71
+ .subscribe
72
+ float: left
73
+ a
74
+ margin-right: 1em
75
+ .add
76
+ float: right
77
+ .fork
78
+ clear: both
79
+ font-size: 0.8em
80
+
81
+ a:link, a:visited
82
+ color: #8aa0b6
83
+
84
+ h1, h2, h3, h4
85
+ margin: 0
86
+ text-shadow: 0 1px 0 white
87
+
88
+ h1
89
+ color: #666666
90
+ font-size: 1.8em
91
+ float: left
92
+
93
+ h2
94
+ color: #999999
95
+ font-size: 1em
96
+ float: right
97
+ text-transform: uppercase
98
+
99
+ h3
100
+ color: #333333
101
+
102
+ h4
103
+ display: inline
104
+ font-size: 1em
105
+ margin-right: 1em
106
+
107
+ .date
108
+ background-color: #cc0000
109
+ +border-radius(4px)
110
+ color: white
111
+ float: left
112
+ text-align: center
113
+ padding: 2px
114
+ width: 60px
115
+ .day
116
+ background-color: white
117
+ color: #333333
118
+ font-size: 1.6em
119
+ padding: 0.2em
@@ -1,3 +1,3 @@
1
1
  module Almanack
2
- VERSION = "0.0.1.alpha2"
2
+ VERSION = "0.0.1.alpha3"
3
3
  end
@@ -2,7 +2,16 @@ require 'spec_helper'
2
2
 
3
3
  module Almanack
4
4
  describe Calendar do
5
-
5
+
6
+ describe "#title" do
7
+ it "delegates to the config's title" do
8
+ config = Configuration.new
9
+ config.title = "Discworld Holidays"
10
+ calendar = Calendar.new(config)
11
+ expect(calendar.title).to eq("Discworld Holidays")
12
+ end
13
+ end
14
+
6
15
  describe "#events" do
7
16
  describe "with simple events" do
8
17
  it "returns the events" do
@@ -40,5 +49,9 @@ module Almanack
40
49
  end
41
50
  end
42
51
 
52
+ it "has a 30 day lookahead" do
53
+ expect(Calendar.new(double).days_lookahead).to eq(30)
54
+ end
55
+
43
56
  end
44
- end
57
+ end
@@ -3,6 +3,14 @@ require 'spec_helper'
3
3
  module Almanack
4
4
  describe Configuration do
5
5
 
6
+ describe "#title" do
7
+ it "can be set and accessed" do
8
+ config = Configuration.new
9
+ config.title = "Discworld Holidays"
10
+ expect(config.title).to eq("Discworld Holidays")
11
+ end
12
+ end
13
+
6
14
  describe "#add_events" do
7
15
  it "adds a simple event collection event source" do
8
16
  config = Configuration.new
@@ -23,7 +31,7 @@ module Almanack
23
31
  expect(config.event_sources.size).to eq(0)
24
32
 
25
33
  config.add_ical_feed "https://www.google.com/calendar/ical/61s2re9bfk01abmla4d17tojuo%40group.calendar.google.com/public/basic.ics"
26
-
34
+
27
35
  expect(config.event_sources.size).to eq(1)
28
36
  expect(config.event_sources.first).to be_an_instance_of(IcalFeed)
29
37
  end
@@ -35,11 +43,11 @@ module Almanack
35
43
  expect(config.event_sources.size).to eq(0)
36
44
 
37
45
  config.add_meetup_group(group_urlname: "CHC-JS", key: "secrettoken")
38
-
46
+
39
47
  expect(config.event_sources.size).to eq(1)
40
48
  expect(config.event_sources.first).to be_an_instance_of(MeetupGroup)
41
49
  end
42
50
  end
43
51
 
44
52
  end
45
- end
53
+ end
data/spec/event_spec.rb CHANGED
@@ -29,4 +29,4 @@ module Almanack
29
29
  end
30
30
 
31
31
  end
32
- end
32
+ end
@@ -4,10 +4,12 @@ describe "Viewing a calendar", :feature do
4
4
  before { Almanack.reset! }
5
5
 
6
6
  it "displays all upcoming events" do
7
+ today = DateTime.now
8
+
7
9
  Almanack.config.add_events [
8
- { title: "Hogswatch" },
9
- { title: "Soul Cake Tuesday" },
10
- { title: "Eve of Small Gods" },
10
+ { title: "Hogswatch", start_date: today },
11
+ { title: "Soul Cake Tuesday", start_date: today + 10 },
12
+ { title: "Eve of Small Gods", start_date: today + 30 },
11
13
  ]
12
14
 
13
15
  get "/"
@@ -19,7 +21,7 @@ describe "Viewing a calendar", :feature do
19
21
 
20
22
  it "displays events from an iCal feed" do
21
23
  Almanack.config.add_ical_feed "https://www.google.com/calendar/ical/61s2re9bfk01abmla4d17tojuo%40group.calendar.google.com/public/basic.ics"
22
-
24
+
23
25
  Timecop.freeze(2014, 4, 3) do
24
26
  VCR.use_cassette('google_calendar') do
25
27
  get "/"
@@ -32,4 +34,9 @@ describe "Viewing a calendar", :feature do
32
34
  expect(last_response).to have_event_on_page("Christchurch Python Meetup")
33
35
  expect(last_response).to have_event_on_page("Coffee & Jam")
34
36
  end
35
- end
37
+
38
+ it "allows being embedded in an iframe" do
39
+ get "/"
40
+ expect(last_response.headers).to_not have_key("X-Frame-Options")
41
+ end
42
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: almanack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1.alpha2
4
+ version: 0.0.1.alpha3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pete Nicholls
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-07 00:00:00.000000000 Z
11
+ date: 2014-07-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra
@@ -24,6 +24,34 @@ dependencies:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: sinatra-contrib
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: sass
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
27
55
  - !ruby/object:Gem::Dependency
28
56
  name: ri_cal
29
57
  requirement: !ruby/object:Gem::Requirement
@@ -192,6 +220,7 @@ files:
192
220
  - README.md
193
221
  - Rakefile
194
222
  - almanac.gemspec
223
+ - example.ru
195
224
  - lib/almanack.rb
196
225
  - lib/almanack/calendar.rb
197
226
  - lib/almanack/configuration.rb
@@ -200,9 +229,9 @@ files:
200
229
  - lib/almanack/meetup_group.rb
201
230
  - lib/almanack/server.rb
202
231
  - lib/almanack/simple_event_collection.rb
203
- - lib/almanack/themes/origami/public/stylesheets/origami.css
204
- - lib/almanack/themes/origami/views/events.erb
205
- - lib/almanack/themes/origami/views/layout.erb
232
+ - lib/almanack/themes/legacy/views/events.erb
233
+ - lib/almanack/themes/legacy/views/layout.erb
234
+ - lib/almanack/themes/legacy/views/stylesheets/legacy.css.sass
206
235
  - lib/almanack/version.rb
207
236
  - spec/calendar_spec.rb
208
237
  - spec/configuration_spec.rb
@@ -236,7 +265,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
236
265
  version: 1.3.1
237
266
  requirements: []
238
267
  rubyforge_project:
239
- rubygems_version: 2.2.2
268
+ rubygems_version: 2.3.0
240
269
  signing_key:
241
270
  specification_version: 4
242
271
  summary: Combined events calendar for Google Calendar, iCal, Meetup.com and friends.
@@ -1,4 +0,0 @@
1
- body {
2
- font: 14pt/1.6em "Helvetica Neue", sans-serif;
3
- font-weight: 300;
4
- }
@@ -1,8 +0,0 @@
1
- <div class="events">
2
- <% @calendar.events.each do |event| %>
3
- <div class="event">
4
- <h2 class="title"><%= event.title %></h2>
5
- (<%= event.start_date %>)
6
- </div>
7
- <% end %>
8
- </div>
@@ -1,13 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8">
5
- <title>Upcoming events</title>
6
- <link rel="stylesheet" type="text/css" href="/stylesheets/origami.css">
7
- </head>
8
- <body>
9
-
10
- <%= yield %>
11
-
12
- </body>
13
- </html>