markdown_media 1.0.0 → 1.1.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
  SHA1:
3
- metadata.gz: 4c41aae15dd55204681c7f3e1643552328690730
4
- data.tar.gz: dac479107bd7538a54278d7ff88176622395080f
3
+ metadata.gz: b202847889838e4504a79dff4f67f3288a090977
4
+ data.tar.gz: 6d0c91d5491b9441b341b06286ab579322fbaae0
5
5
  SHA512:
6
- metadata.gz: 6458da5a6a86516e79a04bb73ff47ce8ca29c61f93687593bcd19d55bf013d2cd6871653a8ebd18fbcca22b0ae67548ad824162bb5548099ef62590bd805623e
7
- data.tar.gz: eaad1b978d151e8467c07efd7cbda7272984d934d080fbcaffabce34672ceeaa792e5fef0b56dbbb2d5bb8e2515042228a582801ccc04ffd592dfaef16ef913f
6
+ metadata.gz: '00030559c43bf3c266bdfee95458fd25ed25fb8485a7c7a3df5a941bc410849186c6a4ec6763154a255b6f01bc11e63c85376d19d81ae149043ada0204815d2d'
7
+ data.tar.gz: 1660b6e3c930161669c0c8fb7e839dcf1139c58704a80e191ae64732cc00c1872ef271b572e260cea4fa9cff862fd1a0c8d216b7b1d098ea5caec78a940431b8
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.0.0-green.svg)
5
+ ![Version 1.0.0](https://img.shields.io/badge/VERSION-1.1.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.
@@ -16,13 +16,15 @@ module MarkdownMedia
16
16
 
17
17
  url = embed_tag_pieces.shift
18
18
  id = remove_id(embed_tag_pieces)
19
- link = if embed_tag_pieces.to_s.empty?
19
+ klass = remove_class(embed_tag_pieces)
20
+
21
+ link = unless embed_tag_pieces.to_s.empty?
20
22
  embed_tag_pieces.pop if url_or_path?(embed_tag_pieces.last)
21
23
  end
22
24
 
23
25
  caption = embed_tag_pieces.join(" ")
24
26
 
25
- expanded_embed(url, caption: caption, link: link, id: id)
27
+ expanded_embed(url, caption: caption, link: link, id: id, klass: klass)
26
28
  end
27
29
  end
28
30
 
@@ -33,6 +35,19 @@ module MarkdownMedia
33
35
  string =~ /^(http|\/)\S+/ ? true : false
34
36
  end
35
37
 
38
+ def remove_class(pieces)
39
+ return if pieces.to_s.empty?
40
+
41
+ klass_string = pieces.detect { |piece| piece =~ /class:\S+/ }
42
+
43
+ if klass_string
44
+ klass = klass_string.split(":").last
45
+ pieces.delete(klass_string)
46
+
47
+ klass
48
+ end
49
+ end
50
+
36
51
  def remove_id(pieces)
37
52
  return if pieces.to_s.empty?
38
53
 
@@ -46,7 +61,7 @@ module MarkdownMedia
46
61
  end
47
62
  end
48
63
 
49
- def expanded_embed(url, caption: nil, link: nil, id: nil)
64
+ def expanded_embed(url, caption: nil, link: nil, id: nil, klass: nil)
50
65
  url = URI.parse(url)
51
66
 
52
67
  case url.host
@@ -90,7 +105,7 @@ module MarkdownMedia
90
105
  end
91
106
  end
92
107
 
93
- render_erb slug, { embed_id: embed_id || url.to_s, caption: caption, link: link, id: id }
108
+ render_erb slug, { embed_id: embed_id || url.to_s, caption: caption, link: link, id: id, klass: klass }
94
109
  end
95
110
 
96
111
  def render_erb(template_slug, locals)
@@ -101,6 +116,7 @@ module MarkdownMedia
101
116
  caption = locals[:caption]
102
117
  link = locals[:link]
103
118
  id = locals[:id]
119
+ klass = locals[:klass]
104
120
 
105
121
  erb = ERB.new(template)
106
122
  erb.result(binding)
@@ -1,3 +1,3 @@
1
1
  module MarkdownMedia
2
- VERSION = "1.0.0"
2
+ VERSION = "1.1.0"
3
3
  end
@@ -1,4 +1,4 @@
1
- <figure id="<%= id %>">
1
+ <figure id="<%= id %>" class="<%= klass %>">
2
2
  <audio controls>
3
3
  <source src="<%= embed_id %>" />
4
4
  </audio>
@@ -1,4 +1,4 @@
1
- <figure class="video-container" id="<%= id %>">
1
+ <figure class="video-container <%= klass %>" id="<%= id %>">
2
2
  <iframe frameborder="0" src="//www.dailymotion.com/embed/video/<%= embed_id %>" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
3
3
 
4
4
  <% unless caption.to_s.empty? %>
@@ -1,6 +1,6 @@
1
1
  <% if caption.to_s.empty? %>
2
2
 
3
- <figure id="<%= id %>">
3
+ <figure id="<%= id %>" class="<%= klass %>">
4
4
  <% if link.to_s.empty? %>
5
5
  <img src="<%= embed_id %>" />
6
6
  <% else %>
@@ -10,7 +10,7 @@
10
10
 
11
11
  <% else %>
12
12
 
13
- <figure id="<%= id %>">
13
+ <figure id="<%= id %>" class="<%= klass %>">
14
14
  <% if link.to_s.empty? %>
15
15
  <img src="<%= embed_id %>" />
16
16
  <% else %>
@@ -1 +1 @@
1
- <a href="<%= embed_id.to_s %>" id="<%= id %>"><%= caption.to_s.empty? ? embed_id.to_s.sub(/^https*:\/\//, "").sub(/\/$/, "") : caption %></a>
1
+ <a href="<%= embed_id.to_s %>" id="<%= id %>" class="<%= klass %>"><%= caption.to_s.empty? ? embed_id.to_s.sub(/^https*:\/\//, "").sub(/\/$/, "") : caption %></a>
@@ -1,4 +1,4 @@
1
- <blockquote class="twitter-tweet" data-lang="en" id="<%= id %>">
1
+ <blockquote class="twitter-tweet <%= klass %>" 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>
@@ -1,4 +1,4 @@
1
- <figure class="video-container" id="<%= id %>">
1
+ <figure class="video-container <%= klass %>" id="<%= id %>">
2
2
  <video controls>
3
3
  <source src="<%= embed_id %>" />
4
4
  </video>
@@ -1,4 +1,4 @@
1
- <figure class="video-container" id="<%= id %>">
1
+ <figure class="video-container <%= klass %>" id="<%= id %>">
2
2
  <iframe src="https://player.vimeo.com/video/<%= embed_id %>?title=0&amp;byline=0&amp;portrait=0" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>
3
3
 
4
4
  <% unless caption.to_s.empty? %>
@@ -1,4 +1,4 @@
1
- <figure class="video-container" id="<%= id %>">
1
+ <figure class="video-container <%= klass %>" id="<%= id %>">
2
2
  <iframe src="https://www.youtube.com/embed/<%= embed_id %>" frameborder="0" allowfullscreen></iframe>
3
3
 
4
4
  <% unless caption.to_s.empty? %>
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.0.0
4
+ version: 1.1.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-05-14 00:00:00.000000000 Z
11
+ date: 2017-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -117,7 +117,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
117
117
  version: '0'
118
118
  requirements: []
119
119
  rubyforge_project:
120
- rubygems_version: 2.6.8
120
+ rubygems_version: 2.6.11
121
121
  signing_key:
122
122
  specification_version: 4
123
123
  summary: A [[ URL ]] syntax to embed media into views.