c80_swiper 0.1.0

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.
@@ -0,0 +1,18 @@
1
+ module C80Swiper
2
+ class Swslider < ActiveRecord::Base
3
+
4
+ has_many :sframes, :dependent => :destroy
5
+ accepts_nested_attributes_for :sframes,
6
+ :reject_if => lambda { |attributes|
7
+ !attributes.present?
8
+ },
9
+ :allow_destroy => true
10
+
11
+ # has_and_belongs_to_many :swprops
12
+ # выдать список тех Примеров, которые должны выводиться в виджете
13
+ # def self.all_widgeted
14
+ # self.joins(:csprops)
15
+ # end
16
+
17
+ end
18
+ end
@@ -0,0 +1,54 @@
1
+ module C80Swiper
2
+
3
+ # грузит картинку фрейма
4
+ class SframeUploader < BaseFileUploader
5
+
6
+ process :resize_to_limit => [1024,768]
7
+
8
+ version :thumb_big_one do
9
+ begin
10
+ p = C80Swiper::Swprop.first
11
+ process :resize_to_fill => [p.big_one_width, p.big_one_height]
12
+ rescue => e
13
+ end
14
+ end
15
+
16
+ version :thumb_preview do
17
+ begin
18
+ p = C80Swiper::Swprop.first
19
+ process :resize_to_fill => [p.preview_width, p.preview_height]
20
+ rescue => e
21
+ end
22
+ end
23
+
24
+ version :thumb_sm do
25
+ begin
26
+ p = C80Swiper::Swprop.first
27
+ process :resize_to_fill => [p.thumb_sm_width, p.thumb_sm_height]
28
+ rescue => e
29
+ end
30
+ end
31
+
32
+ version :thumb_md do
33
+ begin
34
+ p = C80Swiper::Swprop.first
35
+ process :resize_to_fill => [p.thumb_md_width, p.thumb_md_height]
36
+ rescue => e
37
+ end
38
+ end
39
+
40
+ version :thumb_lg do
41
+ begin
42
+ p = C80Swiper::Swprop.first
43
+ process :resize_to_fill => [p.thumb_lg_width, p.thumb_lg_height]
44
+ rescue => e
45
+ end
46
+ end
47
+
48
+ def store_dir
49
+ 'uploads/oimages'
50
+ end
51
+
52
+ end
53
+
54
+ end
@@ -0,0 +1,56 @@
1
+ <!-- Slider main container -->
2
+ <div class="swiper-container">
3
+
4
+ <!-- Additional required wrapper -->
5
+ <div class="swiper-wrapper">
6
+
7
+ <!-- Slides -->
8
+ <% frames.each_with_index do |frame, index| %>
9
+
10
+ <!--Slide #<%= index %>-->
11
+
12
+ <% if options[:mark_lazy].present? %>
13
+ <div class="swiper-slide frame_index_<%= index %>">
14
+ <!-- Required swiper-lazy class and image source specified in data-src attribute -->
15
+ <img data-src="<%= frame.image.thumb_lg %>" class="swiper-lazy">
16
+ <!-- Preloader image -->
17
+ <div class="swiper-lazy-preloader"></div>
18
+ </div>
19
+ <% else %>
20
+ <div class="swiper-slide frame_index_<%= index %>" style="background-image:url(<%= frame.image.thumb_lg %>)">
21
+
22
+ <h3><%= frame.title %></h3>
23
+ <% frame.fcaptions.each_with_index do |fcaption, index2| %>
24
+ <div class="fcaption fcaption_index_<%= index2 %>">
25
+ <%= fcaption.value.html_safe %>
26
+ </div>
27
+ <% end %>
28
+
29
+ </div>
30
+ <% end %>
31
+
32
+ <% end %>
33
+
34
+ </div>
35
+
36
+ <% if options[:mark_pagination].present? %>
37
+ <!-- If we need pagination -->
38
+ <div class="swiper-pagination"></div>
39
+ <% end %>
40
+
41
+ <% if options[:mark_buttons].present? %>
42
+ <!-- If we need navigation buttons -->
43
+ <div class="swiper-button-prev"></div>
44
+ <div class="swiper-button-next"></div>
45
+ <% end %>
46
+
47
+ <% if options[:mark_scrollbar].present? %>
48
+ <!-- If we need scrollbar -->
49
+ <div class="swiper-scrollbar"></div>
50
+ <% end %>
51
+
52
+ </div>
53
+
54
+ <script>
55
+ create_swiper(<%= options.to_json.html_safe %>);
56
+ </script>
@@ -0,0 +1 @@
1
+ <%= error_message.html_safe %>
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "c80_swiper"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,27 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'c80_swiper/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = 'c80_swiper'
8
+ spec.version = C80Swiper::VERSION
9
+ spec.authors = ['C80609A']
10
+ spec.email = ['c80609a@gmail.com']
11
+
12
+ spec.summary = 'News gem'
13
+ spec.description = 'Gem adds swipers to site'
14
+ spec.homepage = 'https://github.com/c80609a/c80_swiper'
15
+
16
+ spec.license = 'MIT'
17
+
18
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
19
+ spec.bindir = 'exe'
20
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
21
+ spec.require_paths = ['lib']
22
+
23
+ spec.add_development_dependency 'bundler', '~> 1.12'
24
+ spec.add_development_dependency 'rake', '~> 10.0'
25
+ spec.add_dependency 'activesupport', ['>= 3.0.0']
26
+
27
+ end
@@ -0,0 +1,17 @@
1
+ class CreateC80SwiperSwprops < ActiveRecord::Migration
2
+ def change
3
+ create_table :c80_swiper_swprops, :options => 'COLLATE=utf8_unicode_ci' do |t|
4
+
5
+ t.integer :thumb_sm_width
6
+ t.integer :thumb_sm_height
7
+
8
+ t.integer :thumb_md_width
9
+ t.integer :thumb_md_height
10
+
11
+ t.integer :thumb_lg_width
12
+ t.integer :thumb_lg_height
13
+
14
+ t.timestamps null: false
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,9 @@
1
+ class CreateC80SwiperSwsliders < ActiveRecord::Migration
2
+ def change
3
+ create_table :c80_swiper_swsliders, :options => 'COLLATE=utf8_unicode_ci' do |t|
4
+ t.string :title
5
+
6
+ t.timestamps null: false
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,15 @@
1
+ class CreateC80SwiperSframes < ActiveRecord::Migration
2
+ def change
3
+ create_table :c80_swiper_sframes, :options => 'COLLATE=utf8_unicode_ci' do |t|
4
+ t.string :title
5
+ t.string :link_url
6
+ t.string :image
7
+ t.integer :ord
8
+ t.boolean :enabled, default: true
9
+ t.references :swslider, index: true
10
+
11
+ t.timestamps null: false
12
+ end
13
+ # add_foreign_key :c80_swiper_sframes, :swsliders
14
+ end
15
+ end
@@ -0,0 +1,12 @@
1
+ class CreateC80SwiperFcaptions < ActiveRecord::Migration
2
+ def change
3
+ create_table :c80_swiper_fcaptions, :options => 'COLLATE=utf8_unicode_ci' do |t|
4
+ t.string :value
5
+ t.references :sframe, index: true
6
+ t.integer :ord
7
+
8
+ t.timestamps null: false
9
+ end
10
+ # add_foreign_key :c80_swiper_fcaptions, :sframes
11
+ end
12
+ end
@@ -0,0 +1,11 @@
1
+ # rake db:seed:c80_swiper_01_fill_props
2
+
3
+ C80Swiper::Swprop.delete_all
4
+ C80Swiper::Swprop.create!({
5
+ thumb_sm_width: 80,
6
+ thumb_sm_height: 50,
7
+ thumb_md_width: 250,
8
+ thumb_md_height: 160,
9
+ thumb_lg_width: 1000,
10
+ thumb_lg_height: 550,
11
+ })
@@ -0,0 +1,23 @@
1
+ module C80Swiper
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace C80Swiper
4
+
5
+ initializer :c80_swiper_engine do
6
+ if defined?(ActiveAdmin)
7
+ ActiveAdmin.application.load_paths += Dir["#{config.root}/app/models/**/"]
8
+ #ActiveAdmin.application.load_paths += Dir["#{config.root}/app/models/concerns/**/"]
9
+ ActiveAdmin.application.load_paths += Dir["#{config.root}/app/admin/c80_swiper/**/"]
10
+ # ActiveAdmin.application.load_paths += Dir["#{config.root}/app/jobs/**/"]
11
+ end
12
+ end
13
+
14
+ initializer :append_migrations do |app|
15
+ unless app.root.to_s.match root.to_s
16
+ config.paths['db/migrate'].expanded.each do |expanded_path|
17
+ app.config.paths['db/migrate'] << expanded_path
18
+ end
19
+ end
20
+ end
21
+
22
+ end
23
+ end
@@ -0,0 +1,3 @@
1
+ module C80Swiper
2
+ VERSION = "0.1.0"
3
+ end
data/lib/c80_swiper.rb ADDED
@@ -0,0 +1,8 @@
1
+ require "c80_swiper/version"
2
+ require "c80_swiper/engine"
3
+
4
+ module C80Swiper
5
+ def self.table_name_prefix
6
+ 'c80_swiper_'
7
+ end
8
+ end
metadata ADDED
@@ -0,0 +1,117 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: c80_swiper
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - C80609A
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-11-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.12'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.12'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: activesupport
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: 3.0.0
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: 3.0.0
55
+ description: Gem adds swipers to site
56
+ email:
57
+ - c80609a@gmail.com
58
+ executables: []
59
+ extensions: []
60
+ extra_rdoc_files: []
61
+ files:
62
+ - ".gitignore"
63
+ - CODE_OF_CONDUCT.md
64
+ - Gemfile
65
+ - LICENSE.txt
66
+ - README.md
67
+ - Rakefile
68
+ - app/admin/c80_swiper/swsliders.rb
69
+ - app/assets/javascripts/c80_swiper.js.coffee
70
+ - app/assets/javascripts/c80_swiper/_lib/swiper.jquery.js
71
+ - app/assets/javascripts/c80_swiper/create_swiper.js
72
+ - app/assets/stylesheets/c80_swiper.scss
73
+ - app/assets/stylesheets/c80_swiper/_lib/swiper.scss
74
+ - app/helpers/c80_swiper/app_helper.rb
75
+ - app/models/c80_swiper/fcaption.rb
76
+ - app/models/c80_swiper/sframe.rb
77
+ - app/models/c80_swiper/swprop.rb
78
+ - app/models/c80_swiper/swslider.rb
79
+ - app/uploaders/c80_swiper/sframe_uploader.rb
80
+ - app/views/c80_swiper/_swipe.html.erb
81
+ - app/views/c80_swiper/shared/_swipe_error_message.html.erb
82
+ - bin/console
83
+ - bin/setup
84
+ - c80_swiper.gemspec
85
+ - db/migrate/20161111034340_create_c80_swiper_swprops.rb
86
+ - db/migrate/20161111041555_create_c80_swiper_swsliders.rb
87
+ - db/migrate/20161111042457_create_c80_swiper_sframes.rb
88
+ - db/migrate/20161111045743_create_c80_swiper_fcaptions.rb
89
+ - db/seeds/c80_swiper_01_fill_props.rb
90
+ - lib/c80_swiper.rb
91
+ - lib/c80_swiper/engine.rb
92
+ - lib/c80_swiper/version.rb
93
+ homepage: https://github.com/c80609a/c80_swiper
94
+ licenses:
95
+ - MIT
96
+ metadata: {}
97
+ post_install_message:
98
+ rdoc_options: []
99
+ require_paths:
100
+ - lib
101
+ required_ruby_version: !ruby/object:Gem::Requirement
102
+ requirements:
103
+ - - ">="
104
+ - !ruby/object:Gem::Version
105
+ version: '0'
106
+ required_rubygems_version: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ requirements: []
112
+ rubyforge_project:
113
+ rubygems_version: 2.5.1
114
+ signing_key:
115
+ specification_version: 4
116
+ summary: News gem
117
+ test_files: []