polyrex-calendar 0.5.11 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data.tar.gz.sig +0 -0
- data/lib/polyrex-calendar.rb +4 -12
- data/{lib → stylesheet}/calendar.xsl +0 -0
- data/{lib → stylesheet}/calendar.xsl~ +0 -0
- data/{lib → stylesheet}/kplanner.xsl +0 -0
- data/{lib → stylesheet}/kplanner_month.xsl +0 -0
- data/{lib → stylesheet}/layout.css +0 -0
- data/{lib → stylesheet}/lmonth.xsl +0 -0
- data/{lib → stylesheet}/month.css +0 -0
- data/{lib → stylesheet}/month_calendar.xsl +0 -0
- data/{lib → stylesheet}/month_layout.css +0 -0
- data/{lib → stylesheet}/monthday.css +0 -0
- data/{lib → stylesheet}/monthday_layout.css +0 -0
- data/{lib → stylesheet}/week.css +0 -0
- data/{lib → stylesheet}/week_calendar.xsl +0 -0
- data/{lib → stylesheet}/week_layout.css +0 -0
- data/{lib → stylesheet}/year.css +0 -0
- metadata +21 -22
- metadata.gz.sig +3 -1
- data/lib/polyrex-calendar.rb~ +0 -267
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 001b1128414967f46cf51eed61bcefb01ff02b60
|
4
|
+
data.tar.gz: c117f734aa278878b124162010655d28cc83a334
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d732bef469d6d4d5d59e648054a055a660d2534361cb0268a47e0582717d76a701d723acfe5e882a818edbe6c12a880a4a36dd7f749b81015319d49bb80cbc4a
|
7
|
+
data.tar.gz: 6e8b68ba13cb8963da914391472cb63f27d21fe0ba38f275c10c1b55d839d208f692686719469181fddace0c8a879577a8e44b1fd2f24b5b26ca30ea889ad293
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
Binary file
|
data/lib/polyrex-calendar.rb
CHANGED
@@ -4,20 +4,11 @@
|
|
4
4
|
|
5
5
|
require 'polyrex_calendarbase'
|
6
6
|
|
7
|
-
module LIBRARY
|
8
|
-
|
9
|
-
def fetch_file(filename)
|
10
|
-
|
11
|
-
lib = File.dirname(__FILE__)
|
12
|
-
File.read File.join(lib,filename)
|
13
|
-
|
14
|
-
end
|
15
|
-
end
|
16
7
|
|
17
8
|
class PolyrexObjects
|
18
9
|
|
19
10
|
class Month
|
20
|
-
|
11
|
+
|
21
12
|
def wk(n)
|
22
13
|
self.records[n-1]
|
23
14
|
end
|
@@ -28,14 +19,14 @@ class PolyrexObjects
|
|
28
19
|
month_layout_css = fetch_file self.css_layout
|
29
20
|
month_css = fetch_file self.css_style
|
30
21
|
|
31
|
-
File.write '
|
22
|
+
File.write 'lmonth.xsl', month_xsl
|
32
23
|
doc = self.to_doc
|
33
24
|
|
34
25
|
xslt_filename = File.basename self.xslt
|
35
26
|
|
36
27
|
doc.instructions << [
|
37
28
|
'xml-stylesheet',
|
38
|
-
"title='XSL_formatting' type='text/xsl' href='
|
29
|
+
"title='XSL_formatting' type='text/xsl' href='lmonth.xsl'"]
|
39
30
|
|
40
31
|
# add a css selector for the current day
|
41
32
|
date = Time.now.strftime("%Y-%b-%d")
|
@@ -69,6 +60,7 @@ class PolyrexObjects
|
|
69
60
|
|
70
61
|
e = self.element("records/day/summary[sdate='#{date}']")
|
71
62
|
e.attributes[:class] = 'selected' if e
|
63
|
+
highlight_today(self)
|
72
64
|
|
73
65
|
|
74
66
|
html = generate_webpage self.to_xml, week_xsl
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/{lib → stylesheet}/week.css
RENAMED
File without changes
|
File without changes
|
File without changes
|
data/{lib → stylesheet}/year.css
RENAMED
File without changes
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: polyrex-calendar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -31,7 +31,7 @@ cert_chain:
|
|
31
31
|
lVRGh/hDZrM+tqTvjxqLAaxm3xsnPfVpEz8i35gI1fQPEYeOYkUFgZQ5gBv1nGDE
|
32
32
|
uikNAnes+rZNGg==
|
33
33
|
-----END CERTIFICATE-----
|
34
|
-
date: 2015-05-
|
34
|
+
date: 2015-05-25 00:00:00.000000000 Z
|
35
35
|
dependencies:
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: polyrex_calendarbase
|
@@ -39,43 +39,42 @@ dependencies:
|
|
39
39
|
requirements:
|
40
40
|
- - "~>"
|
41
41
|
- !ruby/object:Gem::Version
|
42
|
-
version: '0.
|
42
|
+
version: '0.2'
|
43
43
|
- - ">="
|
44
44
|
- !ruby/object:Gem::Version
|
45
|
-
version: 0.
|
45
|
+
version: 0.2.0
|
46
46
|
type: :runtime
|
47
47
|
prerelease: false
|
48
48
|
version_requirements: !ruby/object:Gem::Requirement
|
49
49
|
requirements:
|
50
50
|
- - "~>"
|
51
51
|
- !ruby/object:Gem::Version
|
52
|
-
version: '0.
|
52
|
+
version: '0.2'
|
53
53
|
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
|
-
version: 0.
|
55
|
+
version: 0.2.0
|
56
56
|
description:
|
57
57
|
email: james@r0bertson.co.uk
|
58
58
|
executables: []
|
59
59
|
extensions: []
|
60
60
|
extra_rdoc_files: []
|
61
61
|
files:
|
62
|
-
- lib/calendar.xsl
|
63
|
-
- lib/calendar.xsl~
|
64
|
-
- lib/kplanner.xsl
|
65
|
-
- lib/kplanner_month.xsl
|
66
|
-
- lib/layout.css
|
67
|
-
- lib/lmonth.xsl
|
68
|
-
- lib/month.css
|
69
|
-
- lib/month_calendar.xsl
|
70
|
-
- lib/month_layout.css
|
71
|
-
- lib/monthday.css
|
72
|
-
- lib/monthday_layout.css
|
73
62
|
- lib/polyrex-calendar.rb
|
74
|
-
-
|
75
|
-
-
|
76
|
-
-
|
77
|
-
-
|
78
|
-
-
|
63
|
+
- stylesheet/calendar.xsl
|
64
|
+
- stylesheet/calendar.xsl~
|
65
|
+
- stylesheet/kplanner.xsl
|
66
|
+
- stylesheet/kplanner_month.xsl
|
67
|
+
- stylesheet/layout.css
|
68
|
+
- stylesheet/lmonth.xsl
|
69
|
+
- stylesheet/month.css
|
70
|
+
- stylesheet/month_calendar.xsl
|
71
|
+
- stylesheet/month_layout.css
|
72
|
+
- stylesheet/monthday.css
|
73
|
+
- stylesheet/monthday_layout.css
|
74
|
+
- stylesheet/week.css
|
75
|
+
- stylesheet/week_calendar.xsl
|
76
|
+
- stylesheet/week_layout.css
|
77
|
+
- stylesheet/year.css
|
79
78
|
homepage: https://github.com/jrobertson/polyrex-calendar
|
80
79
|
licenses:
|
81
80
|
- MIT
|
metadata.gz.sig
CHANGED
data/lib/polyrex-calendar.rb~
DELETED
@@ -1,267 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
# file: polyrex-calendar.rb
|
4
|
-
|
5
|
-
require 'polyrex_calendarbase'
|
6
|
-
|
7
|
-
module LIBRARY
|
8
|
-
|
9
|
-
def fetch_file(filename)
|
10
|
-
|
11
|
-
lib = File.dirname(__FILE__)
|
12
|
-
File.read File.join(lib,filename)
|
13
|
-
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
class PolyrexObjects
|
18
|
-
|
19
|
-
class Month
|
20
|
-
|
21
|
-
def wk(n)
|
22
|
-
self.records[n-1]
|
23
|
-
end
|
24
|
-
|
25
|
-
def to_webpage()
|
26
|
-
|
27
|
-
month_xsl = fetch_file self.xslt
|
28
|
-
month_layout_css = fetch_file self.css_layout
|
29
|
-
month_css = fetch_file self.css_style
|
30
|
-
|
31
|
-
# add a css selector for the current day
|
32
|
-
date = Time.now.strftime("%Y-%b-%d")
|
33
|
-
e = self.element("records/week/records/day/summary[sdate='#{date}']")
|
34
|
-
e.attributes[:class] = 'selected' if e
|
35
|
-
|
36
|
-
File.write 'self.xml', self.to_xml(pretty: true)
|
37
|
-
File.write 'month.xsl', month_xsl
|
38
|
-
|
39
|
-
html = generate_webpage self.to_xml, month_xsl
|
40
|
-
{self.title.downcase[0..2] + '_calendar.html' => html,
|
41
|
-
self.css_layout => month_layout_css, self.css_style => month_css}
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
class Week
|
46
|
-
|
47
|
-
def to_webpage()
|
48
|
-
|
49
|
-
week_xsl = fetch_file 'week_calendar.xsl'
|
50
|
-
week_layout_css = fetch_file 'week_layout.css'
|
51
|
-
week_css = fetch_file 'week.css'
|
52
|
-
|
53
|
-
File.write 'self.xml', self.to_xml(pretty: true)
|
54
|
-
File.write 'week.xsl', week_xsl
|
55
|
-
#html = Rexslt.new(week_xsl, self.to_xml).to_xml
|
56
|
-
#html = xsltproc 'week_calendar.xsl', self.to_xml
|
57
|
-
|
58
|
-
# add a css selector for the current day
|
59
|
-
date = Time.now.strftime("%Y-%b-%d")
|
60
|
-
|
61
|
-
e = self.element("records/day/summary[sdate='#{date}']")
|
62
|
-
e.attributes[:class] = 'selected' if e
|
63
|
-
|
64
|
-
|
65
|
-
html = generate_webpage self.to_xml, week_xsl
|
66
|
-
{'week' + self.no + '_planner.html' => html, 'week_layout.css' => week_layout_css, \
|
67
|
-
'week.css' => week_css}
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
|
72
|
-
end
|
73
|
-
|
74
|
-
class PolyrexCalendar < PolyrexCalendarBase
|
75
|
-
|
76
|
-
def initialize(calendar_file=nil, options={})
|
77
|
-
|
78
|
-
super(calendar_file, options)
|
79
|
-
|
80
|
-
@xsl = fetch_file 'calendar.xsl'
|
81
|
-
@css = fetch_file 'layout.css'
|
82
|
-
|
83
|
-
end
|
84
|
-
|
85
|
-
def inspect()
|
86
|
-
%Q(=> #<PolyrexCalendar:#{self.object_id} @id="#{@id}", @year="#{@year}">)
|
87
|
-
end
|
88
|
-
|
89
|
-
def kitchen_planner()
|
90
|
-
|
91
|
-
px = @calendar
|
92
|
-
|
93
|
-
# add a css selector for the current day
|
94
|
-
date = DateTime.now.strftime("%Y-%b-%d")
|
95
|
-
e = px.element("records/month/records/day/summary[sdate='#{date}']")
|
96
|
-
e.attributes[:class] = 'selected' if e
|
97
|
-
|
98
|
-
px.xslt = 'kplanner.xsl'
|
99
|
-
px.css_layout = 'monthday_layout.css'
|
100
|
-
px.css_style = 'monthday.css'
|
101
|
-
px.filename = @year + '-kitchen-planner.html'
|
102
|
-
|
103
|
-
px
|
104
|
-
|
105
|
-
end
|
106
|
-
|
107
|
-
def year_planner()
|
108
|
-
|
109
|
-
px = Polyrex.new(@visual_schema, id_counter: @id)
|
110
|
-
px.summary.year = @year
|
111
|
-
|
112
|
-
(1..12).each {|n| px.add self.month(n, monday_week: true) }
|
113
|
-
|
114
|
-
# add a css selector for the current day
|
115
|
-
date = DateTime.now.strftime("%Y-%b-%d")
|
116
|
-
e = px.element("records/month/records/week/records/day/" \
|
117
|
-
+ "summary[sdate='#{date}']")
|
118
|
-
e.attributes[:class] = 'selected' if e
|
119
|
-
|
120
|
-
px.css_layout = 'layout.css'
|
121
|
-
px.css_style = 'year.css'
|
122
|
-
px.filename = px.summary.year.to_s + '-planner.html'
|
123
|
-
|
124
|
-
px
|
125
|
-
|
126
|
-
end
|
127
|
-
|
128
|
-
def month(m, monday_week: false)
|
129
|
-
|
130
|
-
if monday_week == true
|
131
|
-
|
132
|
-
pxmonth = make_month(m) do |a, wday|
|
133
|
-
|
134
|
-
# Monday start
|
135
|
-
# wdays: 1 = Monday, 0 = Sunday
|
136
|
-
|
137
|
-
r = case wday
|
138
|
-
|
139
|
-
# the 1st day of the month is a Monday, add no placeholders
|
140
|
-
when 1 then a
|
141
|
-
|
142
|
-
# the 1st day is a Sunday, add 6 placeholders before that day
|
143
|
-
when 0 then Array.new(6) + a
|
144
|
-
|
145
|
-
# add a few placeholders before the 1st day
|
146
|
-
else Array.new(wday - 1) + a
|
147
|
-
end
|
148
|
-
|
149
|
-
r
|
150
|
-
|
151
|
-
end
|
152
|
-
|
153
|
-
pxmonth.xslt = 'monthday_calendar.xsl'
|
154
|
-
pxmonth.css_layout = 'monthday_layout.css'
|
155
|
-
pxmonth.css_style = 'monthday.css'
|
156
|
-
pxmonth
|
157
|
-
|
158
|
-
else
|
159
|
-
|
160
|
-
pxmonth = make_month(m) do |a, wday|
|
161
|
-
|
162
|
-
|
163
|
-
# Sunday start
|
164
|
-
# wdays: 1 = Monday, 0 = Sunday
|
165
|
-
|
166
|
-
r = case wday
|
167
|
-
|
168
|
-
# the 1st day of the month is a Sunday, add no placeholders
|
169
|
-
when 0 then a
|
170
|
-
|
171
|
-
# add a few placeholders before the 1st day
|
172
|
-
else Array.new(wday) + a
|
173
|
-
end
|
174
|
-
|
175
|
-
r
|
176
|
-
|
177
|
-
end
|
178
|
-
|
179
|
-
pxmonth.xslt = 'month_calendar.xsl'
|
180
|
-
pxmonth.css_layout = 'month_layout.css'
|
181
|
-
pxmonth.css_style = 'month.css'
|
182
|
-
pxmonth
|
183
|
-
end
|
184
|
-
|
185
|
-
end
|
186
|
-
|
187
|
-
def this_week()
|
188
|
-
|
189
|
-
dt = DateTime.now
|
190
|
-
days = @calendar.month(dt.month).day
|
191
|
-
|
192
|
-
r = days.find {|day| day.date.cweek == dt.cweek }
|
193
|
-
pxweek = PolyrexObjects::Week.new
|
194
|
-
pxweek.mon = Date::MONTHNAMES[dt.month]
|
195
|
-
pxweek.no = dt.cweek.to_s
|
196
|
-
pxweek.label = ''
|
197
|
-
days[days.index(r),7].each{|day| pxweek.add day }
|
198
|
-
|
199
|
-
pxweek
|
200
|
-
end
|
201
|
-
|
202
|
-
def this_month()
|
203
|
-
self.month(DateTime.now.month)
|
204
|
-
end
|
205
|
-
|
206
|
-
private
|
207
|
-
|
208
|
-
|
209
|
-
def make_month(m)
|
210
|
-
|
211
|
-
cal_month = @calendar.month(m)
|
212
|
-
|
213
|
-
days_in_month = cal_month.records
|
214
|
-
pxmonth = cal_month.clone
|
215
|
-
pxmonth.records.each(&:delete)
|
216
|
-
|
217
|
-
a = days_in_month
|
218
|
-
|
219
|
-
i = a[0].wday
|
220
|
-
|
221
|
-
a2 = yield(a, i)
|
222
|
-
|
223
|
-
a2.each_slice(7) do |days_in_week|
|
224
|
-
|
225
|
-
pxweek = PolyrexObjects::Week.new
|
226
|
-
|
227
|
-
days_in_week.each do |day|
|
228
|
-
|
229
|
-
new_day = day ? day.deep_clone : PolyrexObjects::Day.new
|
230
|
-
pxweek.add new_day
|
231
|
-
end
|
232
|
-
|
233
|
-
pxmonth.add pxweek
|
234
|
-
end
|
235
|
-
|
236
|
-
week1 = pxmonth.week[0]
|
237
|
-
|
238
|
-
other_days = week1.day.select{|day| day.sdate.empty? }
|
239
|
-
start_date = week1.day[other_days.length].date
|
240
|
-
|
241
|
-
other_days.reverse.each.with_index do |day, i|
|
242
|
-
day.sdate = (start_date - (i+1)).strftime("%Y %b %d")
|
243
|
-
day.xday = day.date.day.to_s
|
244
|
-
end
|
245
|
-
|
246
|
-
last_week = pxmonth.week[-1]
|
247
|
-
|
248
|
-
gap = 7 - last_week.records.length
|
249
|
-
end_date = last_week.day.last.date
|
250
|
-
|
251
|
-
gap.times do |i|
|
252
|
-
|
253
|
-
day = PolyrexObjects::Day.new
|
254
|
-
day.sdate = (end_date + (i+1)).strftime("%Y %b %d")
|
255
|
-
day.xday = day.date.day.to_s
|
256
|
-
last_week.add day
|
257
|
-
end
|
258
|
-
|
259
|
-
pxmonth
|
260
|
-
end
|
261
|
-
|
262
|
-
def ordinal(val)
|
263
|
-
(10...20).include?(val) ? \
|
264
|
-
'th' : %w{ th st nd rd th th th th th th }[val % 10]
|
265
|
-
end
|
266
|
-
|
267
|
-
end
|