Browse code

added support for preserving customized source/index.html during template updates. Moved the blog index code to a partial in source/_includes/blog_index.html

Brandon Mathis authored on 10/08/2011 at 22:14:56
Showing 3 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,40 @@
0
+<div class="blog-index">
1
+{% assign index = true %}
2
+{% for post in paginator.posts %}
3
+{% assign content = post.content %}
4
+  <article>
5
+    {% include article.html %}
6
+  </article>
7
+{% endfor %}
8
+<nav role="pagination">
9
+  <div>
10
+    {% if paginator.next_page %}
11
+      <a class="prev" href="/page{{paginator.next_page}}/">&larr; Older</a>
12
+    {% endif %}
13
+    <a href="/blog/archives">Blog Archives</a>
14
+    {% if paginator.previous_page and paginator.previous_page > 1 %}
15
+      <a class="next" href="/page{{paginator.previous_page}}/">Newer &rarr;</a>
16
+    {% elsif paginator.previous_page %}
17
+      <a class="next" href="/">Newer &rarr;</a>
18
+    {% endif %}
19
+  </div>
20
+</nav>
21
+{% if site.disqus_short_name %}
22
+<script type="text/javascript">
23
+    var disqus_shortname = '{{ site.disqus_short_name }}';
24
+    (function () {
25
+      var s = document.createElement('script'); s.async = true;
26
+      s.type = 'text/javascript';
27
+      s.src = 'http://' + disqus_shortname + '.disqus.com/count.js';
28
+      (document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
29
+    }());
30
+</script>
31
+{% endif %}
32
+</div>
33
+<aside role=sidebar>
34
+  {% if site.blog_index_asides.size %}
35
+    {% include_array blog_index_asides %}
36
+  {% else %}
37
+    {% include_array default_asides %}
38
+  {% endif %}
39
+</aside>
... ...
@@ -1,44 +1,5 @@
1 1
 ---
2 2
 layout: default
3
-footer: false
4 3
 ---
5
-<div class="blog-index">
6
-{% assign index = true %}
7
-{% for post in paginator.posts %}
8
-{% assign content = post.content %}
9
-  <article>
10
-    {% include article.html %}
11
-  </article>
12
-{% endfor %}
13
-<nav role="pagination">
14
-  <div>
15
-    {% if paginator.next_page %}
16
-      <a class="prev" href="/page{{paginator.next_page}}/">&larr; Older</a>
17
-    {% endif %}
18
-    <a href="/blog/archives">Blog Archives</a>
19
-    {% if paginator.previous_page and paginator.previous_page > 1 %}
20
-      <a class="next" href="/page{{paginator.previous_page}}/">Newer &rarr;</a>
21
-    {% elsif paginator.previous_page %}
22
-      <a class="next" href="/">Newer &rarr;</a>
23
-    {% endif %}
24
-  </div>
25
-</nav>
26
-{% if site.disqus_short_name %}
27
-<script type="text/javascript">
28
-    var disqus_shortname = '{{ site.disqus_short_name }}';
29
-    (function () {
30
-      var s = document.createElement('script'); s.async = true;
31
-      s.type = 'text/javascript';
32
-      s.src = 'http://' + disqus_shortname + '.disqus.com/count.js';
33
-      (document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
34
-    }());
35
-</script>
36
-{% endif %}
37
-</div>
38
-<aside role=sidebar>
39
-  {% if site.blog_index_asides.size %}
40
-    {% include_array blog_index_asides %}
41
-  {% else %}
42
-    {% include_array default_asides %}
43
-  {% endif %}
44
-</aside>
4
+
5
+{% include blog_index.html %}
... ...
@@ -1,6 +1,10 @@
1 1
 require "rubygems"
2 2
 require "bundler/setup"
3 3
 
4
+# If you customize your site's index page setting custom_index to true
5
+# will preserve your changes when running `rake update_source`
6
+custom_index = false
7
+
4 8
 ## -- Rsync Deploy config -- ##
5 9
 # Be sure your public key is listed in your server's ~/.ssh/authorized_keys file
6 10
 ssh_user       = "user@domain.com"
... ...
@@ -150,6 +154,7 @@ task :update_source, :theme do |t, args|
150 150
   system "mkdir -p #{source_dir}; cp -R #{themes_dir}/"+theme+"/source/. #{source_dir}"
151 151
   system "cp -Rn #{source_dir}.old/. #{source_dir}"
152 152
   system "cp -Rf #{source_dir}.old/_includes/custom/. #{source_dir}/_includes/custom/"
153
+  system "cp -Rf #{source_dir}.old/index.html #{source_dir}" if custom_index
153 154
   puts "## Updated #{source_dir} ##"
154 155
 end
155 156