mirror of
https://github.com/danbee/danbarberphoto
synced 2025-03-04 08:49:07 +00:00
View focused code refactor.
This commit is contained in:
parent
e41349c144
commit
dd79d781fe
@ -8,6 +8,8 @@ class CategoriesController < ApplicationController
|
||||
|
||||
@page_title = 'Portfolio'
|
||||
|
||||
@num_blank = 4 - @categories.length
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.xml { render xml: @categories }
|
||||
|
||||
@ -8,6 +8,9 @@ class PhotosController < ApplicationController
|
||||
@photos = Photo.enabled.order{taken_at.desc}.paginate(page: params[:page], per_page: 11)
|
||||
@page_title = 'All Photos'
|
||||
end
|
||||
|
||||
@num_blank = 11 - @photos.length
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
end
|
||||
|
||||
5
app/helpers/entity_helper.rb
Normal file
5
app/helpers/entity_helper.rb
Normal file
@ -0,0 +1,5 @@
|
||||
module EntityHelper
|
||||
def e(entity)
|
||||
"&#{entity};".html_safe
|
||||
end
|
||||
end
|
||||
@ -1,6 +1,6 @@
|
||||
class PagePresenter < SimpleDelegator
|
||||
def content_as_html
|
||||
PagePresenter.markdown.render(content)
|
||||
PagePresenter.markdown.render(content).html_safe
|
||||
end
|
||||
|
||||
def self.markdown
|
||||
|
||||
@ -3,18 +3,16 @@
|
||||
<% content_for :navigation do %>
|
||||
<div class="sg-5 page-links">
|
||||
<% if @categories.previous_page -%>
|
||||
<%= link_to raw('<div>←</div>'), { :page => @categories.previous_page }, :class => 'prev-link' %>
|
||||
<%= link_to content_tag(:div, e(:larr)), { page: @categories.previous_page }, class: 'prev-link' %>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="sg-5 page-links">
|
||||
<% if @categories.next_page -%>
|
||||
<%= link_to raw('<div>→</div>'), { :page => @categories.next_page }, :class => 'next-link' %>
|
||||
<%= link_to content_tag(:div, e(:rarr)), { page: @categories.next_page }, class: 'next-link' %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% @num_blank = 4 - @categories.length -%>
|
||||
|
||||
<% @photos.each do |photo| %>
|
||||
<div class="sg-11 photo" id="<%= photo.name.parameterize %>">
|
||||
<%= link_to_photo photo %>
|
||||
@ -23,7 +21,7 @@
|
||||
|
||||
<% @categories.each do |category| %>
|
||||
<div class="category sg-5" style="background: <%= category.base_colour %>">
|
||||
<%= link_to raw('<h3>'+h(category.name.downcase)+'</h3>'), category_photos_path(category) %>
|
||||
<%= link_to content_tag(:h3, h(category.name.downcase)), category_photos_path(category) %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
<% if flash[:alert] -%>
|
||||
<div id="alert"><%= flash[:alert] %></div>
|
||||
<% end -%>
|
||||
<%= form_for :contact, :url => { :action => 'create' }, :html => { :id => 'contact_form' } do |f| %>
|
||||
<%= form_for :contact, url: { action: 'create' }, html: { id: 'contact_form' } do |f| %>
|
||||
<p>Please use the form below to contact me.</p>
|
||||
<p>
|
||||
<%= f.label :name %>
|
||||
@ -28,7 +28,7 @@
|
||||
<%= f.text_area :message %>
|
||||
</p>
|
||||
<p>
|
||||
<%= f.label "-", :style => "opacity: 0;" %>
|
||||
<%= f.label "-", style: "opacity: 0;" %>
|
||||
<%= f.submit 'Send Message' %>
|
||||
</p>
|
||||
<% end %>
|
||||
|
||||
@ -15,5 +15,5 @@
|
||||
<div class="sg-5" style="background: #555;">
|
||||
</div>
|
||||
<div class="sg-5 contact">
|
||||
<%= link_to raw('<span>contact</span>'), new_contact_path %>
|
||||
<%= link_to content_tag(:span, 'contact'), new_contact_path %>
|
||||
</div>
|
||||
|
||||
@ -7,10 +7,10 @@
|
||||
<meta name="keywords" content="photography, images, landscapes" />
|
||||
<meta name="description" content="The photography portfolio of Dan Barber" />
|
||||
<meta name="language" content="English" />
|
||||
<%= stylesheet_link_tag "application" %>
|
||||
<%= stylesheet_link_tag 'application' %>
|
||||
<%= javascript_include_tag 'application' %>
|
||||
<%= favicon_link_tag 'favicon.ico' %>
|
||||
<%= render :partial => "shared/typekit" %>
|
||||
<%= render 'shared/typekit' %>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
@ -22,7 +22,7 @@
|
||||
|
||||
<div class="sgParent sg-12">
|
||||
<header class="sg-11">
|
||||
<%= link_to image_tag(asset_url('title.svg'), :alt => 'Dan Barber Photography', :width => 236), '/' %>
|
||||
<%= link_to image_tag(asset_url('title.svg'), alt: 'Dan Barber Photography', width: 236), '/' %>
|
||||
</header>
|
||||
|
||||
<%= yield :navigation %>
|
||||
@ -38,7 +38,7 @@
|
||||
|
||||
</div>
|
||||
|
||||
<%= render :partial => 'shared/analytics' if Rails.env.production? %>
|
||||
<%= render 'shared/analytics' if Rails.env.production? %>
|
||||
|
||||
</body>
|
||||
|
||||
|
||||
@ -1 +1 @@
|
||||
<%=h @sender.message %>
|
||||
<%= h @sender.message %>
|
||||
|
||||
@ -2,13 +2,13 @@
|
||||
<div class="sg-5 about">
|
||||
</div>
|
||||
<div class="sg-5 portfolio">
|
||||
<%= link_to raw('<span>portfolio</span>'), :controller => 'categories' %>
|
||||
<%= link_to content_tag(:span, 'portfolio'), controller: 'categories' %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="sg-11 about-content">
|
||||
<div>
|
||||
<%= raw(@page.content_as_html) %>
|
||||
<%= @page.content_as_html %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -22,5 +22,5 @@
|
||||
<div class="sg-5" style="background: #555;">
|
||||
</div>
|
||||
<div class="sg-5 contact">
|
||||
<%= link_to raw('<span>contact</span>'), new_contact_path %>
|
||||
<%= link_to content_tag(:span, 'contact'), new_contact_path %>
|
||||
</div>
|
||||
|
||||
@ -3,19 +3,21 @@
|
||||
<% content_for :navigation do %>
|
||||
<div class="sg-5 page-links">
|
||||
<% if @photos.previous_page -%>
|
||||
<%= link_to raw('<div>←</div>'), { :page => @photos.previous_page }, :class => 'prev-link' %>
|
||||
<%= link_to content_tag(:div, e(:larr)), { page: @photos.previous_page }, class: 'prev-link' %>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="sg-5 page-links">
|
||||
<% if @photos.next_page -%>
|
||||
<%= link_to raw('<div>→</div>'), { :page => @photos.next_page }, :class => 'next-link' %>
|
||||
<%= link_to content_tag(:div, e(:rarr)), { page: @photos.next_page }, class: 'next-link' %>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% if @category %>
|
||||
<div class="sg-5 category" style="background: <%= @category.base_colour %>">
|
||||
<%= link_to raw('<h3>'+h(@category.name.downcase)+'</h3><div class="arrow">↑</div>'), categories_path %>
|
||||
<%= link_to categories_path do %>
|
||||
<h3><%= h(@category.name.downcase) %></h3><div class="arrow">↑</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<% else %>
|
||||
<div class="sg-5 category" style="background: #333;">
|
||||
@ -23,8 +25,6 @@
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% @num_blank = 11 - @photos.length -%>
|
||||
|
||||
<% @photos.each do |photo| %>
|
||||
<div class="sg-5 photo" id="<%= photo.name.parameterize %>">
|
||||
<%= link_to_photo photo %>
|
||||
|
||||
@ -1,5 +1,4 @@
|
||||
<script type="text/javascript">
|
||||
|
||||
<%= javascript_tag do %>
|
||||
var _gaq = _gaq || [];
|
||||
_gaq.push(['_setAccount', 'UA-603600-4']);
|
||||
_gaq.push(['_trackPageview']);
|
||||
@ -9,5 +8,4 @@
|
||||
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
|
||||
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
|
||||
})();
|
||||
|
||||
</script>
|
||||
<% end %>
|
||||
|
||||
@ -1,9 +1,9 @@
|
||||
- if !flash[:notice].blank?
|
||||
%p.flash.notice
|
||||
= flash[:notice]
|
||||
= link_to raw("×"), "#", :class => :close
|
||||
= link_to raw("×"), "#", class: :close
|
||||
|
||||
- if !flash[:alert].blank?
|
||||
%p.flash.alert
|
||||
= flash[:alert]
|
||||
= link_to raw("×"), "#", :class => :close
|
||||
= link_to raw("×"), "#", class: :close
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<div class="sg-5 about">
|
||||
<%= link_to raw('<span>about</span>'), page_path(:about) %>
|
||||
<%= link_to content_tag(:span, 'about'), page_path(:about) %>
|
||||
</div>
|
||||
<div class="sg-5 portfolio">
|
||||
<%= link_to raw('<span>portfolio</span>'), :controller => 'categories' %>
|
||||
<%= link_to content_tag(:span, 'portfolio'), controller: 'categories' %>
|
||||
</div>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user