public
Rubygem
Description: A lightweight and flexible website management system.
Homepage: http://webby.rubyforge.org/
Clone URL: git://github.com/TwP/webby.git
Search Repo:
fixing windows line ending bug
TwP (author)
Mon Feb 04 22:33:39 -0800 2008
commit  4cb65dedf2b7f872bd05730e04cf807531c2cfcf
tree    c5e5b8b06204f0982b1fff997e0ca7b250a03dcc
parent  a4f454c1fb7ec90e241a851ed11a5e7f7f9aea4a
...
3
4
5
6
7
 
8
9
10
...
3
4
5
 
 
6
7
8
9
0
@@ -3,8 +3,7 @@
0
 * 2 bug fixes
0
   - The setup.rb task now requires rubygems in case it is not in the
0
     user's rubyopt
0
- - Now explicitly requiring the most recent version of rake when
0
- building the gem
0
+ - Fixed file line endings on Windows when creating a new site
0
 
0
 == 0.7.2 / 2008-02-02
0
 
...
1
 
2
3
4
...
13
14
15
16
 
17
18
19
...
56
57
58
59
60
 
 
61
62
63
...
 
1
2
3
4
...
13
14
15
 
16
17
18
19
...
56
57
58
 
 
59
60
61
62
63
0
@@ -1,4 +1,4 @@
0
----
0
+---
0
 extension: css
0
 filter: erb
0
 layout: nil # no layout
0
@@ -13,7 +13,7 @@ color:
0
   highlight: "#B2CCFF"
0
   quiet: "#666"
0
   alt: "#666"
0
----
0
+---
0
 
0
 body {
0
   font-family: Verdana, "Bitstream Vera Sans", sans-serif;
0
@@ -56,8 +56,8 @@ p.quiet { color: <%= @page.color['quiet'] %>; }
0
 .alt { color: <%= @page.color['alt'] %>; }
0
 
0
 p.title {
0
- color: #111;
0
- font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
0
+ color: #111;
0
+ font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
0
   font-size: 2em;
0
   margin-bottom: 0.75em;
0
 }
...
1
 
2
3
4
5
6
 
7
8
9
...
 
1
2
3
4
5
 
6
7
8
9
0
@@ -1,9 +1,9 @@
0
----
0
+---
0
 title: Home Page
0
 filter:
0
   - erb
0
   - textile
0
----
0
+---
0
 p(title). <%= @page.title %>
0
 
0
 Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nunc congue ipsum vestibulum libero. Aenean vitae justo. Nam eget tellus. Etiam convallis, est eu lobortis mattis, lectus tellus tempus felis, a ultricies erat ipsum at metus.
...
1
 
2
3
4
 
5
6
7
...
24
25
26
27
 
28
29
30
31
32
 
33
34
35
...
37
38
39
40
 
41
42
43
...
52
53
54
55
 
56
57
58
...
 
1
2
3
 
4
5
6
7
...
24
25
26
 
27
28
29
30
31
 
32
33
34
35
...
37
38
39
 
40
41
42
43
...
52
53
54
 
55
56
57
58
0
@@ -1,7 +1,7 @@
0
----
0
+---
0
 extension: html
0
 filter: erb
0
----
0
+---
0
 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
0
     "DTD/xhtml1-strict.dtd">
0
 
0
@@ -24,12 +24,12 @@ filter: erb
0
 <body>
0
 
0
 <div class="container">
0
-
0
+
0
    <div class="column span-20 prepend-2 append-2 first last" id="header">
0
      <p class="title">A New Website</p>
0
      <hr>
0
    </div>
0
-
0
+
0
    <div class="column span-15 prepend-2 first">
0
       <%= @content %>
0
    </div>
0
@@ -37,7 +37,7 @@ filter: erb
0
    <div class="column span-5 append-2 last">
0
       <h4>Sidebar</h4>
0
       <p>Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Cras ornare mattis nunc. Mauris venenatis, pede sed aliquet vehicula, lectus tellus pulvinar neque, non cursus sem nisi vel augue. </p>
0
-
0
+
0
       <div class="box">
0
          <p class="last">Mauris a lectus. Aliquam erat volutpat. Phasellus ultrices mi a sapien. Nunc rutrum egestas lorem. Duis ac sem sagittis elit tincidunt gravida.</p>
0
       </div>
0
@@ -52,7 +52,7 @@ filter: erb
0
      <hr />
0
      <p>This website was created with <a href="http://webby.rubyforge.org">Webby</a></p>
0
    </div>
0
-
0
+
0
 </div>
0
 </body>
0
 </html>
...
1
 
2
3
4
5
6
7
 
8
9
10
...
 
1
2
3
4
5
6
 
7
8
9
10
0
@@ -1,10 +1,10 @@
0
----
0
+---
0
 title: New Page
0
 created_at: <%= Time.now.to_y %>
0
 filter:
0
   - erb
0
   - textile
0
----
0
+---
0
 p(title). <%%= h(@page.title) %>
0
 
0
 Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nunc congue ipsum vestibulum libero. Aenean vitae justo. Nam eget tellus. Etiam convallis, est eu lobortis mattis, lectus tellus tempus felis, a ultricies erat ipsum at metus.
...
163
164
165
 
166
167
168
...
163
164
165
166
167
168
169
0
@@ -163,6 +163,7 @@ class File < ::File
0
 
0
     truncate 0
0
     unless data.nil?
0
+# TODO: is the corect on the windows platform?
0
       write YAML.dump(data)
0
       write "--- #$/"
0
     end
...
11
12
13
14
15
 
16
17
18
...
145
146
147
148
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
149
150
151
...
11
12
13
 
 
14
15
16
17
...
144
145
146
 
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
0
@@ -11,8 +11,7 @@ module Webby
0
 #
0
 class Main
0
 
0
- # TODO: need to fix line endings for the target platform
0
- # anything that's a page, all the layouts, all the templates
0
+ WINDOWS = %r/djgpp|(cyg|ms|bcc)win|mingw/ =~ RUBY_PLATFORM # :nodoc:
0
 
0
   # Directory where the Webby website will be created
0
   attr_accessor :site
0
@@ -145,7 +144,29 @@ class Main
0
     src = ::File.join(data, file)
0
     dst = ::File.join(site, file)
0
     test(?e, dst) ? updating(dst) : creating(dst)
0
- FileUtils.cp src, dst
0
+# FileUtils.cp(src, dst)
0
+ if WINDOWS then win_line_endings(src, dst)
0
+ else FileUtils.cp(src, dst) end
0
+ end
0
+
0
+ # call-seq:
0
+ # win_line_endings( src, dst )
0
+ #
0
+ # Copy the file from the _src_ location to the _dst_ location and
0
+ # transform the line endings to the windows "\r\n" format.
0
+ #
0
+ def win_line_endings( src, dst )
0
+ case ::File.extname(src)
0
+ when *%w[.png .gif .jpg .jpeg]
0
+ FileUtils.cp src, dst
0
+ else
0
+ ::File.open(dst,'w') do |fd|
0
+ ::File.foreach(src, "\n") do |line|
0
+ line.tr!("\r\n",'')
0
+ fd.puts line
0
+ end
0
+ end
0
+ end
0
   end
0
 
0
   # call-seq:
...
73
74
75
76
 
77
78
79
...
73
74
75
 
76
77
78
79
0
@@ -73,7 +73,7 @@ rakefiles.unshift(rakefiles.delete('tasks/post_load.rake')).compact!
0
 import(*rakefiles)
0
 
0
 # Setup some constants
0
-WIN32 = %r/win32/ =~ RUBY_PLATFORM unless defined? WIN32
0
+WIN32 = %r/djgpp|(cyg|ms|bcc)win|mingw/ =~ RUBY_PLATFORM unless defined? WIN32
0
 
0
 DEV_NULL = WIN32 ? 'NUL:' : '/dev/null'
0
 

Comments

    No one has commented yet.