Browse Source

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
unreleased_contents
Brandon Mathis 13 years ago
parent
commit
44e1351fc7
  1. 4
      .themes/classic/source/_includes/article.html
  2. 2
      .themes/classic/source/_layouts/page.html
  3. 1
      plugins/custom_filters.rb
  4. 9
      plugins/include_code.rb

4
.themes/classic/source/_includes/article.html

@ -11,10 +11,10 @@
</header> </header>
{% endunless %} {% endunless %}
{% if index %} {% if index %}
<div class="entry-content">{{ content | exerpt | smart_quotes }}</div> <div class="entry-content">{{ content | full_urls: site.root | exerpt | smart_quotes }}</div>
<footer> <footer>
<a rel="full-article" href="{{ site.root }}{{ post.url }}">Read on &rarr;</a> <a rel="full-article" href="{{ site.root }}{{ post.url }}">Read on &rarr;</a>
</footer> </footer>
{% else %} {% else %}
<div class="entry-content">{{ content | smart_quotes }}</div> <div class="entry-content">{{ content | full_urls: site.root | smart_quotes }}</div>
{% endif %} {% endif %}

2
.themes/classic/source/_layouts/page.html

@ -8,7 +8,7 @@ layout: default
<h1 class="entry-title">{{ page.title | titlecase }}</h1> <h1 class="entry-title">{{ page.title | titlecase }}</h1>
{% if page.date %}<p class="meta">{% include post/date.html %}</p>{% endif %} {% if page.date %}<p class="meta">{% include post/date.html %}</p>{% endif %}
</header> </header>
{{ content | smart_quotes }} {{ content | full_urls: site.root | smart_quotes }}
{% unless page.footer == false %} {% unless page.footer == false %}
<footer> <footer>
{% if page.date %}<p class="meta">{% include post/date.html %}</p>{% endif %} {% if page.date %}<p class="meta">{% include post/date.html %}</p>{% endif %}

1
plugins/custom_filters.rb

@ -21,6 +21,7 @@ module OctopressFilters
# Replaces relative urls with full urls # Replaces relative urls with full urls
def full_urls(input, url='') def full_urls(input, url='')
url ||= ''
input.gsub /(\s+(href|src)\s*=\s*["|']{1})(\/[^\"'>]+)/ do input.gsub /(\s+(href|src)\s*=\s*["|']{1})(\/[^\"'>]+)/ do
$1+url+$3 $1+url+$3
end end

9
plugins/include_code.rb

@ -5,13 +5,20 @@
# #
# Syntax {% include_code path/to/file %} # Syntax {% include_code path/to/file %}
# #
# Example: # Example 1:
# {% include_code javascripts/test.js %} # {% include_code javascripts/test.js %}
# #
# This will import test.js from source/downloads/code/javascripts/test.js # This will import test.js from source/downloads/code/javascripts/test.js
# and output the contents in a syntax highlighted code block inside a figure, # and output the contents in a syntax highlighted code block inside a figure,
# with a figcaption listing the file name and download link # with a figcaption listing the file name and download link
# #
# Example 2:
# You can also include an optional title for the <figcaption>
#
# {% include_code Example 2 javascripts/test.js %}
#
# will output a figcaption with the title: Example 2 (test.js)
#
require 'pathname' require 'pathname'

Loading…
Cancel
Save