markdown_media 1.1.0 → 1.2.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 +8 -2
- data/lib/markdown_media/version.rb +1 -1
- data/lib/markdown_media.rb +22 -3
- data/lib/templates/image.erb +1 -1
- data/lib/templates/instagram.erb +14 -0
- data/lib/templates/twitter.erb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a490d07fc7560f46e187a7588e28314974a34a8b
|
4
|
+
data.tar.gz: 698f8634725452bae019b5d1c1e48d3aa26068ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 34caf289ccf17469ecdc0153ea6764796be4de4499acd2cac78f680b0e739a86947df8a709106ff0cf6a722d80442565782b9a996b7b34e30ccefc324de4134e
|
7
|
+
data.tar.gz: 78be0c9cc7858d908285c939e7fdf368baf5ad504d0a912318b75a18936b097d1596e088261b577f6472f3442737926494a298e6a0e5bfc7eb4545dd052b3ead
|
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.0.0](https://img.shields.io/badge/VERSION-1.
|
5
|
+
![Version 1.0.0](https://img.shields.io/badge/VERSION-1.2.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.
|
@@ -150,12 +150,18 @@ YouTube's short URL format also works.
|
|
150
150
|
[[https://youtu.be/YX40hbAHx3s]]
|
151
151
|
```
|
152
152
|
|
153
|
-
A Daily Motion
|
153
|
+
A video from Daily Motion.
|
154
154
|
|
155
155
|
```
|
156
156
|
[[http://www.dailymotion.com/video/x5gwr1v_anarchists-in-rojava-announce-irpgf_news]]
|
157
157
|
```
|
158
158
|
|
159
|
+
A video from Twitter.
|
160
|
+
|
161
|
+
```
|
162
|
+
[[https://twitter.com/Breaking911/status/900211169734131713 type:video]]
|
163
|
+
```
|
164
|
+
|
159
165
|
#### Audio
|
160
166
|
|
161
167
|
A simple audio.
|
data/lib/markdown_media.rb
CHANGED
@@ -17,6 +17,7 @@ module MarkdownMedia
|
|
17
17
|
url = embed_tag_pieces.shift
|
18
18
|
id = remove_id(embed_tag_pieces)
|
19
19
|
klass = remove_class(embed_tag_pieces)
|
20
|
+
type = remove_type(embed_tag_pieces)
|
20
21
|
|
21
22
|
link = unless embed_tag_pieces.to_s.empty?
|
22
23
|
embed_tag_pieces.pop if url_or_path?(embed_tag_pieces.last)
|
@@ -24,7 +25,7 @@ module MarkdownMedia
|
|
24
25
|
|
25
26
|
caption = embed_tag_pieces.join(" ")
|
26
27
|
|
27
|
-
expanded_embed(url, caption: caption, link: link, id: id, klass: klass)
|
28
|
+
expanded_embed(url, caption: caption, link: link, id: id, type: type, klass: klass)
|
28
29
|
end
|
29
30
|
end
|
30
31
|
|
@@ -61,7 +62,20 @@ module MarkdownMedia
|
|
61
62
|
end
|
62
63
|
end
|
63
64
|
|
64
|
-
def
|
65
|
+
def remove_type(pieces)
|
66
|
+
return if pieces.to_s.empty?
|
67
|
+
|
68
|
+
type_string = pieces.detect { |piece| piece =~ /type:\S+/ }
|
69
|
+
|
70
|
+
if type_string
|
71
|
+
type = type_string.split(":").last
|
72
|
+
pieces.delete(type_string)
|
73
|
+
|
74
|
+
type
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
def expanded_embed(url, caption: nil, link: nil, id: nil, type: nil, klass: nil)
|
65
79
|
url = URI.parse(url)
|
66
80
|
|
67
81
|
case url.host
|
@@ -90,6 +104,10 @@ module MarkdownMedia
|
|
90
104
|
|
91
105
|
when "twitter.com"
|
92
106
|
slug = "twitter"
|
107
|
+
type ||= "tweet"
|
108
|
+
|
109
|
+
when /instagram/
|
110
|
+
slug = "instagram"
|
93
111
|
|
94
112
|
else
|
95
113
|
slug = case url.path
|
@@ -105,7 +123,7 @@ module MarkdownMedia
|
|
105
123
|
end
|
106
124
|
end
|
107
125
|
|
108
|
-
render_erb slug, { embed_id: embed_id || url.to_s, caption: caption, link: link, id: id, klass: klass }
|
126
|
+
render_erb slug, { embed_id: embed_id || url.to_s, caption: caption, link: link, id: id, type: type, klass: klass }
|
109
127
|
end
|
110
128
|
|
111
129
|
def render_erb(template_slug, locals)
|
@@ -116,6 +134,7 @@ module MarkdownMedia
|
|
116
134
|
caption = locals[:caption]
|
117
135
|
link = locals[:link]
|
118
136
|
id = locals[:id]
|
137
|
+
type = locals[:type]
|
119
138
|
klass = locals[:klass]
|
120
139
|
|
121
140
|
erb = ERB.new(template)
|
data/lib/templates/image.erb
CHANGED
@@ -0,0 +1,14 @@
|
|
1
|
+
<blockquote class="instagram-media <%= klass %>" id="<%= id %>" data-instgrm-version="7" style=" background:#FFF; border:0; border-radius:3px; box-shadow:0 0 1px 0 rgba(0,0,0,0.5),0 1px 10px 0 rgba(0,0,0,0.15); margin: 1px; max-width:658px; padding:0; width:99.375%; width:-webkit-calc(100% - 2px); width:calc(100% - 2px);">
|
2
|
+
<div style="padding:8px;">
|
3
|
+
<div style=" background:#F8F8F8; line-height:0; margin-top:40px; padding:50.0% 0; text-align:center; width:100%;">
|
4
|
+
<div style=" background:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACwAAAAsCAMAAAApWqozAAAABGdBTUEAALGPC/xhBQAAAAFzUkdCAK7OHOkAAAAMUExURczMzPf399fX1+bm5mzY9AMAAADiSURBVDjLvZXbEsMgCES5/P8/t9FuRVCRmU73JWlzosgSIIZURCjo/ad+EQJJB4Hv8BFt+IDpQoCx1wjOSBFhh2XssxEIYn3ulI/6MNReE07UIWJEv8UEOWDS88LY97kqyTliJKKtuYBbruAyVh5wOHiXmpi5we58Ek028czwyuQdLKPG1Bkb4NnM+VeAnfHqn1k4+GPT6uGQcvu2h2OVuIf/gWUFyy8OWEpdyZSa3aVCqpVoVvzZZ2VTnn2wU8qzVjDDetO90GSy9mVLqtgYSy231MxrY6I2gGqjrTY0L8fxCxfCBbhWrsYYAAAAAElFTkSuQmCC); display:block; height:44px; margin:0 auto -44px; position:relative; top:-22px; width:44px;"></div>
|
5
|
+
</div>
|
6
|
+
|
7
|
+
<p style=" color:#c9c8cd; font-family:Arial,sans-serif; font-size:14px; line-height:17px; margin-bottom:0; margin-top:8px; overflow:hidden; padding:8px 0 7px; text-align:center; text-overflow:ellipsis; white-space:nowrap;">
|
8
|
+
<a href="<%= embed_id.to_s %>" style=" color:#c9c8cd; font-family:Arial,sans-serif; font-size:14px; font-style:normal; font-weight:normal; line-height:17px; text-decoration:none;" target="_blank">
|
9
|
+
<%= embed_id.to_s %>
|
10
|
+
</a>
|
11
|
+
</p>
|
12
|
+
</div>
|
13
|
+
</blockquote>
|
14
|
+
<script async defer src="https://platform.instagram.com/en_US/embeds.js"></script>
|
data/lib/templates/twitter.erb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
<blockquote class="twitter
|
1
|
+
<blockquote class="twitter-<%=type %> <%= klass %>" <%= 'data-status="hidden"' if type == "video" %> data-lang="en" id="<%= id %>">
|
2
2
|
<a href="<%= embed_id.to_s %>"><%= embed_id.to_s %></a>
|
3
3
|
</blockquote>
|
4
4
|
<script async src="//platform.twitter.com/widgets.js" charset="utf-8"></script>
|
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.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shane Becker
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-08-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -91,6 +91,7 @@ files:
|
|
91
91
|
- lib/templates/audio.erb
|
92
92
|
- lib/templates/dailymotion.erb
|
93
93
|
- lib/templates/image.erb
|
94
|
+
- lib/templates/instagram.erb
|
94
95
|
- lib/templates/link.erb
|
95
96
|
- lib/templates/twitter.erb
|
96
97
|
- lib/templates/video.erb
|
@@ -117,7 +118,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
117
118
|
version: '0'
|
118
119
|
requirements: []
|
119
120
|
rubyforge_project:
|
120
|
-
rubygems_version: 2.6.
|
121
|
+
rubygems_version: 2.6.13
|
121
122
|
signing_key:
|
122
123
|
specification_version: 4
|
123
124
|
summary: A [[ URL ]] syntax to embed media into views.
|