carrierwave_gallery 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.rdoc +3 -0
  4. data/Rakefile +37 -0
  5. data/app/assets/javascripts/carrierwave_gallery/carrierwave_gallery.js +5 -0
  6. data/app/assets/javascripts/carrierwave_gallery/destroy_image/index.js +3 -0
  7. data/app/assets/javascripts/carrierwave_gallery/destroy_image/init.js.coffee +6 -0
  8. data/app/assets/javascripts/carrierwave_gallery/upload/index.js +0 -0
  9. data/app/assets/javascripts/carrierwave_gallery/upload/init.js.coffee +5 -0
  10. data/app/assets/stylesheets/carrierwave_gallery/_base.sass +48 -0
  11. data/app/assets/stylesheets/carrierwave_gallery/carrierwave_gallery.sass +2 -0
  12. data/app/controllers/carrierwave_gallery/admin/application_controller.rb +2 -0
  13. data/app/controllers/carrierwave_gallery/admin/gallery_controller.rb +60 -0
  14. data/app/controllers/carrierwave_gallery/admin/images_controller.rb +34 -0
  15. data/app/controllers/carrierwave_gallery/application_controller.rb +4 -0
  16. data/app/controllers/carrierwave_gallery/gallery_controller.rb +9 -0
  17. data/app/models/gallery.rb +12 -0
  18. data/app/models/image.rb +5 -0
  19. data/app/uploaders/image_uploader.rb +56 -0
  20. data/app/views/carrierwave_gallery/admin/gallery/_form.html.erb +14 -0
  21. data/app/views/carrierwave_gallery/admin/gallery/edit.html.erb +6 -0
  22. data/app/views/carrierwave_gallery/admin/gallery/index.html.erb +39 -0
  23. data/app/views/carrierwave_gallery/admin/gallery/new.html.erb +6 -0
  24. data/app/views/carrierwave_gallery/admin/gallery/show.html.erb +31 -0
  25. data/app/views/carrierwave_gallery/admin/images/_image.html.erb +16 -0
  26. data/app/views/carrierwave_gallery/admin/images/edit.html.erb +23 -0
  27. data/app/views/carrierwave_gallery/admin/images/new.html.erb +1 -0
  28. data/app/views/carrierwave_gallery/gallery/index.html.erb +32 -0
  29. data/app/views/carrierwave_gallery/gallery/show.html.erb +18 -0
  30. data/app/views/carrierwave_gallery/images/_image.html.erb +11 -0
  31. data/config/locales/carrierwave_gallery.yml +13 -0
  32. data/config/routes.rb +13 -0
  33. data/lib/carrierwave_gallery/engine.rb +5 -0
  34. data/lib/carrierwave_gallery/version.rb +3 -0
  35. data/lib/carrierwave_gallery.rb +4 -0
  36. data/lib/generators/carrierwave_gallery/install/install_generator.rb +25 -0
  37. data/lib/generators/carrierwave_gallery/install/templates/create_galleries.rb +12 -0
  38. data/lib/generators/carrierwave_gallery/install/templates/create_images.rb +14 -0
  39. data/lib/tasks/carrierwave_gallery_tasks.rake +4 -0
  40. metadata +180 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: bf833d3347259d11afea9c49d94ccc01bd598efb
4
+ data.tar.gz: 216fa340f57f360a6b0975ee850d29f5823c3fc2
5
+ SHA512:
6
+ metadata.gz: 0be9adc7b469280987ac4d589af16772d62d04cd27e3541fcdf1824daee4007cc3040b4f23c9425090363a6ef6a524ca8e4fbb3be08a892ff1bb7dba25b5ef78
7
+ data.tar.gz: 5e69083c0dae22a38ea6d85da382d18a573194a905813c5b744a99e31c718132beb269f5f836b7bffd8cab61a19ffd25f4abcc6caf0188bad626a199940dea90
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2015 tab
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.rdoc ADDED
@@ -0,0 +1,3 @@
1
+ = CarrierwaveGallery
2
+
3
+ This project rocks and uses MIT-LICENSE.
data/Rakefile ADDED
@@ -0,0 +1,37 @@
1
+ begin
2
+ require 'bundler/setup'
3
+ rescue LoadError
4
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
5
+ end
6
+
7
+ require 'rdoc/task'
8
+
9
+ RDoc::Task.new(:rdoc) do |rdoc|
10
+ rdoc.rdoc_dir = 'rdoc'
11
+ rdoc.title = 'CarrierwaveGallery'
12
+ rdoc.options << '--line-numbers'
13
+ rdoc.rdoc_files.include('README.rdoc')
14
+ rdoc.rdoc_files.include('lib/**/*.rb')
15
+ end
16
+
17
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
18
+ load 'rails/tasks/engine.rake'
19
+
20
+
21
+ load 'rails/tasks/statistics.rake'
22
+
23
+
24
+
25
+ Bundler::GemHelper.install_tasks
26
+
27
+ require 'rake/testtask'
28
+
29
+ Rake::TestTask.new(:test) do |t|
30
+ t.libs << 'lib'
31
+ t.libs << 'test'
32
+ t.pattern = 'test/**/*_test.rb'
33
+ t.verbose = false
34
+ end
35
+
36
+
37
+ task default: :test
@@ -0,0 +1,5 @@
1
+ //= require jquery
2
+ //= require jquery_ujs
3
+ //= require bootstrap/dropdown
4
+ //= require dropzone
5
+ //= require_tree .
@@ -0,0 +1,3 @@
1
+ /*
2
+ * = require_tree .
3
+ */
@@ -0,0 +1,6 @@
1
+ $ ->
2
+ $('.ajaxed').on 'ajax:success', (evt, response) ->
3
+ target = $(evt.target)
4
+
5
+ if target.hasClass('js-delete')
6
+ target.closest('.image').replaceWith(response)
@@ -0,0 +1,5 @@
1
+ $ ->
2
+ Dropzone.autoDiscover = false
3
+
4
+ dropzone = $('.js-dropzone').dropzone
5
+ dictDefaultMessage: 'Для загрузки перетащите файлы сюда или кликните в этот блок'
@@ -0,0 +1,48 @@
1
+ .header
2
+ background: #fff
3
+ margin: 0
4
+
5
+ .title
6
+ margin: 20px 0
7
+
8
+ .add-gallery
9
+ float: right
10
+ margin: 18px 0 0 0
11
+
12
+ .empty
13
+ color: #999
14
+ font-size: 18px
15
+
16
+ .truncated
17
+ overflow: hidden
18
+ text-overflow: ellipsis
19
+ vertical-align: top
20
+ white-space: nowrap
21
+
22
+ .gallery
23
+ h4
24
+ color: #428bca
25
+ text-align: center
26
+
27
+ .cover
28
+ height: 160px
29
+ margin: 0 auto
30
+ width: 160px
31
+
32
+ .stub
33
+ background: #f1f1f1
34
+ line-height: 160px
35
+ text-align: center
36
+
37
+ .actions
38
+ margin: 10px
39
+ text-align: center
40
+
41
+ .thumbnail
42
+ .info
43
+ margin: 0
44
+ padding: 10px
45
+
46
+ .actions
47
+ margin: 5px 0 0 0
48
+ text-align: center
@@ -0,0 +1,2 @@
1
+ @import dropzone/dropzone
2
+ @import base
@@ -0,0 +1,2 @@
1
+ class CarrierwaveGallery::Admin::ApplicationController < ApplicationController
2
+ end
@@ -0,0 +1,60 @@
1
+ class CarrierwaveGallery::Admin::GalleryController < ApplicationController
2
+ before_action :set_gallery, only: [:show, :edit, :update, :destroy]
3
+
4
+ def index
5
+ @collection = Gallery.all
6
+ end
7
+
8
+ def show
9
+ end
10
+
11
+ def new
12
+ @gallery = Gallery.new
13
+ end
14
+
15
+ def create
16
+ @gallery = Gallery.new(gallery_params)
17
+
18
+ respond_to do |format|
19
+ if @gallery.save
20
+ format.html { redirect_to admin_gallery_path(@gallery), notice: 'Gallery was successfully created.' }
21
+ format.json { render :show, status: :created, location: @gallery }
22
+ else
23
+ format.html { render :new }
24
+ format.json { render json: @gallery.errors, status: :unprocessable_entity }
25
+ end
26
+ end
27
+ end
28
+
29
+ def edit
30
+ end
31
+
32
+ def update
33
+ respond_to do |format|
34
+ if @gallery.update(gallery_params)
35
+ format.html { redirect_to admin_gallery_path(@gallery), notice: 'Gallery was successfully updated.' }
36
+ format.json { render :show, status: :ok, location: @gallery }
37
+ else
38
+ format.html { render :edit }
39
+ format.json { render json: @gallery.errors, status: :unprocessable_entity }
40
+ end
41
+ end
42
+ end
43
+
44
+ def destroy
45
+ @gallery.destroy
46
+ respond_to do |format|
47
+ format.html { redirect_to admin_gallery_index_path, notice: 'Gallery was successfully destroyed.' }
48
+ format.json { head :no_content }
49
+ end
50
+ end
51
+
52
+ private
53
+ def set_gallery
54
+ @gallery = Gallery.find(params[:id])
55
+ end
56
+
57
+ def gallery_params
58
+ params.require(:gallery).permit(:title, :description, :image)
59
+ end
60
+ end
@@ -0,0 +1,34 @@
1
+ class CarrierwaveGallery::Admin::ImagesController < ApplicationController
2
+ inherit_resources
3
+
4
+ belongs_to :gallery
5
+ actions :all, :except => [:index, :show, :create]
6
+
7
+ def create
8
+ @gallery = Gallery.find(params[:gallery_id])
9
+
10
+ @image = @gallery.images.create(:file => params[:file])
11
+
12
+ if @image.save!
13
+ respond_to do |format|
14
+ format.json { render :json => @image }
15
+ end
16
+ end
17
+ end
18
+
19
+ def update
20
+ update!{ admin_gallery_path(@gallery) }
21
+ end
22
+
23
+ def destroy
24
+ destroy! {
25
+ render :nothing => true and return
26
+ }
27
+ end
28
+
29
+ private
30
+
31
+ def permitted_params
32
+ params.permit(:image => [:title, :alt, :description, :file])
33
+ end
34
+ end
@@ -0,0 +1,4 @@
1
+ module CarrierwaveGallery
2
+ class ApplicationController < ActionController::Base
3
+ end
4
+ end
@@ -0,0 +1,9 @@
1
+ class CarrierwaveGallery::GalleryController < ApplicationController
2
+ def index
3
+ @collection = Gallery.all
4
+ end
5
+
6
+ def show
7
+ @gallery = Gallery.find(params[:id])
8
+ end
9
+ end
@@ -0,0 +1,12 @@
1
+ class Gallery < ActiveRecord::Base
2
+ mount_uploader :image, ImageUploader
3
+
4
+ extend FriendlyId
5
+ friendly_id :title, :use => [:slugged, :finders]
6
+
7
+ has_many :images, :dependent => :destroy
8
+
9
+ validates_presence_of :title
10
+
11
+ alias_attribute :to_s, :title
12
+ end
@@ -0,0 +1,5 @@
1
+ class Image < ActiveRecord::Base
2
+ mount_uploader :file, ImageUploader
3
+
4
+ belongs_to :gallery
5
+ end
@@ -0,0 +1,56 @@
1
+ # encoding: utf-8
2
+
3
+ class ImageUploader < CarrierWave::Uploader::Base
4
+ # Include RMagick or MiniMagick support:
5
+ include CarrierWave::RMagick
6
+ # include CarrierWave::MiniMagick
7
+
8
+ # Choose what kind of storage to use for this uploader:
9
+ storage :file
10
+ # storage :fog
11
+
12
+ # Override the directory where uploaded files will be stored.
13
+ # This is a sensible default for uploaders that are meant to be mounted:
14
+ def store_dir
15
+ "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
16
+ end
17
+
18
+ # Provide a default URL as a default if there hasn't been a file uploaded:
19
+ # def default_url
20
+ # # For Rails 3.1+ asset pipeline compatibility:
21
+ # # ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_'))
22
+ #
23
+ # "/images/fallback/" + [version_name, "default.png"].compact.join('_')
24
+ # end
25
+
26
+ # Process files as they are uploaded:
27
+ # process :scale => [200, 300]
28
+ #
29
+ # def scale(width, height)
30
+ # # do something
31
+ # end
32
+
33
+ #process :resize_to_fill => [800, 800]
34
+
35
+ # Create different versions of your uploaded files:
36
+ version :thumb do
37
+ process :resize_to_fill => [160, 160]
38
+ end
39
+
40
+ version :medium do
41
+ process :resize_to_fill => [800, 800]
42
+ end
43
+
44
+ # Add a white list of extensions which are allowed to be uploaded.
45
+ # For images you might use something like this:
46
+ # def extension_white_list
47
+ # %w(jpg jpeg gif png)
48
+ # end
49
+
50
+ # Override the filename of the uploaded files:
51
+ # Avoid using model.id or version_name here, see uploader/store.rb for details.
52
+ # def filename
53
+ # "something.jpg" if original_filename
54
+ # end
55
+
56
+ end
@@ -0,0 +1,14 @@
1
+ <%= simple_form_for(@gallery, :url => @gallery.new_record? ? admin_gallery_index_path : [:admin, @gallery], :html => { :multipart => true }) do |f| %>
2
+ <%= f.error_notification %>
3
+
4
+ <div class="form-inputs">
5
+ <%= f.input :title %>
6
+ <%= f.input :description %>
7
+ <%= f.input :image, :as => :file %>
8
+ </div>
9
+
10
+ <div class="form-actions">
11
+ <%= f.submit 'Сохранить', :class => 'btn btn-primary btn-sm' %>
12
+ <%= link_to 'Отмена', admin_gallery_index_path, :class => 'btn btn-default btn-sm' %>
13
+ </div>
14
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <h3 class="title">
2
+ <%= link_to 'Все галереи', admin_gallery_index_path %> /
3
+ Редактирование &laquo;<%= @gallery %>&raquo;
4
+ </h3>
5
+
6
+ <%= render 'form' %>
@@ -0,0 +1,39 @@
1
+ <%= link_to 'Добавить новую галерею', new_admin_gallery_path, :class => 'btn btn-primary btn-sm add-gallery' %>
2
+
3
+ <h3 class="title">
4
+ Все галереи
5
+ </h3>
6
+
7
+ <div class="row">
8
+ <div class="gallery col-lg-12">
9
+ <% if @collection.any? %>
10
+ <% @collection.each do |gallery| %>
11
+ <div class="col-lg-3">
12
+ <div class="thumbnail">
13
+ <h4 class="truncated">
14
+ <%= link_to gallery, admin_gallery_path(gallery) %>
15
+ </h4>
16
+
17
+ <div class="cover">
18
+ <% if gallery.image? %>
19
+ <%= link_to (image_tag gallery.image.thumb.url), admin_gallery_path(gallery) %>
20
+ <% else %>
21
+ <div class="stub">
22
+ нет изображения
23
+ </div>
24
+ <% end %>
25
+ </div>
26
+
27
+ <div class="actions">
28
+ <%= link_to 'Изменить', edit_admin_gallery_path(gallery), :class => 'btn btn-default btn-xs' %>
29
+ <%= link_to 'Удалить', admin_gallery_path(gallery), :method => :delete, :class => 'btn btn-danger btn-xs' %>
30
+ </div>
31
+ </div>
32
+ </div>
33
+ <% end %>
34
+ <% else %>
35
+ <div class="empty">Еще нет ни одной галереи</div>
36
+ <% end %>
37
+ </div>
38
+ </div>
39
+
@@ -0,0 +1,6 @@
1
+ <h3 class="title">
2
+ <%= link_to 'Все галереи', admin_gallery_index_path %> /
3
+ Добавление новой галереи
4
+ </h3>
5
+
6
+ <%= render 'form' %>
@@ -0,0 +1,31 @@
1
+ <h3 class="title">
2
+ <%= link_to 'Все галереи', admin_gallery_index_path %> /
3
+ <%= @gallery %>
4
+ </h3>
5
+
6
+ <div class="row">
7
+ <div class="images col-lg-9">
8
+ <% if @gallery.images.any? %>
9
+ <% @gallery.images.each do |image| %>
10
+ <div class="col-lg-3 image ajaxed">
11
+ <%= content_for :image_actions do %>
12
+ <li class="actions">
13
+ <%= link_to 'Изменить', edit_admin_gallery_image_path(@gallery, image), :class => 'btn btn-default btn-xs' %>
14
+ <%= link_to 'Удалить', admin_gallery_image_path(@gallery, image), :method => :delete, :class => 'btn btn-danger btn-xs js-delete', :remote => true %>
15
+ </li>
16
+ <% end %>
17
+
18
+ <%= render image %>
19
+ </div>
20
+ <% end %>
21
+ <% else %>
22
+ <div class="empty">В галереи еще нет ни одной фотографии</div>
23
+ <% end %>
24
+ </div>
25
+
26
+ <div class="js-images col-lg-3">
27
+ <%= simple_form_for([:admin, @gallery, @gallery.images.new], :html => { :multipart => true, :class => 'dropzone js-dropzone' }) do |f| %>
28
+ <%= f.input :file, :as => :hidden, :input_html => { :multiple => true, :name => 'image[file]' }, :wrapper_html => { :class => :failback } %>
29
+ <% end %>
30
+ </div>
31
+ </div>
@@ -0,0 +1,16 @@
1
+ <div class="thumbnail">
2
+ <%= image_tag image.file.thumb.url %>
3
+ <ul class="info">
4
+ <li class="truncated">
5
+ <strong>Название:</strong> <%= image.title? ? image.title : 'не задано' %>
6
+ </li>
7
+ <li class="truncated">
8
+ <strong>ALT-тег:</strong> <%= image.alt? ? image.alt : 'не задано' %>
9
+ </li>
10
+ <li class="truncated">
11
+ <strong>Описание:</strong> <%= image.description? ? image.description : 'не задано' %>
12
+ </li>
13
+ <%= yield :image_actions %>
14
+ </ul>
15
+ </div>
16
+
@@ -0,0 +1,23 @@
1
+ <h3 class="title">
2
+ <%= link_to 'Все галереи', admin_gallery_index_path %> /
3
+ <%= link_to @gallery, admin_gallery_path(@gallery) %> /
4
+ Редактирование изображения
5
+ </h3>
6
+
7
+ <div class="row">
8
+ <div class="col-lg-9">
9
+ <%= simple_form_for([:admin, @gallery, @image]) do |f| %>
10
+ <%= f.input :title %>
11
+ <%= f.input :alt %>
12
+ <%= f.input :description %>
13
+
14
+ <%= f.submit 'Сохранить', :class => 'btn btn-primary btn-sm' %>
15
+ <%= link_to 'Отмена', admin_gallery_path(@gallery), :class => 'btn btn-default btn-sm' %>
16
+ <% end %>
17
+ </div>
18
+
19
+ <div class="col-lg-3">
20
+ <%= render @image %>
21
+ </div>
22
+ </div>
23
+
@@ -0,0 +1 @@
1
+ <%= render 'form' %>
@@ -0,0 +1,32 @@
1
+ <h3 class="title">
2
+ Все галереи
3
+ </h3>
4
+
5
+ <div class="row">
6
+ <div class="gallery col-lg-12">
7
+ <% if @collection.any? %>
8
+ <% @collection.each do |gallery| %>
9
+ <div class="col-lg-3">
10
+ <div class="thumbnail">
11
+ <h4 class="truncated">
12
+ <%= link_to gallery, gallery_path(gallery) %>
13
+ </h4>
14
+
15
+ <div class="cover">
16
+ <% if gallery.image? %>
17
+ <%= link_to (image_tag gallery.image.thumb.url), gallery_path(gallery) %>
18
+ <% else %>
19
+ <div class="stub">
20
+ нет изображения
21
+ </div>
22
+ <% end %>
23
+ </div>
24
+
25
+ </div>
26
+ </div>
27
+ <% end %>
28
+ <% else %>
29
+ <div class="empty">Еще нет ни одной галереи</div>
30
+ <% end %>
31
+ </div>
32
+ </div>
@@ -0,0 +1,18 @@
1
+ <h3 class="title">
2
+ <%= link_to 'Все галереи', gallery_index_path %> /
3
+ <%= @gallery %>
4
+ </h3>
5
+
6
+ <div class="row">
7
+ <div class="images col-lg-12">
8
+ <% if @gallery.images.any? %>
9
+ <% @gallery.images.each do |image| %>
10
+ <div class="col-lg-3">
11
+ <%= render image %>
12
+ </div>
13
+ <% end %>
14
+ <% else %>
15
+ <div class="empty">В галереи еще нет ни одной фотографии</div>
16
+ <% end %>
17
+ </div>
18
+ </div>
@@ -0,0 +1,11 @@
1
+ <div class="thumbnail">
2
+ <%= image_tag image.file.thumb.url, :title => image.title? ? image.title : 'не задано', :alt => image.alt? ? image.alt : 'не задано' %>
3
+ <ul class="info">
4
+ <li class="truncated">
5
+ <strong>Название:</strong> <%= image.title? ? image.title : 'не задано' %>
6
+ </li>
7
+ <li class="truncated">
8
+ <strong>Описание:</strong> <%= image.description? ? image.description : 'не задано' %>
9
+ </li>
10
+ </ul>
11
+ </div>
@@ -0,0 +1,13 @@
1
+ ru:
2
+ activerecord:
3
+ attributes:
4
+ gallery:
5
+ title: Название
6
+ description: Описание
7
+ image: Изображение
8
+
9
+ image:
10
+ title: Название
11
+ alt: Содержание тега-ALT
12
+ description: Описание
13
+ file: Изображение
data/config/routes.rb ADDED
@@ -0,0 +1,13 @@
1
+ CarrierwaveGallery::Engine.routes.draw do
2
+ namespace :admin do
3
+ resources :gallery do
4
+ resources :images, :except => [:index, :show]
5
+ end
6
+
7
+ root :to => 'gallery#index'
8
+ end
9
+
10
+ resources :gallery, :only => [:index, :show]
11
+
12
+ root :to => 'gallery#index'
13
+ end
@@ -0,0 +1,5 @@
1
+ module CarrierwaveGallery
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace CarrierwaveGallery
4
+ end
5
+ end
@@ -0,0 +1,3 @@
1
+ module CarrierwaveGallery
2
+ VERSION = "0.0.1"
3
+ end
@@ -0,0 +1,4 @@
1
+ require "carrierwave_gallery/engine"
2
+
3
+ module CarrierwaveGallery
4
+ end
@@ -0,0 +1,25 @@
1
+ require 'rails/generators/migration'
2
+
3
+ module CarrierwaveGallery
4
+ module Generators
5
+ class InstallGenerator < ::Rails::Generators::Base
6
+ include Rails::Generators::Migration
7
+ source_root File.expand_path('../templates', __FILE__)
8
+ desc "add the migrations"
9
+
10
+ def self.next_migration_number(path)
11
+ unless @prev_migration_nr
12
+ @prev_migration_nr = Time.now.utc.strftime("%Y%m%d%H%M%S").to_i
13
+ else
14
+ @prev_migration_nr += 1
15
+ end
16
+ @prev_migration_nr.to_s
17
+ end
18
+
19
+ def copy_migrations
20
+ migration_template "create_galleries.rb", "db/migrate/create_galleries.rb"
21
+ migration_template "create_images.rb", "db/migrate/create_images.rb"
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,12 @@
1
+ class CreateGalleries < ActiveRecord::Migration
2
+ def change
3
+ create_table :galleries do |t|
4
+ t.string :title
5
+ t.string :slug
6
+ t.text :description
7
+ t.string :image
8
+
9
+ t.timestamps null: false
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,14 @@
1
+ class CreateImages < ActiveRecord::Migration
2
+ def change
3
+ create_table :images do |t|
4
+ t.string :title
5
+ t.string :alt
6
+ t.text :description
7
+ t.string :file
8
+ t.references :gallery, index: true
9
+
10
+ t.timestamps null: false
11
+ end
12
+ add_foreign_key :images, :galleries
13
+ end
14
+ end
@@ -0,0 +1,4 @@
1
+ # desc "Explaining what the task does"
2
+ # task :carrierwave_gallery do
3
+ # # Task goes here
4
+ # end
metadata ADDED
@@ -0,0 +1,180 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: carrierwave_gallery
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - tab
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-02-21 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 4.2.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 4.2.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: carrierwave
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: 0.10.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: 0.10.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: dropzonejs-rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.7.1
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.7.1
55
+ - !ruby/object:Gem::Dependency
56
+ name: friendly_id
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 5.1.0
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 5.1.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: inherited_resources
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: 1.6.0
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: 1.6.0
83
+ - !ruby/object:Gem::Dependency
84
+ name: rmagick
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: 2.13.4
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: 2.13.4
97
+ - !ruby/object:Gem::Dependency
98
+ name: sqlite3
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ description: Rails engine for simple gallery with carrierwave and dropzonejs.
112
+ email:
113
+ - ''
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - MIT-LICENSE
119
+ - README.rdoc
120
+ - Rakefile
121
+ - app/assets/javascripts/carrierwave_gallery/carrierwave_gallery.js
122
+ - app/assets/javascripts/carrierwave_gallery/destroy_image/index.js
123
+ - app/assets/javascripts/carrierwave_gallery/destroy_image/init.js.coffee
124
+ - app/assets/javascripts/carrierwave_gallery/upload/index.js
125
+ - app/assets/javascripts/carrierwave_gallery/upload/init.js.coffee
126
+ - app/assets/stylesheets/carrierwave_gallery/_base.sass
127
+ - app/assets/stylesheets/carrierwave_gallery/carrierwave_gallery.sass
128
+ - app/controllers/carrierwave_gallery/admin/application_controller.rb
129
+ - app/controllers/carrierwave_gallery/admin/gallery_controller.rb
130
+ - app/controllers/carrierwave_gallery/admin/images_controller.rb
131
+ - app/controllers/carrierwave_gallery/application_controller.rb
132
+ - app/controllers/carrierwave_gallery/gallery_controller.rb
133
+ - app/models/gallery.rb
134
+ - app/models/image.rb
135
+ - app/uploaders/image_uploader.rb
136
+ - app/views/carrierwave_gallery/admin/gallery/_form.html.erb
137
+ - app/views/carrierwave_gallery/admin/gallery/edit.html.erb
138
+ - app/views/carrierwave_gallery/admin/gallery/index.html.erb
139
+ - app/views/carrierwave_gallery/admin/gallery/new.html.erb
140
+ - app/views/carrierwave_gallery/admin/gallery/show.html.erb
141
+ - app/views/carrierwave_gallery/admin/images/_image.html.erb
142
+ - app/views/carrierwave_gallery/admin/images/edit.html.erb
143
+ - app/views/carrierwave_gallery/admin/images/new.html.erb
144
+ - app/views/carrierwave_gallery/gallery/index.html.erb
145
+ - app/views/carrierwave_gallery/gallery/show.html.erb
146
+ - app/views/carrierwave_gallery/images/_image.html.erb
147
+ - config/locales/carrierwave_gallery.yml
148
+ - config/routes.rb
149
+ - lib/carrierwave_gallery.rb
150
+ - lib/carrierwave_gallery/engine.rb
151
+ - lib/carrierwave_gallery/version.rb
152
+ - lib/generators/carrierwave_gallery/install/install_generator.rb
153
+ - lib/generators/carrierwave_gallery/install/templates/create_galleries.rb
154
+ - lib/generators/carrierwave_gallery/install/templates/create_images.rb
155
+ - lib/tasks/carrierwave_gallery_tasks.rake
156
+ homepage: https://github.com/tab/carrierwave_gallery
157
+ licenses:
158
+ - MIT
159
+ metadata: {}
160
+ post_install_message:
161
+ rdoc_options: []
162
+ require_paths:
163
+ - lib
164
+ required_ruby_version: !ruby/object:Gem::Requirement
165
+ requirements:
166
+ - - ">="
167
+ - !ruby/object:Gem::Version
168
+ version: '0'
169
+ required_rubygems_version: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - ">="
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ requirements: []
175
+ rubyforge_project:
176
+ rubygems_version: 2.2.2
177
+ signing_key:
178
+ specification_version: 4
179
+ summary: Rails engine for simple gallery with carrierwave and dropzonejs.
180
+ test_files: []