imagine 0.0.1 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2011 YOURNAME
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,37 @@
1
+ # Imagine
2
+ [![Travis CI Build Status](http://travis-ci.org/knewter/imagine.png)](http://travis-ci.org/knewter/imagine)
3
+
4
+ A rails image gallery, that's mountable. Works on rails 3.1 at least :)
5
+ It's still in active development.
6
+
7
+ * [Github project](http://www.github.com/knewter/imagine)
8
+
9
+ ## TODO
10
+ * Build the plugin system
11
+ * Build a plugin that ships with core that handles a basic display style
12
+ * Allow a user to choose the default display style at album level
13
+ * Allow a visitor to look at any album with any display style via a param
14
+
15
+ ## Plugins
16
+ New album display types are specified in plugins.
17
+
18
+ Plugins are just gems. There is a plugin shipped with the core project called
19
+ `imagine_basic_list`. It should serve as a good template for building your own.
20
+
21
+ They're just rails engines, that have a bit of configuration logic to let
22
+ Imagine know that they should be incuded in the template style lists.
23
+
24
+
25
+ ## Testing
26
+ I've got this set up to use spork, so just do the following:
27
+
28
+ In one terminal, do:
29
+
30
+ bundle exec spork rspec
31
+
32
+ In another terminal, once that's done, you can:
33
+
34
+ bundle exec rspec spec
35
+
36
+ ## License
37
+ This project rocks and uses MIT-LICENSE.
data/Rakefile CHANGED
@@ -1 +1,36 @@
1
- require "bundler/gem_tasks"
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+ begin
8
+ require 'rdoc/task'
9
+ rescue LoadError
10
+ require 'rdoc/rdoc'
11
+ require 'rake/rdoctask'
12
+ RDoc::Task = Rake::RDocTask
13
+ end
14
+
15
+ RDoc::Task.new(:rdoc) do |rdoc|
16
+ rdoc.rdoc_dir = 'rdoc'
17
+ rdoc.title = 'Imagine'
18
+ rdoc.options << '--line-numbers' << '--inline-source'
19
+ rdoc.rdoc_files.include('README.rdoc')
20
+ rdoc.rdoc_files.include('lib/**/*.rb')
21
+ end
22
+
23
+ APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
24
+ load 'rails/tasks/engine.rake'
25
+
26
+ require 'rake/testtask'
27
+
28
+ Rake::TestTask.new(:test) do |t|
29
+ t.libs << 'lib'
30
+ t.libs << 'test'
31
+ t.pattern = 'test/**/*_test.rb'
32
+ t.verbose = false
33
+ end
34
+
35
+
36
+ task :default => :test
@@ -0,0 +1,9 @@
1
+ // This is a manifest file that'll be compiled into including all the files listed below.
2
+ // Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
3
+ // be included in the compiled file accessible from http://example.com/assets/application.js
4
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
5
+ // the compiled file.
6
+ //
7
+ //= require jquery
8
+ //= require jquery_ujs
9
+ //= require_tree .
@@ -0,0 +1,7 @@
1
+ /*
2
+ * This is a manifest file that'll automatically include all the stylesheets available in this directory
3
+ * and any sub-directories. You're free to add application-wide styles to this file and they'll appear at
4
+ * the top of the compiled file, but it's generally better to create a new file per style scope.
5
+ *= require_self
6
+ *= require_tree .
7
+ */
@@ -0,0 +1,34 @@
1
+ module Imagine
2
+ class AlbumsController < ::ApplicationController
3
+ def index
4
+ end
5
+
6
+ def show
7
+ load_album
8
+ end
9
+
10
+ def new
11
+ load_new_album
12
+ end
13
+
14
+ def create
15
+ load_new_album
16
+ if ::Imagine::Warehouses::Album.save(@album)
17
+ flash[:notice] = "Album has been created!"
18
+ redirect_to @album
19
+ else
20
+ flash.now[:error] = "There was a problem creating the album."
21
+ render :action => 'new'
22
+ end
23
+ end
24
+
25
+ protected
26
+ def load_new_album
27
+ @album = ::Imagine::Warehouses::Album.new(params[:album])
28
+ end
29
+
30
+ def load_album
31
+ @album = ::Imagine::Warehouses::Album.find(params[:id])
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,4 @@
1
+ module Imagine
2
+ class ApplicationController < ActionController::Base
3
+ end
4
+ end
@@ -0,0 +1,37 @@
1
+ module Imagine
2
+ class ImagesController < ::ApplicationController
3
+ before_filter :load_album
4
+
5
+ def show
6
+ load_image
7
+ end
8
+
9
+ def new
10
+ load_new_image
11
+ end
12
+
13
+ def create
14
+ load_new_image
15
+ if ::Imagine::Warehouses::Image.save(@image)
16
+ flash[:notice] = "Image has been attached!"
17
+ redirect_to [@album, @image]
18
+ else
19
+ flash.now[:error] = "There was a problem creating the image."
20
+ render :action => 'new'
21
+ end
22
+ end
23
+
24
+ protected
25
+ def load_album
26
+ @album = ::Imagine::Warehouses::Album.find(params[:album_id])
27
+ end
28
+
29
+ def load_new_image
30
+ @image = ::Imagine::Warehouses::Image.new(@album, params[:image])
31
+ end
32
+
33
+ def load_image
34
+ @image = ::Imagine::Warehouses::Image.find(@album, params[:id])
35
+ end
36
+ end
37
+ end
@@ -0,0 +1,4 @@
1
+ module Imagine
2
+ module ApplicationHelper
3
+ end
4
+ end
@@ -0,0 +1,6 @@
1
+ module Imagine
2
+ class Album < ActiveRecord::Base
3
+ validates :name, :presence => true
4
+ has_many :images
5
+ end
6
+ end
@@ -0,0 +1,7 @@
1
+ module Imagine
2
+ class Image < ActiveRecord::Base
3
+ image_accessor :file
4
+ belongs_to :album
5
+ validates_presence_of :file
6
+ end
7
+ end
@@ -0,0 +1 @@
1
+ = link_to "New Album", new_album_path
@@ -0,0 +1,4 @@
1
+ = form_for @album do |f|
2
+ = f.label :name
3
+ = f.text_field :name
4
+ = f.submit
@@ -0,0 +1,3 @@
1
+ %h2= @album.name
2
+
3
+ = link_to "New Image", new_album_image_path(@album)
@@ -0,0 +1,7 @@
1
+ = form_for [@album, @image], :html => { :multipart => true } do |f|
2
+ = f.label :file
3
+ = f.file_field :file
4
+ or
5
+ = f.label :file_url
6
+ = f.file_field :file_url
7
+ = f.submit "Attach Image"
File without changes
@@ -0,0 +1,19 @@
1
+ module Imagine
2
+ module Warehouses
3
+ class Album
4
+ def self.find(id)
5
+ # returns an album
6
+ ::Imagine::Album.find(id)
7
+ end
8
+
9
+ def self.new(params)
10
+ # returns a new album
11
+ ::Imagine::Album.new params
12
+ end
13
+
14
+ def self.save(album)
15
+ album.save
16
+ end
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,20 @@
1
+ module Imagine
2
+ module Warehouses
3
+ class Image
4
+ def self.find(album, id)
5
+ # returns an image from a given album
6
+ album.images.find(id)
7
+ end
8
+
9
+ def self.new(album, params=nil)
10
+ # returns a new image associated with the given album
11
+ params ||= {}
12
+ ::Imagine::Image.new(params.merge({:album_id => album.id}))
13
+ end
14
+
15
+ def self.save(image)
16
+ image.save
17
+ end
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,21 @@
1
+ # Encoding: UTF-8
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = %q{imagine-basic_list_view}
5
+ s.version = %q{0.1.1}
6
+ s.summary = %q{Basic list view for Imagine}
7
+ s.description = %q{The default album view for Imagine. Just lists images one after another}
8
+ s.date = %q{2011-08-28}
9
+ s.email = %q{josh@isotope11.com}
10
+ s.homepage = %q{http://github.com/knewter/imagine}
11
+ s.rubyforge_project = %q{imagine}
12
+ s.authors = ['Josh Adams']
13
+ s.license = %q{MIT}
14
+ s.require_paths = %w(lib)
15
+ s.executables = %w()
16
+
17
+ s.files = [
18
+ 'imagine-basic_list_view.gemspec',
19
+ 'lib/imagine-basic_list_view.rb'
20
+ ]
21
+ end
@@ -0,0 +1,27 @@
1
+ module Imagine
2
+ module BasicListView
3
+
4
+ class << self
5
+ attr_accessor :root
6
+ def root
7
+ @root ||= Pathname.new(File.expand_path('../../', __FILE__))
8
+ end
9
+ end
10
+
11
+ class Engine < ::Rails::Engine
12
+ isolate_namespace ::Imagine
13
+
14
+ config.after_initialize do |app|
15
+ ::Imagine::Plugin.register do |plugin|
16
+ plugin.pathname = root
17
+ plugin.name = 'imagine_basic_list_view'
18
+ plugin.directory = 'basic_list_view'
19
+ plugin.version = %q{0.0.1}
20
+ end
21
+ end
22
+
23
+ end
24
+ end
25
+ end
26
+
27
+ ::Imagine.engines << 'basic_list_view'
data/lib/imagine.rb CHANGED
@@ -1,5 +1,17 @@
1
- require "imagine/version"
1
+ # Prepare plugin system
2
+ %w(engine plugins plugin).each do |lib|
3
+ require "imagine/#{lib}"
4
+ end
2
5
 
3
6
  module Imagine
4
- # Your code goes here...
7
+ class << self
8
+ def engines
9
+ @engines ||= []
10
+ end
11
+ end
12
+ end
13
+
14
+ # Require the built in engines
15
+ %w(basic_list_view).each do |engine|
16
+ require "imagine-#{engine}"
5
17
  end
@@ -0,0 +1,9 @@
1
+ module Imagine
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace Imagine
4
+ end
5
+ end
6
+
7
+ # FIXME: Why can't I get this into autoload for rails?
8
+ require File.expand_path('../../../app/warehouses/imagine/album', __FILE__)
9
+ require File.expand_path('../../../app/warehouses/imagine/image', __FILE__)
@@ -0,0 +1,31 @@
1
+ module Imagine
2
+ module Engines; end;
3
+
4
+ class Plugin
5
+
6
+ attr_accessor :name, :version, :pathname, :directory
7
+ attr_reader :description
8
+
9
+ def self.register(&block)
10
+ yield(plugin = self.new)
11
+
12
+ raise "A plugin MUST have a name!: #{plugin.inspect}" if plugin.name.blank?
13
+
14
+ # add the new plugin to the collection of registered plugins
15
+ ::Imagine::Plugins.registered << plugin
16
+ end
17
+
18
+ def pathname=(value)
19
+ value = Pathname.new(value) if value.is_a? String
20
+ @pathname = value
21
+ end
22
+
23
+ # Make this protected, so that only Plugin.register can use it.
24
+ protected
25
+ def initialize
26
+ # provide a default pathname to where this plugin is using its lib directory.
27
+ depth = RUBY_VERSION >= "1.9.2" ? 4 : 3
28
+ self.pathname ||= Pathname.new(caller(depth).first.match("(.*)#{File::SEPARATOR}lib")[1])
29
+ end
30
+ end
31
+ end
@@ -0,0 +1,47 @@
1
+ module Imagine
2
+ class Plugins < Array
3
+
4
+ def initialize
5
+ @plugins = []
6
+ end
7
+
8
+ def find_by_name(name)
9
+ self.detect { |plugin| plugin.name == name }
10
+ end
11
+ alias :[] :find_by_name
12
+
13
+ def names
14
+ self.map(&:name)
15
+ end
16
+
17
+ def pathnames
18
+ self.map(&:pathname).compact.uniq
19
+ end
20
+
21
+ class << self
22
+ def active
23
+ @active_plugins ||= self.new
24
+ end
25
+
26
+ def registered
27
+ @registered_plugins ||= self.new
28
+ end
29
+
30
+ def activate(name)
31
+ active << registered[name] if registered[name] && !active[name]
32
+ end
33
+
34
+ def deactivate(name)
35
+ active.delete_if {|p| p.name == name}
36
+ end
37
+
38
+ def set_active(names)
39
+ @active_plugins = self.new
40
+
41
+ names.each do |name|
42
+ activate(name)
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -1,3 +1,7 @@
1
1
  module Imagine
2
- VERSION = "0.0.1"
2
+ class << self
3
+ def version
4
+ %q{0.1.1}
5
+ end
6
+ end
3
7
  end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :imagine do
3
+ # # Task goes here
4
+ # end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: imagine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,35 +9,133 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-08-25 00:00:00.000000000Z
12
+ date: 2011-08-28 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: rake
16
- requirement: &6761080 !ruby/object:Gem::Requirement
15
+ name: imagine-basic_list_view
16
+ requirement: &12852000 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: 0.9.2
21
+ version: 0.1.0
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: *12852000
25
+ - !ruby/object:Gem::Dependency
26
+ name: haml-rails
27
+ requirement: &12851580 !ruby/object:Gem::Requirement
28
+ none: false
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: *12851580
36
+ - !ruby/object:Gem::Dependency
37
+ name: dragonfly
38
+ requirement: &12918360 !ruby/object:Gem::Requirement
39
+ none: false
40
+ requirements:
41
+ - - ~>
42
+ - !ruby/object:Gem::Version
43
+ version: 0.9.0
44
+ type: :runtime
45
+ prerelease: false
46
+ version_requirements: *12918360
47
+ - !ruby/object:Gem::Dependency
48
+ name: rack-cache
49
+ requirement: &12917860 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: 0.5.3
55
+ type: :runtime
56
+ prerelease: false
57
+ version_requirements: *12917860
58
+ - !ruby/object:Gem::Dependency
59
+ name: rspec-rails
60
+ requirement: &12917400 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ~>
64
+ - !ruby/object:Gem::Version
65
+ version: '2.5'
22
66
  type: :development
23
67
  prerelease: false
24
- version_requirements: *6761080
25
- description:
26
- email:
27
- - josh@isotope11.com
68
+ version_requirements: *12917400
69
+ - !ruby/object:Gem::Dependency
70
+ name: capybara
71
+ requirement: &12917020 !ruby/object:Gem::Requirement
72
+ none: false
73
+ requirements:
74
+ - - ! '>='
75
+ - !ruby/object:Gem::Version
76
+ version: '0'
77
+ type: :development
78
+ prerelease: false
79
+ version_requirements: *12917020
80
+ - !ruby/object:Gem::Dependency
81
+ name: factory_girl
82
+ requirement: &12916560 !ruby/object:Gem::Requirement
83
+ none: false
84
+ requirements:
85
+ - - ! '>='
86
+ - !ruby/object:Gem::Version
87
+ version: '0'
88
+ type: :development
89
+ prerelease: false
90
+ version_requirements: *12916560
91
+ - !ruby/object:Gem::Dependency
92
+ name: spork
93
+ requirement: &12916140 !ruby/object:Gem::Requirement
94
+ none: false
95
+ requirements:
96
+ - - ! '>='
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ type: :development
100
+ prerelease: false
101
+ version_requirements: *12916140
102
+ description: Imagine can be dropped into an app to provide albums and images in your
103
+ app. It supports extensions to specify new view styles.
104
+ email: josh@isotope11.com
28
105
  executables: []
29
106
  extensions: []
30
107
  extra_rdoc_files: []
31
108
  files:
32
- - .gitignore
33
- - .rvmrc
34
- - Gemfile
35
- - Rakefile
36
- - imagine.gemspec
37
- - lib/imagine.rb
109
+ - lib/tasks/imagine_tasks.rake
110
+ - lib/imagine/plugins.rb
111
+ - lib/imagine/engine.rb
38
112
  - lib/imagine/version.rb
39
- homepage: ''
40
- licenses: []
113
+ - lib/imagine/plugin.rb
114
+ - lib/imagine.rb
115
+ - app/assets/javascripts/imagine2/application.js
116
+ - app/assets/stylesheets/imagine2/application.css
117
+ - app/models/imagine/album.rb
118
+ - app/models/imagine/image.rb
119
+ - app/controllers/imagine/application_controller.rb
120
+ - app/controllers/imagine/albums_controller.rb
121
+ - app/controllers/imagine/images_controller.rb
122
+ - app/views/imagine/images/new.html.haml
123
+ - app/views/imagine/images/show.html.haml
124
+ - app/views/imagine/albums/new.html.haml
125
+ - app/views/imagine/albums/index.html.haml
126
+ - app/views/imagine/albums/show.html.haml
127
+ - app/warehouses/imagine/album.rb
128
+ - app/warehouses/imagine/image.rb
129
+ - app/helpers/imagine/application_helper.rb
130
+ - basic_list_view/imagine-basic_list_view.gemspec
131
+ - basic_list_view/imagine-basic_list_view-0.1.1.gem
132
+ - basic_list_view/lib/imagine-basic_list_view.rb
133
+ - MIT-LICENSE
134
+ - Rakefile
135
+ - README.md
136
+ homepage: http://www.github.com/knewter/imagine
137
+ licenses:
138
+ - MIT
41
139
  post_install_message:
42
140
  rdoc_options: []
43
141
  require_paths:
@@ -48,23 +146,16 @@ required_ruby_version: !ruby/object:Gem::Requirement
48
146
  - - ! '>='
49
147
  - !ruby/object:Gem::Version
50
148
  version: '0'
51
- segments:
52
- - 0
53
- hash: -1771472949969375942
54
149
  required_rubygems_version: !ruby/object:Gem::Requirement
55
150
  none: false
56
151
  requirements:
57
152
  - - ! '>='
58
153
  - !ruby/object:Gem::Version
59
154
  version: '0'
60
- segments:
61
- - 0
62
- hash: -1771472949969375942
63
155
  requirements: []
64
- rubyforge_project: imagine
156
+ rubyforge_project:
65
157
  rubygems_version: 1.8.6
66
158
  signing_key:
67
159
  specification_version: 3
68
- summary: imagine is a mountable rails engine for dropping a photo gallery into your
69
- application.
160
+ summary: Imagine is a mountable image gallery engine for rails 3.1 and later.
70
161
  test_files: []
data/.gitignore DELETED
@@ -1,4 +0,0 @@
1
- *.gem
2
- .bundle
3
- Gemfile.lock
4
- pkg/*
data/.rvmrc DELETED
@@ -1 +0,0 @@
1
- rvm 1.9.2@imagine --create
data/Gemfile DELETED
@@ -1,4 +0,0 @@
1
- source "http://rubygems.org"
2
-
3
- # Specify your gem's dependencies in imagine.gemspec
4
- gemspec
data/imagine.gemspec DELETED
@@ -1,24 +0,0 @@
1
- # -*- encoding: utf-8 -*-
2
- $:.push File.expand_path("../lib", __FILE__)
3
- require "imagine/version"
4
-
5
- Gem::Specification.new do |s|
6
- s.name = "imagine"
7
- s.version = Imagine::VERSION
8
- s.authors = ["Josh Adams"]
9
- s.email = ["josh@isotope11.com"]
10
- s.homepage = ""
11
- s.summary = %q{imagine is a mountable rails engine for dropping a photo gallery into your application.}
12
-
13
- s.rubyforge_project = "imagine"
14
-
15
- s.files = `git ls-files`.split("\n")
16
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
17
- s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
18
- s.require_paths = ["lib"]
19
-
20
- # specify any dependencies here; for example:
21
- # s.add_development_dependency "rspec"
22
- # s.add_runtime_dependency "rest-client"
23
- s.add_development_dependency "rake", "~> 0.9.2"
24
- end