Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Most recent page

  • Loading branch information...
commit f9c5a0e7ae6fc33e95ca95ab5df15076268789ee 1 parent 1f7159d
@marcgg authored
View
10 app/controllers/front_controller.rb
@@ -2,7 +2,7 @@ class FrontController < ApplicationController
skip_before_filter :find_current_portfolio
skip_before_filter :ensure_portfolio_setup
before_filter :find_front_portfolio
- before_filter :find_category, :except => [:about]
+ before_filter :find_category, :except => [:about, :most_recent]
before_filter :setup_theme_preview
def showcase
@@ -18,6 +18,14 @@ def about
redirect_to root_path unless @portfolio.about_page
end
+ def most_recent
+ @photos = Photo.where(["category_id IN (?)", @portfolio.categories.map(&:id)]).limited.ordered_by_date
+ respond_to do |format|
+ format.html
+ format.rss { render :layout => false }
+ end
+ end
+
private
def find_category
View
1  app/models/photo.rb
@@ -8,6 +8,7 @@ class Photo < ActiveRecord::Base
scope :limited, :limit => 16
scope :ordered, :order => "position DESC"
scope :printed, :conditions => "prints > 0", :order => "prints DESC"
+ scope :ordered_by_date, :order => "created_at DESC"
def mark_as_destroyed
update_attribute(:deleted, true)
View
6 app/views/front/_nav.html.haml
@@ -3,6 +3,10 @@
.nav-link-wrapper{:class => ((!@category.nil? and @category.id == category.id) ? " selected " : "") + "category-order-#{i}"}
= link_to category.title, showcase_path(:slug => @portfolio.slug, :category_slug => category.slug)
+ - if @portfolio.recent_page
+ .nav-link-wrapper#recent{:class => (controller.action_name == "most_recent" ? "selected" : "")}
+ = link_to "Most Recent", most_recent_path(:slug => @portfolio.slug)
+
- if @portfolio.about_page
- .nav-link-wrapper#about{:class => (@category.nil? ? "selected" : "")}
+ .nav-link-wrapper#about{:class => (controller.action_name == "about" ? "selected" : "")}
= link_to "About", about_path(:slug => @portfolio.slug)
View
2  app/views/front/_photo.html.haml
@@ -1,6 +1,6 @@
.photo{:id => "photo-#{photo.id}", :class => "photo-order-#{i} #{cycle("photo-order-even", "photo-order-odd")}"}
.image-wrapper
- %a.img-wrapper-link{:href => single_photo_path(:slug => @portfolio.slug, :category_slug => @category.slug, :photo_id => photo.id)}
+ %a.img-wrapper-link{:href => single_photo_path(:slug => @portfolio.slug, :category_slug => photo.category.slug, :photo_id => photo.id)}
= image_tag photo.large_photo_url
- unless photo.title.blank? && photo.description.blank?
.description-wrapper
View
10 app/views/front/_photo.rss.erb
@@ -0,0 +1,10 @@
+<![CDATA[
+ <a class="img-wrapper-link" href="<%= single_photo_path(:slug => @portfolio.slug, :category_slug => photo.category.slug, :photo_id => photo.id) %>">
+ <%= image_tag photo.large_photo_url %>
+ <% unless photo.title.blank? && photo.description.blank? %>
+ <div class="description-wrapper">
+ <h3> <%= photo.title %></h3>
+ <p> <%= photo.description %></p>
+ </div>
+ <% end %>
+]]>
View
3  app/views/front/_photos.html.haml
@@ -0,0 +1,3 @@
+#photos
+ - photos.each_with_index do |photo, i|
+ = render :partial => "photo", :locals => {:photo => photo, :i => i}
View
2  app/views/front/most_recent.html.haml
@@ -0,0 +1,2 @@
+#main-content#most-recent-showcase
+ = render :partial => "photos", :locals => {:photos => @photos}
View
19 app/views/front/most_recent.rss.builder
@@ -0,0 +1,19 @@
+xml.instruct! :xml, :version => "1.0"
+xml.rss :version => "2.0" do
+ xml.channel do
+ xml.title @portfolio.title
+ xml.description @portfolio.description
+ xml.link "http://ffocused.com/#{@portfolio.slug}"
+
+ for photo in @photos
+ xml.item do
+ xml.title photo.title
+ xml.description do
+ xml << h(render(:partial => 'photo', :locals => {:photo => photo}))
+ end
+ xml.pubDate photo.created_at.to_s(:rfc822)
+ xml.link single_photo_url(:slug => @portfolio.slug, :category_slug => photo.category.slug, :photo_id => photo.id)
+ end
+ end
+ end
+end
View
4 app/views/front/showcase.html.haml
@@ -8,6 +8,4 @@
%h2.name= @category.title
.description= @category.description
- #photos
- - @category.photos.activated.ordered.limited.each_with_index do |photo, i|
- = render :partial => "photo", :locals => {:photo => photo, :i => i}
+ = render :partial => "photos", :locals => {:photos => @category.photos.activated.ordered.limited}
View
8 app/views/layouts/front.html.haml
@@ -2,15 +2,17 @@
%html
%head
%title= @portfolio.title
-
+
= stylesheet_link_tag "compiled/shared_front"
- if @portfolio.theme_id.blank?
%style{:media => "screen", :rel => "stylesheet", :type => "text/css"}= @portfolio.css
- else
= stylesheet_link_tag "themes/#{@portfolio.theme[:code]}"
-
+
= javascript_include_tag "http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"
+ %link{:rel => "alternate", :type => "application/rss+xml", :title => "RSS", :href => most_recent_url(:slug => @portfolio.slug, :format => :rss)}
+
%meta{:name => "title", :content => @portfolio.title}
- if @portfolio.description.blank?
%meta{:name => "description", :content => "Photo portfolio of #{@portfolio.user.login} powered by ffocused"}
@@ -37,8 +39,6 @@
#content= yield
- #nav-bottom= render :partial => "/front/nav"
-
- unless @portfolio.footer.blank?
%footer
= @portfolio.footer
View
3  app/views/portfolios/_form.html.haml
@@ -8,6 +8,9 @@
= f.check_box :about_page
- unless simple
+ = f.label :recent_page
+ = f.check_box :recent_page
+
= f.label :slug
= f.text_field :slug
View
1  config/locales/en.yml
@@ -224,6 +224,7 @@ en:
activerecord:
attributes:
portfolio:
+ recent_page: "Show 'Most Recent' page"
title: "Your Portfolio's Title*"
description: "Description used in the 'about' page*"
flickr_user_email: "Email used on Flickr*"
View
5 config/routes.rb
@@ -53,7 +53,8 @@
match "/how_to/themes" => "faq#themes", :as => :themes_tutorial
# FRONT
- get "/:slug/about" => "front#about", :as => :about
- get "/:slug(/:category_slug)" => "front#showcase", :as => :showcase
+ get "/:slug/about" => "front#about", :as => :about
+ get "/:slug/most_recent" => "front#most_recent", :as => :most_recent
+ get "/:slug(/:category_slug)" => "front#showcase", :as => :showcase
get "/:slug/:category_slug/:photo_id" => "front#single_photo", :as => :single_photo
end
View
9 db/migrate/20120220191831_add_recent_page_to_portfolios.rb
@@ -0,0 +1,9 @@
+class AddRecentPageToPortfolios < ActiveRecord::Migration
+ def self.up
+ add_column :portfolios, :recent_page, :boolean, :default => true
+ end
+
+ def self.down
+ remove_column :portfolios, :recent_page
+ end
+end
View
3  db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20120220190612) do
+ActiveRecord::Schema.define(:version => 20120220191831) do
create_table "beta_codes", :force => true do |t|
t.string "code"
@@ -71,6 +71,7 @@
t.string "google_analytics_code"
t.boolean "facebook_share", :default => false
t.boolean "about_page", :default => false
+ t.boolean "recent_page", :default => true
end
create_table "remote_accounts", :force => true do |t|
Please sign in to comment.
Something went wrong with that request. Please try again.