polyrex-calendar 0.1.8 → 0.1.9

Sign up to get free protection for your applications and to get access to all the features.
data/lib/calendar.xsl CHANGED
@@ -7,7 +7,7 @@
7
7
  <html lang="en">
8
8
 
9
9
  <head>
10
- <title><xsl:value-of select="summary/year"/> Calendar | generated by Polyrex-Calendar</title>
10
+ <title><xsl:value-of select="summary/year"/> Calendar | generated by Polrex-Calendar</title>
11
11
  <link rel="stylesheet" href="xlayout.css"/>
12
12
  </head>
13
13
 
@@ -52,7 +52,12 @@
52
52
  </xsl:template>
53
53
 
54
54
  <xsl:template match="day/summary">
55
- <td><xsl:value-of select="xday"/></td>
55
+ <td>
56
+ <xsl:if test="name!=''">
57
+ <xsl:value-of select="xday"/>
58
+ </xsl:if>
59
+
60
+ </td>
56
61
  </xsl:template>
57
62
 
58
63
  </xsl:stylesheet>
@@ -46,7 +46,11 @@
46
46
 
47
47
  <xsl:template match="day/summary">
48
48
  <td>
49
- <div><xsl:value-of select="xday"/></div>
49
+ <div>
50
+ <xsl:if test="name!=''">
51
+ <xsl:value-of select="xday"/>
52
+ </xsl:if>
53
+ </div>
50
54
  <xsl:choose>
51
55
  <xsl:when test="contains(event,'oliday')">
52
56
  <div><xsl:value-of select="event"/></div>
@@ -78,6 +78,10 @@ class PolyrexCalendar
78
78
  weeks = month.each_slice(7).to_a
79
79
  end
80
80
 
81
+ if weeks[-1].length < 7 then
82
+ weeks[-1] = (weeks[-1] + [nil] * 6 ).slice(0,7)
83
+ end
84
+
81
85
  weeks
82
86
  end
83
87
 
@@ -112,8 +116,9 @@ class PolyrexCalendar
112
116
  date: x.strftime("%Y-%b-%d")}
113
117
  else
114
118
  #if blank find the nearest date in the week and calculate this date
115
- # check right and if nothing then it'sat the end of the month
116
- h = {}
119
+ # check right and if nothing then it's at the end of the month
120
+ x = week[-1] ? (week[-1] - (7-(k+1))) : week[0] + k
121
+ h = {wday: x.wday.to_s, xday: x.day.to_s, date: x.strftime("%Y-%b-%d")}
117
122
  end
118
123
  create.day(h)
119
124
  end
@@ -18,6 +18,18 @@ class PolyrexCalendar
18
18
  @css = File.open(lib + '/layout.css','r').read
19
19
  @month_xsl = File.open(lib + '/month_calendar.xsl','r').read
20
20
  @month_css = File.open(lib + '/month_layout.css','r').read
21
+
22
+ PolyrexObjects::Month.class_eval {
23
+ def to_webpage()
24
+ lib = File.dirname(__FILE__)
25
+ month_xsl = File.open(lib + '/month_calendar.xsl','r').read
26
+ month_css = File.open(lib + '/month_layout.css','r').read
27
+ doc = Nokogiri::XML(self.to_xml); xslt = Nokogiri::XSLT(month_xsl)
28
+ html = xslt.transform(doc).to_xml
29
+ {self.name.downcase[0..2] + '_calendar.html' => html, 'month_layout.css' => month_css}
30
+ end
31
+ }
32
+
21
33
  end
22
34
 
23
35
  def to_a()
@@ -42,16 +54,11 @@ class PolyrexCalendar
42
54
  end
43
55
 
44
56
  def month(m)
45
- monthx = @polyrex.records[m-1]
46
- def monthx.to_webpage()
47
- lib = File.dirname(__FILE__)
48
- month_xsl = File.open(lib + '/month_calendar.xsl','r').read
49
- month_css = File.open(lib + '/month_layout.css','r').read
50
- doc = Nokogiri::XML(self.to_xml); xslt = Nokogiri::XSLT(month_xsl)
51
- html = xslt.transform(doc).to_xml
52
- {self.name.downcase[0..2] + '_calendar.html' => html, 'month_layout.css' => month_css}
53
- end
54
- monthx
57
+ @polyrex.records[m-1]
58
+ end
59
+
60
+ def months
61
+ @polyrex.records
55
62
  end
56
63
 
57
64
  private
@@ -71,6 +78,10 @@ class PolyrexCalendar
71
78
  weeks = month.each_slice(7).to_a
72
79
  end
73
80
 
81
+ if weeks[-1].length < 7 then
82
+ weeks[-1] = (weeks[-1] + [nil] * 6 ).slice(0,7)
83
+ end
84
+
74
85
  weeks
75
86
  end
76
87
 
@@ -83,7 +94,7 @@ class PolyrexCalendar
83
94
 
84
95
  @a = months
85
96
 
86
- @polyrex = Polyrex.new('calendar[year]/month[no,name,year]/week[no, rel_no]/day[wday, xday, name, event]')
97
+ @polyrex = Polyrex.new('calendar[year]/month[no,name,year]/week[no, rel_no]/day[wday, xday, name, event, date]')
87
98
  year_start = months[0][0][-1]
88
99
  @polyrex.summary.year = @year
89
100
  old_year_week = (year_start - 7).cweek
@@ -101,9 +112,13 @@ class PolyrexCalendar
101
112
 
102
113
  if x then
103
114
  week_i += 1 if x.wday == 6
104
- h = {wday: x.wday.to_s, xday: x.day.to_s, name: Date::DAYNAMES[k]}
115
+ h = {wday: x.wday.to_s, xday: x.day.to_s, name: Date::DAYNAMES[k], \
116
+ date: x.strftime("%Y-%b-%d")}
105
117
  else
106
- h = {}
118
+ #if blank find the nearest date in the week and calculate this date
119
+ # check right and if nothing then it's at the end of the month
120
+ x = week[-1] ? (week[-1] - (7-(k+1))) : week[0] + k
121
+ h = {wday: x.wday.to_s, xday: x.day.to_s, date: x.strftime("%Y-%b-%d")}
107
122
  end
108
123
  create.day(h)
109
124
  end
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.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors: []
7
7