Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: kenwierzbo/world-war-1-posters
base: f54bb8237e
...
head fork: kenwierzbo/world-war-1-posters
compare: 05f809cb75
Checking mergeability… Don't worry, you can still create the pull request.
  • 7 commits
  • 9 files changed
  • 0 commit comments
  • 1 contributor
View
7 Gemfile
@@ -43,11 +43,12 @@ gem 'execjs'
gem 'therubyracer'
gem 'rails_admin', :git => 'git://github.com/toddmazierski/rails_admin.git'
+gem "devise"
gem 'carrierwave'
gem 'fog'
-gem 'hashie'
+gem 'mini_magick'
-gem 'tanker'
+gem 'hashie'
-gem "devise"
+gem 'pg_search'
View
11 Gemfile.lock
@@ -99,6 +99,8 @@ GEM
mime-types (~> 1.16)
treetop (~> 1.4.8)
mime-types (1.17.2)
+ mini_magick (3.4)
+ subexec (~> 0.2.1)
multi_json (1.1.0)
net-scp (1.0.4)
net-ssh (>= 1.99.1)
@@ -106,6 +108,9 @@ GEM
nokogiri (1.5.0)
orm_adapter (0.0.6)
pg (0.13.2)
+ pg_search (0.4.2)
+ activerecord (>= 3)
+ activesupport (>= 3)
polyglot (0.3.3)
rack (1.4.1)
rack-cache (1.1)
@@ -146,8 +151,7 @@ GEM
hike (~> 1.2)
rack (~> 1.0)
tilt (~> 1.1, != 1.3.0)
- tanker (1.1.6)
- json (>= 1.5.1)
+ subexec (0.2.2)
therubyracer (0.9.10)
libv8 (~> 3.3.10)
thor (0.14.6)
@@ -173,10 +177,11 @@ DEPENDENCIES
fog
hashie
jquery-rails
+ mini_magick
pg
+ pg_search
rails (= 3.2.0)
rails_admin!
sass-rails (~> 3.2.3)
- tanker
therubyracer
uglifier (>= 1.0.3)
View
16 app/controllers/posters_controller.rb
@@ -1,19 +1,7 @@
class PostersController < ActionController::Base
def index
- @places_of_origin = AccessPoint.places_of_origin
-
- # Initialize an empty set of filters.
- filters = [[]]
-
- # Parse the parameters passed and apply filters as needed.
- if params[:place_of_origin].present?
- filters << [:place_of_origin, @places_of_origin.find_by_entry(params[:place_of_origin])]
- end
-
- # Remove any empty filters.
- filters.delete_if(&:empty?)
-
- @posters = Poster.filter(filters)
+ query = params[:search]
+ @posters = Poster.search(query)
end
View
39 app/models/poster.rb
@@ -1,4 +1,21 @@
class Poster < ActiveRecord::Base
+ include PgSearch
+
+ pg_search_scope :search,
+ :ignoring => :accents,
+ :against => [
+ :title,
+ :credit,
+ :printer,
+ :publisher
+ ],
+ :associated_against => {
+ :access_points => [
+ :entry,
+ :authority_id,
+ :authority_source]
+ }
+
mount_uploader :poster, PosterUploader
has_many :poster_access_points
@@ -6,25 +23,9 @@ class Poster < ActiveRecord::Base
validates :number, :short_title, :presence => true
validates :number, :uniqueness => true
- scope :place_of_origin, (lambda do |access_point|
- relationship = AccessPointRelationship['Place of Origin']
- self.joins(:poster_access_points, :access_points).where(
- :poster_access_points => {
- :access_point_relationship_id => relationship.id
- },
- :access_points => {
- :id => access_point.id
- }
- )
- end)
- # Iterates through an array of arrays of methods and arguments. Useful for
- # chaining together scopes and applying them all at once.
- class << self
- def filter(filters = [])
- filters = [[:all]] if filters.empty?
- filters.inject(self) { |object, method_and_args| object.send(*method_and_args) }
- end
- end #self
+ def to_param
+ self.number
+ end
end
View
8 app/uploaders/poster_uploader.rb
@@ -4,7 +4,7 @@ class PosterUploader < CarrierWave::Uploader::Base
# Include RMagick or MiniMagick support:
# include CarrierWave::RMagick
- # include CarrierWave::MiniMagick
+ include CarrierWave::MiniMagick
# Choose what kind of storage to use for this uploader:
# storage :file
@@ -29,9 +29,9 @@ def store_dir
# end
# Create different versions of your uploaded files:
- # version :thumb do
- # process :scale => [50, 50]
- # end
+ version :large do
+ process :resize_to_fit => [1024, 768]
+ end
# Add a white list of extensions which are allowed to be uploaded.
# For images you might use something like this:
View
15 app/views/posters/index.html.erb
@@ -1,8 +1,7 @@
-<%= form_tag(posters_path, :method => :get) do %>
- <%= label_tag(:place_of_origin, "Place of origin:") %>
- <% places_of_origin_array = [nil] + @places_of_origin.map(&:entry).sort %>
- <%= select_tag(:place_of_origin, options_for_select(places_of_origin_array, params[:place_of_origin])) %>
- <%= submit_tag("Filter", :name => nil) %>
-<% end %>
-
-<%= @posters.map(&:title) %>
+<ul>
+ <% @posters.each do |poster| %>
+ <li>
+ <%= link_to poster.short_title, poster_path(poster) %>
+ </li>
+ <% end %>
+</ul>
View
31 app/views/posters/show.html.erb
@@ -1 +1,30 @@
-<%= @poster %>
+<h1><%= @poster.short_title %></h1>
+
+<%= image_tag(@poster.poster_url(:large)) unless @poster[:poster].nil? %>
+
+<h2>Details</h2>
+<dl>
+ <dt>Title</dt>
+ <dd><%= @poster.title %></dd>
+ <dt>Credit</dt>
+ <dd><%= @poster.credit %></dd>
+ <dt>Printer</dt>
+ <dd><%= @poster.printer %></dd>
+ <dt>Publisher</dt>
+ <dd><%= @poster.publisher %></dd>
+ <dt>Year Published</dt>
+ <dd><%= @poster.year_published %></dd>
+ <dt>Approximate?</dt>
+ <dd><%= @poster.year_approximate %></dd>
+ <dt>Notes</dt>
+ <dd><%= @poster.notes %></dd>
+</dl>
+
+<h2>Access Points</h2>
+<ul>
+ <% @poster.poster_access_points.each do |poster_access_point| %>
+ <li>
+ <%= poster_access_point.name %>
+ </li>
+ <% end %>
+</ul>
View
10 db/migrate/20120513215753_add_unaccent_extension.rb
@@ -0,0 +1,10 @@
+class AddUnaccentExtension < ActiveRecord::Migration
+ def up
+ execute 'CREATE EXTENSION unaccent'
+ execute "ALTER TEXT SEARCH DICTIONARY unaccent (RULES='unaccent')"
+ end
+
+ def down
+ execute 'DROP EXTENSION unaccent'
+ end
+end
View
2  db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended to check this file into your version control system.
-ActiveRecord::Schema.define(:version => 20120513193001) do
+ActiveRecord::Schema.define(:version => 20120513215753) do
create_table "access_point_relationships", :force => true do |t|
t.string "name"

No commit comments for this range

Something went wrong with that request. Please try again.