resizing-rails 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fee8aa49d76956092c278082a2b5101e67a0825a1cd5aed1b77f86bf21eed5ca
4
- data.tar.gz: 9a5d3c0b6e2be6a17b349e16df7bb435d371db7f9a994127e99d4430bdef7790
3
+ metadata.gz: 19bc526581140827ced204007407305cc3fab1c536b3fcc6090cc03db55e3637
4
+ data.tar.gz: b170c6cf1cd7ac32b94b2988b9a4c816f6f9bac05de60eaa53663e7b8eb57b60
5
5
  SHA512:
6
- metadata.gz: 0e557645e13e95c0772d00fae71746a935eebb5b0c6181ac812acee62d841f14b3d8094076c78a4b3ea62d51ae667b8c5b01e0dbcf9f8b2e9758910d8710704c
7
- data.tar.gz: 1fc7f77c26a2c1be2b92a488de5253a4a66b0feacde3c49ee5356d0436c5c4ea86c59eff689086e77cc48b8597594d6f8dbf2ba69fe0376bee6a01bd388b53ef
6
+ metadata.gz: b760a2fc7b6c01f5aca8c3b0a9a4f578f9dd3aed2c412382d2823716829a843039214218102970b8450b1d6de3ae1f8f8d6a9f92365843eefc7999e360c5a6ae
7
+ data.tar.gz: 516d11fd1bd06488f6448f57633762234a41b7429b4bf73e0a680c37aede4e122556c3eeb386bc3905c4efd421422986d86525840d9d05e266f62b8f3ddaa1ff
@@ -3,5 +3,6 @@
3
3
  //= require resizing/rails/toast
4
4
  //= require resizing/rails/video
5
5
  //= require resizing/rails/video_fetcher
6
+ //= require resizing/rails/video_loader
6
7
  //= require resizing/rails/video_uploader
7
8
  //= require resizing/rails/videojs/7.8.2/video.min
@@ -12,6 +12,7 @@ class Video {
12
12
  let video = this.buildVideoTag()
13
13
  this.video = videojs(video.id, {fluid: true})
14
14
  this.record = null
15
+ this.refresh_seconds = 30
15
16
  }
16
17
 
17
18
  fetch() {
@@ -23,7 +24,7 @@ class Video {
23
24
  this.renderVideo(record)
24
25
  }
25
26
  if(record.state != 'ready' && record.state != 'initialized') {
26
- setTimeout(this.fetch.bind(this), 5000)
27
+ setTimeout(this.fetch.bind(this), this.refresh_seconds * 1000)
27
28
  }
28
29
  })
29
30
  }
@@ -0,0 +1,17 @@
1
+ if(window.Resizing === undefined) { window.Resizing = {} }
2
+ if(window.Resizing.Rails === undefined) { window.Resizing.Rails = {} }
3
+
4
+ class VideoLoader {
5
+ constructor() {
6
+ window.addEventListener('DOMContentLoaded', (event)=> {
7
+ let elements = document.querySelectorAll('[data-video-url]')
8
+ elements.forEach(elem => {
9
+ let url = elem.getAttribute('data-video-url')
10
+ let fetcher = new Resizing.Rails.Video(url, elem)
11
+ fetcher.fetch()
12
+ })
13
+ })
14
+ }
15
+ }
16
+
17
+ Resizing.Rails.VideoLoader = VideoLoader
@@ -1,4 +1,19 @@
1
1
  module Resizing::Rails
2
2
  module VideosHelper
3
+ def video_file_field_tag name, options = {}
4
+ raise ArgumentError, "video_file_field_tag requires Hash as option arguments" unless options.is_a? Hash
5
+
6
+ options = options.merge(only_path: true)
7
+ args['data-video-prepare-url'] = prepare_video_url(options)
8
+ file_field_tag name
9
+ end
10
+
11
+ def resizing_prepare_video_url(*args)
12
+ Resizing::Rails::Engine.routes.url_helpers.prepare_videos_url(*args)
13
+ end
14
+
15
+ def resizing_video_tag resizing_rails_video
16
+ raw "<div class='video' data-video-url=#{resizing_rails_video.data_self_url}></div>"
17
+ end
3
18
  end
4
19
  end
@@ -21,25 +21,31 @@ h1 動画詳細
21
21
  a.card-link.hevc-url.data-copy-url href='#'
22
22
  | Copy URL
23
23
  li.list-group-item
24
- label.form-label for='copy-tag' コピー用のタグ(このサイト内だけで有効です)
25
- textarea#copy-tag class='form-control' rows='10'
26
- | <div id='video-#{@video.id}'></div>
24
+ h4 コピー用のタグ
25
+ h5 スタイルシートとJavaScriptの読み込み(共通)
26
+ | app/views/layouts/application.html.slim へ以下を追加
27
+ pre.bg-light
28
+ textarea class='form-control' rows='3'
29
+ | = stylesheet_link_tag 'resizing/rails', media: 'all'
30
+ = javascript_include_tag "resizing/rails"
31
+
32
+ h5 HTML & JavaScriptの場合:
33
+ textarea class='form-control' rows='10'
34
+ |
35
+ <div data-video-url="video-#{@video.id}"></div>
27
36
  <script>
28
- document.addEventListner('DOMContentLoaded', function () {
37
+ window.addEventListner('DOMContentLoaded', function () {
29
38
  video = new Resizing.Rails.Video("#{@video.data_self_url}", document.querySelector('video-#{@video.id}'))
30
39
  video.fetch()
31
40
  })
32
41
  </script>
33
-
34
- p
35
- | ※スタイルシートとJavaScriptの読み込みが必要です。
36
- b 例:
37
- br
38
- | app/views/layouts/application.html.slim へ以下を追加
39
- pre.bg-light
40
- code
41
- | = stylesheet_link_tag 'resizing/rails', media: 'all'
42
- = javascript_include_tag "resizing/rails"
42
+ h5 ERBの場合:
43
+ textarea class='form-control' rows='5'
44
+ | # Controller内で該当のレコードを取得する
45
+ @video_record = Resizing::Rails::Video.find(#{@video.id})
46
+ &nbsp;
47
+ # View内でHelperを使ってタグ出力する
48
+ <%= Resizing::Rails::VideosHelper.resizing_video_tag(@video_record) %>
43
49
 
44
50
  javascript:
45
51
  document.addEventListener('DOMContentLoaded', function() {
@@ -1,5 +1,5 @@
1
1
  module Resizing
2
2
  module Rails
3
- VERSION = '0.2.0'
3
+ VERSION = '0.3.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resizing-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Junichiro Kasuya
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-03-07 00:00:00.000000000 Z
11
+ date: 2021-03-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -70,16 +70,16 @@ dependencies:
70
70
  name: bootstrap
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: 5.0.0.beta1
75
+ version: '0'
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
- version: 5.0.0.beta1
82
+ version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: sassc
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -112,6 +112,7 @@ files:
112
112
  - app/assets/javascripts/resizing/rails/toast.js
113
113
  - app/assets/javascripts/resizing/rails/video.js
114
114
  - app/assets/javascripts/resizing/rails/video_fetcher.js
115
+ - app/assets/javascripts/resizing/rails/video_loader.js
115
116
  - app/assets/javascripts/resizing/rails/video_uploader.js
116
117
  - app/assets/javascripts/resizing/rails/videojs/7.8.2/video.min.js
117
118
  - app/assets/stylesheets/resizing/rails.scss