mix-rails-albums 0.10.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 (76) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.rdoc +3 -0
  3. data/Rakefile +27 -0
  4. data/app/assets/images/albums/crop.png +0 -0
  5. data/app/assets/images/albums/delete.png +0 -0
  6. data/app/assets/images/albums/photos.png +0 -0
  7. data/app/assets/images/albums/rotate_ccw.png +0 -0
  8. data/app/assets/images/albums/rotate_cw.png +0 -0
  9. data/app/assets/images/colorbox/border.png +0 -0
  10. data/app/assets/images/colorbox/controls.png +0 -0
  11. data/app/assets/images/colorbox/ie6/borderBottomCenter.png +0 -0
  12. data/app/assets/images/colorbox/ie6/borderBottomLeft.png +0 -0
  13. data/app/assets/images/colorbox/ie6/borderBottomRight.png +0 -0
  14. data/app/assets/images/colorbox/ie6/borderMiddleLeft.png +0 -0
  15. data/app/assets/images/colorbox/ie6/borderMiddleRight.png +0 -0
  16. data/app/assets/images/colorbox/ie6/borderTopCenter.png +0 -0
  17. data/app/assets/images/colorbox/ie6/borderTopLeft.png +0 -0
  18. data/app/assets/images/colorbox/ie6/borderTopRight.png +0 -0
  19. data/app/assets/images/colorbox/loading.gif +0 -0
  20. data/app/assets/images/colorbox/loading_background.png +0 -0
  21. data/app/assets/images/colorbox/overlay.png +0 -0
  22. data/app/assets/javascripts/admix/photos.js.erb +78 -0
  23. data/app/assets/javascripts/albums/jquery.jcarousel.min.js +16 -0
  24. data/app/assets/javascripts/albums/show.js.coffee +62 -0
  25. data/app/assets/javascripts/albums.js +0 -0
  26. data/app/assets/javascripts/collections/filelist.js +5 -0
  27. data/app/assets/javascripts/colorbox/jquery.colorbox-min.js +4 -0
  28. data/app/assets/javascripts/models/fileitem.js +40 -0
  29. data/app/assets/javascripts/models/filezip.js +8 -0
  30. data/app/assets/javascripts/photo_uploader.coffee +2 -0
  31. data/app/assets/javascripts/templates/photo_view.hamlc.erb +16 -0
  32. data/app/assets/javascripts/views/filelistview.js +15 -0
  33. data/app/assets/javascripts/views/fileview.js +34 -0
  34. data/app/assets/javascripts/views/filezipview.js +42 -0
  35. data/app/assets/stylesheets/colorbox/colorbox.css.scss +86 -0
  36. data/app/assets/stylesheets/skins/ie7/credits.txt +1 -0
  37. data/app/assets/stylesheets/skins/ie7/loading-small.gif +0 -0
  38. data/app/assets/stylesheets/skins/ie7/loading.gif +0 -0
  39. data/app/assets/stylesheets/skins/ie7/loading_small.gif +0 -0
  40. data/app/assets/stylesheets/skins/ie7/next-horizontal.gif +0 -0
  41. data/app/assets/stylesheets/skins/ie7/prev-horizontal.gif +0 -0
  42. data/app/assets/stylesheets/skins/ie7/skin.css +190 -0
  43. data/app/assets/stylesheets/skins/tango/credits.txt +1 -0
  44. data/app/assets/stylesheets/skins/tango/next-horizontal.png +0 -0
  45. data/app/assets/stylesheets/skins/tango/next-vertical.png +0 -0
  46. data/app/assets/stylesheets/skins/tango/prev-horizontal.png +0 -0
  47. data/app/assets/stylesheets/skins/tango/prev-vertical.png +0 -0
  48. data/app/assets/stylesheets/skins/tango/skin.css +186 -0
  49. data/app/controllers/admix/albums_controller.rb +5 -0
  50. data/app/controllers/admix/photos_controller.rb +24 -0
  51. data/app/controllers/albums_controller.rb +19 -0
  52. data/app/helpers/admix/albums_helper.rb +11 -0
  53. data/app/models/admix/albums_datagrid.rb +34 -0
  54. data/app/models/admix/photos_datagrid.rb +15 -0
  55. data/app/models/album.rb +29 -0
  56. data/app/models/photo.rb +14 -0
  57. data/app/uploaders/albums/image_uploader.rb +72 -0
  58. data/app/views/admix/albums/_form_fields.html.haml +4 -0
  59. data/app/views/admix/albums/_show.html.haml +7 -0
  60. data/app/views/admix/albums/_table_actions.html.haml +4 -0
  61. data/app/views/admix/photos/_upload.html.haml +26 -0
  62. data/app/views/admix/photos/index.html.haml +1 -0
  63. data/app/views/albums/index.html.haml +4 -0
  64. data/app/views/albums/show.html.haml +3 -0
  65. data/config/application.rb +1 -0
  66. data/config/initializers/albums.rb +1 -0
  67. data/config/initializers/carrierwave.rb +9 -0
  68. data/config/locales/albums.en.yml +13 -0
  69. data/config/locales/albums.pt-BR.yml +17 -0
  70. data/config/locales/photos.pt-BR.yml +11 -0
  71. data/config/routes.rb +13 -0
  72. data/lib/mix-rails-albums/engine.rb +19 -0
  73. data/lib/mix-rails-albums/version.rb +10 -0
  74. data/lib/mix-rails-albums.rb +10 -0
  75. data/lib/tasks/albums_tasks.rake +4 -0
  76. metadata +222 -0
@@ -0,0 +1,190 @@
1
+ .jcarousel-skin-ie7 .jcarousel-container {
2
+ -moz-border-radius: 10px;
3
+ -webkit-border-radius: 10px;
4
+ border-radius: 10px;
5
+ background: #D4D0C8;
6
+ border: 1px solid #808080;
7
+ }
8
+
9
+ .jcarousel-skin-ie7 .jcarousel-direction-rtl {
10
+ direction: rtl;
11
+ }
12
+
13
+ .jcarousel-skin-ie7 .jcarousel-container-horizontal {
14
+ width: 245px;
15
+ padding: 20px 40px;
16
+ }
17
+
18
+ .jcarousel-skin-ie7 .jcarousel-container-vertical {
19
+ width: 75px;
20
+ height: 245px;
21
+ padding: 40px 20px;
22
+ }
23
+
24
+ .jcarousel-skin-ie7 .jcarousel-clip {
25
+ overflow: hidden;
26
+ }
27
+
28
+ .jcarousel-skin-ie7 .jcarousel-clip-horizontal {
29
+ width: 245px;
30
+ height: 77px;
31
+ }
32
+
33
+ .jcarousel-skin-ie7 .jcarousel-clip-vertical {
34
+ width: 77px;
35
+ height: 245px;
36
+ }
37
+
38
+ .jcarousel-skin-ie7 .jcarousel-item {
39
+ width: 75px;
40
+ height: 75px;
41
+ border: 1px solid #fff;
42
+ }
43
+
44
+ .jcarousel-skin-ie7 .jcarousel-item:hover,
45
+ .jcarousel-skin-ie7 .jcarousel-item:focus {
46
+ border-color: #808080;
47
+ }
48
+
49
+ .jcarousel-skin-ie7 .jcarousel-item-horizontal {
50
+ margin-left: 0;
51
+ margin-right: 7px;
52
+ }
53
+
54
+ .jcarousel-skin-ie7 .jcarousel-direction-rtl .jcarousel-item-horizontal {
55
+ margin-left: 7px;
56
+ margin-right: 0;
57
+ }
58
+
59
+ .jcarousel-skin-ie7 .jcarousel-item-vertical {
60
+ margin-bottom: 7px;
61
+ }
62
+
63
+ .jcarousel-skin-ie7 .jcarousel-item-placeholder {
64
+ }
65
+
66
+ /**
67
+ * Horizontal Buttons
68
+ */
69
+ .jcarousel-skin-ie7 .jcarousel-next-horizontal {
70
+ position: absolute;
71
+ top: 43px;
72
+ right: 5px;
73
+ width: 32px;
74
+ height: 32px;
75
+ cursor: pointer;
76
+ background: transparent url(next-horizontal.gif) no-repeat 0 0;
77
+ }
78
+
79
+ .jcarousel-skin-ie7 .jcarousel-direction-rtl .jcarousel-next-horizontal {
80
+ left: 5px;
81
+ right: auto;
82
+ background-image: url(prev-horizontal.gif);
83
+ }
84
+
85
+ .jcarousel-skin-ie7 .jcarousel-next-horizontal:hover,
86
+ .jcarousel-skin-ie7 .jcarousel-next-horizontal:focus {
87
+ background-position: -32px 0;
88
+ }
89
+
90
+ .jcarousel-skin-ie7 .jcarousel-next-horizontal:active {
91
+ background-position: -64px 0;
92
+ }
93
+
94
+ .jcarousel-skin-ie7 .jcarousel-next-disabled-horizontal,
95
+ .jcarousel-skin-ie7 .jcarousel-next-disabled-horizontal:hover,
96
+ .jcarousel-skin-ie7 .jcarousel-next-disabled-horizontal:focus,
97
+ .jcarousel-skin-ie7 .jcarousel-next-disabled-horizontal:active {
98
+ cursor: default;
99
+ background-position: -96px 0;
100
+ }
101
+
102
+ .jcarousel-skin-ie7 .jcarousel-prev-horizontal {
103
+ position: absolute;
104
+ top: 43px;
105
+ left: 5px;
106
+ width: 32px;
107
+ height: 32px;
108
+ cursor: pointer;
109
+ background: transparent url(prev-horizontal.gif) no-repeat 0 0;
110
+ }
111
+
112
+ .jcarousel-skin-ie7 .jcarousel-direction-rtl .jcarousel-prev-horizontal {
113
+ left: auto;
114
+ right: 5px;
115
+ background-image: url(next-horizontal.gif);
116
+ }
117
+
118
+ .jcarousel-skin-ie7 .jcarousel-prev-horizontal:hover,
119
+ .jcarousel-skin-ie7 .jcarousel-prev-horizontal:focus {
120
+ background-position: -32px 0;
121
+ }
122
+
123
+ .jcarousel-skin-ie7 .jcarousel-prev-horizontal:active {
124
+ background-position: -64px 0;
125
+ }
126
+
127
+ .jcarousel-skin-ie7 .jcarousel-prev-disabled-horizontal,
128
+ .jcarousel-skin-ie7 .jcarousel-prev-disabled-horizontal:hover,
129
+ .jcarousel-skin-ie7 .jcarousel-prev-disabled-horizontal:focus,
130
+ .jcarousel-skin-ie7 .jcarousel-prev-disabled-horizontal:active {
131
+ cursor: default;
132
+ background-position: -96px 0;
133
+ }
134
+
135
+ /**
136
+ * Vertical Buttons
137
+ */
138
+ .jcarousel-skin-ie7 .jcarousel-next-vertical {
139
+ position: absolute;
140
+ bottom: 5px;
141
+ left: 43px;
142
+ width: 32px;
143
+ height: 32px;
144
+ cursor: pointer;
145
+ background: transparent url(next-vertical.gif) no-repeat 0 0;
146
+ }
147
+
148
+ .jcarousel-skin-ie7 .jcarousel-next-vertical:hover,
149
+ .jcarousel-skin-ie7 .jcarousel-next-vertical:focus {
150
+ background-position: 0 -32px;
151
+ }
152
+
153
+ .jcarousel-skin-ie7 .jcarousel-next-vertical:active {
154
+ background-position: 0 -64px;
155
+ }
156
+
157
+ .jcarousel-skin-ie7 .jcarousel-next-disabled-vertical,
158
+ .jcarousel-skin-ie7 .jcarousel-next-disabled-vertical:hover,
159
+ .jcarousel-skin-ie7 .jcarousel-next-disabled-vertical:focus,
160
+ .jcarousel-skin-ie7 .jcarousel-next-disabled-vertical:active {
161
+ cursor: default;
162
+ background-position: 0 -96px;
163
+ }
164
+
165
+ .jcarousel-skin-ie7 .jcarousel-prev-vertical {
166
+ position: absolute;
167
+ top: 5px;
168
+ left: 43px;
169
+ width: 32px;
170
+ height: 32px;
171
+ cursor: pointer;
172
+ background: transparent url(prev-vertical.gif) no-repeat 0 0;
173
+ }
174
+
175
+ .jcarousel-skin-ie7 .jcarousel-prev-vertical:hover,
176
+ .jcarousel-skin-ie7 .jcarousel-prev-vertical:focus {
177
+ background-position: 0 -32px;
178
+ }
179
+
180
+ .jcarousel-skin-ie7 .jcarousel-prev-vertical:active {
181
+ background-position: 0 -64px;
182
+ }
183
+
184
+ .jcarousel-skin-ie7 .jcarousel-prev-disabled-vertical,
185
+ .jcarousel-skin-ie7 .jcarousel-prev-disabled-vertical:hover,
186
+ .jcarousel-skin-ie7 .jcarousel-prev-disabled-vertical:focus,
187
+ .jcarousel-skin-ie7 .jcarousel-prev-disabled-vertical:active {
188
+ cursor: default;
189
+ background-position: 0 -96px;
190
+ }
@@ -0,0 +1 @@
1
+ Button images copyright by Tango Icon Library Team (http://tango.freedesktop.org/Tango_Icon_Library)
@@ -0,0 +1,186 @@
1
+ .jcarousel-skin-tango .jcarousel-container {
2
+ -moz-border-radius: 10px;
3
+ -webkit-border-radius: 10px;
4
+ border-radius: 10px;
5
+ background: #F0F6F9;
6
+ border: 1px solid #346F97;
7
+ }
8
+
9
+ .jcarousel-skin-tango .jcarousel-direction-rtl {
10
+ direction: rtl;
11
+ }
12
+
13
+ .jcarousel-skin-tango .jcarousel-container-horizontal {
14
+ width: 245px;
15
+ padding: 20px 40px;
16
+ }
17
+
18
+ .jcarousel-skin-tango .jcarousel-container-vertical {
19
+ width: 75px;
20
+ height: 245px;
21
+ padding: 40px 20px;
22
+ }
23
+
24
+ .jcarousel-skin-tango .jcarousel-clip {
25
+ overflow: hidden;
26
+ }
27
+
28
+ .jcarousel-skin-tango .jcarousel-clip-horizontal {
29
+ width: 245px;
30
+ height: 75px;
31
+ }
32
+
33
+ .jcarousel-skin-tango .jcarousel-clip-vertical {
34
+ width: 75px;
35
+ height: 245px;
36
+ }
37
+
38
+ .jcarousel-skin-tango .jcarousel-item {
39
+ width: 75px;
40
+ height: 75px;
41
+ }
42
+
43
+ .jcarousel-skin-tango .jcarousel-item-horizontal {
44
+ margin-left: 0;
45
+ margin-right: 10px;
46
+ }
47
+
48
+ .jcarousel-skin-tango .jcarousel-direction-rtl .jcarousel-item-horizontal {
49
+ margin-left: 10px;
50
+ margin-right: 0;
51
+ }
52
+
53
+ .jcarousel-skin-tango .jcarousel-item-vertical {
54
+ margin-bottom: 10px;
55
+ }
56
+
57
+ .jcarousel-skin-tango .jcarousel-item-placeholder {
58
+ background: #fff;
59
+ color: #000;
60
+ }
61
+
62
+ /**
63
+ * Horizontal Buttons
64
+ */
65
+ .jcarousel-skin-tango .jcarousel-next-horizontal {
66
+ position: absolute;
67
+ top: 43px;
68
+ right: 5px;
69
+ width: 32px;
70
+ height: 32px;
71
+ cursor: pointer;
72
+ background: transparent url(next-horizontal.png) no-repeat 0 0;
73
+ }
74
+
75
+ .jcarousel-skin-tango .jcarousel-direction-rtl .jcarousel-next-horizontal {
76
+ left: 5px;
77
+ right: auto;
78
+ background-image: url(prev-horizontal.png);
79
+ }
80
+
81
+ .jcarousel-skin-tango .jcarousel-next-horizontal:hover,
82
+ .jcarousel-skin-tango .jcarousel-next-horizontal:focus {
83
+ background-position: -32px 0;
84
+ }
85
+
86
+ .jcarousel-skin-tango .jcarousel-next-horizontal:active {
87
+ background-position: -64px 0;
88
+ }
89
+
90
+ .jcarousel-skin-tango .jcarousel-next-disabled-horizontal,
91
+ .jcarousel-skin-tango .jcarousel-next-disabled-horizontal:hover,
92
+ .jcarousel-skin-tango .jcarousel-next-disabled-horizontal:focus,
93
+ .jcarousel-skin-tango .jcarousel-next-disabled-horizontal:active {
94
+ cursor: default;
95
+ background-position: -96px 0;
96
+ }
97
+
98
+ .jcarousel-skin-tango .jcarousel-prev-horizontal {
99
+ position: absolute;
100
+ top: 43px;
101
+ left: 5px;
102
+ width: 32px;
103
+ height: 32px;
104
+ cursor: pointer;
105
+ background: transparent url(prev-horizontal.png) no-repeat 0 0;
106
+ }
107
+
108
+ .jcarousel-skin-tango .jcarousel-direction-rtl .jcarousel-prev-horizontal {
109
+ left: auto;
110
+ right: 5px;
111
+ background-image: url(next-horizontal.png);
112
+ }
113
+
114
+ .jcarousel-skin-tango .jcarousel-prev-horizontal:hover,
115
+ .jcarousel-skin-tango .jcarousel-prev-horizontal:focus {
116
+ background-position: -32px 0;
117
+ }
118
+
119
+ .jcarousel-skin-tango .jcarousel-prev-horizontal:active {
120
+ background-position: -64px 0;
121
+ }
122
+
123
+ .jcarousel-skin-tango .jcarousel-prev-disabled-horizontal,
124
+ .jcarousel-skin-tango .jcarousel-prev-disabled-horizontal:hover,
125
+ .jcarousel-skin-tango .jcarousel-prev-disabled-horizontal:focus,
126
+ .jcarousel-skin-tango .jcarousel-prev-disabled-horizontal:active {
127
+ cursor: default;
128
+ background-position: -96px 0;
129
+ }
130
+
131
+ /**
132
+ * Vertical Buttons
133
+ */
134
+ .jcarousel-skin-tango .jcarousel-next-vertical {
135
+ position: absolute;
136
+ bottom: 5px;
137
+ left: 43px;
138
+ width: 32px;
139
+ height: 32px;
140
+ cursor: pointer;
141
+ background: transparent url(next-vertical.png) no-repeat 0 0;
142
+ }
143
+
144
+ .jcarousel-skin-tango .jcarousel-next-vertical:hover,
145
+ .jcarousel-skin-tango .jcarousel-next-vertical:focus {
146
+ background-position: 0 -32px;
147
+ }
148
+
149
+ .jcarousel-skin-tango .jcarousel-next-vertical:active {
150
+ background-position: 0 -64px;
151
+ }
152
+
153
+ .jcarousel-skin-tango .jcarousel-next-disabled-vertical,
154
+ .jcarousel-skin-tango .jcarousel-next-disabled-vertical:hover,
155
+ .jcarousel-skin-tango .jcarousel-next-disabled-vertical:focus,
156
+ .jcarousel-skin-tango .jcarousel-next-disabled-vertical:active {
157
+ cursor: default;
158
+ background-position: 0 -96px;
159
+ }
160
+
161
+ .jcarousel-skin-tango .jcarousel-prev-vertical {
162
+ position: absolute;
163
+ top: 5px;
164
+ left: 43px;
165
+ width: 32px;
166
+ height: 32px;
167
+ cursor: pointer;
168
+ background: transparent url(prev-vertical.png) no-repeat 0 0;
169
+ }
170
+
171
+ .jcarousel-skin-tango .jcarousel-prev-vertical:hover,
172
+ .jcarousel-skin-tango .jcarousel-prev-vertical:focus {
173
+ background-position: 0 -32px;
174
+ }
175
+
176
+ .jcarousel-skin-tango .jcarousel-prev-vertical:active {
177
+ background-position: 0 -64px;
178
+ }
179
+
180
+ .jcarousel-skin-tango .jcarousel-prev-disabled-vertical,
181
+ .jcarousel-skin-tango .jcarousel-prev-disabled-vertical:hover,
182
+ .jcarousel-skin-tango .jcarousel-prev-disabled-vertical:focus,
183
+ .jcarousel-skin-tango .jcarousel-prev-disabled-vertical:active {
184
+ cursor: default;
185
+ background-position: 0 -96px;
186
+ }
@@ -0,0 +1,5 @@
1
+ class Admix::AlbumsController < Admix::InheritedController
2
+
3
+ respond_to :html, :json, :js
4
+
5
+ end
@@ -0,0 +1,24 @@
1
+ class Admix::PhotosController < Admix::InheritedController
2
+
3
+ before_filter :image_param
4
+
5
+ polymorphic_belongs_to :album, param: :album_id
6
+
7
+ # load_and_authorize_resource :album
8
+ # load_and_authorize_resource :photo, :through => :album_id
9
+ skip_load_and_authorize_resource
10
+
11
+ respond_to :json
12
+
13
+ def upload
14
+ render inline: params.to_s
15
+ end
16
+
17
+ def image_param
18
+ if params[:image]
19
+ params[:photo] = { image: params[:image] }
20
+ end
21
+ end
22
+
23
+
24
+ end
@@ -0,0 +1,19 @@
1
+ class AlbumsController < ApplicationController
2
+
3
+ def index
4
+ @albums = Album.published.paginate(:page => params[:page], :per_page => 12)
5
+ # @albums.each do |a|
6
+ # a.photos.each do |p|
7
+ # p.image.recreate_versions!
8
+ # end
9
+ # end
10
+
11
+ end
12
+
13
+ def show
14
+ @album = Album.find(params[:id])
15
+ end
16
+
17
+
18
+
19
+ end
@@ -0,0 +1,11 @@
1
+ module Admix::AlbumsHelper
2
+ def form2_attributes
3
+ %w(name description date published)
4
+ end
5
+
6
+ def album_form_attributes(form)
7
+ form.input :name
8
+ form.input :date
9
+ end
10
+
11
+ end
@@ -0,0 +1,34 @@
1
+ class Admix::AlbumsDatagrid
2
+
3
+ include Datagrid
4
+
5
+
6
+ scope do
7
+ Album.desc(:date)
8
+ end
9
+
10
+ filter :name, :string
11
+ filter :date do |value|
12
+ value.to_s(:created_at)
13
+ end
14
+
15
+ column :name, header: I18n.t('albums.name')
16
+ column :date, header: I18n.t('albums.date') do |album|
17
+ album.date.strftime("%d/%m/%Y") #album.date.to_s(:created_at)
18
+ end
19
+ column :photos_quantity, header: I18n.t('albums.photos_quantity') do |album|
20
+ album.photos.count
21
+ end
22
+
23
+ column :published, header: I18n.t('albums.published') do |album|
24
+ if album.published
25
+ I18n.t("albums.published_yes")
26
+ else
27
+ I18n.t("albums.published_no")
28
+ end
29
+ end
30
+
31
+
32
+ include Admix::TableActions
33
+
34
+ end
@@ -0,0 +1,15 @@
1
+ class Admix::PhotosDatagrid
2
+
3
+ include Datagrid
4
+
5
+ scope do
6
+ Photo.desc(:date)
7
+ end
8
+
9
+ filter :name, :string
10
+ filter :date, :date
11
+
12
+ column :name
13
+ column :date
14
+
15
+ end
@@ -0,0 +1,29 @@
1
+ class Album
2
+
3
+ include Mongoid::Document
4
+ include Mongoid::Timestamps
5
+ include Mongoid::Paranoia
6
+ include Mongoid::Slug
7
+
8
+ field :name, type: String
9
+ field :description, type: String
10
+ field :date, type: Date
11
+ field :published, type: Boolean, default: true
12
+
13
+
14
+ validates_presence_of :name
15
+ validates_presence_of :date
16
+
17
+ #slug :name, history: true
18
+
19
+ slug :name, history: true do |current_object|
20
+ current_object.name.parameterize
21
+ end
22
+
23
+ embeds_many :photos, cascade_callbacks: true
24
+
25
+
26
+ scope :published, where(published: true)
27
+
28
+
29
+ end
@@ -0,0 +1,14 @@
1
+ class Photo
2
+
3
+ include Mongoid::Document
4
+ include Mongoid::Timestamps
5
+
6
+ attr_accessible :image, :image_cache
7
+
8
+ field :legend
9
+
10
+ embedded_in :album
11
+
12
+ mount_uploader :image, Albums::ImageUploader
13
+
14
+ end
@@ -0,0 +1,72 @@
1
+ # encoding: utf-8
2
+ require 'carrierwave/processing/mini_magick'
3
+
4
+ class Albums::ImageUploader < CarrierWave::Uploader::Base
5
+
6
+ # Include RMagick or MiniMagick support:
7
+ # include CarrierWave::RMagick
8
+ include CarrierWave::MiniMagick
9
+
10
+ # Include the Sprockets helpers for Rails 3.1+ asset pipeline compatibility:
11
+ include Sprockets::Helpers::RailsHelper
12
+ include Sprockets::Helpers::IsolatedHelper
13
+
14
+ # Choose what kind of storage to use for this uploader:
15
+ storage :grid_fs
16
+ # storage :fog
17
+
18
+ # Override the directory where uploaded files will be stored.
19
+ # This is a sensible default for uploaders that are meant to be mounted:
20
+ def store_dir
21
+ "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
22
+ end
23
+
24
+ def cache_dir
25
+ "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
26
+ end
27
+
28
+ # Provide a default URL as a default if there hasn't been a file uploaded:
29
+ # def default_url
30
+ # # For Rails 3.1+ asset pipeline compatibility:
31
+ # # asset_path("fallback/" + [version_name, "default.png"].compact.join('_'))
32
+ #
33
+ # "/images/fallback/" + [version_name, "default.png"].compact.join('_')
34
+ # end
35
+
36
+ # Process files as they are uploaded:
37
+ # process :scale => [200, 300]
38
+ #
39
+ # def scale(width, height)
40
+ # # do something
41
+ # end
42
+
43
+ # Create different versions of your uploaded files:
44
+ # version :thumb do
45
+ # process :resize_to_fit => [80, 80]
46
+ # end
47
+
48
+ version :medium do
49
+ process :resize_to_fill => [640,420]
50
+ end
51
+
52
+ version :thumb do
53
+ process :resize_to_fill => [190,143]
54
+ end
55
+
56
+ version :small_thumb do
57
+ process :resize_to_fill => [82,62]
58
+ end
59
+
60
+ # Add a white list of extensions which are allowed to be uploaded.
61
+ # For images you might use something like this:
62
+ # def extension_white_list
63
+ # %w(jpg jpeg gif png)
64
+ # end
65
+
66
+ # Override the filename of the uploaded files:
67
+ # Avoid using model.id or version_name here, see uploader/store.rb for details.
68
+ # def filename
69
+ # "something.jpg" if original_filename
70
+ # end
71
+
72
+ end
@@ -0,0 +1,4 @@
1
+ = f.input :name, as: 'string'
2
+ = f.input :description, as: 'text'
3
+ = f.input :date, as: 'datepicker'
4
+ = f.input :published, as: 'boolean'
@@ -0,0 +1,7 @@
1
+ %dl
2
+ %dt= t('albums.name')
3
+ %dd= resource.name
4
+ %dt= t('albums.date')
5
+ %dd= resource.date
6
+
7
+ = render('admix/photos/upload')
@@ -0,0 +1,4 @@
1
+ = link_to image_tag('albums/photos.png'), resource_url([resource, :photos]), class: 'btn', title:'Adicionar fotos'
2
+ = link_to image_tag('admix/zoom.png'), resource_url(resource), class: 'btn', title:'Visualizar registro'
3
+ = link_to image_tag('admix/page_edit.png'), edit_resource_url(resource), class: 'btn', title:'Editar registro'
4
+ = link_to image_tag('admix/cancel.png'), resource_url(resource), method: :delete, data: { confirm: t('admix.crud.destroy_confirm') }, class: 'btn', title:'Deletar registro'
@@ -0,0 +1,26 @@
1
+ - content_for :stylesheets do
2
+ = stylesheet_link_tag 'colorbox/colorbox'
3
+ - content_for :javascripts do
4
+ = javascript_include_tag 'admix/photos'
5
+ = javascript_include_tag 'jquery.livequery'
6
+ = javascript_include_tag 'colorbox/jquery.colorbox-min'
7
+ :coffeescript
8
+ $ ->
9
+ $('.colorbox').livequery ->
10
+ $(@).colorbox();
11
+
12
+
13
+ %h3 Upload de fotos
14
+ #upload-buttons{:style => "padding: 20px;"}
15
+ %div{:style => "display:none;"}
16
+ %input#uploader{:multiple => "multiple", :name => "files", :style => "display:none;", :type => "file", :value => "Selecionar File(s)"}/
17
+ %input#uploaderZip{:name => "files", :style => "display:none;", :type => "file", :value => "Selecionar File(s)"}/
18
+ %p= t('photos.upload.explanation')
19
+ %div
20
+ %a.btn.btn-primary.btn-upload{:onclick => "jQuery('#uploader').click();"}= t('photos.btn.upload_pictures')
21
+ -#
22
+ = t('photos.or')
23
+ %a.btn.btn-primary.btn-upload{:onclick => "jQuery('#uploaderZip').click();"}= t('photos.btn.upload_zip')
24
+
25
+ #fileZip
26
+ %ul#files.thumbnails{'data-url' => admix_album_photos_path(defined?(parent) ? parent : resource, format: :json)}
@@ -0,0 +1 @@
1
+ = render('upload')
@@ -0,0 +1,4 @@
1
+ - content_for(:albums_content) do
2
+ = render @albums
3
+ = will_paginate @albums
4
+ = render template: 'templates/albums/index'
@@ -0,0 +1,3 @@
1
+ - content_for(:album_content) do
2
+ = render partial: 'album_show', locals: {album: @album}
3
+ = render template: 'templates/albums/show'
@@ -0,0 +1 @@
1
+ config.assets.paths << "#{ Rails.root }/app/assets/jcarousel/lib/"
@@ -0,0 +1 @@
1
+ Time::DATE_FORMATS[:created_at] = "%b, %m %Y - %I:%M%p"