mirror of
https://github.com/kremalicious/blog.git
synced 2024-11-22 01:46:51 +01:00
handle WP more tag if present in some posts
This commit is contained in:
parent
4b84d6a19c
commit
a0b9c5b1ec
32
_src/_plugins/octopress_filters.rb
Normal file
32
_src/_plugins/octopress_filters.rb
Normal file
@ -0,0 +1,32 @@
|
||||
# Filters taken from the Octopress project by Brandon Mathis.
|
||||
# https://github.com/imathis/octopress/blob/master/plugins/octopress_filters.rb
|
||||
module Jekyll
|
||||
|
||||
module Filters
|
||||
|
||||
# Used on the blog index to split posts on the <!--more--> marker
|
||||
def excerpt(input)
|
||||
if input.index(/<!--\s*more\s*-->/i)
|
||||
input.split(/<!--\s*more\s*-->/i)[0]
|
||||
else
|
||||
input
|
||||
end
|
||||
end
|
||||
|
||||
# Checks for excerpts (helpful for template conditionals)
|
||||
def has_more(input)
|
||||
input =~ /<!--\s*more\s*-->/i ? true : false
|
||||
end
|
||||
|
||||
# Replaces relative urls with full urls
|
||||
def expand_urls(input, url='')
|
||||
url ||= '/'
|
||||
input.gsub /(\s+(href|src)\s*=\s*["|']{1})(\/[^\"'>]*)/ do
|
||||
$1+url+$3
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
Liquid::Template.register_filter(Jekyll::Filters)
|
@ -18,6 +18,8 @@ And it looks gorgeous. Here's a detail screenshot of the admin area in 3.4 in fu
|
||||
|
||||
![](/media/wp34_retina_icons.png)
|
||||
|
||||
<!-- more -->
|
||||
|
||||
So if you're a plugin developer you absolutely want to make sure to include retina assets for your plugin, like a double sized admin menu icon.
|
||||
|
||||
There's just one problem: WordPress doesn't include anything to make this easy for developers. The functions `register_post_type()` and `add_menu_page()` only allow you to define one image as menu icon which then gets inserted as `img` tag.
|
||||
|
@ -16,9 +16,9 @@ post_format:
|
||||
Couldn't agree more:
|
||||
|
||||
> People. 140-character messages. That’s Twitter.
|
||||
|
||||
So simple. So powerful. So fragile.
|
||||
|
||||
So leave it alone. We’re talking. Don’t interrupt.
|
||||
>
|
||||
> So simple. So powerful. So fragile.
|
||||
>
|
||||
> So leave it alone. We’re talking. Don’t interrupt.
|
||||
|
||||
But just rebuilding Twitter before it gets more "richer stories" and crammed by ads probably won't help: [We could build an open Twitter, but would anyone use it?](http://gigaom.com/2012/07/04/we-could-build-an-open-twitter-but-would-anyone-use-it/)
|
||||
|
@ -54,7 +54,13 @@ description: 'Blog of designer & developer Matthias Kretschmann'
|
||||
</a>
|
||||
{% endif %}
|
||||
|
||||
{{ post.excerpt }}
|
||||
{% capture has_more %}{{ post.content | has_more }}{% endcapture %}
|
||||
|
||||
{% if has_more == 'true' %}
|
||||
{{ post.content | post.excerpt | excerpt }}
|
||||
{% else %}
|
||||
{{ post.excerpt }}
|
||||
{% endif %}
|
||||
|
||||
<a class="more-link" href="{{ post.url }}">Continue reading <i class="icon-arrow-right"></i></a>
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user