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 +4 -4
- data/app/assets/javascripts/resizing/rails.js +1 -0
- data/app/assets/javascripts/resizing/rails/video.js +2 -1
- data/app/assets/javascripts/resizing/rails/video_loader.js +17 -0
- data/app/helpers/resizing/rails/videos_helper.rb +15 -0
- data/app/views/resizing/rails/videos/show.html.slim +20 -14
- data/lib/resizing/rails/version.rb +1 -1
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 19bc526581140827ced204007407305cc3fab1c536b3fcc6090cc03db55e3637
|
4
|
+
data.tar.gz: b170c6cf1cd7ac32b94b2988b9a4c816f6f9bac05de60eaa53663e7b8eb57b60
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b760a2fc7b6c01f5aca8c3b0a9a4f578f9dd3aed2c412382d2823716829a843039214218102970b8450b1d6de3ae1f8f8d6a9f92365843eefc7999e360c5a6ae
|
7
|
+
data.tar.gz: 516d11fd1bd06488f6448f57633762234a41b7429b4bf73e0a680c37aede4e122556c3eeb386bc3905c4efd421422986d86525840d9d05e266f62b8f3ddaa1ff
|
@@ -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),
|
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
|
-
|
25
|
-
|
26
|
-
|
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
|
-
|
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
|
-
|
35
|
-
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
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
|
+
|
47
|
+
# View内でHelperを使ってタグ出力する
|
48
|
+
<%= Resizing::Rails::VideosHelper.resizing_video_tag(@video_record) %>
|
43
49
|
|
44
50
|
javascript:
|
45
51
|
document.addEventListener('DOMContentLoaded', function() {
|
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.
|
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-
|
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:
|
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:
|
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
|