teepee 0.7.7 → 0.7.8

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: 4416bff207cfb31bd7a1463cdd4992a04bc973e0
4
- data.tar.gz: 04c7fafaa3e5e7318a2146c4ac907b1bb510df4e
3
+ metadata.gz: 0d4c46f3b0b0f37c3ce936555bbfae80774c89a0
4
+ data.tar.gz: d63d77136cf1a0a52c95e23577819427127030a5
5
5
  SHA512:
6
- metadata.gz: 183a6f720ef1763c4036d16cce0ec361e4a4021e8bfc323fca71f0f73a6d68888f97a77a8c7edb1ab9a2ef28638dd8c60829f0069e22a17baadf4cae70dcba98
7
- data.tar.gz: 16adc3436f2b76872c499120e797fc9b0ec9cf92334121e2b9fe3e398dad040b4f59b1d80811026390b292a7eca7b8485a66bfa00d3200d52527793bbcb85257
6
+ metadata.gz: fc847c01ec8104372ae6364e298ddb70895a992a8abc22ed8258dfd3122a12d47913a88133a570f92746660ef9637367ff6430957534f7d51a175bece6cf5db9
7
+ data.tar.gz: a6cd7debb19dd2cc9bf6e19aabbddd28835f926a9e362ed6374cb1c4910fc9b6339f98f187c5df40c572271ea56ea9f918cad645578acc81b48d510a9ba73000
@@ -1,7 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  # -*- mode: Ruby -*-
3
3
 
4
- # Copyright © 2013-2015, Christopher Mark Gore,
4
+ # Copyright © 2013-2016, Christopher Mark Gore,
5
5
  # Soli Deo Gloria,
6
6
  # All rights reserved.
7
7
  #
@@ -94,8 +94,6 @@ module Teepee
94
94
  "strikethrough",
95
95
  "strikeout"
96
96
  @@commander.del expressions
97
- when "i"
98
- @@commander.i
99
97
  when "italic",
100
98
  "textit",
101
99
  "it"
@@ -222,6 +220,10 @@ module Teepee
222
220
  "table-cell",
223
221
  "table_cell"
224
222
  @@commander.table_data expressions
223
+ when "link",
224
+ "href",
225
+ "url"
226
+ @@commander.link expressions
225
227
  when "user",
226
228
  "user-id",
227
229
  "user_id"
@@ -250,6 +252,8 @@ module Teepee
250
252
  "bookmark_folder-id",
251
253
  "bookmark-folder_id"
252
254
  @@commander.bookmarks_folder_id first_word_token
255
+ when "i" # sqrt(-1), not yet supported
256
+ @@commander.i
253
257
  when "pi"
254
258
  @@commander.pi
255
259
  when "e"
@@ -35,6 +35,8 @@
35
35
  # ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36
36
  # POSSIBILITY OF SUCH DAMAGE.
37
37
 
38
+ require 'uri'
39
+
38
40
  require 'active_support/all'
39
41
  require 'monkey-patch'
40
42
 
@@ -45,6 +47,12 @@ include ERB::Util
45
47
 
46
48
  module Teepee
47
49
  class Commander
50
+ def valid_uri? uri
51
+ (!! (u = URI.parse(uri))) and not u.scheme.nil?
52
+ rescue URI::InvalidURIError
53
+ false
54
+ end
55
+
48
56
  def command_error message
49
57
  %{<span style="color: red">[#{message}]</span>}
50
58
  end
@@ -314,6 +322,17 @@ module Teepee
314
322
  ensure_numeric Math::lgamma(n).first
315
323
  end
316
324
 
325
+ def link expressions
326
+ uri, *desc = expressions
327
+ uri = html_safe uri.to_s
328
+ if not valid_uri? uri
329
+ command_error "Not a valid URI."
330
+ else
331
+ desc = [uri] if desc.empty?
332
+ html_tag :a, desc, {href: uri}
333
+ end
334
+ end
335
+
317
336
  def link_id id
318
337
  id_command_handler id, :Link
319
338
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: teepee
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.7
4
+ version: 0.7.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Christopher Mark Gore
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-02-12 00:00:00.000000000 Z
11
+ date: 2016-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport