nivo 0.0.2

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.
Files changed (61) hide show
  1. data/.DS_Store +0 -0
  2. data/.gitignore +4 -0
  3. data/Gemfile +15 -0
  4. data/README.md +76 -0
  5. data/Rakefile +38 -0
  6. data/app/.DS_Store +0 -0
  7. data/app/controllers/.DS_Store +0 -0
  8. data/app/controllers/nivo/manage_slides_controller.rb +19 -0
  9. data/app/controllers/nivo/slides_controller.rb +55 -0
  10. data/app/models/.DS_Store +0 -0
  11. data/app/models/nivo/slide.rb +60 -0
  12. data/app/views/.DS_Store +0 -0
  13. data/app/views/nivo/_slideshow.html.haml +14 -0
  14. data/app/views/nivo/slides/_form.html.haml +27 -0
  15. data/app/views/nivo/slides/_search.html.haml +5 -0
  16. data/app/views/nivo/slides/edit.html.haml +5 -0
  17. data/app/views/nivo/slides/index.html.haml +26 -0
  18. data/app/views/nivo/slides/index.js.haml +2 -0
  19. data/app/views/nivo/slides/new.html.haml +6 -0
  20. data/app/views/nivo/slides/show.html.haml +19 -0
  21. data/config/.DS_Store +0 -0
  22. data/config/nivo_config.yml +34 -0
  23. data/config/routes.rb +15 -0
  24. data/lib/.DS_Store +0 -0
  25. data/lib/engine.rb +34 -0
  26. data/lib/nivo/config.rb +8 -0
  27. data/lib/nivo/helper.rb +14 -0
  28. data/lib/nivo/manage_slides.rb +17 -0
  29. data/lib/nivo/version.rb +3 -0
  30. data/lib/nivo.rb +13 -0
  31. data/lib/rails/.DS_Store +0 -0
  32. data/lib/rails/generators/.DS_Store +0 -0
  33. data/lib/rails/generators/nivo/.DS_Store +0 -0
  34. data/lib/rails/generators/nivo/controller_generator.rb +18 -0
  35. data/lib/rails/generators/nivo/install_generator.rb +49 -0
  36. data/lib/rails/generators/nivo/stylesheet_generator.rb +18 -0
  37. data/lib/rails/generators/nivo/templates/migration.rb +12 -0
  38. data/lib/rails/generators/nivo/templates/nivo_config.yml +29 -0
  39. data/lib/rails/generators/nivo/templates/schema.rb +15 -0
  40. data/lib/rails/generators/nivo/views_generator.rb +18 -0
  41. data/lib/rails/railties/tasks.rake +0 -0
  42. data/nivo.gemspec +28 -0
  43. data/public/.DS_Store +0 -0
  44. data/public/images/.DS_Store +0 -0
  45. data/public/images/arrows.png +0 -0
  46. data/public/images/bullets.png +0 -0
  47. data/public/images/loading.gif +0 -0
  48. data/public/javascripts/.DS_Store +0 -0
  49. data/public/javascripts/nivo-admin.js +10 -0
  50. data/public/javascripts/nivo-dragsort.js +288 -0
  51. data/public/javascripts/nivo-serialize.js +98 -0
  52. data/public/javascripts/nivo-settings.js +6 -0
  53. data/public/javascripts/nivo-slider.js +685 -0
  54. data/public/stylesheets/.DS_Store +0 -0
  55. data/public/stylesheets/.gitkeep +0 -0
  56. data/public/stylesheets/default.css +75 -0
  57. data/public/stylesheets/nivo-slider.css +89 -0
  58. data/test/.DS_Store +0 -0
  59. data/test/helper.rb +18 -0
  60. data/test/test_nivo.rb +10 -0
  61. metadata +157 -0
data/.DS_Store ADDED
Binary file
data/.gitignore ADDED
@@ -0,0 +1,4 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
data/Gemfile ADDED
@@ -0,0 +1,15 @@
1
+ source "http://rubygems.org"
2
+ # Add dependencies required to use your gem here.
3
+ # Example:
4
+ # gem "activesupport", ">= 2.3.5"
5
+ gem 'rake', '0.8.7'
6
+ # Add dependencies to develop your gem here.
7
+ # Include everything needed to run rake, tests, features, etc.
8
+ group :development do
9
+ gem "shoulda", ">= 0"
10
+ gem "bundler", "~> 1.0.0"
11
+ gem "rcov", ">= 0"
12
+ end
13
+
14
+ # Specify your gem's dependencies in nivo.gemspec
15
+ gemspec
data/README.md ADDED
@@ -0,0 +1,76 @@
1
+ #Nivo Slider Rails
2
+
3
+
4
+ What am I
5
+ =====
6
+
7
+ Rails engine that supplies administration of slides and view helpers for the [nivo slider jQuery plugin](http://nivo.dev7studios.com/).
8
+
9
+ #####My Dependancies
10
+
11
+ paperclip
12
+ haml
13
+ jquery-rails
14
+
15
+ Install Me
16
+ =====
17
+
18
+ Add this to your Gemfile
19
+
20
+ gem 'nivo', :git => "git://github.com/hificreative/nivo.git"
21
+
22
+ run
23
+
24
+ bundle
25
+
26
+ then
27
+
28
+ rails g nivo:install
29
+
30
+ This will create the necessary migrations and copy the `nivo_config.yml` to the config directory.
31
+
32
+ If jquery is not installed run
33
+
34
+ rails g jquery:install
35
+
36
+ Use Me
37
+ =====
38
+
39
+ The following view helpers are shown in haml.
40
+
41
+ Edit the `nivo_config.yml` to your liking.
42
+ Then after you run `rake db:migrate` add this to your application layout
43
+
44
+ = show_slider?
45
+
46
+ and insert
47
+
48
+ = yield(:js)
49
+
50
+ after the closing body tag.
51
+
52
+ On each view you would like the slider to be visible insert
53
+
54
+ - slider
55
+
56
+ if the variable `slider` is set, `show_slider?` will render the slideshow partial and include the stylesheets and javascripts required by Nivo Slider.
57
+
58
+ #####To add slides
59
+
60
+ navigate to `nivo/slides`
61
+
62
+ My Extras
63
+ =====
64
+
65
+ We hate engines that you can't customize. With that in mind, there are 3 more generators available.
66
+
67
+ nivo:views
68
+ nivo:controller
69
+ nivo:stylesheet
70
+
71
+ Do I need to explain what these do?
72
+
73
+ ToDo
74
+ =====
75
+
76
+ * js include tag view helper
data/Rakefile ADDED
@@ -0,0 +1,38 @@
1
+ require "bundler/gem_tasks"
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts "Run `bundle install` to install missing gems"
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'rake/testtask'
15
+ Rake::TestTask.new(:test) do |test|
16
+ test.libs << 'lib' << 'test'
17
+ test.pattern = 'test/**/test_*.rb'
18
+ test.verbose = true
19
+ end
20
+
21
+ require 'rcov/rcovtask'
22
+ Rcov::RcovTask.new do |test|
23
+ test.libs << 'test'
24
+ test.pattern = 'test/**/test_*.rb'
25
+ test.verbose = true
26
+ end
27
+
28
+ task :default => :test
29
+
30
+ require 'rdoc/task'
31
+ RDoc::Task.new do |rdoc|
32
+ version = File.exist?('VERSION') ? File.read('VERSION') : ""
33
+
34
+ rdoc.rdoc_dir = 'rdoc'
35
+ rdoc.title = "imdb_api #{version}"
36
+ rdoc.rdoc_files.include('README*')
37
+ rdoc.rdoc_files.include('lib/**/*.rb')
38
+ end
data/app/.DS_Store ADDED
Binary file
Binary file
@@ -0,0 +1,19 @@
1
+ module Nivo
2
+ class ManageSlidesController < ApplicationController
3
+
4
+ if defined?(Dust::Application)
5
+ filter_access_to :all
6
+ layout 'cms'
7
+ end
8
+
9
+ unloadable
10
+
11
+ def create
12
+ Nivo::Slide.sort(params[:slides])
13
+
14
+ flash[:notice] = "Successfully sorted slides."
15
+ redirect_to nivo_slides_url(:format => 'js')
16
+ end
17
+
18
+ end
19
+ end
@@ -0,0 +1,55 @@
1
+ module Nivo
2
+ class SlidesController < ApplicationController
3
+
4
+ if defined?(Dust::Application)
5
+ filter_access_to :all
6
+ layout 'cms'
7
+ end
8
+
9
+ unloadable
10
+
11
+ def index
12
+ @slides = Nivo::Slide.page(params[:search])
13
+ end
14
+
15
+ def show
16
+ @slide = Nivo::Slide.find(params[:id])
17
+ end
18
+
19
+ def new
20
+ @slide = Nivo::Slide.new
21
+ end
22
+
23
+ def create
24
+ @slide = Nivo::Slide.new(params[:nivo_slide])
25
+ if @slide.save
26
+ flash[:notice] = "Successfully created slide."
27
+ redirect_to @slide
28
+ else
29
+ render :action => 'new'
30
+ end
31
+ end
32
+
33
+ def edit
34
+ @slide = Nivo::Slide.find(params[:id])
35
+ end
36
+
37
+ def update
38
+ @slide = Nivo::Slide.find(params[:id])
39
+ if @slide.update_attributes(params[:nivo_slide])
40
+ flash[:notice] = "Successfully updated slide."
41
+ redirect_to @slide
42
+ else
43
+ render :action => 'edit'
44
+ end
45
+ end
46
+
47
+ def destroy
48
+ @slide = Nivo::Slide.find(params[:id])
49
+ @slide.destroy
50
+ flash[:notice] = "Successfully destroyed slide."
51
+ redirect_to nivo_slides_url
52
+ end
53
+
54
+ end
55
+ end
Binary file
@@ -0,0 +1,60 @@
1
+ module Nivo
2
+ class Slide < ActiveRecord::Base
3
+ include Nivo::ManageSlides
4
+
5
+ attr_accessible :caption, :url, :active, :lft, :rgt, :image
6
+
7
+ has_attached_file :image, :styles => Nivo::Config.file['paperclip_options'].symbolize_keys
8
+
9
+ ##
10
+ # Save the image dimensions only when a new photo is uploaded
11
+ #
12
+ after_post_process :save_image_dimensions
13
+ def save_image_dimensions
14
+ geo = Paperclip::Geometry.from_file(image.queued_for_write[:slide])
15
+ self.width = geo.width
16
+ self.height = geo.height
17
+ end
18
+
19
+ ##
20
+ # html options for the slide image_tag
21
+ #
22
+ def image_options
23
+ image_options = {
24
+ :height => height,
25
+ :width => width,
26
+ :class => "slide",
27
+ :title => (caption if Nivo::Config.file['caption'] == true)
28
+ }
29
+ end
30
+
31
+ ##
32
+ # Find for slideshow
33
+ #
34
+ def self.rotate
35
+ where("active = ?", true).order("position")
36
+ end
37
+
38
+ ##
39
+ # Find for admin index
40
+ #
41
+ def self.page(search)
42
+ if defined?(Dust::Application)
43
+ with_permissions_to(:manage).search(search).order("position")
44
+ else
45
+ search(search).order("position")
46
+ end
47
+ end
48
+
49
+ ##
50
+ # currently used in self.page
51
+ #
52
+ def self.search(search)
53
+ if search
54
+ where("caption LIKE ?", "%#{search}%")
55
+ else
56
+ scoped
57
+ end
58
+ end
59
+ end
60
+ end
Binary file
@@ -0,0 +1,14 @@
1
+ - content_for :js do
2
+ = javascript_include_tag "nivo-slider"
3
+ -# Can't wait for the asset pipeline. ruby in js files, Amazing!
4
+ :javascript
5
+ $(document).ready(function() {
6
+ $('.slides').nivoSlider(#{Nivo::Config.file['nivo_options'].to_json});
7
+ });
8
+ = stylesheet_link_tag "nivo-slider", "default"
9
+
10
+
11
+ .theme-default
12
+ .slides{ :style =>"width:#{slides.first.width}px;" }
13
+ - slides.each do |slide|
14
+ = link_to image_tag(slide.image.url(:slide), slide.image_options), slide.url, :class => "slide_link"
@@ -0,0 +1,27 @@
1
+ = form_for @slide, :validate => true, :html => { :multipart => true } do |f|
2
+ - if @slide.errors.any?
3
+ #error_explanation
4
+ %h2
5
+ = pluralize(@slide.errors.count, "error")
6
+ prohibited this page from being saved:
7
+ %ul
8
+ - @slide.errors.full_messages.each do |msg|
9
+ %li= msg
10
+ .item
11
+ = f.label :caption
12
+ %br
13
+ = f.text_field :caption, :class => 'field'
14
+ .item
15
+ = f.label :url
16
+ %br
17
+ = f.text_field :url, :class => 'field'
18
+ .item
19
+ = f.label :active
20
+ %br
21
+ = f.check_box :active, :class => 'field'
22
+ .item
23
+ = f.label :image
24
+ %br
25
+ = f.file_field :image, :class => 'field'
26
+ .item
27
+ = f.submit
@@ -0,0 +1,5 @@
1
+ #searchbox
2
+ = form_tag nivo_slides_path, :method => 'get' do
3
+ = text_field_tag :search, params[:search], :class => "input-text", :placeholder => 'Search Slides by Caption'
4
+ = image_submit_tag "admin/blank.png", :class => "image-submit"
5
+
@@ -0,0 +1,5 @@
1
+ - if defined?(Dust::Application)
2
+ - title "Edit Slide"
3
+ - heading "Edit Slide"
4
+
5
+ = render 'form'
@@ -0,0 +1,26 @@
1
+ - if defined?(Dust::Application)
2
+ - title "Slides"
3
+
4
+
5
+ .button_bar
6
+ = render :partial => 'search' if defined?(Dust::Application)
7
+ = link_to 'Order Slides', nivo_manage_slides_path, :class => 'ordernav tip', :id => "order_slides", :title => "ReOrder Slides"
8
+ = link_to 'New Slide', new_nivo_slide_path, :class => 'newfile tip', :title => "New Slide"
9
+
10
+
11
+ %ul#slides
12
+ - @slides.each do |slide|
13
+ %li.item{:id => "#{slide.id}"}
14
+ .ui-widget.ui-helper-clearfix{:style => 'float:right'}
15
+ = link_to '', edit_nivo_slide_path(slide), :class => 'ui-icon ui-icon-pencil edit tip', :title => "Edit This Item"
16
+ = link_to '', slide, :confirm => 'Are you sure?', :method => :delete, :class => 'ui-icon ui-icon-close destroy tip', :title => "Destroy This Item"
17
+ .handle{:style => "float:left; padding:0 10px;"}
18
+ = image_tag slide.image.url(:thumb)
19
+ %h3= link_to slide.caption, slide
20
+ %p
21
+ = link_to "Preview Slide", slide.image.url, :id => 'single_image'
22
+ %br/
23
+ %br/
24
+
25
+
26
+ = javascript_include_tag "nivo-serialize", "nivo-dragsort", "nivo-admin"
@@ -0,0 +1,2 @@
1
+ alert("Reorder Complete");
2
+
@@ -0,0 +1,6 @@
1
+ - if defined?(Dust::Application)
2
+ - title "New Slide"
3
+ - heading "New Slide"
4
+
5
+ = render 'form'
6
+
@@ -0,0 +1,19 @@
1
+ - if defined?(Dust::Application)
2
+ - title "Slide"
3
+
4
+ .item
5
+ .ui-widget.ui-helper-clearfix{:style => "float:right"}
6
+ =link_to '', edit_nivo_slide_path(@slide), :class => 'ui-icon ui-icon-pencil edit tip', :title => "Edit This Item"
7
+ =link_to "", @slide, :confirm => 'Are you sure?', :method => :delete, :class => 'ui-icon ui-icon-close destroy tip', :title => "Destroy This Item"
8
+ %h3= link_to @slide.caption, @slide
9
+ %p
10
+ = link_to image_tag(@slide.image.url), @slide, :class => 'remote_iframe'
11
+ %p
12
+ %strong Caption:
13
+ = @slide.caption
14
+ %p
15
+ %strong Url:
16
+ = @slide.url
17
+ %p
18
+ %strong Active:
19
+ = @slide.active
data/config/.DS_Store ADDED
Binary file
@@ -0,0 +1,34 @@
1
+ ---
2
+ paperclip_options:
3
+ style:
4
+ slide: '950x184#'
5
+ thumb: '200x200>'
6
+ ## example paperclip S3 storage solution
7
+ # storage: !ruby/symbol s3
8
+ # s3_credentials: "#{Rails.root.to_s}/config/s3.yml"
9
+ # path: "site_name/:attachment/:id/:style.:extension"
10
+ # bucket: 'bucket_name'
11
+
12
+ show_caption: false
13
+
14
+ nivo_options: #for more support visit http://nivo.dev7studios.com
15
+ effect: "boxRainGrow" # Specify sets like: sliceDown sliceDownLeft sliceUp sliceUpLeft sliceUpDown sliceUpDownLeft fold fade random slideInRight slideInLeft boxRandom boxRain boxRainReverse boxRainGrow boxRainGrowReverse
16
+ slices: 15 # For slice animations
17
+ boxCols: 8 # For box animations
18
+ boxRows: 4 # For box animations
19
+ animSpeed: 500 # Slide transition speed
20
+ pauseTime: 3000 # How long each slide will show
21
+ startSlide: 0 # Set starting Slide (0 index)
22
+ directionNav: true # Next & Prev navigation
23
+ directionNavHide: true # Only show on hover
24
+ controlNav: false # 1,2,3... navigation
25
+ controlNavThumbs: false # Use thumbnails for Control Nav
26
+ controlNavThumbsFromRel: false # Use image rel for thumbs
27
+ controlNavThumbsSearch: '.jpg' # Replace this with...
28
+ controlNavThumbsReplace: '_thumb.jpg' # ...this in thumb Image src
29
+ keyboardNav: true # Use left & right arrows
30
+ pauseOnHover: true # Stop animation while hovering
31
+ manualAdvance: false # Force manual transitions
32
+ captionOpacity: 0.8 # Universal caption opacity
33
+ prevText: 'Prev' # Prev directionNav text
34
+ nextText: 'Next' # Next directionNav text
data/config/routes.rb ADDED
@@ -0,0 +1,15 @@
1
+ Rails.application.routes.draw do |map|
2
+
3
+ mount_at = Nivo::Engine.config.mount_at
4
+
5
+ match mount_at => 'nivo/slides#index'
6
+
7
+ map.resources :slides, :controller => "nivo/slides",
8
+ :path_prefix => mount_at,
9
+ :name_prefix => "nivo_"
10
+
11
+ map.resources :manage_slides, :only => [:create],
12
+ :controller => "nivo/manage_slides",
13
+ :path_prefix => mount_at,
14
+ :name_prefix => "nivo_"
15
+ end
data/lib/.DS_Store ADDED
Binary file
data/lib/engine.rb ADDED
@@ -0,0 +1,34 @@
1
+ require 'nivo'
2
+ require 'rails'
3
+ require 'paperclip'
4
+ require 'haml'
5
+ require 'jquery-rails'
6
+ # require 'action_controller'
7
+
8
+
9
+ module Nivo
10
+ class Engine < Rails::Engine
11
+
12
+ # Config defaults
13
+ config.slider_factory_name = "nivo"
14
+ config.mount_at = '/nivo'
15
+
16
+ # Load rake tasks
17
+ rake_tasks do
18
+ load File.join(File.dirname(__FILE__), 'rails/railties/tasks.rake')
19
+ end
20
+
21
+ # Check the gem config
22
+ initializer "check config" do |app|
23
+
24
+ # make sure mount_at ends with trailing slash
25
+ config.mount_at += '/' unless config.mount_at.last == '/'
26
+ end
27
+
28
+ initializer "static assets" do |app|
29
+ app.middleware.use ::ActionDispatch::Static, "#{root}/public"
30
+ end
31
+
32
+ end
33
+ end
34
+
@@ -0,0 +1,8 @@
1
+ module Nivo
2
+ class Config
3
+ def self.file
4
+ raw_config = File.read("#{Rails.root}/config/nivo_config.yml")
5
+ config = YAML.load(raw_config)
6
+ end
7
+ end
8
+ end
@@ -0,0 +1,14 @@
1
+ module Nivo
2
+ module Helper
3
+ def slider(show_slider = true)
4
+ @show_slider = show_slider
5
+ end
6
+
7
+ def show_slider?
8
+ if @show_slider
9
+ @slides = Nivo::Slide.rotate
10
+ render "nivo/slideshow", :slides => @slides
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,17 @@
1
+ module Nivo
2
+ module ManageSlides
3
+ extend ActiveSupport::Concern
4
+
5
+ module ClassMethods
6
+ def sort(new_order={})
7
+ new_order.to_a
8
+ new_order.each do |order|
9
+ slide = self.find(order[1])
10
+ slide.position = order[0]
11
+ slide.save
12
+ end
13
+ end
14
+ end
15
+
16
+ end
17
+ end
@@ -0,0 +1,3 @@
1
+ module Nivo
2
+ VERSION = "0.0.2"
3
+ end
data/lib/nivo.rb ADDED
@@ -0,0 +1,13 @@
1
+ require "nivo/version"
2
+ require "nivo/helper"
3
+ require "nivo/config"
4
+ require "nivo/manage_slides"
5
+ require 'engine' if defined?(Rails) && Rails::VERSION::MAJOR == 3
6
+
7
+ if defined?(ActionView::Base)
8
+ ActionView::Base.send :include, Nivo::Helper
9
+ end
10
+
11
+ Dir.glob(File.join(File.dirname(__FILE__), "../", "db", "migrate", "*")).each do |file|
12
+ require file
13
+ end
Binary file
Binary file
Binary file
@@ -0,0 +1,18 @@
1
+ require 'rails/generators'
2
+ require 'rails/generators/migration'
3
+
4
+ module Nivo
5
+ module Generators
6
+ class ControllerGenerator < Rails::Generators::Base
7
+ source_root File.expand_path("../../../../../app/controllers", __FILE__)
8
+ desc "Copies the Nivo::Slide model to your application."
9
+
10
+ argument :scope, :required => false, :default => nil,
11
+ :desc => "The scope to copy views to"
12
+
13
+ def copy_model
14
+ directory "nivo", "app/controllers/#{scope || :nivo}"
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,49 @@
1
+ require 'rails/generators'
2
+ require 'rails/generators/migration'
3
+
4
+ module Nivo
5
+ module Generators
6
+ class InstallGenerator < Rails::Generators::Base
7
+ include Rails::Generators::Migration
8
+
9
+ def self.source_root
10
+ File.join(File.dirname(__FILE__), 'templates')
11
+ end
12
+
13
+ def create_config
14
+ copy_file "nivo_config.yml", "config/nivo_config.yml"
15
+ end
16
+
17
+ def self.next_migration_number(dirname) #:nodoc:
18
+ if ActiveRecord::Base.timestamped_migrations
19
+ Time.now.utc.strftime("%Y%m%d%H%M%S")
20
+ else
21
+ "%.3d" % (current_migration_number(dirname) + 1)
22
+ end
23
+ end
24
+
25
+ # Every method that is declared below will be automatically executed when the generator is run
26
+
27
+ def create_migration_file
28
+ f = File.open File.join(File.dirname(__FILE__), 'templates', 'schema.rb')
29
+ schema = f.read; f.close
30
+
31
+ schema.gsub!(/ActiveRecord::Schema.*\n/, '')
32
+ schema.gsub!(/^end\n*$/, '')
33
+
34
+ f = File.open File.join(File.dirname(__FILE__), 'templates', 'migration.rb')
35
+ migration = f.read; f.close
36
+ migration.gsub!(/SCHEMA_AUTO_INSERTED_HERE/, schema)
37
+
38
+ tmp = File.open "tmp/~migration_ready.rb", "w"
39
+ tmp.write migration
40
+ tmp.close
41
+
42
+ migration_template '../../../../tmp/~migration_ready.rb',
43
+ 'db/migrate/create_nivo_tables.rb'
44
+ remove_file 'tmp/~migration_ready.rb'
45
+ end
46
+
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,18 @@
1
+ require 'rails/generators'
2
+ require 'rails/generators/migration'
3
+
4
+ module Nivo
5
+ module Generators
6
+ class StylesheetGenerator < Rails::Generators::Base
7
+ source_root File.expand_path("../../../../../public/stylesheets", __FILE__)
8
+ desc "Copies Nivo stylesheets to your application."
9
+
10
+ argument :scope, :required => false, :default => nil,
11
+ :desc => "The scope to copy stylesheets to"
12
+
13
+ def copy_stylesheets
14
+ copy_file "default.css", "public/stylesheets/default.css"
15
+ end
16
+ end
17
+ end
18
+ end
@@ -0,0 +1,12 @@
1
+ class CreateNivoTables < ActiveRecord::Migration
2
+ def self.up
3
+ SCHEMA_AUTO_INSERTED_HERE
4
+ CmsMenuItem.create({:title =>"Slides", :controller_name => "nivo/slides", :url => "/nivo/slides"})
5
+ end
6
+
7
+ def self.down
8
+ drop_table :slides
9
+ item = CmsMenuItem.find_by_title("Slides")
10
+ item.destroy
11
+ end
12
+ end