mirror of
https://github.com/moparisthebest/android.moparisthebest.org
synced 2024-12-24 08:28:50 -05:00
Finally a nice solution for mapping relative urls
This commit is contained in:
parent
44e1351fc7
commit
39d56bc988
@ -1,5 +1,5 @@
|
|||||||
{% capture category %}{{ post.categories | size }}{% endcapture %}
|
{% capture category %}{{ post.categories | size }}{% endcapture %}
|
||||||
<h1><a href="{{ site.root }}{{ post.url }}">{{post.title}}</a></h1>
|
<h1><a href="{{ root_url }}{{ post.url }}">{{post.title}}</a></h1>
|
||||||
<time datetime="{{ post.date | datetime }}" pubdate>{{ post.date | date: "<span class='month'>%b</span> <span class='day'>%d</span> <span class='year'>%Y</span>"}}</time>
|
<time datetime="{{ post.date | datetime }}" pubdate>{{ post.date | date: "<span class='month'>%b</span> <span class='day'>%d</span> <span class='year'>%Y</span>"}}</time>
|
||||||
{% if category != '0' %}
|
{% if category != '0' %}
|
||||||
<footer>
|
<footer>
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
{% unless page.no_header %}
|
{% unless page.no_header %}
|
||||||
<header>
|
<header>
|
||||||
{% if index %}
|
{% if index %}
|
||||||
<h1 class="entry-title"><a href="{{ site.root }}{{ post.url }}">{{ post.title | titlecase }}</a></h1>
|
<h1 class="entry-title"><a href="{{ root_url }}{{ post.url }}">{{ post.title | titlecase }}</a></h1>
|
||||||
{% else %}
|
{% else %}
|
||||||
<h1 class="entry-title">{{ page.title | titlecase }}</h1>
|
<h1 class="entry-title">{{ page.title | titlecase }}</h1>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
@ -11,10 +11,10 @@
|
|||||||
</header>
|
</header>
|
||||||
{% endunless %}
|
{% endunless %}
|
||||||
{% if index %}
|
{% if index %}
|
||||||
<div class="entry-content">{{ content | full_urls: site.root | exerpt | smart_quotes }}</div>
|
<div class="entry-content">{{ content | exerpt }}</div>
|
||||||
<footer>
|
<footer>
|
||||||
<a rel="full-article" href="{{ site.root }}{{ post.url }}">Read on →</a>
|
<a rel="full-article" href="{{ root_url }}{{ post.url }}">Read on →</a>
|
||||||
</footer>
|
</footer>
|
||||||
{% else %}
|
{% else %}
|
||||||
<div class="entry-content">{{ content | full_urls: site.root | smart_quotes }}</div>
|
<div class="entry-content">{{ content }}</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -12,7 +12,7 @@
|
|||||||
var pinboardInit = document.createElement('script');
|
var pinboardInit = document.createElement('script');
|
||||||
pinboardInit.type = 'text/javascript';
|
pinboardInit.type = 'text/javascript';
|
||||||
pinboardInit.async = true;
|
pinboardInit.async = true;
|
||||||
pinboardInit.src = '{{ site.root }}/javascripts/pinboard.js';
|
pinboardInit.src = '{{ root_url }}/javascripts/pinboard.js';
|
||||||
document.getElementsByTagName('head')[0].appendChild(pinboardInit);
|
document.getElementsByTagName('head')[0].appendChild(pinboardInit);
|
||||||
})();
|
})();
|
||||||
</script>
|
</script>
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
<ul id="recent_posts">
|
<ul id="recent_posts">
|
||||||
{% for post in site.posts limit: site.recent_posts %}
|
{% for post in site.posts limit: site.recent_posts %}
|
||||||
<li class="post">
|
<li class="post">
|
||||||
<a href="{{ site.root }}{{ post.url }}">{{ post.title }}</a>
|
<a href="{{ root_url }}{{ post.url }}">{{ post.title }}</a>
|
||||||
</li>
|
</li>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
getTwitterFeed("{{site.twitter_user}}", {{site.twitter_tweet_count}}, {{site.twitter_show_replies}});
|
getTwitterFeed("{{site.twitter_user}}", {{site.twitter_tweet_count}}, {{site.twitter_show_replies}});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<script src="{{ site.root }}/javascripts/twitter.js" type="text/javascript"> </script>
|
<script src="{{ root_url }}/javascripts/twitter.js" type="text/javascript"> </script>
|
||||||
{% if site.twitter_follow_button %}
|
{% if site.twitter_follow_button %}
|
||||||
<a href="http://twitter.com/{{ site.twitter_user }}" class="twitter-follow-button" data-width="208px" data-show-count="{{ site.twitter_show_follower_count }}">Follow @{{ site.twitter_user }}</a>
|
<a href="http://twitter.com/{{ site.twitter_user }}" class="twitter-follow-button" data-width="208px" data-show-count="{{ site.twitter_show_follower_count }}">Follow @{{ site.twitter_user }}</a>
|
||||||
{% else %}
|
{% else %}
|
||||||
|
@ -19,14 +19,14 @@
|
|||||||
<meta name="keywords" content="{{page.keywords}}"/>
|
<meta name="keywords" content="{{page.keywords}}"/>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<link href="{{ site.root }}/favicon.png" rel="shortcut icon" />
|
<link href="{{ root_url }}/favicon.png" rel="shortcut icon" />
|
||||||
<link href="{{ site.root }}/stylesheets/screen.css" media="screen, projection" rel="stylesheet" type="text/css">
|
<link href="{{ root_url }}/stylesheets/screen.css" media="screen, projection" rel="stylesheet" type="text/css">
|
||||||
<script src="{{ site.root }}/javascripts/modernizr-2.0.js"></script>
|
<script src="{{ root_url }}/javascripts/modernizr-2.0.js"></script>
|
||||||
<script src="http://s3.amazonaws.com/ender-js/jeesh.min.js"></script>
|
<script src="http://s3.amazonaws.com/ender-js/jeesh.min.js"></script>
|
||||||
<script src="{{ site.root }}/javascripts/octopress.js" type="text/javascript"></script>
|
<script src="{{ root_url }}/javascripts/octopress.js" type="text/javascript"></script>
|
||||||
<link href='http://fonts.googleapis.com/css?family=PT+Serif:regular,italic,bold,bolditalic' rel='stylesheet' type='text/css'>
|
<link href='http://fonts.googleapis.com/css?family=PT+Serif:regular,italic,bold,bolditalic' rel='stylesheet' type='text/css'>
|
||||||
<link href='http://fonts.googleapis.com/css?family=PT+Sans:regular,italic,bold,bolditalic' rel='stylesheet' type='text/css'>
|
<link href='http://fonts.googleapis.com/css?family=PT+Sans:regular,italic,bold,bolditalic' rel='stylesheet' type='text/css'>
|
||||||
<link href="{{ site.root }}/atom.xml" rel="alternate" title="{{site.title}}" type="application/atom+xml"/>
|
<link href="{{ root_url }}/atom.xml" rel="alternate" title="{{site.title}}" type="application/atom+xml"/>
|
||||||
{% include google_analytics.html %}
|
{% include google_analytics.html %}
|
||||||
{% include google_plus_one.html %}
|
{% include google_plus_one.html %}
|
||||||
{% include twitter_sharing.html %}
|
{% include twitter_sharing.html %}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<hgroup>
|
<hgroup>
|
||||||
<h1><a href="{{ site.root }}/">{{ site.title }}</a></h1>
|
<h1><a href="{{ root_url }}/">{{ site.title }}</a></h1>
|
||||||
{% if site.subtitle %}
|
{% if site.subtitle %}
|
||||||
<h2>{{ site.subtitle }}</h2>
|
<h2>{{ site.subtitle }}</h2>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -6,11 +6,11 @@
|
|||||||
</ul>
|
</ul>
|
||||||
<form action="{{ site.simple_search }}" method="get">
|
<form action="{{ site.simple_search }}" method="get">
|
||||||
<fieldset role="site-search">
|
<fieldset role="site-search">
|
||||||
<input type="hidden" name="q" value="site:{{ site.url | search_url }}" />
|
<input type="hidden" name="q" value="site:{{ site.url | shorthand_url }}" />
|
||||||
<input class="search" type="text" name="q" results="0" placeholder="Search"/>
|
<input class="search" type="text" name="q" results="0" placeholder="Search"/>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</form>
|
</form>
|
||||||
<ul role="navigation">
|
<ul role=main-navigation>
|
||||||
<li><a href="{{ site.root }}/">Blog</a></li>
|
<li><a href="{{ root_url }}/">Blog</a></li>
|
||||||
<li><a href="{{ site.root }}/blog/archives">Archives</a></li>
|
<li><a href="{{ root_url }}/blog/archives">Archives</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
|
{% capture root_url %}{{ site.root | strip_slash }}{% endcapture %}
|
||||||
{% include head.html %}
|
{% include head.html %}
|
||||||
<body {% if page.body_id %} id="{{ page.body_id }}" {% endif %} {% if page.sidebar == false %} class="no-sidebar" {% endif %}>
|
<body {% if page.body_id %} id="{{ page.body_id }}" {% endif %} {% if page.sidebar == false %} class="no-sidebar" {% endif %}>
|
||||||
<header>{% include header.html %}</header>
|
<header>{% include header.html %}</header>
|
||||||
<nav>{% include navigation.html %}</nav>
|
<nav>{% include navigation.html %}</nav>
|
||||||
<div id="main">
|
<div id="main">
|
||||||
<div id="content">
|
<div id="content">
|
||||||
{{ content }}
|
{{ content | expand_urls: root_url | smart_quotes }}
|
||||||
{% unless page.sidebar == false %}
|
{% unless page.sidebar == false %}
|
||||||
<aside role=sidebar>{% include sidebar.html %}</aside>
|
<aside role=sidebar>{% include sidebar.html %}</aside>
|
||||||
{% endunless %}
|
{% endunless %}
|
||||||
|
@ -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 | full_urls: site.root | smart_quotes }}
|
{{ content }}
|
||||||
{% 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 %}
|
||||||
|
@ -14,13 +14,13 @@ footer: false
|
|||||||
<nav role="pagination">
|
<nav role="pagination">
|
||||||
<div>
|
<div>
|
||||||
{% if paginator.next_page %}
|
{% if paginator.next_page %}
|
||||||
<a class="prev" href="{{ site.root }}/page{{paginator.next_page}}/">← Older</a>
|
<a class="prev" href="/page{{paginator.next_page}}/">← Older</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
<a href="{{ site.root }}/blog/archives">Blog Archives</a>
|
<a href="/blog/archives">Blog Archives</a>
|
||||||
{% if paginator.previous_page and paginator.previous_page > 1 %}
|
{% if paginator.previous_page and paginator.previous_page > 1 %}
|
||||||
<a class="next" href="{{ site.root }}/page{{paginator.previous_page}}/">Newer →</a>
|
<a class="next" href="/page{{paginator.previous_page}}/">Newer →</a>
|
||||||
{% elsif paginator.previous_page %}
|
{% elsif paginator.previous_page %}
|
||||||
<a class="next" href="{{ site.root }}/">Newer →</a>
|
<a class="next" href="/">Newer →</a>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
|
@ -130,7 +130,7 @@ module Jekyll
|
|||||||
#
|
#
|
||||||
def category_links(categories)
|
def category_links(categories)
|
||||||
dir = @context.registers[:site].config['category_dir']
|
dir = @context.registers[:site].config['category_dir']
|
||||||
root_url = @context.registers[:site].config['root']
|
root_url = @context.registers[:site].config['root'].sub(/\/$/, '')
|
||||||
categories = categories.sort!.map do |item|
|
categories = categories.sort!.map do |item|
|
||||||
"<a class='category' href='#{root_url}/#{dir}/#{item.gsub(/_|\W/, '-')}/'>#{item}</a>"
|
"<a class='category' href='#{root_url}/#{dir}/#{item.gsub(/_|\W/, '-')}/'>#{item}</a>"
|
||||||
end
|
end
|
||||||
|
@ -20,15 +20,23 @@ module OctopressFilters
|
|||||||
end
|
end
|
||||||
|
|
||||||
# Replaces relative urls with full urls
|
# Replaces relative urls with full urls
|
||||||
def full_urls(input, url='')
|
def expand_urls(input, url='')
|
||||||
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
|
||||||
end
|
end
|
||||||
|
|
||||||
# Returns a url without the http:// for use in as a search modifier eg. 'search terms site:website.com'
|
# Removes trailing forward slash from a string for easily appending url segments
|
||||||
def search_url(input)
|
def strip_slash(input)
|
||||||
|
if input =~ /(.+)\/$|^\/$/
|
||||||
|
input = $1
|
||||||
|
end
|
||||||
|
input
|
||||||
|
end
|
||||||
|
|
||||||
|
# Returns a url without the protocol (http://)
|
||||||
|
def shorthand_url(input)
|
||||||
input.gsub /(https?:\/\/)(\S+)/ do
|
input.gsub /(https?:\/\/)(\S+)/ do
|
||||||
$2
|
$2
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user