kielce 2.0.3 → 2.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 36158b72d9d7f3baf4adc37f9d50d9b61a09238a8d13e24f099df352c231a09a
4
- data.tar.gz: '086476ea182c32f3b6afd2307a3ed521b51c49c8b5ccaa4ca89aca7d3b7e0f00'
3
+ metadata.gz: f8c3f77d063506dc5a2cc9cf05cf4e1533e4285be392626d011d772f3cc72899
4
+ data.tar.gz: 23d1b29068daa91274bbabab558a7ec34c31a03c14c7927b9c8209ff84450689
5
5
  SHA512:
6
- metadata.gz: 02be2e3eee8ce8f9da8cd547e808b5a88bb1f0d38d622d2e09e2e27491efc39c98c3eaf71a5f899729cccf7402bb58bbcb9b556ca868df37e8efe225894f0818
7
- data.tar.gz: e4a7608ea3273ed9ae9947b59d389e29ec69219925df9b49223e8422bb45ef7756d9bf4d86371899fc3e0ea43c80c06a36ad12a5900b3fda53197c56a95006b1
6
+ metadata.gz: c8a4b799e7003ffa4981af5593e06c131f6c1cbe9ed777a8726e62dbde7dac09bfffcac775e7967a49a1f876aa017150ea409bc5a5de3fb4683de7875db28d48
7
+ data.tar.gz: 1d4dbf33350ad953b1552cc3efba048f88992e58cfff88e27e6b5b08a97c3717b307cb42ef533bbf00ac9f554974f0e6c5753e1030a8bf5b4c0c0dfc7a403580
data/lib/kielce/kielce.rb CHANGED
@@ -38,7 +38,7 @@ module Kielce
38
38
  #
39
39
  # This could be a class method. We make it
40
40
  # an instance method so it can be used using the "$k.link" syntax.
41
- def link(url, text_param = nil, code: nil, classes: nil)
41
+ def link(url, text_param = nil, code: nil, classes: nil, target: nil)
42
42
  class_list = classes.nil? ? "" : " class='#{classes}'"
43
43
 
44
44
  # Make the text the same as the URL if no text given
@@ -47,7 +47,15 @@ module Kielce
47
47
  # use <code> if either (1) user requests it, or (2) no text_param given and no code param given
48
48
  text = "<code>#{text}</code>" if code || (text_param.nil? && code.nil?)
49
49
 
50
- "<a href='#{url}'#{class_list}>#{text}</a>"
50
+ if target.nil?
51
+ target_str = ''
52
+ else
53
+ target = "_#{target.to_s}" if target.is_a?(Symbol)
54
+ # NOTE: Space at the end of target_str is important
55
+ target_str = "target='#{target}' " unless target.nil?
56
+ end
57
+
58
+ "<a #{target_str}href='#{url}'#{class_list}>#{text}</a>"
51
59
  end
52
60
 
53
61
  # Load +file+ and run ERB. The binding parameter determines
@@ -87,12 +95,12 @@ module Kielce
87
95
  # another erb template. In order for such nested calls to work
88
96
  # properly, each call must have a unique variable in which to
89
97
  # store its output. This parameter is called "eoutvar". (If you
90
- # don't specifiy eoutvar and make a nested call, the output
98
+ # don't specify eoutvar and make a nested call, the output
91
99
  # can get messed up.)
92
100
  @@render_count += 1
93
101
 
94
102
  begin
95
- erb = ERB.new(content, nil, nil, "render_out_#{@@render_count}")
103
+ erb = ERB.new(content, eoutvar: "render_out_#{@@render_count}")
96
104
  erb.filename = file.to_s
97
105
  result = erb.result(b)
98
106
  rescue NoKeyError => e
data/lib/kielce.rb CHANGED
@@ -14,7 +14,12 @@ require "kielce/kielce"
14
14
  ##############################################################################################
15
15
 
16
16
  module Kielce
17
- VERSION = "2.0.3"
17
+ VERSION = "2.0.4"
18
+
19
+ # Changelog
20
+ #
21
+ # 2.0.4: Added a "target" option to "link", and made the timeline links open in a new tab.
22
+
18
23
 
19
24
  def self.run
20
25
 
@@ -51,7 +51,7 @@ module KielcePlugins
51
51
  end
52
52
 
53
53
  # build a link, if a link provided
54
- (linked && !@link.nil?) ? "<a href='#{@link}'>#{text}</a>" : text
54
+ (linked && !@link.nil?) ? "<a target='_blank' href='#{@link}'>#{text}</a>" : text
55
55
  end # title
56
56
  end # class Assignment
57
57
  end # module Schedule
@@ -24,7 +24,7 @@ module KielcePlugins
24
24
  # Replace link markup
25
25
  value.gsub!(/\[\[([^\s]+)(\s+(\S.*)|\s*)\]\]/) do
26
26
  text = $3.nil? ? "<code>#{$1}</code>" : $3
27
- "<a href='#{$1}'>#{text}</a>"
27
+ "<a target='_blank' href='#{$1}'>#{text}</a>"
28
28
  end
29
29
 
30
30
  value.gsub!(/<<(assign|due|ref)\s+(\S.+?)>>/) do
@@ -57,8 +57,9 @@ module KielcePlugins
57
57
  link = $d.course.notesTemplates.method_missing(method, param)
58
58
  else
59
59
  link = link_rule
60
- end
61
- "(<a href='#{link}'>#{text}</a>)"
60
+ end
61
+ # Suppress links if text begins with xx.
62
+ text =~ /^xx/ ? '': "(<a target='_blank' href='#{link}'>#{text}</a>)"
62
63
  end # end gsub
63
64
 
64
65
  end # end if value is string
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kielce
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.3
4
+ version: 2.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Zachary Kurmas
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-01-03 00:00:00.000000000 Z
11
+ date: 2022-07-06 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: 'An ERB-based templating engine for generating course documents. '
14
14
  email:
@@ -46,7 +46,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
46
46
  - !ruby/object:Gem::Version
47
47
  version: '0'
48
48
  requirements: []
49
- rubygems_version: 3.2.3
49
+ rubygems_version: 3.3.7
50
50
  signing_key:
51
51
  specification_version: 4
52
52
  summary: An ERB-based templating engine for generating course documents.