mirror of
https://github.com/danbee/danbarberphoto
synced 2025-03-04 08:49:07 +00:00
Added view count to photos. Used acts_as_markdown for pages.
This commit is contained in:
parent
57418726ca
commit
3c8ddc1923
1
Gemfile
1
Gemfile
@ -36,3 +36,4 @@ gem 'typus', :git => 'git://github.com/fesplugas/typus.git'
|
||||
gem 'mini_exiftool'
|
||||
gem 'will_paginate', :git => 'http://github.com/mislav/will_paginate.git', :branch => 'rails3'
|
||||
gem 'rdiscount'
|
||||
gem 'acts_as_markup'
|
||||
|
||||
@ -20,6 +20,7 @@ GIT
|
||||
GEM
|
||||
remote: http://rubygems.org/
|
||||
specs:
|
||||
RedCloth (4.2.3)
|
||||
abstract (1.0.0)
|
||||
actionmailer (3.0.0)
|
||||
actionpack (= 3.0.0)
|
||||
@ -47,6 +48,12 @@ GEM
|
||||
activemodel (= 3.0.0)
|
||||
activesupport (= 3.0.0)
|
||||
activesupport (3.0.0)
|
||||
acts_as_markup (1.3.4)
|
||||
RedCloth (~> 4.2)
|
||||
activerecord (>= 2.3.2)
|
||||
activesupport (>= 2.3.2)
|
||||
rdiscount (~> 1.3)
|
||||
wikitext (~> 2.0)
|
||||
arel (1.0.1)
|
||||
activesupport (~> 3.0.0)
|
||||
builder (2.1.2)
|
||||
@ -90,11 +97,13 @@ GEM
|
||||
treetop (1.4.8)
|
||||
polyglot (>= 0.3.1)
|
||||
tzinfo (0.3.23)
|
||||
wikitext (2.1.1)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
acts_as_markup
|
||||
exception_notification!
|
||||
meta_where
|
||||
mini_exiftool
|
||||
|
||||
@ -6,6 +6,7 @@ class PagesController < ApplicationController
|
||||
end
|
||||
|
||||
def about
|
||||
@content = Page.find_by_name('about')
|
||||
@page = Page.find_by_name('about')
|
||||
@content = @page.content
|
||||
end
|
||||
end
|
||||
|
||||
@ -17,6 +17,12 @@ class PhotosController < ApplicationController
|
||||
end
|
||||
|
||||
def show
|
||||
# Log the view
|
||||
@photo = Photo.find(params[:id])
|
||||
@photo.views += 1
|
||||
@photo.save
|
||||
# Get the image and send it to the browser
|
||||
data = File.open(@photo.photo.path, 'rb').read
|
||||
send_data(data , :filename => 'photo', :type => 'image/jpg', :disposition => 'inline')
|
||||
end
|
||||
end
|
||||
|
||||
@ -1,8 +1,5 @@
|
||||
require 'rdiscount'
|
||||
|
||||
class Page < ActiveRecord::Base
|
||||
def html
|
||||
markdown = Markdown.new(self.content, :smart)
|
||||
markdown.to_html
|
||||
end
|
||||
acts_as_markdown :content
|
||||
end
|
||||
|
||||
@ -17,7 +17,7 @@
|
||||
<% @photos.each do |photo| %>
|
||||
|
||||
<div class="sg-11 photo" style="background: url('<%= photo.photo.url(:size11) %>')">
|
||||
<%= link_to '', photo.photo.url, :rel => 'photo', :class => 'fancy' %>
|
||||
<%= link_to '', photo_url(photo, :format => :jpg), :class => 'fancy' %>
|
||||
</div>
|
||||
|
||||
<% end %>
|
||||
|
||||
@ -9,7 +9,7 @@
|
||||
|
||||
<div class="sg-11 about-content">
|
||||
<div>
|
||||
<%= raw(@content.html) %>
|
||||
<%= raw(@content.to_html) %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
|
||||
<% if @photo %>
|
||||
<div class="sg-17 photo" style="background: url('<%= @photo.photo.url(:size17) %>')">
|
||||
<%= link_to '', @photo.photo.url, :rel => 'photo', :class => 'fancy' %>
|
||||
<%= link_to '', photo_url(@photo, :format => :jpg), :rel => 'photo', :class => 'fancy' %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
|
||||
@ -27,7 +27,7 @@
|
||||
<% @photos.each do |photo| %>
|
||||
|
||||
<div class="sg-5 photo" style="background: url('<%= photo.photo.url(:size5) %>')">
|
||||
<%= link_to '', photo.photo.url, :rel => 'photo', :class => 'fancy' %>
|
||||
<%= link_to '', photo_url(photo, :format => :jpg), :class => 'fancy' %>
|
||||
</div>
|
||||
|
||||
<% end %>
|
||||
|
||||
9
db/migrate/20101216180143_add_view_count_to_photos.rb
Normal file
9
db/migrate/20101216180143_add_view_count_to_photos.rb
Normal file
@ -0,0 +1,9 @@
|
||||
class AddViewCountToPhotos < ActiveRecord::Migration
|
||||
def self.up
|
||||
add_column :photos, :views, :integer, :default => 0
|
||||
end
|
||||
|
||||
def self.down
|
||||
remove_column :photos, :views
|
||||
end
|
||||
end
|
||||
@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20101215172105) do
|
||||
ActiveRecord::Schema.define(:version => 20101216180143) do
|
||||
|
||||
create_table "admin_users", :force => true do |t|
|
||||
t.string "first_name", :default => "", :null => false
|
||||
@ -63,6 +63,7 @@ ActiveRecord::Schema.define(:version => 20101215172105) do
|
||||
t.boolean "featured", :default => false
|
||||
t.boolean "enabled", :default => true
|
||||
t.datetime "taken_at"
|
||||
t.integer "views", :default => 0
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Loading…
Reference in New Issue
Block a user