markdown_media 1.6.0 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +7 -1
- data/lib/markdown_media.rb +49 -43
- data/lib/markdown_media/version.rb +1 -1
- metadata +6 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 16042959f63276782a51a0ba97464089d6c6811adfd01cfb5b2716fad4f4bd63
|
4
|
+
data.tar.gz: 73518ef8fa11dd100ba4d48a4ac63b0bdfb6e0b0c8a6596af229ae1025bde46f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54f8455ae1329dcdaf788f4bede41cc4fead9db0a57aadd277dda643abe53cddb8a227a7967c3804dff2652d2de99aa960f780aa21a805b5fd87892666469c6e
|
7
|
+
data.tar.gz: 89f0b56692c2ed81352394decd441e10bbb9db7ce99fd3209ef5b7e7bd2ba00daea255173e097c4ffa568d4d3942f3b338d2a38a5e824a1a1740fb9937e7f3ff
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
[![Build Status](https://travis-ci.org/veganstraightedge/markdown_media.svg?branch=master)](https://travis-ci.org/veganstraightedge/markdown_media)
|
4
4
|
[![Code Climate](https://codeclimate.com/github/veganstraightedge/markdown_media/badges/gpa.svg)](https://codeclimate.com/github/veganstraightedge/markdown_media)
|
5
|
-
![Version 1.
|
5
|
+
![Version 1.6.0](https://img.shields.io/badge/VERSION-1.6.0-green.svg)
|
6
6
|
|
7
7
|
This syntax uses doubles square brackets on each side of a URL and optional options.
|
8
8
|
It expands into the current preferred embed code for that site’s media or raw media.
|
@@ -152,6 +152,12 @@ YouTube’s short URL format also works.
|
|
152
152
|
[[https://youtu.be/YX40hbAHx3s]]
|
153
153
|
```
|
154
154
|
|
155
|
+
YouTube’s embed URL format also works.
|
156
|
+
|
157
|
+
```
|
158
|
+
[[https://www.youtube.com/embed/YX40hbAHx3s]]
|
159
|
+
```
|
160
|
+
|
155
161
|
A video from Daily Motion.
|
156
162
|
|
157
163
|
```
|
data/lib/markdown_media.rb
CHANGED
@@ -103,53 +103,59 @@ module MarkdownMedia
|
|
103
103
|
def extract_options url:, include_media: true
|
104
104
|
type = nil
|
105
105
|
|
106
|
-
|
107
|
-
when /youtube.com/
|
106
|
+
if url.to_s =~ %r{youtube.com/embed}
|
108
107
|
slug = "youtube"
|
109
|
-
embed_id =
|
110
|
-
|
111
|
-
url.query.split("&").each do |key_value_pair|
|
112
|
-
argument, value = key_value_pair.split("=")
|
113
|
-
if argument == "v"
|
114
|
-
embed_id = value
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
when "youtu.be"
|
119
|
-
slug = "youtube"
|
120
|
-
embed_id = url.path.split("/").map{ |path_piece| path_piece unless path_piece.to_s.empty? }.compact.first
|
121
|
-
|
122
|
-
when /dailymotion.com/
|
123
|
-
slug = "dailymotion"
|
124
|
-
embed_id = url.path.split("/video/").map{ |path_piece| path_piece unless path_piece.to_s.empty? }.compact.first.split("_").first
|
125
|
-
|
126
|
-
when "vimeo.com"
|
127
|
-
slug = "vimeo"
|
128
|
-
embed_id = url.path.split("/").map{ |path_piece| path_piece unless path_piece.to_s.empty? }.compact.first
|
129
|
-
|
130
|
-
when "twitter.com"
|
131
|
-
slug = "twitter"
|
132
|
-
type ||= "tweet"
|
133
|
-
|
134
|
-
when /instagram/
|
135
|
-
slug = "instagram"
|
108
|
+
embed_id = url.path.split("/embed/")[1]
|
109
|
+
else
|
136
110
|
|
137
|
-
|
138
|
-
|
139
|
-
|
111
|
+
case url.host
|
112
|
+
when /youtube.com/
|
113
|
+
slug = "youtube"
|
114
|
+
embed_id = nil
|
140
115
|
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
when /\.mp4|\.avi|\.mov|\.ogv|\.webm|\.m4v|\.3gp|\.m3u8/
|
147
|
-
"video"
|
148
|
-
when /\.png|\.jpeg|\.jpg|\.gif|\.svg/
|
149
|
-
"image"
|
150
|
-
else
|
151
|
-
"link"
|
116
|
+
url.query.split("&").each do |key_value_pair|
|
117
|
+
argument, value = key_value_pair.split("=")
|
118
|
+
if argument == "v"
|
119
|
+
embed_id = value
|
120
|
+
end
|
152
121
|
end
|
122
|
+
|
123
|
+
when "youtu.be"
|
124
|
+
slug = "youtube"
|
125
|
+
embed_id = url.path.split("/").map{ |path_piece| path_piece unless path_piece.to_s.empty? }.compact.first
|
126
|
+
|
127
|
+
when /dailymotion.com/
|
128
|
+
slug = "dailymotion"
|
129
|
+
embed_id = url.path.split("/video/").map{ |path_piece| path_piece unless path_piece.to_s.empty? }.compact.first.split("_").first
|
130
|
+
|
131
|
+
when "vimeo.com"
|
132
|
+
slug = "vimeo"
|
133
|
+
embed_id = url.path.split("/").map{ |path_piece| path_piece unless path_piece.to_s.empty? }.compact.first
|
134
|
+
|
135
|
+
when "twitter.com"
|
136
|
+
slug = "twitter"
|
137
|
+
type ||= "tweet"
|
138
|
+
|
139
|
+
when /instagram/
|
140
|
+
slug = "instagram"
|
141
|
+
|
142
|
+
when "giphy.com"
|
143
|
+
slug = "giphy"
|
144
|
+
embed_id = url.path.split("/").last.split('-').last
|
145
|
+
|
146
|
+
else
|
147
|
+
slug =
|
148
|
+
case url.path
|
149
|
+
when /\.mp3|\.aac|\.wav|\.ogg|\.oga|\.m4a/
|
150
|
+
"audio"
|
151
|
+
when /\.mp4|\.avi|\.mov|\.ogv|\.webm|\.m4v|\.3gp|\.m3u8/
|
152
|
+
"video"
|
153
|
+
when /\.png|\.jpeg|\.jpg|\.gif|\.svg/
|
154
|
+
"image"
|
155
|
+
else
|
156
|
+
"link"
|
157
|
+
end
|
158
|
+
end
|
153
159
|
end
|
154
160
|
|
155
161
|
slug = 'link' if include_media == false
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: markdown_media
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shane Becker
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -103,7 +103,7 @@ homepage: https://github.com/veganstraightedge/markdown_media
|
|
103
103
|
licenses:
|
104
104
|
- CC0
|
105
105
|
metadata: {}
|
106
|
-
post_install_message:
|
106
|
+
post_install_message:
|
107
107
|
rdoc_options: []
|
108
108
|
require_paths:
|
109
109
|
- lib
|
@@ -118,8 +118,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
118
|
- !ruby/object:Gem::Version
|
119
119
|
version: '0'
|
120
120
|
requirements: []
|
121
|
-
rubygems_version: 3.
|
122
|
-
signing_key:
|
121
|
+
rubygems_version: 3.1.4
|
122
|
+
signing_key:
|
123
123
|
specification_version: 4
|
124
124
|
summary: A [[ URL ]] syntax to embed media into views.
|
125
125
|
test_files: []
|