ish_manager 0.1.3 → 0.1.6

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 (30) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -26
  3. data/app/assets/javascripts/ish_manager/application.js +24 -1
  4. data/app/assets/javascripts/ish_manager/jquery-3.2.1.min.js +4 -0
  5. data/app/assets/javascripts/ish_manager/jquery.fileupload.js +1482 -0
  6. data/app/assets/javascripts/ish_manager/jquery.iframe-transport.js +224 -0
  7. data/app/assets/javascripts/ish_manager/jquery.ui.widget.js +572 -0
  8. data/app/assets/stylesheets/ish_manager/application.css +21 -0
  9. data/app/controllers/ish_manager/application_controller.rb +10 -0
  10. data/app/controllers/ish_manager/galleries_controller.rb +14 -7
  11. data/app/controllers/ish_manager/photos_controller.rb +3 -4
  12. data/app/models/ish_manager/ability.rb +23 -5
  13. data/app/views/ish_manager/application/_main_footer.haml +15 -12
  14. data/app/views/ish_manager/application/_main_header.haml +2 -2
  15. data/app/views/ish_manager/galleries/_form.haml +15 -22
  16. data/app/views/ish_manager/galleries/_list.haml +1 -1
  17. data/app/views/ish_manager/galleries/_meta.haml +1 -4
  18. data/app/views/ish_manager/galleries/_thumbs.haml +7 -6
  19. data/app/views/ish_manager/galleries/_title.haml +9 -16
  20. data/app/views/ish_manager/galleries/edit.haml +4 -10
  21. data/app/views/ish_manager/galleries/index.haml +4 -4
  22. data/app/views/ish_manager/galleries/new.haml +1 -1
  23. data/app/views/ish_manager/galleries/show.haml +1 -10
  24. data/app/views/ish_manager/photos/_multinew.haml +2 -18
  25. data/app/views/layouts/ish_manager/application.haml +9 -5
  26. data/config/routes.rb +3 -1
  27. data/lib/ish_manager/engine.rb +11 -0
  28. data/lib/ish_manager/version.rb +1 -1
  29. metadata +6 -3
  30. data/app/views/ish_manager/galleries/#_thumbs.haml# +0 -5
@@ -14,6 +14,27 @@
14
14
  *= require_self
15
15
  */
16
16
 
17
+ .bg-white {
18
+ background: white;
19
+ padding-bottom: 1em;
20
+ }
21
+
22
+ body {
23
+ background: #dedede;
24
+ }
25
+
17
26
  .center {
18
27
  text-align: center;
19
28
  }
29
+
30
+ hr {
31
+ background: red;
32
+ height: 1px;
33
+ }
34
+
35
+ .thumb {
36
+ background: dedede;
37
+ border: 1px solid red;
38
+ width: 100px;
39
+ height: 100px;
40
+ }
@@ -15,5 +15,15 @@ module IshManager
15
15
  @current_ability ||= ::IshManager::Ability.new( current_user )
16
16
  end
17
17
 
18
+ def set_lists
19
+ @sites_list = Site.all.list
20
+ @cities_list = City.all.list
21
+ @venues_list = Venue.all.list
22
+ @reports_list = Report.all.list
23
+ @galleries_list = Gallery.all.list
24
+ @videos_list = Video.all.list
25
+ @user_profiles_list = UserProfile.all.list
26
+ end
27
+
18
28
  end
19
29
  end
@@ -1,14 +1,18 @@
1
1
  class IshManager::GalleriesController < IshManager::ApplicationController
2
2
 
3
- # before_action :set_lists
3
+ before_action :set_lists
4
4
 
5
5
  def index
6
6
  authorize! :index, Gallery
7
- @galleries = Gallery.unscoped.where( :is_trash => false ).order_by( :created_at => :desc ).page( params[:galleries_page] ).per( 10 )
7
+ @galleries = Gallery.unscoped.where( :is_trash => false
8
+ ).order_by( :created_at => :desc
9
+ ).page( params[:galleries_page] ).per( 10 )
8
10
  end
9
11
 
10
12
  def index_thumb
11
- @galleries = Gallery.unscoped.where( :is_trash => false ).order_by( :created_at => :desc ).page( params[:galleries_page] ).per( 10 )
13
+ @galleries = Gallery.unscoped.where( :is_trash => false
14
+ ).order_by( :created_at => :desc
15
+ ).page( params[:galleries_page] ).per( 10 )
12
16
  end
13
17
 
14
18
  def index_mini
@@ -17,18 +21,19 @@ class IshManager::GalleriesController < IshManager::ApplicationController
17
21
 
18
22
  def new
19
23
  @gallery = Gallery.new
24
+ authorize! :new, @gallery
20
25
  @cities_list = City.list
21
26
  @tags_list = Tag.list
22
27
  end
23
28
 
24
29
  def create
25
30
  @gallery = Gallery.new params[:gallery].permit!
26
- @gallery.user = current_user
27
31
  authorize! :create, @gallery
32
+ # @gallery.username = current_user.profile.username
28
33
 
29
34
  if @gallery.save
30
35
  flash[:notice] = 'Success'
31
- redirect_to manager_galleries_path
36
+ redirect_to galleries_path
32
37
  else
33
38
  flash[:error] = 'No Luck. ' + @gallery.errors.inspect
34
39
  @cities_list = City.list
@@ -39,13 +44,15 @@ class IshManager::GalleriesController < IshManager::ApplicationController
39
44
 
40
45
  def edit
41
46
  @gallery = Gallery.unscoped.find params[:id]
47
+ authorize! :edit, @gallery
42
48
  end
43
49
 
44
50
  def update
45
51
  @gallery = Gallery.unscoped.find params[:id]
52
+ authorize! :update, @gallery
46
53
  if @gallery.update_attributes( params[:gallery].permit! )
47
54
  flash[:notice] = 'Success.'
48
- redirect_to manager_galleries_path
55
+ redirect_to galleries_path
49
56
  else
50
57
  flash[:error] = 'No Luck. ' + @gallery.errors
51
58
  render :action => :edit
@@ -63,7 +70,7 @@ class IshManager::GalleriesController < IshManager::ApplicationController
63
70
  @gallery.is_trash = true
64
71
  @gallery.save
65
72
  flash[:notice] = 'Logically deleted gallery.'
66
- redirect_to manager_galleries_title_path
73
+ redirect_to galleries_path
67
74
  end
68
75
 
69
76
  def j_show
@@ -11,6 +11,7 @@ class IshManager::PhotosController < IshManager::ApplicationController
11
11
 
12
12
  def destroy
13
13
  @photo = Photo.unscoped.find params[:id]
14
+ authorize! :destroy, @photo
14
15
  @photo.is_trash = true
15
16
  @photo.save
16
17
  redirect_to request.referrer
@@ -29,13 +30,11 @@ class IshManager::PhotosController < IshManager::ApplicationController
29
30
  gallery = Gallery.unscoped.where( :galleryname => params[:galleryname] ).first
30
31
  @photo.gallery_id = gallery.id
31
32
  elsif params[:gallery_id]
32
- gallery = Gallery.find( params[:gallery_id] )
33
+ gallery = Gallery.unscoped.where( :galleryname => params[:gallery_id] ).first
34
+ gallery ||= Gallery.find( params[:gallery_id] )
33
35
  @photo.gallery_id = gallery.id
34
36
  end
35
37
 
36
- # @TODO this is badd
37
- @photo.user = User.where( :username => 'piousbox' ).first
38
-
39
38
  if @photo.save
40
39
  j = { :name => @photo.photo.original_filename,
41
40
  :size => @photo.photo.size,
@@ -2,13 +2,31 @@
2
2
  class IshManager::Ability
3
3
  include ::CanCan::Ability
4
4
 
5
- def initialize user
5
+ def initialize user
6
+
7
+ #
8
+ # signed in user
9
+ #
10
+ unless user.blank?
11
+
12
+ if user.profile && user.profile.manager?
13
+ can :manage, :all
14
+ end
15
+
16
+ can [ :show ], Gallery do |gallery|
17
+ gallery.user == user
18
+ end
19
+
20
+ end
6
21
  user ||= User.new
22
+
23
+ can [ :read ], Gallery do |gallery|
24
+ gallery.is_public
25
+ end
7
26
 
8
- if user.profile && user.profile.manager?
9
- can :manage, :all
10
- else
11
- can :read, :all
27
+ can [ :read ], Report do |report|
28
+ report.is_public
12
29
  end
30
+
13
31
  end
14
32
  end
@@ -1,14 +1,17 @@
1
1
 
2
- %hr
3
- %ul
4
- %li ^__^
5
- - if current_user
6
- %li
7
- >[ #{current_user.email} ]<
8
- %div{ :style => 'float: left' }= button_to '[x]', main_app.destroy_user_session_path, :method => :delete
9
- - else
10
- %li
11
- Please log in
12
- = link_to '[+]', main_app.new_user_session_path
13
-
2
+ .container
3
+ %br
4
+ .row
5
+ .col-sm-6
6
+ - if current_user
7
+ >[ #{current_user.email} ]<
8
+ = button_to '[x]', main_app.destroy_user_session_path, :method => :delete
9
+ - else
10
+ Please log in
11
+ = link_to '[+]', main_app.new_user_session_path
14
12
 
13
+ .col-sm-6
14
+ %br
15
+ \~__^
16
+ %br
17
+ %br
@@ -1,8 +1,8 @@
1
- %br
2
1
 
2
+ %br
3
3
  .container
4
4
  .row
5
- .col-12-xs
5
+ .col-sm-12
6
6
  %ul.nav.nav-pills
7
7
  %li= link_to 'Cities', cities_path
8
8
  %li= link_to 'Events', events_path
@@ -1,46 +1,39 @@
1
1
 
2
- - url ||= manager_galleries_path
2
+ - url ||= galleries_path
3
3
 
4
4
  = form_for gallery, :url => url do |f|
5
5
  .row
6
- .large-12.columns
6
+ .col-sm-12
7
7
  = f.label :name
8
8
  = f.text_field :name
9
9
  = gallery.galleryname
10
- %br
11
- %br
10
+ = f.submit
12
11
 
13
12
  .row
14
- .large-4.columns
13
+ .col-sm-4
15
14
  = f.label :site
16
15
  = select :gallery, :site_id, @sites_list
17
- .large-4.columns
16
+ .col-sm-4
18
17
  = f.label :city
19
18
  = select :gallery, :city_id, @cities_list
20
- .large-4.columns
21
- = f.label :tag
22
- = select :gallery, :tag_id, @tags_list
23
- .large-4.columns
24
- = f.label :user
25
- = select :gallery, :user_id, @users_list
26
- .large-4.columns.end
19
+ .col-sm-4
27
20
  = f.label :venue
28
21
  = select :gallery, :venue_id, @venues_list
29
-
22
+ .col-sm-4
23
+ = f.label :user_proifle
24
+ = select :user_profile, :user_profile_id, @user_profiles_list
25
+
30
26
  .row
31
- .large-3.columns
27
+ .col-sm-3
32
28
  = f.label :is_public
33
29
  = f.check_box :is_public
34
- .large-3.columns
30
+ .col-sm-3
35
31
  = f.label :is_done
36
32
  = f.check_box :is_done
37
- .large-3.columns
33
+ .col-sm-3
38
34
  = f.label :is_trash
39
35
  = f.check_box :is_trash
40
- .large-3.columns
36
+ .col-sm-3
41
37
  = f.label :is_feature
42
38
  = f.check_box :is_feature
43
-
44
- .row
45
- .large-3.columns.end
46
- = f.submit
39
+
@@ -6,7 +6,7 @@
6
6
  - galleries.each do |g|
7
7
  .item
8
8
  %h3
9
- = link_to '[~]', edit_gallery_path( g.galleryname )
9
+ = link_to '[~]', edit_gallery_path( g )
10
10
  = link_to g.name, gallery_path(g.galleryname)
11
11
  -# = render 'meta', :item => g
12
12
  - if g.photos.length == 0
@@ -4,10 +4,7 @@
4
4
  .large-12.columns
5
5
  - if gallery.site
6
6
  Site #{link_to "http://#{gallery.site.domain}/#{gallery.site.lang}", site_path(gallery.site)}
7
- - if gallery.user
8
- User #{link_to gallery.user.username, user_path(gallery.user)}
9
- - if gallery.tag
10
- Tag #{link_to gallery.tag.name, tag_path(gallery.tag)}
7
+ User :: #{gallery.username ? gallery.username.inspect : '<no-user>' }
11
8
  - if gallery.city
12
9
  City #{link_to gallery.city.name, city_path(gallery.city)}
13
10
  - if gallery.venue
@@ -1,12 +1,13 @@
1
1
 
2
2
  - #
3
- - # manager / galleries / _thumbs
3
+ - # ish_manager / galleries / _thumbs
4
4
  - #
5
5
 
6
6
  %hr
7
- .manager-galleries--thumbs
8
- .row
9
- .large-12.columns
10
- - gallery.photos.each do |photo|
11
- = image_tag photo.photo.url( :thumb )
7
+ .row
8
+ - gallery.photos.each do |photo|
9
+ .col-xs-6.col-sm-6.col-md-4.col-lg-2
10
+ %br
11
+ = button_to '[x]', photo_path( photo ), :method => :delete, :data => { :confirm => 'Are you sure?' }
12
+ .thumb= image_tag( photo.photo.url( :thumb ), :alt => '' )
12
13
  %hr
@@ -1,17 +1,10 @@
1
1
 
2
- .title
3
- %h5
4
- .btn-group
5
- %a{ 'data-toggle' => 'dropdown', :class => 'btn dropdown-toggle' }
6
- = t('galleries.list')
7
- %span.caret
8
- %ul.dropdown-menu
9
- %li= link_to 'Add New', new_manager_gallery_path
10
- %li= link_to 'Public', :action => :index, :public => '1'
11
- %li= link_to 'Nonpublic', :action => :index, :public => '0'
12
- %li= link_to 'Done', :action => :index, :done => '1'
13
- %li= link_to 'Nondone', :action => :index, :done => '0'
14
- %li= link_to 'Trash', :action => :index, :is_trash => '1'
15
- %li= link_to 'Fullindex', manager_galleries_fullindex_path
16
- %li= link_to 'Paginated', manager_galleries_path
17
- %li= link_to 'Short List', :action => :index, :short_list => true
2
+ .row
3
+ .col-xs-12
4
+ .center
5
+ %h2
6
+ #{gallery.name} (#{gallery.photos.length})
7
+ = link_to '[~]', edit_gallery_path( gallery )
8
+ [x]
9
+ galleryname :: #{gallery.galleryname}
10
+ = render 'meta', :gallery => gallery
@@ -1,11 +1,5 @@
1
1
 
2
- .row
3
- .large-12.columns
4
- %h1
5
- = t('galleries.edit')
6
- = link_to @gallery.name, manager_gallery_path( @gallery )
7
- (#{@gallery.photos.count})
8
-
9
- = render 'manager/galleries/form', :gallery => @gallery, :url => manager_gallery_path( @gallery )
10
- = render 'manager/galleries/thumbs', :gallery => @gallery
11
- = render 'manager/photos/multinew', :gallery => @gallery
2
+ = render 'title', :gallery => @gallery
3
+ = render 'form', :gallery => @gallery, :url => gallery_path( @gallery )
4
+ = render 'thumbs', :gallery => @gallery
5
+ = render 'ish_manager/photos/multinew', :gallery => @gallery
@@ -7,12 +7,12 @@
7
7
 
8
8
  .container
9
9
  .row
10
- .col-xs-6
10
+ .col-sm-6
11
11
  %h4
12
- = t('galleries.list')
12
+ Galleries (#{Gallery.count})
13
13
  = link_to '[+]', new_gallery_path
14
- .col-xs-6= render 'search'
14
+ .col-sm-6= render 'search'
15
15
  .row
16
- .lcol-xs-12
16
+ .col-sm-12
17
17
  -# = render 'ish_manager/galleries/menu_secondary'
18
18
  = render 'ish_manager/galleries/list', :galleries => @galleries
@@ -4,4 +4,4 @@
4
4
  %h3 New Gallery
5
5
  = flash[:error]
6
6
 
7
- = render 'manager/galleries/form', :gallery => @gallery
7
+ = render 'form', :gallery => @gallery
@@ -1,14 +1,5 @@
1
1
 
2
- .row
3
- .col-xs-12
4
- .center
5
- Gallery
6
- %h2
7
- #{@gallery.name} (#{@photos.length})
8
- = link_to '[~]', edit_gallery_path( @gallery )
9
- [x]
10
- = @gallery.galleryname
11
- = render 'meta', :gallery => @gallery
2
+ = render 'title', :gallery => @gallery
12
3
 
13
4
  .row
14
5
  %ul
@@ -3,21 +3,5 @@
3
3
  .row
4
4
  .small-12.columns
5
5
  %h3.center Add Photos
6
- %ul{ :id => 'photos', :class => 'thumbnails', 'data-json-url' => manager_j_gallery_path( gallery.id ) }
7
- %input{ :id => 'fileupload', :type => 'file', :name => 'photo[photo]', 'data-url' => manager_photos_multiadd_path( gallery.galleryname ), :multiple => '' }
8
-
9
- %script{:src => "//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"}
10
- %script{:src => "/js/jquery.ui.widget.js"}
11
- %script{:src => "/js/jquery.iframe-transport.js"}
12
- %script{:src => "/js/jquery.fileupload.js"}
13
- :javascript
14
- $(function () {
15
- $('#fileupload').fileupload({
16
- dataType: 'json',
17
- done: function (e, data) {
18
- $.each(data.result.files, function (index, file) {
19
- $('<p/>').text(file.name).appendTo(document.body);
20
- });
21
- }
22
- });
23
- });
6
+ %ul{ :id => 'photos', :class => 'thumbnails' }
7
+ %input{ :id => 'fileupload', :type => 'file', :name => 'photo[photo]', 'data-url' => gallery_multiadd_path( gallery.galleryname ), :multiple => '' }
@@ -3,12 +3,16 @@
3
3
  %head
4
4
  %title Ish manager
5
5
  = stylesheet_link_tag "ish_manager/application", media: "all"
6
+ %script{ :src => "https://ajax.googleapis.com/ajax/libs/jquery/3.0.0/jquery.min.js" }
6
7
  = javascript_include_tag "ish_manager/application"
7
8
  = csrf_meta_tags
8
9
  %body
9
- = render :partial => 'ish_manager/application/main_header'
10
- %p.notice= notice
11
- %p.alert= alert
12
- .container
13
- = yield
10
+ .bg-white
11
+ = render :partial => 'ish_manager/application/main_header'
12
+ - if notice
13
+ %p.notice= notice
14
+ - if alert
15
+ %p.alert= alert
16
+ .container
17
+ = yield
14
18
  = render :partial => 'ish_manager/application/main_footer'