middleman-calendar 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.rspec +2 -0
- data/.travis.yml +5 -0
- data/Gemfile +15 -0
- data/LICENSE.txt +21 -0
- data/README.md +102 -0
- data/Rakefile +5 -0
- data/fixtures/calendar-app/config.rb +10 -0
- data/fixtures/calendar-app/source/archive.html.erb +0 -0
- data/fixtures/calendar-app/source/blog/2016-05-29.html.markdown +4 -0
- data/fixtures/calendar-app/source/blog/2016-06-15.html.markdown +4 -0
- data/fixtures/calendar-app/source/blog/2016-06-16.html.markdown +4 -0
- data/fixtures/calendar-app/source/blog/2016-07-01.html.markdown +4 -0
- data/fixtures/calendar-app/source/layouts/basic.erb +1 -0
- data/lib/middleman/calendar/calendar.erb +106 -0
- data/lib/middleman/calendar/extension.rb +23 -0
- data/lib/middleman/calendar/version.rb +5 -0
- data/lib/middleman/calendar.rb +8 -0
- data/middleman-calendar.gemspec +30 -0
- metadata +156 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 7a520c2ee0c18991ea28773947663581048f0149
|
4
|
+
data.tar.gz: 149687f1af830ff67c256b31da46291dc48c5fc5
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 7bb600d81a6388053ecc9f37dc33ea43dadf37f264227417d7670997fe54b66af36910d858dabd0869e733df0997d10906c7b8bef7eece177cfcdd85de9fc564
|
7
|
+
data.tar.gz: 9c61d02b65f75179912458b0e164ec9a56aa1e3eb56f40d628c339d477722658f0a75169d1e61eca13a464a51304c019d705513b8a4b822c763b20d102e1e2d4
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.travis.yml
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
source 'https://rubygems.org'
|
2
|
+
|
3
|
+
# Specify your gem's dependencies in middleman-calendar.gemspec
|
4
|
+
gemspec
|
5
|
+
|
6
|
+
group :development do
|
7
|
+
gem 'rake', '~> 0.9.2'
|
8
|
+
gem 'rdoc', '~> 3.9'
|
9
|
+
gem 'yard', '~> 0.8.0'
|
10
|
+
end
|
11
|
+
|
12
|
+
group :test do
|
13
|
+
gem 'rspec', '~> 3.4'
|
14
|
+
gem 'capybara', '~> 2.5'
|
15
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2016 Daniel Siemer
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,102 @@
|
|
1
|
+
# Middleman::Calendar
|
2
|
+
|
3
|
+
When building the site for my [comic](http://bobscomic.com) in [middleman](https://middlemanapp.com), I wanted a graphical calendar for the archives, and in looking for solutions,
|
4
|
+
I found [week_of_month](https://github.com/sachin87/week-of-month) which let me build a GUI fairly easily
|
5
|
+
|
6
|
+
The calendar is stylable to your desire (and does require some styling to not just be an ugly list of lists), and an example is provided below
|
7
|
+
|
8
|
+
This is my time creating a gem, so admit that it's not probably entirely correctly done.
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Add this line to your application's Gemfile:
|
13
|
+
|
14
|
+
```ruby
|
15
|
+
gem 'middleman-calendar'
|
16
|
+
```
|
17
|
+
|
18
|
+
And then execute:
|
19
|
+
|
20
|
+
$ bundle
|
21
|
+
|
22
|
+
Or install it yourself as:
|
23
|
+
|
24
|
+
$ gem install middleman-calendar
|
25
|
+
|
26
|
+
|
27
|
+
## Usage
|
28
|
+
|
29
|
+
Activate it in your site's config.rb
|
30
|
+
```ruby
|
31
|
+
activate :calendar
|
32
|
+
```
|
33
|
+
|
34
|
+
To display a calendar:
|
35
|
+
```ruby
|
36
|
+
<%= calendar(article) %>
|
37
|
+
```
|
38
|
+
|
39
|
+
You can also optionally specify a blog
|
40
|
+
```ruby
|
41
|
+
<%= calendar(article, 'blog') %>
|
42
|
+
```
|
43
|
+
|
44
|
+
|
45
|
+
You will also need to have some CSS styling for it
|
46
|
+
|
47
|
+
```css
|
48
|
+
.middleman_calendar_div {
|
49
|
+
width:auto;
|
50
|
+
padding:10px;
|
51
|
+
|
52
|
+
.middleman_calendar_previous_link {
|
53
|
+
float:left;
|
54
|
+
}
|
55
|
+
.middleman_calendar_month_link {
|
56
|
+
float:center;
|
57
|
+
}
|
58
|
+
.middleman_calendar_next_link {
|
59
|
+
float:right;
|
60
|
+
}
|
61
|
+
|
62
|
+
ul {
|
63
|
+
list-style-type:none;
|
64
|
+
padding:0px;
|
65
|
+
margin:0px;
|
66
|
+
|
67
|
+
li {
|
68
|
+
margin-left:0px;
|
69
|
+
margin-top:5px;
|
70
|
+
margin-bottom:0px;
|
71
|
+
|
72
|
+
ul {
|
73
|
+
columns:7;
|
74
|
+
list-style-type:none;
|
75
|
+
padding:0px;
|
76
|
+
margin:0px;
|
77
|
+
margin-left:5px;
|
78
|
+
margin-right:5px;
|
79
|
+
|
80
|
+
li {
|
81
|
+
border-width:1px;
|
82
|
+
border-style:solid;
|
83
|
+
margin:0px;
|
84
|
+
padding-left:3px;
|
85
|
+
padding-right:3px;
|
86
|
+
margin-left:-5px;
|
87
|
+
margin-right:-5px;
|
88
|
+
}
|
89
|
+
}
|
90
|
+
}
|
91
|
+
}
|
92
|
+
}
|
93
|
+
```
|
94
|
+
|
95
|
+
## Contributing
|
96
|
+
|
97
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/jcfalkenberg/middleman-calendar.
|
98
|
+
|
99
|
+
## License
|
100
|
+
|
101
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
102
|
+
|
data/Rakefile
ADDED
File without changes
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= calendar(current_article) %>
|
@@ -0,0 +1,106 @@
|
|
1
|
+
<div class="middleman_calendar_div">
|
2
|
+
<% WeekOfMonth.configuration.monday_active = false %>
|
3
|
+
<% articlesForMonth = Hash.new %>
|
4
|
+
<% articlesForMonthArray = Array.new %>
|
5
|
+
|
6
|
+
<% previousTest = @calendar_article.previous_article %>
|
7
|
+
<% while previousTest %>
|
8
|
+
<% if previousTest.date.year == @calendar_article.date.year && previousTest.date.month == @calendar_article.date.month %>
|
9
|
+
<% articlesForMonth[previousTest.date.day] = previousTest %>
|
10
|
+
<% articlesForMonthArray += [previousTest] %>
|
11
|
+
<% previousTest = previousTest.previous_article %>
|
12
|
+
<% else %>
|
13
|
+
<% previousTest = nil %>
|
14
|
+
<% end %>
|
15
|
+
<% end %>
|
16
|
+
<% articlesForMonthArray = articlesForMonthArray.reverse() %>
|
17
|
+
<% articlesForMonthArray += [@calendar_article] %>
|
18
|
+
<% articlesForMonth[@calendar_article.date.day] = article %>
|
19
|
+
|
20
|
+
<% nextTest = @calendar_article.next_article %>
|
21
|
+
<% while nextTest %>
|
22
|
+
<% if nextTest.date.year == @calendar_article.date.year && nextTest.date.month == @calendar_article.date.month %>
|
23
|
+
<% articlesForMonth[nextTest.date.day] = nextTest %>
|
24
|
+
<% articlesForMonthArray += [nextTest] %>
|
25
|
+
<% nextTest = nextTest.next_article %>
|
26
|
+
<% else %>
|
27
|
+
<% nextTest = nil %>
|
28
|
+
<% end %>
|
29
|
+
<% end %>
|
30
|
+
|
31
|
+
<% first_article = articlesForMonthArray.first %>
|
32
|
+
|
33
|
+
<span class="middleman_calendar_previous_link">
|
34
|
+
<% if first_article %>
|
35
|
+
<% previous = first_article.previous_article %>
|
36
|
+
<% if previous %>
|
37
|
+
<%= link_to "<<", previous %>
|
38
|
+
<% else %>
|
39
|
+
<%= "<<" %>
|
40
|
+
<% end %>
|
41
|
+
<% else %>
|
42
|
+
<%= "<<" %>
|
43
|
+
<% end %>
|
44
|
+
</span>
|
45
|
+
|
46
|
+
<span class="middleman_calendar_month_link">
|
47
|
+
<%= link_to @calendar_article.date.strftime("%B %Y"), blog_month_path(@calendar_article.date.year, @calendar_article.date.month, @blog_name) %>
|
48
|
+
</span>
|
49
|
+
|
50
|
+
<span class="middleman_calendar_next_link">
|
51
|
+
<% last_calendar_article = articlesForMonthArray.last %>
|
52
|
+
<% if last_calendar_article %>
|
53
|
+
<% nextarticle = last_calendar_article.next_article %>
|
54
|
+
<% if nextarticle %>
|
55
|
+
<%= link_to ">>", nextarticle %>
|
56
|
+
<% else %>
|
57
|
+
<%= ">>" %>
|
58
|
+
<% end %>
|
59
|
+
<% else %>
|
60
|
+
<%= ">>" %>
|
61
|
+
<% end %>
|
62
|
+
</span>
|
63
|
+
|
64
|
+
<br>
|
65
|
+
<ul>
|
66
|
+
<% days = @calendar_article.date.week_split %>
|
67
|
+
<li>
|
68
|
+
<ul>
|
69
|
+
<li>S</li>
|
70
|
+
<li>M</li>
|
71
|
+
<li>T</li>
|
72
|
+
<li>W</li>
|
73
|
+
<li>T</li>
|
74
|
+
<li>F</li>
|
75
|
+
<li>S</li>
|
76
|
+
</ul>
|
77
|
+
</li>
|
78
|
+
<% days.each_with_index do |week, week_index| %>
|
79
|
+
<li>
|
80
|
+
<ul>
|
81
|
+
<% week.each do |day| %>
|
82
|
+
<li>
|
83
|
+
<% articleForDay = articlesForMonth[day] %>
|
84
|
+
<% if articleForDay %>
|
85
|
+
<%= link_to day, articleForDay %>
|
86
|
+
<% else %>
|
87
|
+
<% if day %>
|
88
|
+
<%= day %>
|
89
|
+
<% else %>
|
90
|
+
-
|
91
|
+
<% end %>
|
92
|
+
<% end %>
|
93
|
+
</li>
|
94
|
+
<% end %>
|
95
|
+
<% if week_index + 1 == @calendar_article.date.total_weeks %>
|
96
|
+
<% if week.count < 7 %>
|
97
|
+
<% for i in (week.count)..6 %>
|
98
|
+
<li>-</li>
|
99
|
+
<% end %>
|
100
|
+
<% end %>
|
101
|
+
<% end %>
|
102
|
+
</ul>
|
103
|
+
</li>
|
104
|
+
<% end %>
|
105
|
+
</ul>
|
106
|
+
</div>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'middleman-core'
|
2
|
+
require 'middleman-blog'
|
3
|
+
require 'week_of_month'
|
4
|
+
|
5
|
+
module Middleman
|
6
|
+
class CalendarExtension < Extension
|
7
|
+
def initialize(app, options_hash={}, &block)
|
8
|
+
super
|
9
|
+
# place in class variable so helpers can access
|
10
|
+
@@calendar_article = nil
|
11
|
+
end
|
12
|
+
|
13
|
+
helpers do
|
14
|
+
def calendar(article, blog_name='blog')
|
15
|
+
@calendar_article = article
|
16
|
+
@blog_name = blog_name
|
17
|
+
|
18
|
+
file = File.join(File.dirname(__FILE__), 'calendar.erb')
|
19
|
+
ERB.new(File.read(file), 0, '>').result(binding)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path('../lib', __FILE__)
|
3
|
+
require 'middleman/calendar/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "middleman-calendar"
|
7
|
+
spec.version = Middleman::Calendar::VERSION
|
8
|
+
spec.authors = ["Daniel Siemer"]
|
9
|
+
spec.email = ["jcfalkenberg@mac.com"]
|
10
|
+
|
11
|
+
spec.summary = %q{Generates a calendar GUI for your middleman blog}
|
12
|
+
spec.description = %q{Middleman-Calendar creates a list based, stylable calendar GUI for middleman blogs}
|
13
|
+
spec.homepage = "https://github.com/jcfalkenberg/middleman-calendar"
|
14
|
+
spec.license = "MIT"
|
15
|
+
|
16
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
17
|
+
spec.bindir = "exe"
|
18
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
19
|
+
spec.require_paths = ["lib"]
|
20
|
+
spec.test_files = `git ls-files -- {features,fixtures}/*`.split("\n")
|
21
|
+
|
22
|
+
|
23
|
+
spec.add_development_dependency "bundler", "~> 1.12"
|
24
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
25
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
26
|
+
|
27
|
+
spec.add_runtime_dependency('middleman', ['~> 4.1'])
|
28
|
+
spec.add_runtime_dependency('middleman-blog', ['~> 4.0'])
|
29
|
+
spec.add_runtime_dependency('week_of_month', ['~> 1.2'])
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,156 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: middleman-calendar
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Daniel Siemer
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-06-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: bundler
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.12'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.12'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '10.0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rspec
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '3.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '3.0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: middleman
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '4.1'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '4.1'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: middleman-blog
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '4.0'
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '4.0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: week_of_month
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '1.2'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '1.2'
|
97
|
+
description: Middleman-Calendar creates a list based, stylable calendar GUI for middleman
|
98
|
+
blogs
|
99
|
+
email:
|
100
|
+
- jcfalkenberg@mac.com
|
101
|
+
executables: []
|
102
|
+
extensions: []
|
103
|
+
extra_rdoc_files: []
|
104
|
+
files:
|
105
|
+
- ".gitignore"
|
106
|
+
- ".rspec"
|
107
|
+
- ".travis.yml"
|
108
|
+
- Gemfile
|
109
|
+
- LICENSE.txt
|
110
|
+
- README.md
|
111
|
+
- Rakefile
|
112
|
+
- fixtures/calendar-app/config.rb
|
113
|
+
- fixtures/calendar-app/source/archive.html.erb
|
114
|
+
- fixtures/calendar-app/source/blog/2016-05-29.html.markdown
|
115
|
+
- fixtures/calendar-app/source/blog/2016-06-15.html.markdown
|
116
|
+
- fixtures/calendar-app/source/blog/2016-06-16.html.markdown
|
117
|
+
- fixtures/calendar-app/source/blog/2016-07-01.html.markdown
|
118
|
+
- fixtures/calendar-app/source/layouts/basic.erb
|
119
|
+
- lib/middleman/calendar.rb
|
120
|
+
- lib/middleman/calendar/calendar.erb
|
121
|
+
- lib/middleman/calendar/extension.rb
|
122
|
+
- lib/middleman/calendar/version.rb
|
123
|
+
- middleman-calendar.gemspec
|
124
|
+
homepage: https://github.com/jcfalkenberg/middleman-calendar
|
125
|
+
licenses:
|
126
|
+
- MIT
|
127
|
+
metadata: {}
|
128
|
+
post_install_message:
|
129
|
+
rdoc_options: []
|
130
|
+
require_paths:
|
131
|
+
- lib
|
132
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
133
|
+
requirements:
|
134
|
+
- - ">="
|
135
|
+
- !ruby/object:Gem::Version
|
136
|
+
version: '0'
|
137
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
138
|
+
requirements:
|
139
|
+
- - ">="
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '0'
|
142
|
+
requirements: []
|
143
|
+
rubyforge_project:
|
144
|
+
rubygems_version: 2.5.1
|
145
|
+
signing_key:
|
146
|
+
specification_version: 4
|
147
|
+
summary: Generates a calendar GUI for your middleman blog
|
148
|
+
test_files:
|
149
|
+
- fixtures/calendar-app/config.rb
|
150
|
+
- fixtures/calendar-app/source/archive.html.erb
|
151
|
+
- fixtures/calendar-app/source/blog/2016-05-29.html.markdown
|
152
|
+
- fixtures/calendar-app/source/blog/2016-06-15.html.markdown
|
153
|
+
- fixtures/calendar-app/source/blog/2016-06-16.html.markdown
|
154
|
+
- fixtures/calendar-app/source/blog/2016-07-01.html.markdown
|
155
|
+
- fixtures/calendar-app/source/layouts/basic.erb
|
156
|
+
has_rdoc:
|