polyrex-calendar 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/month_calendar.xsl +69 -0
- data/lib/month_layout.css +41 -0
- data/lib/polyrex-calendar.rb +51 -16
- data/lib/polyrex-calendar.rb~ +4 -2
- metadata +4 -2
@@ -0,0 +1,69 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
|
3
|
+
<xsl:output method="xml" indent="yes" />
|
4
|
+
|
5
|
+
<xsl:template match="month">
|
6
|
+
|
7
|
+
<html lang="en">
|
8
|
+
|
9
|
+
<head>
|
10
|
+
<title><xsl:value-of select="summary/name"/><xsl:text> </xsl:text><xsl:value-of select="summary/year"/> planner | generated by Polyrex-Calendar</title>
|
11
|
+
<link rel="stylesheet" href="xmonth_layout.css"/>
|
12
|
+
</head>
|
13
|
+
|
14
|
+
<body>
|
15
|
+
<div id="wrap">
|
16
|
+
<h1><xsl:value-of select="summary/name"/><xsl:text> </xsl:text><xsl:value-of select="summary/year"/></h1>
|
17
|
+
<table border="1">
|
18
|
+
<tr><th>Sunday</th><th>Monday</th><th>Tuesday</th><th>Wednesday</th><th>Thursday</th><th>Friday</th><th>Saturday</th></tr>
|
19
|
+
<xsl:apply-templates select="records"/>
|
20
|
+
</table>
|
21
|
+
</div>
|
22
|
+
</body>
|
23
|
+
</html>
|
24
|
+
|
25
|
+
</xsl:template>
|
26
|
+
|
27
|
+
<xsl:template match="month/summary">
|
28
|
+
<caption><xsl:value-of select="name"/></caption>
|
29
|
+
</xsl:template>
|
30
|
+
|
31
|
+
|
32
|
+
<xsl:template match="records/week">
|
33
|
+
<tr>
|
34
|
+
<xsl:apply-templates select="summary"/>
|
35
|
+
<xsl:apply-templates select="records"/>
|
36
|
+
</tr>
|
37
|
+
</xsl:template>
|
38
|
+
|
39
|
+
<xsl:template match="week/summary">
|
40
|
+
|
41
|
+
</xsl:template>
|
42
|
+
|
43
|
+
<xsl:template match="records/day">
|
44
|
+
<xsl:apply-templates select="summary"/>
|
45
|
+
</xsl:template>
|
46
|
+
|
47
|
+
<xsl:template match="day/summary">
|
48
|
+
<td>
|
49
|
+
<div><xsl:value-of select="xday"/></div>
|
50
|
+
<xsl:choose>
|
51
|
+
<xsl:when test="contains(event,'oliday')">
|
52
|
+
<div><xsl:value-of select="event"/></div>
|
53
|
+
<div></div>
|
54
|
+
</xsl:when>
|
55
|
+
<xsl:when test="substring(event,1,1) = '*'">
|
56
|
+
<div><xsl:value-of select="substring-after(event,'*')"/></div>
|
57
|
+
<div></div>
|
58
|
+
</xsl:when>
|
59
|
+
<xsl:otherwise>
|
60
|
+
<div></div>
|
61
|
+
<div><xsl:value-of select="event"/></div>
|
62
|
+
</xsl:otherwise>
|
63
|
+
</xsl:choose>
|
64
|
+
|
65
|
+
</td>
|
66
|
+
</xsl:template>
|
67
|
+
|
68
|
+
|
69
|
+
</xsl:stylesheet>
|
@@ -0,0 +1,41 @@
|
|
1
|
+
body {background-color: transparent }
|
2
|
+
|
3
|
+
#wrap {
|
4
|
+
background-color: transparent;
|
5
|
+
margin: 0 auto;
|
6
|
+
width: 1200px;
|
7
|
+
}
|
8
|
+
|
9
|
+
#wrap h1 {
|
10
|
+
background-color: transparent;
|
11
|
+
margin: 0.5em 0.3em;
|
12
|
+
padding: 0.2em 0.2em;
|
13
|
+
}
|
14
|
+
|
15
|
+
#wrap table {background-color: transparent; }
|
16
|
+
#wrap table td {background-color: transparent; }
|
17
|
+
#wrap table td div {
|
18
|
+
background-color: transparent;
|
19
|
+
font: 0.6em Serif;
|
20
|
+
margin: 0.33em 0.5em 0.3em 3.7em;
|
21
|
+
overflow: hidden;
|
22
|
+
padding: 0.2em 0.3em;
|
23
|
+
text-align: right;
|
24
|
+
}
|
25
|
+
#wrap table td div:first-child {
|
26
|
+
background-color: transparent;
|
27
|
+
float: left;
|
28
|
+
width: 1em; height: 1em;
|
29
|
+
margin: 0; padding: 0.3em 0.3em;
|
30
|
+
font: 1.0em Serif;
|
31
|
+
text-align: right;
|
32
|
+
}
|
33
|
+
#wrap table td div:last-child {
|
34
|
+
background-color: transparent;
|
35
|
+
margin: 0 0.4em 0 0.5em; padding: 0.2em 0.13em;
|
36
|
+
font: 0.8em Sans;
|
37
|
+
width: 9.0em; min-height: 4.0em;
|
38
|
+
overflow: hidden;
|
39
|
+
text-align: left
|
40
|
+
}
|
41
|
+
|
data/lib/polyrex-calendar.rb
CHANGED
@@ -8,9 +8,16 @@ require 'nokogiri'
|
|
8
8
|
|
9
9
|
class PolyrexCalendar
|
10
10
|
|
11
|
+
attr_accessor :xsl, :css, :polyrex, :month_xsl, :month_css
|
12
|
+
|
11
13
|
def initialize(year=nil)
|
12
14
|
@year = year ? year : Time.now.year
|
13
15
|
generate_calendar
|
16
|
+
lib = File.dirname(__FILE__)
|
17
|
+
@xsl = File.open(lib + '/calendar.xsl','r').read
|
18
|
+
@css = File.open(lib + '/layout.css','r').read
|
19
|
+
@month_xsl = File.open(lib + '/month_calendar.xsl','r').read
|
20
|
+
@month_css = File.open(lib + '/month_layout.css','r').read
|
14
21
|
end
|
15
22
|
|
16
23
|
def to_a()
|
@@ -18,20 +25,33 @@ class PolyrexCalendar
|
|
18
25
|
end
|
19
26
|
|
20
27
|
def to_xml()
|
21
|
-
@
|
28
|
+
@polyrex.to_xml pretty: true
|
22
29
|
end
|
23
30
|
|
24
|
-
def to_webpage()
|
25
|
-
|
26
|
-
|
27
|
-
|
31
|
+
def to_webpage()
|
32
|
+
html = generate_webpage(@polyrex.to_xml, @xsl)
|
33
|
+
{'calendar.html' => html, 'layout.css' => @css}
|
34
|
+
end
|
28
35
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
36
|
+
def import_events(dynarex)
|
37
|
+
dynarex.flat_records.each do |event|
|
38
|
+
m,w,i = @day[Date.parse(event[:date])]
|
39
|
+
@polyrex.records[m].week[w].day[i].event = event[:title]
|
40
|
+
end
|
41
|
+
self
|
42
|
+
end
|
43
|
+
|
44
|
+
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
|
35
55
|
end
|
36
56
|
|
37
57
|
private
|
@@ -54,18 +74,25 @@ class PolyrexCalendar
|
|
54
74
|
weeks
|
55
75
|
end
|
56
76
|
|
77
|
+
@day = {}
|
78
|
+
months.each_with_index do |month,m|
|
79
|
+
month.each_with_index do |weeks,w|
|
80
|
+
weeks.each_with_index{|d,i| @day[d] = [m,w,i]}
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
57
84
|
@a = months
|
58
85
|
|
59
|
-
|
86
|
+
@polyrex = Polyrex.new('calendar[year]/month[no,name,year]/week[no, rel_no]/day[wday, xday, name, event]')
|
60
87
|
year_start = months[0][0][-1]
|
61
|
-
|
62
|
-
old_year_week = year_start.
|
88
|
+
@polyrex.summary.year = @year
|
89
|
+
old_year_week = (year_start - 7).cweek
|
63
90
|
|
64
91
|
week_i = 0
|
65
92
|
|
66
93
|
months.each_with_index do |month,i|
|
67
94
|
|
68
|
-
|
95
|
+
@polyrex.create.month no: (i+1).to_s, name: Date::MONTHNAMES[i+1], year: @year do |create|
|
69
96
|
month.each_with_index do |week,j|
|
70
97
|
|
71
98
|
week_s = (week_i == 0 ? old_year_week : week_i).to_s
|
@@ -85,7 +112,15 @@ class PolyrexCalendar
|
|
85
112
|
end
|
86
113
|
end
|
87
114
|
|
88
|
-
|
115
|
+
end
|
116
|
+
|
117
|
+
def generate_webpage(xml, xsl)
|
118
|
+
|
119
|
+
# transform the xml to html
|
120
|
+
doc = Nokogiri::XML(xml)
|
121
|
+
xslt = Nokogiri::XSLT(xsl)
|
122
|
+
html = xslt.transform(doc).to_xml
|
123
|
+
html
|
89
124
|
|
90
125
|
end
|
91
126
|
end
|
data/lib/polyrex-calendar.rb~
CHANGED
@@ -8,6 +8,8 @@ require 'nokogiri'
|
|
8
8
|
|
9
9
|
class PolyrexCalendar
|
10
10
|
|
11
|
+
attr_accessor :xsl
|
12
|
+
|
11
13
|
def initialize(year=nil)
|
12
14
|
@year = year ? year : Time.now.year
|
13
15
|
generate_calendar
|
@@ -24,7 +26,7 @@ class PolyrexCalendar
|
|
24
26
|
def to_webpage()
|
25
27
|
|
26
28
|
# transform the xml to html
|
27
|
-
lib = File.
|
29
|
+
lib = File.dirname(__FILE__)
|
28
30
|
|
29
31
|
doc = Nokogiri::XML(@xml)
|
30
32
|
xslt = Nokogiri::XSLT(File.open(lib + '/calendar.xsl','r').read)
|
@@ -32,7 +34,7 @@ class PolyrexCalendar
|
|
32
34
|
css = File.open(lib + '/layout.css','r').read
|
33
35
|
|
34
36
|
{'calendar.html' => html, 'layout.css' => css}
|
35
|
-
end
|
37
|
+
end
|
36
38
|
|
37
39
|
private
|
38
40
|
|
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.6
|
5
5
|
platform: ruby
|
6
6
|
authors: []
|
7
7
|
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2011-01-
|
12
|
+
date: 2011-01-23 00:00:00 +00:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
@@ -41,8 +41,10 @@ extensions: []
|
|
41
41
|
extra_rdoc_files: []
|
42
42
|
|
43
43
|
files:
|
44
|
+
- lib/month_calendar.xsl
|
44
45
|
- lib/polyrex-calendar.rb~
|
45
46
|
- lib/calendar.xsl
|
47
|
+
- lib/month_layout.css
|
46
48
|
- lib/layout.css
|
47
49
|
- lib/calendar.xsl~
|
48
50
|
- lib/polyrex-calendar.rb
|