Browse code

1. Added condition to full_url filter to allow it to be used as a root_url appending filter for remapping root "/" urls when octopress is deployed to a subdirectory. Updated _includes/article and _layouts/page to use the filter 2. Added documentation for the include_code plugin

Brandon Mathis authored on 21/07/2011 at 19:45:09
Showing 4 changed files
... ...
@@ -11,10 +11,10 @@
11 11
   </header>
12 12
 {% endunless %}
13 13
 {% if index %}
14
-  <div class="entry-content">{{ content | exerpt | smart_quotes }}</div>
14
+  <div class="entry-content">{{ content | full_urls: site.root | exerpt | smart_quotes }}</div>
15 15
   <footer>
16 16
     <a rel="full-article" href="{{ site.root }}{{ post.url }}">Read on &rarr;</a>
17 17
   </footer>
18 18
 {% else %}
19
-<div class="entry-content">{{ content | smart_quotes }}</div>
19
+<div class="entry-content">{{ content | full_urls: site.root | smart_quotes }}</div>
20 20
 {% endif %}
... ...
@@ -8,7 +8,7 @@ layout: default
8 8
     <h1 class="entry-title">{{ page.title | titlecase }}</h1>
9 9
     {% if page.date %}<p class="meta">{% include post/date.html %}</p>{% endif %}
10 10
   </header>
11
-  {{ content | smart_quotes }}
11
+  {{ content | full_urls: site.root | smart_quotes }}
12 12
   {% unless page.footer == false %}
13 13
     <footer>
14 14
       {% if page.date %}<p class="meta">{% include post/date.html %}</p>{% endif %}
... ...
@@ -21,6 +21,7 @@ module OctopressFilters
21 21
 
22 22
   # Replaces relative urls with full urls
23 23
   def full_urls(input, url='')
24
+    url ||= ''
24 25
     input.gsub /(\s+(href|src)\s*=\s*["|']{1})(\/[^\"'>]+)/ do
25 26
       $1+url+$3
26 27
     end
... ...
@@ -5,13 +5,20 @@
5 5
 #
6 6
 # Syntax {% include_code path/to/file %}
7 7
 #
8
-# Example:
8
+# Example 1:
9 9
 # {% include_code javascripts/test.js %}
10 10
 #
11 11
 # This will import test.js from source/downloads/code/javascripts/test.js
12 12
 # and output the contents in a syntax highlighted code block inside a figure,
13 13
 # with a figcaption listing the file name and download link
14 14
 #
15
+# Example 2:
16
+# You can also include an optional title for the <figcaption>
17
+#
18
+# {% include_code Example 2 javascripts/test.js %}
19
+#
20
+# will output a figcaption with the title: Example 2 (test.js)
21
+#
15 22
 
16 23
 require 'pathname'
17 24