wco_models 3.1.0.44 → 3.1.0.46

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7f7d273b37602a1f2a1f82302c8d56f5369a4a09d2acb1ddfeb098e6f33add57
4
- data.tar.gz: f78a545087d198449ff639e58b179baaeda53233a5787fabbb5ad45baf7f130b
3
+ metadata.gz: 0a5d5670d27e5ffe31a148d7c746b5da9ab488cbe69dc6858d3ea5dd30bba67a
4
+ data.tar.gz: 301c1ed8eab2e77f157a5b7560dbfcb6d2e23b45b6dc64b469b5de2c0d75e5df
5
5
  SHA512:
6
- metadata.gz: 2a2060ae9563387d736cd45e538a89faf731412f52f8d47641a0526459ebf821d89c628dd36ad0170791a013c28f8ca5cfbeeeb0c254208ff533688d22de026e
7
- data.tar.gz: a06f1efb029dbee94b04047fb0c0b2a02fba799aae644d457700672f408fb908fe8b50ba4e87cb2434ff79c6f175ad504490d313db1647e65cf21a5015e9400e
6
+ metadata.gz: 254d577ba591a0fa571637f7530608cee0993ec36095669e4eae89d672c463ee53c30a4e9d03333b456aef8b267d91edd348ccbac7695db05c681d157dc140e8
7
+ data.tar.gz: b4ac32502cf0456b89281681a704dc9bbc91fc92807b7f5c5844acbdfc2f3f7b5a0d8f0901670c260adf174c6e8ed7e6d161f758b3b18dcbd5c161c4fd401955
@@ -7,6 +7,7 @@ class Wco::ApplicationController < ActionController::Base
7
7
  before_action :current_profile
8
8
 
9
9
  def home
10
+ authorize! :home, Wco
10
11
  end
11
12
 
12
13
  ##
@@ -0,0 +1,106 @@
1
+
2
+ class Wco::VideosController < Wco::ApplicationController
3
+
4
+ # before_action :set_lists
5
+
6
+ # Alphabetized : )
7
+
8
+ def create
9
+ @video = Wco::Video.new params[:video].permit!
10
+ authorize! :create, @video
11
+
12
+ if @video.save
13
+ flash[:notice] = 'Success'
14
+ redirect_to videos_path
15
+ else
16
+ flash[:alert] = 'No luck'
17
+ render :action => 'new'
18
+ end
19
+ end
20
+
21
+ def destroy
22
+ @video = Wco::Video.find params[:id]
23
+ authorize! :destroy, @video
24
+ flag = @video.delete
25
+ if flag
26
+ flash[:notice] = "deleted video"
27
+ else
28
+ flash[:alert] = "Cannot delete video: #{@video.errors.messages}"
29
+ end
30
+ redirect_to :action => 'index'
31
+ end
32
+
33
+ def edit
34
+ @video = Wco::Video.unscoped.find params[:id]
35
+ authorize! :edit, @video
36
+ end
37
+
38
+ def index
39
+ authorize! :index, Wco::Video.new
40
+ @videos = Wco::Video.order_by( :created_at => :desc )
41
+
42
+ if params[:q]
43
+ @videos = @videos.where({ :name => /#{params[:q]}/i })
44
+ end
45
+
46
+ @videos = @videos.page( params[:videos_page] ).per( 9 )
47
+
48
+ respond_to do |format|
49
+ format.html do
50
+ render
51
+ end
52
+ format.json do
53
+ render :json => @videos
54
+ end
55
+ end
56
+ end
57
+
58
+ def show
59
+ if params[:youtube_id].present?
60
+ @video = Wco::Video.unscoped.where( :youtube_id => params[:youtube_id] ).first
61
+ end
62
+ @video ||= Wco::Video.unscoped.find params[:id]
63
+ authorize! :show, @video
64
+
65
+ respond_to do |format|
66
+ format.html
67
+ format.json do
68
+ render :json => @video
69
+ end
70
+ end
71
+ end
72
+
73
+ def new
74
+ @video = Wco::Video.new
75
+ authorize! :new, @video
76
+ end
77
+
78
+ def update
79
+ @video = Wco::Video.unscoped.find params[:id]
80
+ authorize! :update, @video
81
+
82
+ # old_shared_profile_ids = @video.shared_profile_ids
83
+ # if params[:video][:shared_profiles].present?
84
+ # params[:video][:shared_profiles].delete('')
85
+ # end
86
+ # params[:video][:shared_profile_ids] = params[:video][:shared_profiles]
87
+ # params[:video].delete :shared_profiles
88
+
89
+ @video.update params[:video].permit!
90
+ if @video.save
91
+
92
+ # if params[:video][:shared_profile_ids].present?
93
+ # new_shared_profiles = Ish::UserProfile.find( params[:video][:shared_profile_ids]
94
+ # ).select { |p| !old_shared_profile_ids.include?( p.id ) }
95
+ # ::IshManager::ApplicationMailer.shared_video( new_shared_profiles, @video ).deliver
96
+ # end
97
+
98
+ flash[:notice] = 'Success.'
99
+ redirect_to video_path(@video)
100
+ else
101
+ flash[:alert] = "No luck: #{@video.errors.full_messages.joing(', ')}"
102
+ render :edit
103
+ end
104
+ end
105
+
106
+ end
@@ -5,7 +5,7 @@ class Wco::Gallery
5
5
  include Mongoid::Paranoia
6
6
  # include Wco::PremiumItem
7
7
  include Wco::Utils
8
- store_in collection: 'wco_galleries'
8
+ store_in collection: 'galleries'
9
9
 
10
10
  PER_PAGE = 6
11
11
 
@@ -30,7 +30,7 @@ class Wco::Lead
30
30
  # has_many :videos, class_name: 'Wco::Video'
31
31
 
32
32
  def self.list
33
- all.map { |p| [ p.id, p.email ] }
33
+ [[nil,nil]] + all.map { |p| [ p.email, p.id ] }
34
34
  end
35
35
 
36
36
  OP_DELETE = 'delete'
@@ -8,7 +8,7 @@ class Wco::Photo
8
8
  include Mongoid::Paperclip
9
9
  include Mongoid::Paranoia
10
10
  include Wco::Utils
11
- store_in collection: 'wco_photos'
11
+ store_in collection: 'photos'
12
12
 
13
13
  belongs_to :email_message, class_name: 'WcoEmail::Message', optional: true
14
14
  belongs_to :gallery, class_name: 'Wco::Gallery', optional: true
@@ -0,0 +1,72 @@
1
+
2
+ require 'mongoid_paperclip'
3
+
4
+ class Wco::Video
5
+ include Mongoid::Document
6
+ include Mongoid::Timestamps
7
+ include Mongoid::Paperclip
8
+ include Mongoid::Paranoia
9
+ include Wco::Utils
10
+ store_in collection: 'videos'
11
+
12
+ field :name, :type => String
13
+ field :descr, :type => String, :as => :description
14
+ field :subhead ## still need it... 2023-03-24
15
+
16
+ field :is_public, :type => Boolean, :default => false
17
+ def published
18
+ where({ :is_public => true }).order_by({ :created_at => :desc })
19
+ end
20
+
21
+ field :x, type: Float
22
+ field :y, type: Float
23
+ field :z, type: Float
24
+
25
+ field :youtube_id
26
+ validates_uniqueness_of :youtube_id, allow_blank: true, case_sensitive: false
27
+ before_save { youtube_id.present? || youtube_id = nil }
28
+
29
+ # belongs_to :user_profile, :class_name => 'Ish::UserProfile', :inverse_of => :videos
30
+ # has_and_belongs_to_many :shared_profiles, :class_name => 'Ish::UserProfile', :inverse_of => :shared_videos
31
+
32
+ has_mongoid_attached_file :video,
33
+ # styles: { :thumb => { geometry: '192x108', format: 'jpeg' }, },
34
+ # processors: [ :transcoder ],
35
+ :storage => :s3,
36
+ :s3_credentials => ::S3_CREDENTIALS,
37
+ :path => "videos/:style/:id/:filename",
38
+ :s3_protocol => 'https',
39
+ :s3_permissions => 'public-read',
40
+ :validate_media_type => false,
41
+ s3_region: ::S3_CREDENTIALS[:region]
42
+ validates_attachment_content_type :video, content_type: /\Avideo\/.*\Z/
43
+
44
+ has_mongoid_attached_file :thumb,
45
+ :styles => {
46
+ :mini => '20x20#',
47
+ :thumb => "100x100#",
48
+ :thumb2 => "200x200#",
49
+ :s169 => "640x360#",
50
+ # :s43 => "640x480#",
51
+ :small => "400x400>",
52
+ :large => '950x650>',
53
+ },
54
+ :storage => :s3,
55
+ :s3_credentials => ::S3_CREDENTIALS,
56
+ :path => "videos/:style/:id/thumb_:filename",
57
+ :s3_protocol => 'https',
58
+ :validate_media_type => false,
59
+ s3_region: ::S3_CREDENTIALS[:region]
60
+ validates_attachment_content_type :thumb, :content_type => ["image/jpg", "image/jpeg", "image/png", "image/gif", 'application/octet-stream' ]
61
+
62
+ def export_fields
63
+ %w| name descr |
64
+ end
65
+
66
+ def self.list
67
+ [['', nil]] + self.unscoped.order_by( :created_at => :desc ).map do |item|
68
+ [ "#{item.created_at.strftime('%Y%m%d')} #{item.name}", item.id ]
69
+ end
70
+ end
71
+
72
+ end
@@ -45,8 +45,6 @@ class WcoEmail::Context
45
45
  self[:subject].presence || tmpl.subject
46
46
  end
47
47
 
48
- has_and_belongs_to_many :leads, class_name: 'Wco::Lead'
49
-
50
48
  belongs_to :email_template, class_name: 'WcoEmail::EmailTemplate'
51
49
  def tmpl; email_template; end
52
50
 
@@ -76,6 +74,9 @@ class WcoEmail::Context
76
74
 
77
75
 
78
76
  belongs_to :lead, class_name: 'Wco::Lead'
77
+ def to_email
78
+ lead.email
79
+ end
79
80
 
80
81
  field :cc, type: :string
81
82
  field :ccs, type: :array, default: []
@@ -32,6 +32,7 @@
32
32
  %li= render '/wco/publishers/header'
33
33
  %li= render '/wco/galleries/header'
34
34
  %li= render '/wco/reports/header'
35
+ %li= render '/wco/videos/header'
35
36
 
36
37
 
37
38
  .c
@@ -0,0 +1,13 @@
1
+
2
+ .meta
3
+
4
+ <b>On</b> #{item.created_at.to_s[0...10]}
5
+ -# - if item.user_profile
6
+ -# <b>By</b>
7
+ -# = link_to item.user_profile.name, edit_user_profile_path( item.user_profile )
8
+
9
+ -# - if item.tags.length > 0
10
+ -# <b>Tags:</b> #{ item.tags.map(&:name).join(', ') }
11
+
12
+ -# - if defined?(item.premium_tier) && item.premium_tier > 0
13
+ -# <b>Tier $#{item.premium_tier}</b>
@@ -0,0 +1,39 @@
1
+
2
+ = form_for video do |f|
3
+ .row
4
+ .col-sm-6
5
+ .field
6
+ = f.label :youtube_id
7
+ = f.text_field :youtube_id
8
+ .field
9
+ = f.label :name
10
+ = f.text_field :name
11
+ -# .input-group
12
+ -# = f.label :premium_tier
13
+ -# = f.number_field :premium_tier
14
+ -# .input-group
15
+ -# = f.check_box :is_trash
16
+ -# = f.label :is_trash
17
+ -# .field
18
+ -# %label Lead
19
+ -# = f.select :lead_id, options_for_select(@leads_list, selected: video.lead_id), {}, class: :select2
20
+ .col-sm-6
21
+ .field
22
+ = f.label :video
23
+ = f.file_field :video
24
+ .field
25
+ = f.label :thumb
26
+ = f.file_field :thumb
27
+
28
+
29
+ -# = render 'wco/application/form_nonpublic', f: f, model: video
30
+
31
+ .row
32
+ .col-md-6
33
+ .field
34
+ = f.label :descr
35
+ = f.text_area :descr, class: :tinymce
36
+
37
+
38
+ .action
39
+ = f.submit
@@ -0,0 +1,6 @@
1
+
2
+ = link_to "Videos (#{Wco::Video.all.length})", wco.videos_path
3
+ .inline-search
4
+ = form_tag wco.videos_path, method: :get do
5
+ = text_field_tag :q
6
+ = link_to '[+]', wco.new_video_path
@@ -0,0 +1,37 @@
1
+
2
+ - videos ||= @videos
3
+ - this_videos_path ||= videos_path
4
+
5
+ .videos--index
6
+ .videos--menu
7
+ = link_to "Videos (#{videos.count})", this_videos_path
8
+
9
+ -# = render 'search', path: this_videos_path
10
+ .inline-search
11
+ = form_tag this_videos_path, method: :get do
12
+ = text_field_tag :q
13
+
14
+ = link_to '[+]', new_video_path
15
+ %hr
16
+
17
+ = paginate videos, param_name: :videos_page, views_prefix: 'wco'
18
+
19
+ .row
20
+ - videos.each do |video|
21
+ .col-md-4.item
22
+ .float-left
23
+ - if video.youtube_id.present?
24
+ %iframe{:allowfullscreen => "true", :frameborder => "0", :height => "150", :src => "//www.youtube.com/embed/#{video.youtube_id}", :width => "200"}
25
+ - else
26
+ .thumb= image_tag video.thumb.url(:thumb)
27
+ .title
28
+ = link_to video.name, video_path( video )
29
+ .meta-edit
30
+ .inline= button_to '[x]', video_path( video ), :method => :delete, :data => { :confirm => 'Are you sure?' }
31
+ = link_to '[~]', edit_video_path( video )
32
+
33
+ = render 'meta', item: video
34
+
35
+ = paginate videos, param_name: :videos_page, views_prefix: 'wco'
36
+
37
+
@@ -0,0 +1,7 @@
1
+
2
+
3
+ .videos-edit.max-width
4
+ .header
5
+ %h3.title Edit Video
6
+
7
+ = render 'form', :video => @video
@@ -0,0 +1,3 @@
1
+
2
+ .videos-index.padded
3
+ = render 'index', :videos => @videos
@@ -0,0 +1,6 @@
1
+
2
+ .videos-new.max-width
3
+ .header
4
+ %h3.title New Video
5
+
6
+ = render 'form', :video => @video
@@ -0,0 +1,25 @@
1
+
2
+ - video ||= @video
3
+
4
+ .videos-show.max-width
5
+ .row
6
+ = link_to '[Back]', videos_path
7
+
8
+ - if video.youtube_id.present?
9
+ %iframe{:allowfullscreen => "", :frameborder => "0", :height => "315", :src => "//www.youtube.com/embed/#{video.youtube_id}", :width => "560"}
10
+ - else
11
+ %iframe{:allowfullscreen => "true", :frameborder => "0", :height => "480", :src => "#{video.video.url}", :width => "640"}
12
+
13
+ .my-row
14
+ .a= image_tag video.thumb.url(:thumb)
15
+ .a
16
+ %h3
17
+ = video.name.blank? ? t('videos.no_title') : video.name
18
+ .meta-edit
19
+ .inline= button_to '[x]', video_path( video ), :method => :delete, :data => { :confirm => 'Are you sure?' }
20
+ = link_to '[~]', edit_video_path( video )
21
+
22
+ = render 'wco/application/metaline', :item => video
23
+ .flex-row
24
+ Download File:&nbsp;#{link_to video.video_file_name, video.video.url}
25
+
@@ -0,0 +1,5 @@
1
+
2
+ - if video.youtube_id.present?
3
+ = render 'embed_youtube', video: video
4
+ - else
5
+ = render 'embed_s3', video: video
@@ -0,0 +1,4 @@
1
+
2
+ <div class="video-embed-half">
3
+ <iframe width="430" height="322" src="//www.youtube.com/embed/<%= video.youtube_id %>" frameborder="0" allowfullscreen></iframe>
4
+ </div>
@@ -0,0 +1,4 @@
1
+
2
+ <div class="video-embed-half">
3
+ <iframe width="200" height="150" src="//www.youtube.com/embed/<%= video.youtube_id %>" frameborder="0" allowfullscreen></iframe>
4
+ </div>
@@ -0,0 +1,6 @@
1
+
2
+ <div class="" style="" >
3
+ <!-- <iframe width="430" height="322" src="<%= video.video.url %>" frameborder="0" allowfullscreen></iframe> -->
4
+ <iframe width="640" height="480" src="<%= video.video.url %>" frameborder="0" allowfullscreen></iframe>
5
+ <!-- <iframe src="<%= video.video.url %>" frameborder="0" allowfullscreen></iframe> -->
6
+ </div>
@@ -0,0 +1,4 @@
1
+
2
+ <div class="video-embed">
3
+ <iframe width="560" height="315" src="//www.youtube.com/embed/<%= video.youtube_id %>" frameborder="0" allowfullscreen></iframe>
4
+ </div>
@@ -0,0 +1,27 @@
1
+
2
+ -# videos ||= @videos
3
+ -# videos = videos.page params[:videos_page]
4
+
5
+ .row
6
+ .col.s12
7
+ %h5
8
+ Videos (#{videos.count})
9
+ = link_to image_new, new_video_path
10
+
11
+ = paginate videos, :param_name => :videos_page, :views_prefix => 'ish_manager'
12
+
13
+ - videos.each do |video|
14
+ .panel
15
+ .panel-content
16
+ .row
17
+ .col.s12
18
+ .float-left= youtube_image_tag( video )
19
+ .a
20
+ = link_to video.name, video_path( video )
21
+ = link_to image_edit, edit_video_path( video )
22
+ .inline= button_to '[x]', video_path( video ), :method => :delete, :data => { :confirm => 'Are you sure?' }
23
+ = render 'meta', :item => video
24
+
25
+ = paginate videos, :param_name => :videos_page, :views_prefix => 'ish_manager'
26
+
27
+
@@ -0,0 +1,14 @@
1
+
2
+ .videos-list
3
+ - if videos.blank?
4
+ = t('videos.no_videos')
5
+ - else
6
+ = paginate videos, :param_name => :videos_page, :views_prefix => 'templates'
7
+ - videos.each do |video|
8
+ .callout
9
+ %h5= link_to (video.name.blank? ? t('videos.no_title') : video.name), video_path( video.youtube_id )
10
+ .text-center= render 'videos/embed', :video => video
11
+ = video.descr
12
+ = paginate videos, :param_name => :videos_page, :views_prefix => 'templates'
13
+ .c
14
+ .c
@@ -0,0 +1,9 @@
1
+
2
+ .list-small
3
+ %ul
4
+ - videos.each do |v|
5
+ %li
6
+ = image_tag( "http://img.youtube.com/vi/#{v.youtube_id}/1.jpg" )
7
+ = link_to '[~]', edit_video_path( v )
8
+ = link_to '[_]', video_path( v )
9
+ = paginate videos, :param_name => :videos_page, :views_prefix => 'templates'
@@ -0,0 +1,4 @@
1
+
2
+ .meta-edit
3
+ .inline= button_to '[x]', video_path( item ), :method => :delete, :data => { :confirm => 'Are you sure?' }
4
+ = link_to '[~]', edit_video_path( item )
@@ -0,0 +1,2 @@
1
+
2
+ = image_tag "https://img.youtube.com/vi/#{video.youtube_id}/0.jpg", :style => "width: 100%"
data/config/routes.rb CHANGED
@@ -49,4 +49,6 @@ Wco::Engine.routes.draw do
49
49
 
50
50
  resources :tags
51
51
 
52
+ resources :videos
53
+
52
54
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wco_models
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0.44
4
+ version: 3.1.0.46
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Pudeyev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-01-06 00:00:00.000000000 Z
11
+ date: 2024-01-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-s3
@@ -381,6 +381,7 @@ files:
381
381
  - app/controllers/wco/sites_controller.rb
382
382
  - app/controllers/wco/subscriptions_controller.rb
383
383
  - app/controllers/wco/tags_controller.rb
384
+ - app/controllers/wco/videos_controller.rb
384
385
  - app/helpers/wco/application_helper.rb
385
386
  - app/jobs/wco_hosting/certbot_job.rb
386
387
  - app/mailers/ish_models/application_mailer.rb
@@ -407,6 +408,7 @@ files:
407
408
  - app/models/wco/subscription.rb
408
409
  - app/models/wco/tag.rb
409
410
  - app/models/wco/utils.rb
411
+ - app/models/wco/video.rb
410
412
  - app/models/wco_email/campaign.rb
411
413
  - app/models/wco_email/context.rb
412
414
  - app/models/wco_email/conversation.rb
@@ -433,6 +435,7 @@ files:
433
435
  - app/views/wco/application/_auth_widget.haml
434
436
  - app/views/wco/application/_debug.haml
435
437
  - app/views/wco/application/_meta.haml
438
+ - app/views/wco/application/_metaline.haml
436
439
  - app/views/wco/application/home.haml
437
440
  - app/views/wco/galleries/_form.haml
438
441
  - app/views/wco/galleries/_header.haml
@@ -541,6 +544,23 @@ files:
541
544
  - app/views/wco/tags/index.haml
542
545
  - app/views/wco/tags/new.haml
543
546
  - app/views/wco/tags/show.haml
547
+ - app/views/wco/videos/_form.haml
548
+ - app/views/wco/videos/_header.haml
549
+ - app/views/wco/videos/_index.haml
550
+ - app/views/wco/videos/edit.haml
551
+ - app/views/wco/videos/index.haml
552
+ - app/views/wco/videos/new.haml
553
+ - app/views/wco/videos/show.haml
554
+ - app/views/wco/videos/trash/_embed.haml
555
+ - app/views/wco/videos/trash/_embed_half.erb
556
+ - app/views/wco/videos/trash/_embed_mini.erb
557
+ - app/views/wco/videos/trash/_embed_s3.erb
558
+ - app/views/wco/videos/trash/_embed_youtube.erb
559
+ - app/views/wco/videos/trash/_index_title.haml
560
+ - app/views/wco/videos/trash/_list.haml
561
+ - app/views/wco/videos/trash/_list_small.haml
562
+ - app/views/wco/videos/trash/_meta_edit.haml
563
+ - app/views/wco/videos/trash/_preview.haml
544
564
  - app/views/wco_hosting/docker-compose/dc-any.erb
545
565
  - app/views/wco_hosting/docker-compose/dc-helloworld.erb
546
566
  - app/views/wco_hosting/docker-compose/dc-wordpress.erb