polyrex-calendar 0.1.14 → 0.1.15
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 +1 -2
- data/lib/polyrex-calendar.rb +57 -17
- data/lib/week.xsl +3 -3
- metadata +3 -3
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb941b9ce09a7826d6ef965a8c1b5bee0e4cfc4f
|
4
|
+
data.tar.gz: 351f4020b16f485cdb8b9968fe9440f2f3aa16ce
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c53727432e3f781dd3444aa60027154c1494678b8f1ec8abff78aa7c817a21bd2ffda5a0c974f97ba9cf01862625f5c79e72171420f2603ac98c620f894a801d
|
7
|
+
data.tar.gz: 6adc0c1d066f3dafe2573749fce04dd0a01da1dd272e6f2f45b82ae1248d6567bd7b5ed9af44739b3edb4d3ebb205381732a22f7dc1326a98998e1ac98e03d56
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data.tar.gz.sig
CHANGED
@@ -1,2 +1 @@
|
|
1
|
-
|
2
|
-
�Iw���I���&��6fAQ�1���l���-��c�8iG4˵��RMtd�H�6<�Dˎ�e�ֿ���䶎鵆<'B���!�h��H��s��$t5�W!5����=����e��I��eaF�=,߮m�@�.�o\��N�C)���1ȄF�P��O %oY�|�=��Y6hWl��h�,/���+�u��qN����ƛ���a��L�|��U<
|
1
|
+
�{ؠ�,��DJe�Q~;c���Q�n��?m��]�E�aA���z�Yࡵ��EO��6���t�8%D�O��D���&��\�9�tr6��e�`��;����Dᰶ��9@6;n�"�XgQ�; ��B+ļ�B0s�`�x�� n��/�Ȣ�^p��(slۄcB'u�K������UFd�lְ)����@I����{�P��j�m�c�1�O�֒���NLWI
|
data/lib/polyrex-calendar.rb
CHANGED
@@ -7,6 +7,12 @@ require 'date'
|
|
7
7
|
require 'nokogiri'
|
8
8
|
require 'chronic_duration'
|
9
9
|
|
10
|
+
MINUTE = 60
|
11
|
+
HOUR = MINUTE * 60
|
12
|
+
DAY = HOUR * 24
|
13
|
+
WEEK = DAY * 7
|
14
|
+
MONTH = DAY * 30
|
15
|
+
|
10
16
|
class Numeric
|
11
17
|
def ordinal
|
12
18
|
( (10...20).include?(self) ? 'th' : %w{ th st nd rd th th th th th th }[self % 10] )
|
@@ -20,12 +26,13 @@ class PolyrexCalendar
|
|
20
26
|
def initialize(year=nil, options={})
|
21
27
|
|
22
28
|
@id = '1'
|
23
|
-
|
29
|
+
|
30
|
+
lib = File.dirname(__FILE__)
|
24
31
|
opts = {calendar_xsl: lib + '/calendar.xsl'
|
25
32
|
}.merge(options)
|
26
33
|
@year = year ? year.to_s : Time.now.year.to_s
|
27
34
|
generate_calendar
|
28
|
-
|
35
|
+
|
29
36
|
|
30
37
|
@xsl = File.read lib + '/calendar.xsl'
|
31
38
|
@css = File.read lib + '/layout.css'
|
@@ -41,7 +48,11 @@ class PolyrexCalendar
|
|
41
48
|
|
42
49
|
month_xsl = File.read lib + '/month_calendar.xsl'
|
43
50
|
month_css = File.read lib + '/month_layout.css'
|
44
|
-
|
51
|
+
|
52
|
+
File.open('self.xml','w'){|f| f.write self.to_xml pretty: true}
|
53
|
+
File.open('month.xsl','w'){|f| f.write month_xsl }
|
54
|
+
#html = Rexslt.new(month_xsl, self.to_xml).to_xml
|
55
|
+
|
45
56
|
xslt = Nokogiri::XSLT(month_xsl)
|
46
57
|
html = xslt.transform(Nokogiri::XML(self.to_xml)).to_s
|
47
58
|
{self.name.downcase[0..2] + '_calendar.html' => html, 'month_layout.css' => month_css}
|
@@ -60,12 +71,17 @@ class PolyrexCalendar
|
|
60
71
|
end
|
61
72
|
|
62
73
|
def to_webpage()
|
74
|
+
|
63
75
|
lib = File.dirname(__FILE__)
|
64
|
-
|
76
|
+
|
65
77
|
week_xsl = File.read lib + '/week_calendar.xsl'
|
66
78
|
week_layout_css = File.read lib + '/week_layout.css'
|
67
79
|
week_css = File.read lib + '/week.css'
|
68
|
-
|
80
|
+
|
81
|
+
File.open('self.xml','w'){|f| f.write self.to_xml pretty: true}
|
82
|
+
File.open('week.xsl','w'){|f| f.write week_xsl }
|
83
|
+
#html = Rexslt.new(week_xsl, self.to_xml).to_xml
|
84
|
+
#html = xsltproc 'week_calendar.xsl', self.to_xml
|
69
85
|
xslt = Nokogiri::XSLT(week_xsl)
|
70
86
|
html = xslt.transform(Nokogiri::XML(self.to_xml)).to_s
|
71
87
|
{'week' + self.no + '_planner.html' => html, 'week_layout.css' => week_layout_css, \
|
@@ -85,8 +101,9 @@ class PolyrexCalendar
|
|
85
101
|
end
|
86
102
|
|
87
103
|
def to_webpage()
|
88
|
-
#html = Rexslt.new(@xsl, @polyrex.to_xml).to_xml
|
89
|
-
|
104
|
+
# jr2441213 html = Rexslt.new(@xsl, @polyrex.to_xml).to_xml
|
105
|
+
xslt = Nokogiri::XSLT(@xsl)
|
106
|
+
html = xslt.transform(Nokogiri::XML(@polyrex.to_xml)).to_s
|
90
107
|
{'calendar.html' => html, 'layout.css' => @css}
|
91
108
|
end
|
92
109
|
|
@@ -122,15 +139,36 @@ class PolyrexCalendar
|
|
122
139
|
polyrex.parse(list)
|
123
140
|
|
124
141
|
self.import_events polyrex
|
142
|
+
# for testing only
|
143
|
+
#polyrex
|
125
144
|
end
|
126
145
|
|
127
146
|
def this_week()
|
147
|
+
|
128
148
|
m = DateTime.now.month
|
129
|
-
self.month(m).records.find do |week|
|
149
|
+
thisweek = self.month(m).records.find do |week|
|
130
150
|
now = DateTime.now
|
131
|
-
week_no = now.cwday < 7 ? now.cweek - 1: now.cweek
|
151
|
+
#week_no = now.cwday < 7 ? now.cweek - 1: now.cweek
|
152
|
+
week_no = now.cweek
|
132
153
|
week.no == week_no.to_s
|
133
154
|
end
|
155
|
+
|
156
|
+
day = (Time.now - DAY * (Time.now.wday - 1)).day
|
157
|
+
|
158
|
+
days_in_week = self.this_month.xpath('records/week/records/.')\
|
159
|
+
.select {|x| x.text('summary/xday').to_i >= day}\
|
160
|
+
.take 7
|
161
|
+
|
162
|
+
doc_week = Rexle.new thisweek.to_xml
|
163
|
+
records = doc_week.root.element 'records'
|
164
|
+
records.insert_before Rexle::Element.new('records')
|
165
|
+
|
166
|
+
records.delete
|
167
|
+
|
168
|
+
week = doc_week.root.element 'records'
|
169
|
+
days_in_week.each {|day| week.add day }
|
170
|
+
PolyrexObjects.new(@schema).to_h['Week'].new doc_week.root
|
171
|
+
|
134
172
|
end
|
135
173
|
|
136
174
|
def this_month()
|
@@ -166,13 +204,14 @@ class PolyrexCalendar
|
|
166
204
|
|
167
205
|
start_time = entry.start_time
|
168
206
|
|
169
|
-
if entry.end_time then
|
207
|
+
if entry.end_time.length > 0 then
|
208
|
+
|
170
209
|
end_time = entry.end_time
|
171
210
|
duration = ChronicDuration.output(Time.parse(sd + end_time) \
|
172
211
|
- Time.parse(sd + start_time))
|
173
212
|
else
|
174
213
|
|
175
|
-
if entry.duration then
|
214
|
+
if entry.duration.length > 0 then
|
176
215
|
duration = entry.duration
|
177
216
|
else
|
178
217
|
duration = '10 mins'
|
@@ -236,22 +275,23 @@ class PolyrexCalendar
|
|
236
275
|
end
|
237
276
|
|
238
277
|
@a = months
|
239
|
-
schema = 'calendar[year]/month[no,name,year]/week[no, rel_no, mon, label]/' + \
|
278
|
+
@schema = 'calendar[year]/month[no,name,year]/week[no, rel_no, mon, label]/' + \
|
240
279
|
'day[wday, xday, name, event, date, ordinal, overlap]/' + \
|
241
280
|
'entry[time_start, time_end, duration, title]'
|
242
|
-
@polyrex = Polyrex.new(schema, id_counter: @id)
|
281
|
+
@polyrex = Polyrex.new(@schema, id_counter: @id)
|
243
282
|
year_start = months[0][0][-1]
|
244
283
|
@polyrex.summary.year = @year
|
245
284
|
old_year_week = (year_start - 7).cweek
|
246
285
|
|
247
|
-
week_i =
|
286
|
+
week_i = 1
|
248
287
|
|
249
288
|
months.each_with_index do |month,i|
|
250
289
|
month_name = Date::MONTHNAMES[i+1]
|
251
290
|
@polyrex.create.month no: (i+1).to_s, name: month_name, year: @year do |create|
|
252
291
|
month.each_with_index do |week,j|
|
253
292
|
|
254
|
-
week_s = (week_i == 0 ? old_year_week : week_i).to_s
|
293
|
+
# jr241213 week_s = (week_i == 0 ? old_year_week : week_i).to_s
|
294
|
+
week_s = week_i.to_s
|
255
295
|
|
256
296
|
if week[0].nil? then
|
257
297
|
label = Date::MONTHNAMES[(i > 0 ? i : 12)] + " - " + month_name
|
@@ -261,6 +301,7 @@ class PolyrexCalendar
|
|
261
301
|
label = month_name + " - " + Date::MONTHNAMES[(i+2 <= 12 ? i+2 : 1)]
|
262
302
|
end
|
263
303
|
|
304
|
+
|
264
305
|
week_record = {
|
265
306
|
rel_no: (j+1).to_s,
|
266
307
|
no: week_s,
|
@@ -329,6 +370,5 @@ class PolyrexCalendar
|
|
329
370
|
html = xslt.transform(doc).to_xml
|
330
371
|
html
|
331
372
|
|
332
|
-
end
|
333
|
-
|
373
|
+
end
|
334
374
|
end
|
data/lib/week.xsl
CHANGED
@@ -34,12 +34,12 @@
|
|
34
34
|
<xsl:template match='week/records'>
|
35
35
|
<div id='col1'>
|
36
36
|
<ul>
|
37
|
-
<xsl:apply-templates select="day[
|
37
|
+
<xsl:apply-templates select="day[position() < 5]"/>
|
38
38
|
</ul>
|
39
39
|
</div>
|
40
40
|
<div id='col2'>
|
41
41
|
<ul>
|
42
|
-
<xsl:apply-templates select="day[
|
42
|
+
<xsl:apply-templates select="day[position() >= 5]"/>
|
43
43
|
</ul>
|
44
44
|
</div>
|
45
45
|
</xsl:template>
|
@@ -98,4 +98,4 @@
|
|
98
98
|
</xsl:template>
|
99
99
|
|
100
100
|
|
101
|
-
</xsl:stylesheet>
|
101
|
+
</xsl:stylesheet>
|
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.1.
|
4
|
+
version: 0.1.15
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- James Robertson
|
@@ -29,7 +29,7 @@ cert_chain:
|
|
29
29
|
CIpMEIXEnQwmcmWL07xvpUquKTab0tCXtmcfjr74KP2KCm5guZyxeXaj9lD1OrnC
|
30
30
|
Kgt/mRI2beG8K7QY81GGMsQjiG95Dcko
|
31
31
|
-----END CERTIFICATE-----
|
32
|
-
date: 2013-12-
|
32
|
+
date: 2013-12-24 00:00:00.000000000 Z
|
33
33
|
dependencies:
|
34
34
|
- !ruby/object:Gem::Dependency
|
35
35
|
name: polyrex
|
@@ -109,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
109
109
|
version: '0'
|
110
110
|
requirements: []
|
111
111
|
rubyforge_project:
|
112
|
-
rubygems_version: 2.0.
|
112
|
+
rubygems_version: 2.0.3
|
113
113
|
signing_key:
|
114
114
|
specification_version: 4
|
115
115
|
summary: polyrex-calendar
|
metadata.gz.sig
CHANGED
Binary file
|