diff --git a/Gemfile b/Gemfile index 4c614d2..e44c566 100644 --- a/Gemfile +++ b/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' diff --git a/Gemfile.lock b/Gemfile.lock index 550f115..8ecf844 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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 diff --git a/app/controllers/pages_controller.rb b/app/controllers/pages_controller.rb index cc45f9e..39b8aad 100644 --- a/app/controllers/pages_controller.rb +++ b/app/controllers/pages_controller.rb @@ -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 diff --git a/app/controllers/photos_controller.rb b/app/controllers/photos_controller.rb index 4e22029..c9a0d57 100644 --- a/app/controllers/photos_controller.rb +++ b/app/controllers/photos_controller.rb @@ -1,22 +1,28 @@ class PhotosController < ApplicationController - def new - @photo = Photo.new - @categories = Category.find(:all).map { |c| [c.name, c.id] } - end + def new + @photo = Photo.new + @categories = Category.find(:all).map { |c| [c.name, c.id] } + end - def index - if params[:category_id] - @category = Category.find_by_id(params[:category_id]) - @photos = @category.photos.enabled.order(:taken_at.desc).paginate(:page => params[:page], :per_page => 11) - else - @photos = Photo.enabled.order(:taken_at.desc).paginate :all, :page => params[:page], :per_page => 11 - end - respond_to do |format| - format.html - end + def index + if params[:category_id] + @category = Category.find_by_id(params[:category_id]) + @photos = @category.photos.enabled.order(:taken_at.desc).paginate(:page => params[:page], :per_page => 11) + else + @photos = Photo.enabled.order(:taken_at.desc).paginate :all, :page => params[:page], :per_page => 11 end + respond_to do |format| + format.html + end + end - def show - @photo = Photo.find(params[:id]) - 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 diff --git a/app/models/page.rb b/app/models/page.rb index 191f5cc..84498a7 100644 --- a/app/models/page.rb +++ b/app/models/page.rb @@ -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 diff --git a/app/views/categories/index.html.erb b/app/views/categories/index.html.erb index 157e71f..0515e4f 100644 --- a/app/views/categories/index.html.erb +++ b/app/views/categories/index.html.erb @@ -16,8 +16,8 @@ <% @photos.each do |photo| %> -