Skip to content

Commit

Permalink
Refactor and clean up views
Browse files Browse the repository at this point in the history
  • Loading branch information
Trung Lê committed Aug 27, 2012
1 parent 5a045bd commit c4d976b
Show file tree
Hide file tree
Showing 9 changed files with 65 additions and 46 deletions.
5 changes: 4 additions & 1 deletion app/views/archives/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<% content_for(:page_title) do %><%= archives_title %><% end -%>
<% content_for(:page_title) do -%>
<%= archives_title %>
<% end -%>

<h2>Archives</h2>

<% if @months.empty? -%>
Expand Down
4 changes: 2 additions & 2 deletions app/views/comments/_comment.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<cite><%= author_link(comment) %></cite> says:
<br>
<br/>
<small class="commentmetadata"><a href="#comment-<%= comment.id %>" title=""><%= format_comment_date(comment.created_at) %></a></small>
<p><%=raw comment.body_html %></p>
<p><%== comment.body_html %></p>
10 changes: 5 additions & 5 deletions app/views/layouts/admin.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
<%= yield(:head) %>
<% if flash[:notice] -%>
<script>
jQuery(document).ready(function() {
humanMsg.displayMsg('<%= escape_javascript(flash[:notice]) %>');
})
</script>
<%= javascript_tag do -%>
$(function() {
humanMsg.displayMsg('<%= escape_javascript(flash[:notice]) %>');
})
<% end -%>
<% end -%>

</head>
Expand Down
4 changes: 1 addition & 3 deletions app/views/layouts/login.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
<html dir="ltr" lang="en-US">
<head>
<meta charset="utf-8">

<title><%= enki_config[:title] %> - Admin Login</title>

<%= stylesheet_link_tag 'login' %>
</head>
<body>
Expand All @@ -14,7 +12,7 @@
</div>
<div id="nav">
<ul>
<li><%= link_to("View Site", '/', :title => 'View Site') %></li>
<li><%= link_to 'View Site', root_path, :title => 'View Site' %></li>
</ul>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion app/views/pages/_page.html.erb
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<%=raw page.body_html %>
<%== page.body_html %>
5 changes: 3 additions & 2 deletions app/views/pages/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<% content_for(:page_title) do -%>
<%= page_title(@page) -%>
<%= page_title(@page) -%>
<% end -%>
<%= render :partial => 'pages/page', :locals => {:page => @page} %>
<%= render @page %>
8 changes: 4 additions & 4 deletions app/views/posts/_post.html.erb
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<h2><%= link_to(post.title, post_path(post)) %></h2>
<div class="entrybody">
<%=raw post.body_html %>
<div class="entry-body">
<%== post.body_html %>
</div>
<div class="meta">
<ul>
<li class="date">Posted on <%= format_post_date(post.published_at) %></li>
<li class="comments"><%= link_to(pluralize(post.approved_comments.size, "comment"), post_path(post, :anchor => 'comments')) %></li>
<li class="comments"><%= link_to pluralize(post.approved_comments.size, "comment"), post_path(post, :anchor => 'comments') %></li>
<% unless post.tags.empty? -%>
<li class="tags">Tagged <%= linked_tag_list(post.tags) %></li>
<li class="tags">Tagged <%= linked_tag_list(post.tags) %></li>
<% end -%>
</ul>
</div>
15 changes: 10 additions & 5 deletions app/views/posts/index.html.erb
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
<% content_for(:page_title) do %><%= posts_title(@tag) %><% end -%>
<% content_for(:head) do %><%= auto_discovery_link_tag(:atom, @tag.nil? ? formatted_posts_path(:format => 'atom') : posts_path(:tag => @tag, :format => 'atom')) %><% end -%>
<% content_for :page_title do -%>
<%= posts_title(@tag) %>
<% end -%>
<% content_for :head do -%>
<%= auto_discovery_link_tag(:atom, @tag.nil? ? formatted_posts_path(:format => 'atom') : posts_path(:tag => @tag, :format => 'atom')) %>
<% end -%>
<% if @posts.empty? -%>
<p>There are no posts yet.</p>
<% else -%>
<% @posts.each do |post| -%>
<div class="post post-<%= post.id %>">
<%= render :partial => 'post', :locals => {:post => post} %>
<div class="post" id="<%= dom_id(post) %>">
<%= render post %>
</div>
<% end -%>
<% if more_content? -%>
<div class="related">Looking for more? Head on over to the <%= link_to("archives", archives_path) %>.</div>
<div class="related">Looking for more? Head on over to the <%= link_to 'archives', archives_path %>.</div>
<% end -%>
<% end -%>
58 changes: 35 additions & 23 deletions app/views/posts/show.html.erb
Original file line number Diff line number Diff line change
@@ -1,30 +1,42 @@
<% content_for(:page_title) do -%>
<%= post_title(@post) -%>
<% content_for :page_title do -%>
<%= post_title @post -%>
<% end -%>
<%= render :partial => 'posts/post', :locals => {:post => @post} %>
<%= render @post %>

<ol class="commentlist">
<% @post.approved_comments.each do |comment| -%>
<li<%=raw cycle(' class="alt"', '') %> id="comment-<%= comment.id %>">
<%= render :partial => 'comments/comment', :locals => {:comment => comment} %>
</li>
<li<%=raw cycle(' class="alt"', '') %> id="comment-<%= comment.id %>">
<%= render comment %>
</li>
<% end -%>
</ol>
<div class="related">Looking for more? Head on over to the <%= link_to("archives", archives_path) %>.</div>

<div class="related">Looking for more? Head on over to the <%= link_to 'archives', archives_path %>.</div>

<h2>Post a comment</h2>
<% unless @comment.errors.empty? -%>
<div class="errors">
<h3>Comment not added!</h3>
<ul>
<% @comment.errors.sort_by(&:first).each do |error| -%>
<li><%= format_comment_error(error) %></li>
<% end -%>
</ul>
</div>
<% end -%>
<%= form_for([@post, @comment]) do |form| -%>
<div>
<p><%= form.text_field 'author' %><label for="comment_author"><small>Name or <a href="http://openidexplained.com/">OpenID</a> (required)</small></label></p>
<p><%= form.text_area 'body' %><br><small>(<a href="http://lesstile.rubyforge.org">lesstile enabled</a> - surround code blocks with ---)</small></p>
<p><%= submit_tag "Add Comment" %></p>
</div>
<% unless @comment.errors.empty? -%>
<div class="errors">
<h3>Comment not added!</h3>
<ul>
<% @comment.errors.sort_by(&:first).each do |error| -%>
<li><%= format_comment_error(error) %></li>
<% end -%>
</ul>
</div>
<% end -%>

<div>
<%= form_for [@post, @comment] do |form| -%>
<p>
<%= form.text_field 'author' %>
<%= form.label :author %>
<small>Name or <%= link_to 'OpenID', 'http://openidexplained.com/' %> (required)</small>
</p>
<p>
<%= form.text_area 'body' %><br/>
<small>(<%= link_to 'lesstile enabled', 'http://lesstile.rubyforge.org' %> - surround code blocks with ---)</small>
</p>
<p><%= form.submit 'Add Comment' %></p>
<% end -%>
</div>

0 comments on commit c4d976b

Please sign in to comment.