Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix broken links and use uri() methods in the templates #37

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/PearlBee/Helpers/Util.pm
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,8 @@ sub map_posts {
'id', 'slug',
'description', 'cover',
'created_date', 'status',
'user_id', 'nr_of_comments'
'user_id', 'nr_of_comments',
'uri', 'edit_uri',
);

# extract a sample from the content (first words)
Expand Down
2 changes: 1 addition & 1 deletion lib/PearlBee/Model/Schema/Result/Category.pm
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ sub safe_cascade_delete {
}

sub uri {
'/posts/category/' . $_[0]->slug . ( $PearlBee::is_static && '.html ' );
'/category/' . $_[0]->slug . ( $PearlBee::is_static && '.html ' );
}

sub edit_uri { '/dashboard/categories/edit/' . $_[0]->id }
Expand Down
2 changes: 1 addition & 1 deletion lib/PearlBee/Model/Schema/Result/Tag.pm
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ __PACKAGE__->many_to_many( "posts", "post_tags", "post" );

# You can replace this text with custom code or comments, and it will be preserved on regeneration

sub uri { '/posts/tag/' . $_[0]->slug . ( $PearlBee::is_static && '.html ' ) }
sub uri { '/tag/' . $_[0]->slug . ( $PearlBee::is_static && '.html ' ) }

sub edit_uri { '/dashboard/tags/edit/' . $_[0]->id }

Expand Down
2 changes: 1 addition & 1 deletion lib/PearlBee/Model/Schema/Result/User.pm
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ sub allow {
}

sub uri {
'/posts/user/' . $_[0]->username . ( $PearlBee::is_static && '.html ' );
'/author/' . $_[0]->username . ( $PearlBee::is_static && '.html ' );
}

1;
6 changes: 3 additions & 3 deletions views/admin/comments/list.tt
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,14 @@
[% END %]
</td>

<td width="15%"> <a href="/posts/[% comment.post.slug %]"> [% comment.post.title %] </a> </td>
<td width="15%"> <a href="[% comment.post.uri %]"> [% comment.post.title %] </a> </td>

<td width="10%">
[% IF comment.reply_to %]
<a href="/posts/[% comment.post.slug %]#comment_[% comment.reply_to %]"> Reply </a>
<a href="[% comment.post.uri %]#comment_[% comment.reply_to %]"> Reply </a>
[% ELSE %]
[% IF comment.status == 'approved' %]
<a href="/posts/[% comment.post.slug %]#comment_[% comment.id %]"> Comment </a>
<a href="[% comment.post.uri %]#comment_[% comment.id %]"> Comment </a>
[% ELSE %]
Comment
[% END %]
Expand Down
14 changes: 7 additions & 7 deletions views/admin/posts/list.tt
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@

<tr>
<td width="20%">
<b> <i class="icon-user"></i> <a href="/posts/user/[% post.user.username %]">[% post.user.username %]</a></b>
<b> <i class="icon-user"></i> <a href="[% post.user.uri %]">[% post.user.username %]</a></b>
<br />
<b> [% post.user.first_name %] [% post.user.last_name %] </b>
<br />
<i> [% post.created_date %] </i>
</td>

<td width="25%">
<b> <a href="/posts/[% post.slug %]"> [% post.title %] </a> </b>
<b> <a href="[% post.uri %]"> [% post.title %] </a> </b>
<br />
<br />

Expand Down Expand Up @@ -78,23 +78,23 @@

<td>
[% FOREACH post_category IN post.post_categories %]
<a href="/posts/category/[% post_category.category.slug %]"> [% post_category.category.name %] </a>
<a href="[% post_category.category.uri %]"> [% post_category.category.name %] </a>
[% END %]
</td>

<td width="5%">
[% FOREACH post_tag IN post.post_tags %]
<a href="/posts/tag/[% post_tag.tag.slug %]"> [% post_tag.tag.name %] </a>
<a href="[% post_tag.tag.uri %]"> [% post_tag.tag.name %] </a>
[% END %]
</td>

<td width="5">
<a href="/posts/[% post.slug %]#comments"> [% post.nr_of_comments %] </a>
<a href="[% post.uri %]#comments"> [% post.nr_of_comments %] </a>
</td>

<td width="10%">
<a href="/posts/[% post.slug %]"> <button class="btn btn-xs btn-success"><i class="icon-eye-open"></i> </button> </a>
<a href="/dashboard/posts/edit/[% post.slug %]"> <button class="btn btn-xs btn-warning"><i class="icon-pencil"></i> </button> </a>
<a href="[% post.uri %]"> <button class="btn btn-xs btn-success"><i class="icon-eye-open"></i> </button> </a>
<a href="[% post.edit_uri %]"> <button class="btn btn-xs btn-warning"><i class="icon-pencil"></i> </button> </a>
</td>
</tr>

Expand Down
2 changes: 1 addition & 1 deletion views/comments/builtin/comment_form.tt
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
[% IF vars.user.username %]

<div class="form-group">
Comment as <b><i class="icon-user"></i> <a href="/posts/user/[% vars.user.username %]">[% vars.user.username %]</a></b>
Comment as <b><i class="icon-user"></i> <a href="[% vars.user.uri %]">[% vars.user.username %]</a></b>
<input type="hidden" name="comment_as" email" value="[% vars.user.id %]" />
</div>

Expand Down
4 changes: 2 additions & 2 deletions views/comments/builtin/list_comments.tt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
</div>
[% ELSE %]
<div class="comment-author comment-author-registered">
<i class="icon-user"></i> <a href="/posts/user/[% comment.uid.username %][% settings.static && '.html' %]" >[% comment.uid.username %]</a>
<i class="icon-user"></i> <a href="[% comment.uid.uri %]" >[% comment.uid.username %]</a>
</div>
[% END %]

Expand Down Expand Up @@ -50,7 +50,7 @@
</div>
[% ELSE %]
<div class="comment-author comment-author-registered">
<i class="icon-user"></i> <a href="/posts/user/[% reply.uid.username %][% settings.static && '.html' %]" >[% reply.uid.username %]</a>
<i class="icon-user"></i> <a href="[% reply.uid.uri %]" >[% reply.uid.username %]</a>
</div>
[% END %]

Expand Down
8 changes: 4 additions & 4 deletions views/index.tt
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,20 @@
[% END %]
[% FOREACH post in posts %]
<div class="entry">
<h2><a href="/posts/[% post.slug %][% settings.static && '.html' %]">[% post.title %]</a></h2>
<h2><a href="[% post.uri %]">[% post.title %]</a></h2>

<!-- Meta details -->
<div class="meta">
<div class="block_elements">
<i class="icon-calendar"></i> [% post.created_date %]
</div>
<div class="block_elements">
<i class="icon-user"></i> <a href="/posts/user/[% post.user.username %][% settings.static && '.html' %]">[% post.user.username %]</a>
<i class="icon-user"></i> <a href="[% post.user.uri %]">[% post.user.username %]</a>
</div>

[% FOREACH category in post.post_categories %]
<div class="block_elements">
<i class="icon-list"></i> <a href="[% session.app_url %]/posts/category/[% category.category.slug %][% settings.static && '.html' %]">[% category.category.name %]</a>
<i class="icon-list"></i> <a href="[% category.category.uri %]">[% category.category.name %]</a>
</div>
[% END %]

Expand All @@ -61,7 +61,7 @@
</div>

<!-- Read more -->
<a href="[% session.app_url %]/posts/[% post.slug %][% settings.static && '.html' %]" class="btn btn-info">Read More...</a>
<a href="[% post.uri %]" class="btn btn-info">Read More...</a>
</div>
[% END %]
[% IF posts.first %]
Expand Down
4 changes: 2 additions & 2 deletions views/post.tt
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
<i class="icon-calendar"></i> [% post.created_date %]
</div>
<div class="block_elements">
<i class="icon-user"></i> <a href="/posts/user/[% post.user.username %][% settings.static && '.html' %]">[% post.user.username %]</a>
<i class="icon-user"></i> <a href="[% post.user.uri %]">[% post.user.username %]</a>
</div>

[% FOREACH category in post.post_categories %]
<div class="block_elements">
<i class="icon-list"></i> <a href="[% session.app_url %]/posts/category/[% category.category.slug %][% settings.static && '.html' %]">[% category.category.name %]</a>
<i class="icon-list"></i> <a href="[% category.category.uri %]">[% category.category.name %]</a>
</div>
[% END %]

Expand Down
10 changes: 5 additions & 5 deletions views/post_sidebar.tt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<h4> Categories </h4>
<ul class="simple-list">
[% FOREACH category in categories %]
<li><a href="[% session.app_url %]/posts/category/[% category.slug %][% settings.static && '.html' %]"> [% category.name %] </a></li>
<li><a href="[% category.uri %]"> [% category.name %] </a></li>
[% END %]
</ul>
</div>
Expand All @@ -16,14 +16,14 @@
<div class="tab-pane fade in active" id="recent">
<ul class="simple-list">
[% FOREACH recent_post in recent %]
<li><a href="[% session.app_url %]/posts/[% recent_post.slug %][% settings.static && '.html' %]">[% recent_post.title %]</a></li>
<li><a href="[% recent_post.uri %]">[% recent_post.title %]</a></li>
[% END %]
</ul>
</div>
<div class="tab-pane fade" id="popular">
<ul class="simple-list">
[% FOREACH popular_post in popular %]
<li><a href="[% session.app_url %]/posts/[% popular_post.slug %][% settings.static && '.html' %]">[% popular_post.title %]</a></li>
<li><a href="[% popular_post.uri %]">[% popular_post.title %]</a></li>
[% END %]
</ul>
</div>
Expand All @@ -33,9 +33,9 @@
<h4 class="widget-head">Tags</h4>
<ul id="tag-list" class="cf">
[% FOREACH tag in post.post_tags %]
<li><a class="btn btn-info" href="[% session.app_url %]/posts/tag/[% tag.tag.slug %][% settings.static && '.html' %]">[% tag.tag.name %]</a></li>
<li><a class="btn btn-info" href="[% tag.tag.uri %]">[% tag.tag.name %]</a></li>
[% END %]
</ul>
</div>
</div>
</div>
</div>
10 changes: 5 additions & 5 deletions views/sidebar.tt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<h4> Categories </h4>
<ul class="simple-list">
[% FOREACH category in categories %]
<li><a href="[% session.app_url %]/posts/category/[% category.slug %]"> [% category.name %] </a></li>
<li><a href="[% category.uri %]"> [% category.name %] </a></li>
[% END %]
</ul>
</div>
Expand All @@ -16,14 +16,14 @@
<div class="tab-pane fade in active" id="recent">
<ul class="simple-list">
[% FOREACH post in recent %]
<li><a href="[% session.app_url %]/posts/[% post.slug %][% settings.static && '.html' %]">[% post.title %]</a></li>
<li><a href="[% post.uri %]">[% post.title %]</a></li>
[% END %]
</ul>
</div>
<div class="tab-pane fade" id="popular">
<ul class="simple-list">
[% FOREACH post in popular %]
<li><a href="[% session.app_url %]/posts/[% post.slug %][% settings.static && '.html' %]">[% post.title %]</a></li>
<li><a href="[% post.uri %]">[% post.title %]</a></li>
[% END %]
</ul>
</div>
Expand All @@ -32,8 +32,8 @@
<h4 class="widget-head">Tags</h4>
<ul id="tag-list" class="cf">
[% FOREACH tag in tags %]
<li><a href="[% session.app_url %]/posts/tag/[% tag.slug %][% settings.static && '.html' %]me %]</a></li>
<li><a href="[% tag.uri %]">[% tag.name %]</a></li>
[% END %]
</ul>
</div>
</div>
</div>