Skip to content
This repository has been archived by the owner on Mar 17, 2020. It is now read-only.

Commit

Permalink
Add trailing slashes to URL re: #5 & improve readability of tempaltes.
Browse files Browse the repository at this point in the history
  • Loading branch information
douglatornell committed Nov 17, 2012
1 parent 8c63e46 commit 35034a1
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 27 deletions.
5 changes: 3 additions & 2 deletions blogofile_blog/site_src/_controllers/blog/post.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def __parse_yaml(self, yaml_src):

def permapath(self):
"""Get just the path portion of a permalink"""
return urlparse(self.permalink)[2]
return urlparse(self.permalink)[2] + "/"

def __cmp__(self, other_post):
"Posts should be comparable by date"
Expand All @@ -304,7 +304,8 @@ def __init__(self, name):
self.path = bf.util.site_path_helper(
blog_config.path,
blog_config.category_dir,
self.url_name)
self.url_name,
trailing_slash=True)

def __hash__(self):
return hash(self.name)
Expand Down
10 changes: 5 additions & 5 deletions blogofile_blog/site_src/_templates/blog/archive_index.mako
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<%inherit file="bf_base_template" />
% for posts in month_posts:
%for posts in month_posts:
<h1>${posts[0].date.strftime("%B %Y")}</h1>
<ul>
% for post in posts:
<li><a href="${post.permapath()}">${post.title}</a></li>
% endfor
%for post in posts:
<li><a href="${post.path}">${post.title}</a></li>
%endfor
</ul>
% endfor
%endfor
25 changes: 19 additions & 6 deletions blogofile_blog/site_src/_templates/head.mako
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,29 @@
%if bf.config.site.author:
<meta name="author" content="${bf.config.site.author}">
%endif
<link rel="alternate" type="application/rss+xml" title="RSS 2.0" href="${bf.util.site_path_helper(bf.config.blog.path,'/feed')}" />
<link rel="alternate" type="application/atom+xml" title="Atom 1.0" href="${bf.util.site_path_helper(bf.config.blog.path,'/feed/atom')}" />

<link rel="alternate" type="application/rss+xml" title="RSS 2.0"
href="${bf.util.site_path_helper(
bf.config.blog.path, '/feed',trailing_slash=True)}">
<link rel="alternate" type="application/atom+xml" title="Atom 1.0"
href="${bf.util.site_path_helper(
bf.config.blog.path, '/feed/atom', trailing_slash=True)}">

<link rel="shortcut icon" href="${bf.util.site_path_helper('favicon.ico')}">
<link rel="apple-touch-icon" href="${bf.util.site_path_helper('img/apple-touch-icon.png')}">
<link rel="apple-touch-icon"
href="${bf.util.site_path_helper('img/apple-touch-icon.png')}">

<link rel="stylesheet" href="${bf.util.site_path_helper('css/base.css?v=1')}">
<link rel="stylesheet" href="${bf.util.site_path_helper('css/grid.css?v=1')}">
<link rel="stylesheet" media="handheld" href="${bf.util.site_path_helper('/css/handheld.css?v=1')}">
<link rel="stylesheet" href="${bf.util.site_path_helper(bf.config.filters.syntax_highlight.css_dir,'/pygments_'+bf.config.filters.syntax_highlight.style+'.css')}" type="text/css" />
<link rel="stylesheet" media="handheld"
href="${bf.util.site_path_helper('/css/handheld.css?v=1')}">
<link rel="stylesheet"
href="${bf.util.site_path_helper(
bf.config.filters.syntax_highlight.css_dir,' /pygments_'
+ bf.config.filters.syntax_highlight.style+'.css')}">

<script src="${bf.util.site_path_helper('js/libs/modernizr-1.7.min.js')}"></script>
<script
src="${bf.util.site_path_helper('js/libs/modernizr-1.7.min.js')}">
</script>

<%include file="theme.mako"/>
54 changes: 40 additions & 14 deletions blogofile_blog/site_src/_templates/header.mako
Original file line number Diff line number Diff line change
@@ -1,23 +1,49 @@
<header>
<div id="header" class="header_gradient theme_font">
<h1><a href="${bf.util.site_path_helper()}">${bf.config.blog.name}</a></h1>
<h1>
<a href="${bf.util.site_path_helper(trailing_slash=True)}">
${bf.config.blog.name}
</a>
</h1>
<h2>${bf.config.blog.description}</h2>
</div>
<div id="navigation" class="grid_12">
<%
def nav_class(path):
render_path = bf.template_context.render_path.rsplit("/index.html")[0]
if render_path == path or (path == "/" and render_path == "."):
return "selected"
return ""
%>
<%
def nav_class(path):
render_path = bf.template_context.render_path.rsplit("index.html")[0]
if path == "/" and render_path == "./":
return "selected"
elif render_path == path or "/" + render_path == path:
return "selected"
else:
return ""
%>
<%
def blog_nav_class():
render_path = bf.template_context.render_path
if render_path.startswith("/blog/") and "archive" not in render_path:
return "selected"
return ""
%>
<ul class="theme_font">
<li><a href="${bf.util.site_path_helper()}"
class="${nav_class(bf.util.site_path_helper())}">Home</a></li>
<li><a href="${bf.util.site_path_helper(bf.config.blog.path)}"
class="${nav_class(bf.util.site_path_helper(bf.config.blog.path))}">Blog</a></li>
<li><a href="${bf.util.site_path_helper(bf.config.blog.path,'archive')}"
class="${nav_class(bf.util.site_path_helper(bf.config.blog.path,'archive'))}">Archives</a></li>
<li>
<% path = bf.util.site_path_helper(trailing_slash=True) %>
<a href="${path}" class="${nav_class(path)}">Home</a>
</li>
<li>
<%
path = bf.util.site_path_helper(
bf.config.blog.path)
%>
<a href="${path}" class="${blog_nav_class()}">Blog</a>
</li>
<li>
<%
path = bf.util.site_path_helper(
bf.config.blog.path, "archive", trailing_slash=True)
%>
<a href="${path}" class="${nav_class(path)}">Archives</a>
</li>
</ul>
</div>
</header>

0 comments on commit 35034a1

Please sign in to comment.