Browse code

updated rakefile to use FSSM in `rake watch`, generate a sitemap, and moved typography to a debug folder

B Mathis authored on 31/10/2009 at 17:52:56
Showing 3 changed files
... ...
@@ -1,15 +1,13 @@
1 1
 require 'active_support'
2 2
 
3
-# preview project on this port - http://localhost:4000
4
-port = "4000"
5
-
6
-# compiled site directory
7
-site = "site"
8
-
9
-# for rsync deployment
10
-ssh_user      = "user@host.com"
11
-document_root = "~/document_root/"
3
+port = "4000"     # preview project port eg. http://localhost:4000
4
+site = "site"     # compiled site directory
5
+source = "source" # source file directory
12 6
 
7
+# MUST CHANGE FOR YOUR PROJECT
8
+site_url = "http://yoursite.com"   # deployed site url
9
+ssh_user      = "user@host.com"    # for rsync deployment
10
+document_root = "~/document_root/" # for rsync deployment
13 11
 
14 12
 def ok_failed(condition)
15 13
   if (condition)
... ...
@@ -34,12 +32,29 @@ end
34 34
 desc "generate website in output directory"
35 35
 task :generate => :clean do
36 36
   puts "Generating website..."
37
-  system "compass"
38 37
   system "jekyll"
39 38
   Dir["#{site}/stylesheets/*.sass"].each { |f| rm_rf(f) }
39
+  system "compass"
40 40
   system "mv #{site}/atom.html #{site}/atom.xml"
41 41
 end
42 42
 
43
+def rebuild_site(relative)
44
+  puts ">>> Change Detected to: #{relative} <<<"
45
+  IO.popen('rake generate'){|io| print(io.readpartial(512)) until io.eof?}
46
+  puts '>>> Update Complete <<<'
47
+end
48
+
49
+desc "Watch the site and regenerate when it changes"
50
+task :watch do
51
+  require 'fssm'
52
+  puts ">>> Watching for Changes <<<"
53
+  FSSM.monitor("#{File.dirname(__FILE__)}/#{source}", '**/*') do
54
+    update {|base, relative| rebuild_site(relative)}
55
+    delete {|base, relative| rebuild_site(relative)}
56
+    create {|base, relative| rebuild_site(relative)}
57
+  end
58
+end
59
+
43 60
 desc "generate and deploy website"
44 61
 task :deploy => :generate do
45 62
   print "Deploying website..."
... ...
@@ -68,4 +83,38 @@ end
68 68
 desc "preview the site in a web browser"
69 69
 multitask :preview => [:generate, :start_serve] do
70 70
   system "open http://localhost:#{port}"
71
+end
72
+
73
+
74
+desc "Build an XML sitemap of all html files."
75
+task :sitemap => :generate do
76
+  html_files = FileList.new("#{site}/**/*.html").map{|f| f[("#{site}".size)..-1]}.map do |f|
77
+    if f.ends_with?("index.html")
78
+      f[0..(-("index.html".size + 1))]
79
+    else
80
+      f
81
+    end
82
+  end.sort_by{|f| f.size}
83
+  open("#{site}/sitemap.xml", 'w') do |sitemap|
84
+    sitemap.puts %Q{<?xml version="1.0" encoding="UTF-8"?>}
85
+    sitemap.puts %Q{<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">}
86
+    html_files.each do |f|
87
+      priority = case f
88
+      when %r{^/$}
89
+        1.0
90
+      when %r{^/blog}
91
+        0.9
92
+      else
93
+        0.8
94
+      end
95
+      sitemap.puts %Q{  <url>}
96
+      sitemap.puts %Q{    <loc>#{site_url}#{f}</loc>}
97
+      sitemap.puts %Q{    <lastmod>#{Time.to_s('%Y-%m-%d')}</lastmod>}
98
+      sitemap.puts %Q{    <changefreq>weekly</changefreq>}
99
+      sitemap.puts %Q{    <priority>#{priority}</priority>}
100
+      sitemap.puts %Q{  </url>}
101
+    end
102
+    sitemap.puts %Q{</urlset>}
103
+    puts "Created #{site}/sitemap.xml"
104
+  end
71 105
 end
72 106
\ No newline at end of file
73 107
new file mode 100644
... ...
@@ -0,0 +1,116 @@
0
+---
1
+layout: default
2
+title: Typography Debug
3
+---
4
+
5
+%h1 Level 01 Heading
6
+%h2 Level 02 Heading
7
+%h3 Level 03 Heading
8
+%h4 Level 04 Heading
9
+%h5 Level 05 Heading
10
+%h6 Level 06 Heading
11
+
12
+%p
13
+  Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Fusce sodales ligula sed urna. Aliquam posuere arcu
14
+  viverra erat. Pellentesque et enim dapibus ante facilisis bibendum. Nam congue dapibus urna. Vestibulum consequat
15
+  arcu at magna. Nunc faucibus mollis lacus. Nulla tempor luctus tellus. Donec blandit lobortis pede. Vestibulum
16
+  vel pede ut urna eleifend lacinia.
17
+%p
18
+  Maecenas ligula nibh, imperdiet at, interdum eget, sagittis eu, enim. Vivamus vel urna. Donec fringilla
19
+  ullamcorper sem. In risus arcu, pellentesque cursus, faucibus cursus, consequat quis, est. Aliquam id erat.
20
+  Aliquam arcu. Phasellus vulputate. Integer sem diam, mattis vel, viverra ullamcorper, ultricies quis, nisl. Sed
21
+  sollicitudin quam ut nisi. Vivamus velit sapien, volutpat eu, faucibus id, nonummy id, urna.
22
+%p
23
+  Take it<sub>2</sub> to the power of<sup>3</sup>
24
+  Praesent iaculis pellentesque est. Nulla facilisi. Etiam fringilla vehicula orci. Aliquam fermentum ipsum id
25
+  nulla. Aliquam interdum laoreet leo. Cras accumsan. Nam pharetra diam id nunc. Integer blandit tellus vulputate
26
+  felis. Cras aliquam, eros in euismod aliquam, enim nisl mollis metus, quis fringilla ipsum diam ut pede. Mauris a
27
+  libero ac velit interdum pulvinar. Nunc ipsum mauris, semper rhoncus, feugiat ut, egestas id, diam. Nullam
28
+  porttitor condimentum risus. Vivamus nec enim eget nisi commodo euismod. Ut turpis. Nullam malesuada rutrum
29
+  neque. Nam sodales porta elit. Mauris mollis nisl vel augue.
30
+
31
+%p
32
+  And we were like <q>Woah</q>, and he was like <q>Woah</q>, and they were like <q>WOAH!</q>
33
+
34
+%p
35
+  %abbr(title="For The Win!") FTW!
36
+%p
37
+  
38
+%h3 Unordered lists
39
+%ul
40
+  %li Lorem ipsum dolor sit amet
41
+  %li Consectetur adipisicing elit
42
+  %li Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua
43
+  %li Ut enim ad minim veniam
44
+
45
+%h3 Ordered lists
46
+%ol
47
+  %li Consectetur adipisicing elit
48
+  %li Sed do eiusmod tempor incididunt ut labore
49
+  %li Et dolore magna aliqua
50
+  
51
+%h3 Blockquotes
52
+%blockquote
53
+  %p
54
+    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore
55
+    magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
56
+    consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
57
+    Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
58
+
59
+%h3 Tables
60
+%table
61
+  %caption
62
+    Jimi Hendrix - albums
63
+    %thead
64
+      %tr
65
+        %th Album
66
+        %th Year
67
+        %th Price
68
+    %tfoot
69
+      %tr
70
+        %td Album
71
+        %td Year
72
+        %td Price
73
+    %tbody
74
+      %tr
75
+        %td Are You Experienced
76
+        %td 1967
77
+        %td $10.00
78
+      %tr
79
+        %td Axis: Bold as Love
80
+        %td 1967
81
+        %td $12.00
82
+      %tr
83
+        %td Electric Ladyland
84
+        %td 1968
85
+        %td $10.00
86
+      %tr
87
+        %td Band of Gypsys
88
+        %td 1970
89
+        %td $12.00
90
+%p
91
+  %a(href="#")Link
92
+  %br/
93
+  %strong &lt;strong&gt;
94
+  %br/
95
+  %del &lt;del&gt; deleted
96
+  %br/
97
+  %dfn &lt;dfn&gt; dfn
98
+  %br/
99
+  %em &lt;em&gt; emphasis
100
+  %br/
101
+
102
+%pre
103
+  %code
104
+    &lt;html&gt;
105
+    &lt;head&gt;
106
+    &lt;/head&gt;
107
+    &lt;body&gt;
108
+    &lt;div class = "main"&gt; &lt;div&gt;
109
+    &lt;/body&gt;
110
+    &lt;/html&gt;
111
+
112
+%tt
113
+  &lt;tt&gt;
114
+  Pellentesque tempor, dui ut ultrices viverra, neque urna blandit nisi, id accumsan dolor est vitae risus.
115
+%hr
0 116
\ No newline at end of file
1 117
deleted file mode 100644
... ...
@@ -1,116 +0,0 @@
1
-layout: default
2
-title: Typography Debug
3
-
4
-%h1 Level 01 Heading
5
-%h2 Level 02 Heading
6
-%h3 Level 03 Heading
7
-%h4 Level 04 Heading
8
-%h5 Level 05 Heading
9
-%h6 Level 06 Heading
10
-
11
-%p
12
-  Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Fusce sodales ligula sed urna. Aliquam posuere arcu
13
-  viverra erat. Pellentesque et enim dapibus ante facilisis bibendum. Nam congue dapibus urna. Vestibulum consequat
14
-  arcu at magna. Nunc faucibus mollis lacus. Nulla tempor luctus tellus. Donec blandit lobortis pede. Vestibulum
15
-  vel pede ut urna eleifend lacinia.
16
-%p
17
-  Maecenas ligula nibh, imperdiet at, interdum eget, sagittis eu, enim. Vivamus vel urna. Donec fringilla
18
-  ullamcorper sem. In risus arcu, pellentesque cursus, faucibus cursus, consequat quis, est. Aliquam id erat.
19
-  Aliquam arcu. Phasellus vulputate. Integer sem diam, mattis vel, viverra ullamcorper, ultricies quis, nisl. Sed
20
-  sollicitudin quam ut nisi. Vivamus velit sapien, volutpat eu, faucibus id, nonummy id, urna.
21
-%p
22
-  Take it<sub>2</sub> to the power of<sup>3</sup>
23
-  Praesent iaculis pellentesque est. Nulla facilisi. Etiam fringilla vehicula orci. Aliquam fermentum ipsum id
24
-  nulla. Aliquam interdum laoreet leo. Cras accumsan. Nam pharetra diam id nunc. Integer blandit tellus vulputate
25
-  felis. Cras aliquam, eros in euismod aliquam, enim nisl mollis metus, quis fringilla ipsum diam ut pede. Mauris a
26
-  libero ac velit interdum pulvinar. Nunc ipsum mauris, semper rhoncus, feugiat ut, egestas id, diam. Nullam
27
-  porttitor condimentum risus. Vivamus nec enim eget nisi commodo euismod. Ut turpis. Nullam malesuada rutrum
28
-  neque. Nam sodales porta elit. Mauris mollis nisl vel augue.
29
-
30
-%p
31
-  And we were like <q>Woah</q>, and he was like <q>Woah</q>, and they were like <q>WOAH!</q>
32
-
33
-%p
34
-  %abbr(title="For The Win!") FTW!
35
-%p
36
-  
37
-%h3 Unordered lists
38
-%ul
39
-  %li Lorem ipsum dolor sit amet
40
-  %li Consectetur adipisicing elit
41
-  %li Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua
42
-  %li Ut enim ad minim veniam
43
-
44
-%h3 Ordered lists
45
-%ol
46
-  %li Consectetur adipisicing elit
47
-  %li Sed do eiusmod tempor incididunt ut labore
48
-  %li Et dolore magna aliqua
49
-  
50
-%h3 Blockquotes
51
-%blockquote
52
-  %p
53
-    Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore
54
-    magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
55
-    consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.
56
-    Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
57
-
58
-%h3 Tables
59
-%table
60
-  %caption
61
-    Jimi Hendrix - albums
62
-    %thead
63
-      %tr
64
-        %th Album
65
-        %th Year
66
-        %th Price
67
-    %tfoot
68
-      %tr
69
-        %td Album
70
-        %td Year
71
-        %td Price
72
-    %tbody
73
-      %tr
74
-        %td Are You Experienced
75
-        %td 1967
76
-        %td $10.00
77
-      %tr
78
-        %td Axis: Bold as Love
79
-        %td 1967
80
-        %td $12.00
81
-      %tr
82
-        %td Electric Ladyland
83
-        %td 1968
84
-        %td $10.00
85
-      %tr
86
-        %td Band of Gypsys
87
-        %td 1970
88
-        %td $12.00
89
-%p
90
-  %a(href="#")Link
91
-  %br/
92
-  %strong &lt;strong&gt;
93
-  %br/
94
-  %del &lt;del&gt; deleted
95
-  %br/
96
-  %dfn &lt;dfn&gt; dfn
97
-  %br/
98
-  %em &lt;em&gt; emphasis
99
-  %br/
100
-
101
-%pre
102
-  %code
103
-    &lt;html&gt;
104
-    &lt;head&gt;
105
-    &lt;/head&gt;
106
-    &lt;body&gt;
107
-    &lt;div class = "main"&gt; &lt;div&gt;
108
-    &lt;/body&gt;
109
-    &lt;/html&gt;
110
-
111
-%tt
112
-  &lt;tt&gt;
113
-  Pellentesque tempor, dui ut ultrices viverra, neque urna blandit nisi, id accumsan dolor est vitae risus.
114
-%hr
115 1
\ No newline at end of file