c80_album_gallery 0.1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +11 -0
  3. data/.idea/.rakeTasks +7 -0
  4. data/CODE_OF_CONDUCT.md +49 -0
  5. data/Gemfile +4 -0
  6. data/LICENSE.txt +21 -0
  7. data/README.md +41 -0
  8. data/Rakefile +2 -0
  9. data/app/admin/c80_album_gallery/galleries.rb +55 -0
  10. data/app/assets/javascripts/c80_album_gallery.js.coffee +1 -0
  11. data/app/assets/javascripts/c80_album_gallery/gallery.js +13 -0
  12. data/app/assets/stylesheets/c80_album_gallery.scss +1 -0
  13. data/app/assets/stylesheets/c80_album_gallery/_mixins/gallery_list_default.scss +45 -0
  14. data/app/assets/stylesheets/c80_album_gallery/_mixins/slot_item_overlayed.scss +70 -0
  15. data/app/assets/stylesheets/c80_album_gallery/_styles/style_photostudio.scss +34 -0
  16. data/app/assets/stylesheets/c80_album_gallery/_styles/style_photostudio_widget.scss +37 -0
  17. data/app/assets/stylesheets/c80_album_gallery/gallery_list.scss +13 -0
  18. data/app/assets/stylesheets/c80_album_gallery/gallery_list_slots.scss +5 -0
  19. data/app/assets/stylesheets/c80_album_gallery/gallery_view.scss +20 -0
  20. data/app/helpers/c80_album_gallery/c80_album_gallery_application_helper.rb +125 -0
  21. data/app/models/c80_album_gallery/gallery.rb +14 -0
  22. data/app/models/c80_album_gallery/gphoto.rb +6 -0
  23. data/app/models/c80_album_gallery/prop.rb +4 -0
  24. data/app/uploaders/c80_album_gallery/gphoto_uploader.rb +100 -0
  25. data/app/views/c80_album_gallery/_flow_galleries_slots.html.erb +27 -0
  26. data/app/views/c80_album_gallery/_gallery_list.html.erb +28 -0
  27. data/app/views/c80_album_gallery/_gallery_view_page.html.erb +23 -0
  28. data/bin/console +14 -0
  29. data/bin/setup +8 -0
  30. data/c80_album_gallery.gemspec +27 -0
  31. data/db/migrate/20160916114444_create_galleries.rb +10 -0
  32. data/db/migrate/20160916114545_create_gphotos.rb +10 -0
  33. data/db/migrate/20161006151414_c80_album_gallery_create_props.rb +17 -0
  34. data/db/migrate/20161010072525_c80_album_gallery_add_preview_to_props.rb +6 -0
  35. data/db/seeds/c80_album_gallery_fill_props.rb +24 -0
  36. data/db/seeds/c80_album_gallery_fill_sample_galleries.rb +17 -0
  37. data/db/seeds/c80_album_gallery_recreate_versions.rb +7 -0
  38. data/lib/c80_album_gallery.rb +8 -0
  39. data/lib/c80_album_gallery/engine.rb +23 -0
  40. data/lib/c80_album_gallery/version.rb +3 -0
  41. metadata +139 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: dedff5028fd9d1e6e663291780606a1a6e4ce54d
4
+ data.tar.gz: 04bcbc89b76812fd538acbc278b90e161e3b0e42
5
+ SHA512:
6
+ metadata.gz: 6d5a9e4e7914c30265024bc56b47d9b18b46292a827ce3bb5009d438b9aa4831f5a30e82c5135b35271b5534bf5919c7feec692380d0a7daff033f912e3ee6fe
7
+ data.tar.gz: 0b3362e329bea664125f10c1462f666609341ea384826dbd872966f11c991789e499c4c1b6e4dd744a1c0f20e3d2d29a21d317a000140c00ae680c4efffd3945
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ /.idea/
2
+ /.bundle/
3
+ /.yardoc
4
+ /Gemfile.lock
5
+ /_yardoc/
6
+ /coverage/
7
+ /doc/
8
+ /pkg/
9
+ /spec/reports/
10
+ /tmp/
11
+ *.bin
data/.idea/.rakeTasks ADDED
@@ -0,0 +1,7 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <Settings><!--This file was automatically generated by Ruby plugin.
3
+ You are allowed to:
4
+ 1. Remove rake task
5
+ 2. Add existing rake tasks
6
+ To add existing rake tasks automatically delete this file and reload the project.
7
+ --><RakeGroup description="" fullCmd="" taksId="rake"><RakeTask description="Build c80_album_gallery-0.1.0.gem into the pkg directory" fullCmd="build" taksId="build" /><RakeTask description="Remove any temporary products" fullCmd="clean" taksId="clean" /><RakeTask description="Remove any generated files" fullCmd="clobber" taksId="clobber" /><RakeTask description="Build and install c80_album_gallery-0.1.0.gem into system gems" fullCmd="install" taksId="install" /><RakeGroup description="" fullCmd="" taksId="install"><RakeTask description="Build and install c80_album_gallery-0.1.0.gem into system gems without network access" fullCmd="install:local" taksId="local" /></RakeGroup><RakeTask description="Create tag v0.1.0 and build and push c80_album_gallery-0.1.0.gem to Rubygems" fullCmd="release[remote]" taksId="release[remote]" /><RakeTask description="" fullCmd="default" taksId="default" /><RakeTask description="" fullCmd="release" taksId="release" /><RakeGroup description="" fullCmd="" taksId="release"><RakeTask description="" fullCmd="release:guard_clean" taksId="guard_clean" /><RakeTask description="" fullCmd="release:rubygem_push" taksId="rubygem_push" /><RakeTask description="" fullCmd="release:source_control_push" taksId="source_control_push" /></RakeGroup></RakeGroup></Settings>
@@ -0,0 +1,49 @@
1
+ # Contributor Code of Conduct
2
+
3
+ As contributors and maintainers of this project, and in the interest of
4
+ fostering an open and welcoming community, we pledge to respect all people who
5
+ contribute through reporting issues, posting feature requests, updating
6
+ documentation, submitting pull requests or patches, and other activities.
7
+
8
+ We are committed to making participation in this project a harassment-free
9
+ experience for everyone, regardless of level of experience, gender, gender
10
+ identity and expression, sexual orientation, disability, personal appearance,
11
+ body size, race, ethnicity, age, religion, or nationality.
12
+
13
+ Examples of unacceptable behavior by participants include:
14
+
15
+ * The use of sexualized language or imagery
16
+ * Personal attacks
17
+ * Trolling or insulting/derogatory comments
18
+ * Public or private harassment
19
+ * Publishing other's private information, such as physical or electronic
20
+ addresses, without explicit permission
21
+ * Other unethical or unprofessional conduct
22
+
23
+ Project maintainers have the right and responsibility to remove, edit, or
24
+ reject comments, commits, code, wiki edits, issues, and other contributions
25
+ that are not aligned to this Code of Conduct, or to ban temporarily or
26
+ permanently any contributor for other behaviors that they deem inappropriate,
27
+ threatening, offensive, or harmful.
28
+
29
+ By adopting this Code of Conduct, project maintainers commit themselves to
30
+ fairly and consistently applying these principles to every aspect of managing
31
+ this project. Project maintainers who do not follow or enforce the Code of
32
+ Conduct may be permanently removed from the project team.
33
+
34
+ This code of conduct applies both within project spaces and in public spaces
35
+ when an individual is representing the project or its community.
36
+
37
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
38
+ reported by contacting a project maintainer at c080609a@gmail.com. All
39
+ complaints will be reviewed and investigated and will result in a response that
40
+ is deemed necessary and appropriate to the circumstances. Maintainers are
41
+ obligated to maintain confidentiality with regard to the reporter of an
42
+ incident.
43
+
44
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
45
+ version 1.3.0, available at
46
+ [http://contributor-covenant.org/version/1/3/0/][version]
47
+
48
+ [homepage]: http://contributor-covenant.org
49
+ [version]: http://contributor-covenant.org/version/1/3/0/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in c80_album_gallery.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2016 C80609A
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,41 @@
1
+ # C80AlbumGallery
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/c80_album_gallery`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'c80_album_gallery'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install c80_album_gallery
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
30
+
31
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/c80_album_gallery. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
+
37
+
38
+ ## License
39
+
40
+ The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
41
+
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
@@ -0,0 +1,55 @@
1
+ ActiveAdmin.register C80AlbumGallery::Gallery, :as => 'Gallery' do
2
+
3
+ menu :label => "Галереи"
4
+
5
+ permit_params :title,
6
+ :tag,
7
+ :gphotos_attributes => [:id,:image,:_destroy]
8
+
9
+ before_filter :skip_sidebar!, :only => :index
10
+
11
+ # controller do
12
+ # cache_sweeper :suit_sweeper, :only => [:update,:create,:destroy]
13
+ # end
14
+
15
+ index do
16
+ selectable_column
17
+ id_column
18
+ column :tag
19
+ column "Дата" do |gallery|
20
+ "#{local_time(gallery[:created_at],format: '%e/%m/%Y')}".html_safe
21
+ end
22
+ column "Заголовок" do |gallery|
23
+ "<h3 style='width:150px;'>#{gallery.title}</h3>".html_safe
24
+ end
25
+
26
+ column "" do |gallery|
27
+ arr = []
28
+ gallery.gphotos.limit(2).each do |gp|
29
+ arr << image_tag(gp.image.thumb_md, :style => "margin-left:5px")
30
+ end
31
+ arr << "<br>Всего фотографий: #{gallery.gphotos.count}"
32
+ arr.join("").html_safe
33
+ end
34
+
35
+ actions
36
+ end
37
+
38
+ form(:html => {:multipart => true}) do |f|
39
+ f.inputs "Галерея" do
40
+ f.input :title
41
+ # f.input :tag
42
+
43
+ f.inputs "Фотографии" do
44
+ f.has_many :gphotos, :allow_destroy => true do |gp|
45
+ gp.input :image,
46
+ :as => :file,
47
+ :hint => gp.template.image_tag(gp.object.image.thumb_md)
48
+ end
49
+ end
50
+
51
+ end
52
+ f.actions
53
+ end
54
+
55
+ end
@@ -0,0 +1 @@
1
+ #= require_tree ./c80_album_gallery
@@ -0,0 +1,13 @@
1
+ $(document).ready(function () {
2
+
3
+ var $butts = $("ul#gallery_list").find("a");
4
+
5
+ $butts.bind({
6
+ mouseenter: function() {
7
+ $(this).addClass("plusOpacity");
8
+ },
9
+ mouseleave: function() {
10
+ $(this).removeClass("plusOpacity");
11
+ }
12
+ })
13
+ });
@@ -0,0 +1 @@
1
+ @import "c80_album_gallery/**/*";
@@ -0,0 +1,45 @@
1
+ %gallery_list_default {
2
+
3
+ .slot_item {
4
+ padding: 0;
5
+
6
+ div.photo {
7
+ margin: 0 auto 5px auto;
8
+
9
+ a {
10
+
11
+ img {
12
+ max-width: 100%;
13
+ }
14
+
15
+ /* если картинка не загрузилась - она не будет показана */
16
+ &.nil_img {
17
+
18
+ background-color: #f7f7f7 !important;
19
+
20
+ img {
21
+ display: none;
22
+ }
23
+
24
+ }
25
+
26
+ }
27
+
28
+ }
29
+
30
+ div.title {
31
+ margin: 0 auto 5px auto;
32
+
33
+ a {
34
+ text-decoration: none;
35
+ color: black;
36
+ &:hover { color: #111111; text-decoration: none; }
37
+ &:focus { color: #202020; }
38
+ &:active { color: #2b2b2b; }
39
+ }
40
+
41
+ }
42
+
43
+ }
44
+
45
+ }
@@ -0,0 +1,70 @@
1
+ // слот, у которого title находится поверх картинки и виден только тогда, когда наводим мышкой
2
+
3
+ %slot_item_overlayed {
4
+ overflow: hidden;
5
+ /*margin-bottom: 8px;*/
6
+
7
+ div.photo {
8
+
9
+ > a {
10
+
11
+ > img {
12
+ -webkit-transition: all 0.5s;
13
+ transition: all 0.5s;
14
+
15
+ filter: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg"><filter id="filter"><feComponentTransfer color-interpolation-filters="sRGB"><feFuncR type="linear" slope="1.4" /><feFuncG type="linear" slope="1.4" /><feFuncB type="linear" slope="1.4" /></feComponentTransfer></filter></svg>#filter');
16
+ filter: grayscale(1);
17
+ -webkit-filter: grayscale(1);
18
+
19
+ }
20
+
21
+ }
22
+
23
+ }
24
+
25
+ div.title {
26
+ margin-top: -41px;
27
+ margin-left: 7px; /*NOTE:: помещаем вместе с фоном прямо под картинку */
28
+ z-index: 2;
29
+ position: absolute;
30
+ opacity: 0.0;
31
+ filter: alpha(opacity=0);
32
+ -webkit-transition: all 0.5s;
33
+ transition: all 0.5s;
34
+ padding-left: 15px;
35
+
36
+ > a {
37
+ color: white;
38
+ font-size: 21px;
39
+ line-height: 65px;
40
+
41
+ &:hover {
42
+ color: white;
43
+ }
44
+
45
+ }
46
+
47
+ }
48
+
49
+ &:hover {
50
+
51
+ div.photo {
52
+ > a {
53
+ > img {
54
+ filter: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg"><filter id="filter"><feComponentTransfer color-interpolation-filters="sRGB"><feFuncR type="linear" slope="1.4" /><feFuncG type="linear" slope="1.4" /><feFuncB type="linear" slope="1.4" /></feComponentTransfer></filter></svg>#filter');
55
+ filter: grayscale(0);
56
+ -webkit-filter: grayscale(0);
57
+ }
58
+ }
59
+ }
60
+
61
+ div.title {
62
+ margin-top: -71px;
63
+ background-color: rgba(0, 0, 0, 0.6);
64
+ opacity: 1;
65
+ filter: alpha(opacity=100);
66
+ }
67
+
68
+ }
69
+
70
+ }
@@ -0,0 +1,34 @@
1
+ $minus_left_right_margin: -5px; // отрицательные отступы слева и справа
2
+ $top_margin: 20px; // отступ сверху
3
+ $bottom_margin: 25px; // отступ снизу
4
+
5
+ @mixin style_photostudio {
6
+
7
+ padding: 0;
8
+ margin: $top_margin $minus_left_right_margin $bottom_margin $minus_left_right_margin;
9
+
10
+ .slot_item {
11
+ margin-bottom: 8px;
12
+
13
+ @extend %slot_item_overlayed;
14
+
15
+ div.photo {
16
+ margin-bottom: 5px;
17
+
18
+ > a {
19
+
20
+ > img {
21
+
22
+ }
23
+
24
+ }
25
+
26
+ }
27
+
28
+ div.title {
29
+ /*margin-bottom: 20px;*/
30
+ }
31
+
32
+ }
33
+
34
+ }
@@ -0,0 +1,37 @@
1
+ $minus_left_right_margin: -5px; // отрицательные отступы слева и справа
2
+ $top_margin: 20px; // отступ сверху
3
+ $bottom_margin: 25px; // отступ снизу
4
+
5
+ @mixin style_photostudio_widget {
6
+
7
+ padding: 0;
8
+ margin: $top_margin $minus_left_right_margin $bottom_margin $minus_left_right_margin;
9
+
10
+ .slot_item {
11
+ margin-bottom: 8px;
12
+ float: left;
13
+ margin-right: 15px;
14
+
15
+ @extend %slot_item_overlayed;
16
+
17
+ div.photo {
18
+ margin-bottom: 5px;
19
+
20
+ > a {
21
+
22
+ > img {
23
+
24
+ }
25
+
26
+ }
27
+
28
+ }
29
+
30
+ div.title {
31
+ /*margin-bottom: 20px;*/
32
+ margin-left: 0 !important;
33
+ }
34
+
35
+ }
36
+
37
+ }
@@ -0,0 +1,13 @@
1
+ div.gallery_list {
2
+
3
+ @extend %gallery_list_default;
4
+
5
+ &.style_photostudio {
6
+ @include style_photostudio;
7
+ }
8
+
9
+ &.style_photostudio_widget {
10
+ @include style_photostudio_widget;
11
+ }
12
+
13
+ }
@@ -0,0 +1,5 @@
1
+ div.gallery_list_slots {
2
+
3
+ @extend %gallery_list_default;
4
+
5
+ }
@@ -0,0 +1,20 @@
1
+ .gallery_view {
2
+
3
+ padding: 0;
4
+ margin-left: -15px;
5
+ width: calc(100% + 15px);
6
+
7
+ > div {
8
+ margin-bottom: 25px;
9
+
10
+ a {
11
+
12
+ img {
13
+ max-width: 100%;
14
+ }
15
+
16
+ }
17
+
18
+ }
19
+
20
+ }
@@ -0,0 +1,125 @@
1
+ module C80AlbumGallery
2
+ module C80AlbumGalleryApplicationHelper
3
+
4
+ # TODO:: негибко: а что делать, если мне нужен иной путь в host приложеии, не portfolio?
5
+ def my_url_for_gallery(gallery)
6
+ "#{root_url}portfolio/#{gallery.id}"
7
+ end
8
+
9
+ # выдать список обложек галерей, снабжённых title, при клике ведущих на просмотр галери
10
+ def render_gallery_list_old
11
+
12
+ v = Gallery.all
13
+
14
+ render :partial => 'c80_album_gallery/flow_galleries',
15
+ :locals => {
16
+ list:v
17
+ }
18
+
19
+ end
20
+
21
+ # отрендерить "внутренности" галереи: т.е. открыть на просмотр фото
22
+ def render_view_gallery_page_old(gallery,perrow=3)
23
+
24
+ render :partial => 'c80_album_gallery/gallery',
25
+ :locals => {
26
+ :gallery => gallery,
27
+ :perrow => perrow,
28
+ :gtag => gallery.id
29
+ }
30
+
31
+ end
32
+
33
+ def render_view_gallery_page(gallery,
34
+ css_list_klass='style_1',
35
+ css_item_klass='col-lg-4 col-md-4 col-sm-6 col-xs-6',
36
+ thumb_size='thumb_md')
37
+
38
+ list = gallery.gphotos
39
+
40
+ w = C80AlbumGallery::Prop.first.send("#{thumb_size}_width")
41
+ h = C80AlbumGallery::Prop.first.send("#{thumb_size}_height")
42
+ w_style = "width:#{w}px"
43
+ h_style = "height:#{h}px"
44
+ # wh_style = "#{w_style};#{h_style}"
45
+
46
+ render :partial => 'c80_album_gallery/gallery_view_page',
47
+ :locals => {
48
+ list: list,
49
+ css_list_klass: css_list_klass,
50
+ css_item_klass: css_item_klass,
51
+ thumb_size: thumb_size,
52
+ w_style: w_style,
53
+ h_style: h_style,
54
+ gallery_title: gallery.title
55
+ }
56
+
57
+ end
58
+
59
+ # выдать список обложек галерей, снабжённых title, при клике ведущих на просмотр галери
60
+ # 1. Под список фиксируется count позиций: если галереи для какой-то позиции не нашлось - будет выведена серая болванка (которая будет как бы намекать "дружок, тут должно быть что-то согласно макету, загрузи недостающие элементы")
61
+ # 2. Галереи берутся в порядке def_order, затем случайным образом перемешиваются, затем уже вставляются во VIEW.
62
+ # 3. С помощью css_klass можно регулировать количество элементов в ряду.
63
+ # 4. С помощью css_list_klass можно кастомизировать внеший вид списка.
64
+ # 5. С помощью thumb_size можно регулировать размер картинки
65
+ def render_gallery_list_slots(count=3,
66
+ css_list_klass='style_1',
67
+ css_item_klass='col-lg-4 col-md-4 col-sm-6 col-xs-6',
68
+ thumb_size='thumb_md')
69
+
70
+ # извлечём нужное количество альбомов (нужно помнить, что нужного количества может и не набраться)
71
+ galleries = Gallery.all.def_order.limit(count).order('rand()')
72
+
73
+ # предварительно подготовим список к рендеру
74
+ list = []
75
+ count.times do |i|
76
+ gallery = galleries[i]
77
+ if gallery.present?
78
+ list << gallery
79
+ else
80
+ list << Gallery.new({ title: "Слот #{i}", tag: "slot_#{i}" })
81
+ end
82
+ end
83
+
84
+ render :partial => 'c80_album_gallery/flow_galleries_slots',
85
+ :locals => {
86
+ list: list,
87
+ count: count,
88
+ css_list_klass: css_list_klass,
89
+ css_item_klass: css_item_klass,
90
+ thumb_size: thumb_size
91
+ }
92
+
93
+ end
94
+
95
+ # выдать список обложек галерей, снабжённых title, при клике ведущих на просмотр галереи
96
+ # 2. Галереи берутся в порядке def_order
97
+ # 3. С помощью css_klass можно регулировать количество элементов в ряду.
98
+ # 4. С помощью css_list_klass можно кастомизировать внеший вид списка.
99
+ # 5. С помощью thumb_size можно регулировать размер картинки
100
+ def render_gallery_list( css_list_klass='style_1',
101
+ css_item_klass='col-lg-4 col-md-4 col-sm-6 col-xs-6',
102
+ thumb_size='thumb_md')
103
+
104
+ galleries_list = Gallery.all.def_order
105
+
106
+ w = C80AlbumGallery::Prop.first.send("#{thumb_size}_width")
107
+ h = C80AlbumGallery::Prop.first.send("#{thumb_size}_height")
108
+ w_style = "width:#{w}px"
109
+ h_style = "height:#{h}px"
110
+ # wh_style = "#{w_style};#{h_style}"
111
+
112
+ render :partial => 'c80_album_gallery/gallery_list',
113
+ :locals => {
114
+ list: galleries_list,
115
+ css_list_klass: css_list_klass,
116
+ css_item_klass: css_item_klass,
117
+ thumb_size: thumb_size,
118
+ w_style: w_style,
119
+ h_style: h_style
120
+ }
121
+
122
+ end
123
+
124
+ end
125
+ end
@@ -0,0 +1,14 @@
1
+ module C80AlbumGallery
2
+ class Gallery < ActiveRecord::Base
3
+ has_many :gphotos, :dependent => :destroy
4
+ accepts_nested_attributes_for :gphotos,
5
+ :reject_if => lambda { |attributes|
6
+ !attributes.present?
7
+ },
8
+ :allow_destroy => true
9
+
10
+ scope :def_order, -> {order(:created_at => :desc)}
11
+
12
+ end
13
+
14
+ end
@@ -0,0 +1,6 @@
1
+ module C80AlbumGallery
2
+ class Gphoto < ActiveRecord::Base
3
+ belongs_to :gallery
4
+ mount_uploader :image, GphotoUploader
5
+ end
6
+ end
@@ -0,0 +1,4 @@
1
+ module C80AlbumGallery
2
+ class Prop < ActiveRecord::Base
3
+ end
4
+ end
@@ -0,0 +1,100 @@
1
+ module C80AlbumGallery
2
+
3
+ class GphotoUploader < BaseFileUploader
4
+
5
+ def store_dir
6
+ "uploads/gallery/#{format("%03d",model.gallery_id)}"
7
+ end
8
+
9
+ # ограничение оригинальной картинки
10
+ process :resize_to_limit => [1600,1600]
11
+
12
+ version :thumb_lg do
13
+ process :resize_to_lg
14
+ end
15
+
16
+ version :thumb_md do
17
+ process :resize_to_md
18
+ end
19
+
20
+ version :thumb_sm do
21
+ process :resize_to_sm
22
+ end
23
+
24
+ version :thumb_preview do
25
+ process :resize_to_preview
26
+ end
27
+
28
+ # ------------------------------------------------------------------------------------------------------------------------
29
+
30
+ def resize_to_lg
31
+
32
+ manipulate! do |img|
33
+
34
+ w = C80AlbumGallery::Prop.first.thumb_lg_width
35
+ h = C80AlbumGallery::Prop.first.thumb_lg_height
36
+
37
+ img.resize "#{w}x#{h}^"
38
+ img.gravity 'center'
39
+ img.extent "#{w}x#{h}"
40
+ img = yield(img) if block_given?
41
+ img
42
+
43
+ end
44
+
45
+ end
46
+
47
+ def resize_to_md
48
+
49
+ manipulate! do |img|
50
+
51
+ w = C80AlbumGallery::Prop.first.thumb_md_width
52
+ h = C80AlbumGallery::Prop.first.thumb_md_height
53
+
54
+ img.resize "#{w}x#{h}^"
55
+ img.gravity 'center'
56
+ img.extent "#{w}x#{h}"
57
+ img = yield(img) if block_given?
58
+ img
59
+
60
+ end
61
+
62
+ end
63
+
64
+ def resize_to_sm
65
+
66
+ manipulate! do |img|
67
+
68
+ w = C80AlbumGallery::Prop.first.thumb_sm_width
69
+ h = C80AlbumGallery::Prop.first.thumb_sm_height
70
+
71
+ img.resize "#{w}x#{h}^"
72
+ img.gravity 'center'
73
+ img.extent "#{w}x#{h}"
74
+ img = yield(img) if block_given?
75
+ img
76
+
77
+ end
78
+
79
+ end
80
+
81
+ def resize_to_preview
82
+
83
+ manipulate! do |img|
84
+
85
+ w = C80AlbumGallery::Prop.first.thumb_preview_width
86
+ h = C80AlbumGallery::Prop.first.thumb_preview_height
87
+
88
+ img.resize "#{w}x#{h}^"
89
+ img.gravity 'center'
90
+ img.extent "#{w}x#{h}"
91
+ img = yield(img) if block_given?
92
+ img
93
+
94
+ end
95
+
96
+ end
97
+
98
+ end
99
+
100
+ end
@@ -0,0 +1,27 @@
1
+ <div class="gallery_list_slots <%= css_list_klass %> clearfix">
2
+
3
+ <% count.times do |i| %>
4
+ <% gallery = list[i] %>
5
+ <% title = gallery.title %>
6
+ <% image = nil %>
7
+ <% a_klass = 'nil_img' %>
8
+ <% image = gallery.gphotos.first.image.send(thumb_size) if gallery.gphotos.count > 0 %>
9
+ <% a_klass = '' if gallery.gphotos.count > 0 %>
10
+ <% url = my_url_for_gallery(gallery) %>
11
+
12
+ <div class="slot_item <%= css_item_klass %>">
13
+ <div class="photo">
14
+ <%= render_image_link_lazy({
15
+ :alt_image => title,
16
+ :image => image,
17
+ :a_href => url,
18
+ :a_class => a_klass
19
+ }) %>
20
+ </div>
21
+ <div class="title">
22
+ <%= link_to title, url, :title => title %>
23
+ </div>
24
+ </div>
25
+ <% end %>
26
+
27
+ </div>
@@ -0,0 +1,28 @@
1
+ <div class="gallery_list <%= css_list_klass %> clearfix">
2
+
3
+ <% list.each_with_index do |gallery,i| %>
4
+ <% title = gallery.title %>
5
+ <% image = nil %>
6
+ <% a_klass = 'nil_img' %>
7
+ <% image = gallery.gphotos.first.image.send(thumb_size) if gallery.gphotos.count > 0 %>
8
+ <% a_klass = '' if gallery.gphotos.count > 0 %>
9
+ <% url = my_url_for_gallery(gallery) %>
10
+
11
+ <div class="slot_item <%= css_item_klass %> n_<%= i %>">
12
+ <div class="photo" style="<%= "#{w_style};#{h_style}" %>">
13
+ <%= render_image_link_lazy({
14
+ :alt_image => title,
15
+ :image => image,
16
+ :a_href => url,
17
+ :a_class => a_klass,
18
+ :a_css_style => "#{w_style};#{h_style}",
19
+ :a_rel => 'nofollow'
20
+ }) %>
21
+ </div>
22
+ <div class="title" style="<%= "#{w_style}" %>">
23
+ <%= link_to title, url, :title => title %>
24
+ </div>
25
+ </div>
26
+ <% end %>
27
+
28
+ </div>
@@ -0,0 +1,23 @@
1
+ <div class="gallery_list <%= css_list_klass %> clearfix">
2
+
3
+ <% list.each_with_index do |gphoto,i| %>
4
+ <% image = gphoto.image.send(thumb_size) %>
5
+ <% a_klass = '' %>
6
+ <% url = gphoto.image.url %>
7
+
8
+ <div class="slot_item <%= css_item_klass %> n_<%= i %>">
9
+ <div class="photo" style="<%= "#{w_style};#{h_style}" %>">
10
+ <%= render_image_link_lazy({
11
+ :alt_image => gallery_title,
12
+ :image => image,
13
+ :a_href => url,
14
+ :a_class => a_klass,
15
+ :a_css_style => "#{w_style};#{h_style}",
16
+ :a_rel => 'nofollow'
17
+ }) %>
18
+ </div>
19
+
20
+ </div>
21
+ <% end %>
22
+
23
+ </div>
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "c80_album_gallery"
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_album_gallery/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "c80_album_gallery"
8
+ spec.version = C80AlbumGallery::VERSION
9
+ spec.authors = ["C80609A"]
10
+ spec.email = ["c080609a@gmail.com"]
11
+
12
+ spec.summary = "Album galleries gem"
13
+ spec.description = "Gem adds galleries to site"
14
+ spec.homepage = "https://github.com/c080609a/c80_album_galleries"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.bindir = "exe"
19
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.add_development_dependency "bundler", "~> 1.12"
23
+ spec.add_development_dependency "rake", "~> 10.0"
24
+ spec.add_dependency 'activesupport', ['>= 3.0.0']
25
+ spec.add_dependency 'c80_lazy_images'
26
+
27
+ end
@@ -0,0 +1,10 @@
1
+ class CreateGalleries < ActiveRecord::Migration
2
+ def change
3
+ create_table :c80_album_gallery_galleries, :options => 'COLLATE=utf8_unicode_ci' do |t|
4
+ t.string :title
5
+ t.string :tag
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,10 @@
1
+ class CreateGphotos < ActiveRecord::Migration
2
+ def change
3
+ create_table :c80_album_gallery_gphotos, :options => 'COLLATE=utf8_unicode_ci' do |t|
4
+ t.string :image
5
+ t.references :gallery, index: true
6
+
7
+ t.timestamps
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,17 @@
1
+ class C80AlbumGalleryCreateProps < ActiveRecord::Migration
2
+ def change
3
+ create_table :c80_album_gallery_props, :options => 'COLLATE=utf8_unicode_ci' do |t|
4
+
5
+ t.integer :thumb_lg_width
6
+ t.integer :thumb_lg_height
7
+
8
+ t.integer :thumb_md_width
9
+ t.integer :thumb_md_height
10
+
11
+ t.integer :thumb_sm_width
12
+ t.integer :thumb_sm_height
13
+
14
+ t.timestamps null: false
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,6 @@
1
+ class C80AlbumGalleryAddPreviewToProps < ActiveRecord::Migration
2
+ def change
3
+ add_column :c80_album_gallery_props, :thumb_preview_width, :integer
4
+ add_column :c80_album_gallery_props, :thumb_preview_height, :integer
5
+ end
6
+ end
@@ -0,0 +1,24 @@
1
+ # rake db:seed:c80_album_gallery_fill_props
2
+
3
+ C80AlbumGallery::Prop.delete_all
4
+ C80AlbumGallery::Prop.create!({
5
+ thumb_lg_width: 640,
6
+ thumb_lg_height: 400,
7
+
8
+ thumb_md_width: 320,
9
+ thumb_md_height: 200,
10
+
11
+ thumb_sm_width: 80,
12
+ thumb_sm_height: 50,
13
+
14
+ thumb_preview_width: 250,
15
+ thumb_preview_height: 164
16
+
17
+ })
18
+
19
+ =begin
20
+ p = C80AlbumGallery::Prop.first
21
+ p.thumb_preview_width = 250
22
+ p.thumb_preview_height = 164
23
+ p.save!
24
+ =end
@@ -0,0 +1,17 @@
1
+ # rake db:seed:c80_album_gallery_fill_sample_galleries
2
+
3
+ C80AlbumGallery::Gallery.delete_all
4
+ C80AlbumGallery::Gallery.create!([
5
+ {
6
+ id: 1,
7
+ title: 'Люди'
8
+ },
9
+ {
10
+ id: 2,
11
+ title: 'Осень'
12
+ },
13
+ {
14
+ id: 3,
15
+ title: 'Натюрморт'
16
+ }
17
+ ])
@@ -0,0 +1,7 @@
1
+ # rake db:seed:c80_album_gallery_recreate_versions
2
+
3
+ C80AlbumGallery::Gallery.all.each do |gallery|
4
+ gallery.gphotos.each do |gphoto|
5
+ gphoto.image.recreate_versions!
6
+ end
7
+ end
@@ -0,0 +1,8 @@
1
+ require "c80_album_gallery/version"
2
+ require "c80_album_gallery/engine"
3
+
4
+ module C80AlbumGallery
5
+ def self.table_name_prefix
6
+ 'c80_album_gallery_'
7
+ end
8
+ end
@@ -0,0 +1,23 @@
1
+ module C80AlbumGallery
2
+ class Engine < ::Rails::Engine
3
+ isolate_namespace C80AlbumGallery
4
+
5
+ initializer :c80_album_gallery_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_album_gallery/**/"]
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 C80AlbumGallery
2
+ VERSION = "0.1.0.1"
3
+ end
metadata ADDED
@@ -0,0 +1,139 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: c80_album_gallery
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0.1
5
+ platform: ruby
6
+ authors:
7
+ - C80609A
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-10-10 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
+ - !ruby/object:Gem::Dependency
56
+ name: c80_lazy_images
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Gem adds galleries to site
70
+ email:
71
+ - c080609a@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - ".gitignore"
77
+ - ".idea/.rakeTasks"
78
+ - CODE_OF_CONDUCT.md
79
+ - Gemfile
80
+ - LICENSE.txt
81
+ - README.md
82
+ - Rakefile
83
+ - app/admin/c80_album_gallery/galleries.rb
84
+ - app/assets/javascripts/c80_album_gallery.js.coffee
85
+ - app/assets/javascripts/c80_album_gallery/gallery.js
86
+ - app/assets/stylesheets/c80_album_gallery.scss
87
+ - app/assets/stylesheets/c80_album_gallery/_mixins/gallery_list_default.scss
88
+ - app/assets/stylesheets/c80_album_gallery/_mixins/slot_item_overlayed.scss
89
+ - app/assets/stylesheets/c80_album_gallery/_styles/style_photostudio.scss
90
+ - app/assets/stylesheets/c80_album_gallery/_styles/style_photostudio_widget.scss
91
+ - app/assets/stylesheets/c80_album_gallery/gallery_list.scss
92
+ - app/assets/stylesheets/c80_album_gallery/gallery_list_slots.scss
93
+ - app/assets/stylesheets/c80_album_gallery/gallery_view.scss
94
+ - app/helpers/c80_album_gallery/c80_album_gallery_application_helper.rb
95
+ - app/models/c80_album_gallery/gallery.rb
96
+ - app/models/c80_album_gallery/gphoto.rb
97
+ - app/models/c80_album_gallery/prop.rb
98
+ - app/uploaders/c80_album_gallery/gphoto_uploader.rb
99
+ - app/views/c80_album_gallery/_flow_galleries_slots.html.erb
100
+ - app/views/c80_album_gallery/_gallery_list.html.erb
101
+ - app/views/c80_album_gallery/_gallery_view_page.html.erb
102
+ - bin/console
103
+ - bin/setup
104
+ - c80_album_gallery.gemspec
105
+ - db/migrate/20160916114444_create_galleries.rb
106
+ - db/migrate/20160916114545_create_gphotos.rb
107
+ - db/migrate/20161006151414_c80_album_gallery_create_props.rb
108
+ - db/migrate/20161010072525_c80_album_gallery_add_preview_to_props.rb
109
+ - db/seeds/c80_album_gallery_fill_props.rb
110
+ - db/seeds/c80_album_gallery_fill_sample_galleries.rb
111
+ - db/seeds/c80_album_gallery_recreate_versions.rb
112
+ - lib/c80_album_gallery.rb
113
+ - lib/c80_album_gallery/engine.rb
114
+ - lib/c80_album_gallery/version.rb
115
+ homepage: https://github.com/c080609a/c80_album_galleries
116
+ licenses:
117
+ - MIT
118
+ metadata: {}
119
+ post_install_message:
120
+ rdoc_options: []
121
+ require_paths:
122
+ - lib
123
+ required_ruby_version: !ruby/object:Gem::Requirement
124
+ requirements:
125
+ - - ">="
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
128
+ required_rubygems_version: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ requirements: []
134
+ rubyforge_project:
135
+ rubygems_version: 2.5.1
136
+ signing_key:
137
+ specification_version: 4
138
+ summary: Album galleries gem
139
+ test_files: []