card 1.19.5 → 1.19.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/card/name.rb +11 -5
- data/mod/account/set/self/account_links.rb +2 -2
- data/mod/basic_formats/set/all/base.rb +5 -4
- data/mod/basic_formats/spec/set/all/base_spec.rb +1 -0
- data/mod/core/set/all/fetch.rb +2 -3
- data/mod/core/set/all/utils.rb +1 -1
- data/mod/email/set/all/follow.rb +2 -2
- data/mod/history/set/all/history.rb +2 -2
- data/mod/standard/set/all/error.rb +6 -8
- data/mod/standard/set/all/links.rb +56 -80
- data/mod/standard/set/all/rich_html/editing.rb +2 -2
- data/mod/standard/set/rstar/rules_editor.rb +1 -1
- data/mod/standard/spec/chunk/link_spec.rb +2 -1
- data/spec/lib/card/content_spec.rb +13 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3c91002b7b0036a9412a5b3f4d24c785d6cc7cd3
|
4
|
+
data.tar.gz: 91b617c019d6a60441ac0b9e08d9557099094f1c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93ab7930c6911b7bb811c106ad2167178d9bbd79a3b7b9e0027d5204c381ceeed0d9e6ff122748b4f966c3c37ebf8eb155483526b435660bd69cd72b18f11dd5
|
7
|
+
data.tar.gz: 9d2e34c1d4778d25fe534384bac6fd26a5bb54bcf8bccfbde7a721b5477be596cc212f005d61691aac4e014365ab3e66b1e40a01aac6b36a13966856957de552
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.19.
|
1
|
+
1.19.6
|
data/lib/card/name.rb
CHANGED
@@ -11,11 +11,17 @@ class Card
|
|
11
11
|
self.session = proc { Card::Auth.current.name }
|
12
12
|
self.banned_array = ["/"]
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
14
|
+
class << self
|
15
|
+
def cardish mark
|
16
|
+
case mark
|
17
|
+
when Card then mark.cardname
|
18
|
+
when Symbol, Integer then Card.quick_fetch(mark).cardname
|
19
|
+
else mark.to_name
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def url_key_to_standard key
|
24
|
+
key.to_s.tr "_", " "
|
19
25
|
end
|
20
26
|
end
|
21
27
|
|
@@ -37,7 +37,7 @@ format :html do
|
|
37
37
|
|
38
38
|
def default_sign_up_args args
|
39
39
|
account_link_text :sign_up, args
|
40
|
-
account_link_opts "signup-link", args, action: :new,
|
40
|
+
account_link_opts "signup-link", args, action: :new, mark: :signup
|
41
41
|
end
|
42
42
|
|
43
43
|
def default_sign_in_args args
|
@@ -47,7 +47,7 @@ format :html do
|
|
47
47
|
|
48
48
|
def default_invite_args args
|
49
49
|
account_link_text :invite, args
|
50
|
-
account_link_opts "invite-a-friend-link", args, action: :new,
|
50
|
+
account_link_opts "invite-a-friend-link", args, action: :new, mark: :signup
|
51
51
|
end
|
52
52
|
|
53
53
|
def default_sign_out_args args
|
@@ -43,10 +43,11 @@ format do
|
|
43
43
|
|
44
44
|
view :link, closed: true, perms: :none do |args|
|
45
45
|
title = showname args[:title]
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
46
|
+
opts = { known: card.known? }
|
47
|
+
if args[:type] && !opts[:known]
|
48
|
+
opts[:path] = { card: { type: args[:type] } }
|
49
|
+
end
|
50
|
+
link_to_card card.name, title, opts
|
50
51
|
end
|
51
52
|
|
52
53
|
view(:codename, closed: true) { card.codename.to_s }
|
data/mod/core/set/all/fetch.rb
CHANGED
@@ -187,9 +187,8 @@ module ClassMethods
|
|
187
187
|
opts = (args[:card] || {}).clone
|
188
188
|
# clone so that original params remain unaltered. need deeper clone?
|
189
189
|
opts[:type] ||= args[:type] if args[:type]
|
190
|
-
# for /new/:type shortcut. we should
|
191
|
-
opts[:name] ||= args[:id]
|
192
|
-
# move handling to Card::Name?
|
190
|
+
# for /new/:type shortcut. we should handle in routing and deprecate this
|
191
|
+
opts[:name] ||= Card::Name.url_key_to_standard(args[:id])
|
193
192
|
opts
|
194
193
|
end
|
195
194
|
|
data/mod/core/set/all/utils.rb
CHANGED
data/mod/email/set/all/follow.rb
CHANGED
@@ -37,7 +37,7 @@ format do
|
|
37
37
|
end
|
38
38
|
set_card = card.default_follow_set_card
|
39
39
|
hash[:path] = path(
|
40
|
-
|
40
|
+
mark: set_card.follow_rule_name(Auth.current.name),
|
41
41
|
action: :update,
|
42
42
|
success: { layout: :modal, view: :follow_status },
|
43
43
|
card: { content: "[[#{hash[:content]}]]" }
|
@@ -62,7 +62,7 @@ format :html do
|
|
62
62
|
# card.default_follow_set_card.follow_rule_name(Auth.current.name),
|
63
63
|
# new: {}
|
64
64
|
# )
|
65
|
-
opts = (args[:
|
65
|
+
opts = (args[:link_opts] || {}).clone
|
66
66
|
opts.merge!(
|
67
67
|
title: hash[:title],
|
68
68
|
"data-path" => hash[:path],
|
@@ -384,8 +384,8 @@ format :html do
|
|
384
384
|
end
|
385
385
|
|
386
386
|
def rollback_link actions
|
387
|
-
#
|
388
|
-
prior = #
|
387
|
+
# FIXME -- doesn't this need to specify which action it wants?
|
388
|
+
prior = # FIXME - should be a Card::Action method
|
389
389
|
actions.select { |action| action.card.last_action_id != action.id }
|
390
390
|
return unless card.ok?(:update) && prior.present?
|
391
391
|
link = link_to(
|
@@ -100,12 +100,10 @@ format :html do
|
|
100
100
|
|
101
101
|
view :missing do |args|
|
102
102
|
return "" unless card.ok? :create # should this be moved into ok_view?
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
class: "slotter missing-#{missing_view}"
|
108
|
-
end
|
103
|
+
path_opts = args[:type] ? { card: { type: args[:type] } } : {}
|
104
|
+
link_text = "Add #{fancy_title args[:title]}"
|
105
|
+
klass = "slotter missing-#{args[:denied_view] || args[:home_view]}"
|
106
|
+
wrap(args) { link_to_view :new, link_text, path: path_opts, class: klass }
|
109
107
|
end
|
110
108
|
|
111
109
|
view :closed_missing, perms: :none do
|
@@ -153,7 +151,7 @@ format :html do
|
|
153
151
|
sign_in_or_up_links =
|
154
152
|
unless Auth.signed_in?
|
155
153
|
signin_link = link_to_card :signin, "Sign in"
|
156
|
-
signup_link = link_to "Sign up", path: {
|
154
|
+
signup_link = link_to "Sign up", path: { action: :new, mark: :signup }
|
157
155
|
%(<div>#{signin_link} or #{signup_link} to create it.</div>)
|
158
156
|
end
|
159
157
|
frame args.merge(title: "Not Found", optional_menu: :never) do
|
@@ -184,7 +182,7 @@ format :html do
|
|
184
182
|
or_signup_link =
|
185
183
|
if Card.new(type_id: Card::SignupID).ok? :create
|
186
184
|
"or " +
|
187
|
-
link_to("sign up", path: {
|
185
|
+
link_to("sign up", path: { action: "new", mark: :signup })
|
188
186
|
end
|
189
187
|
Env.save_interrupted_action(request.env["REQUEST_URI"])
|
190
188
|
"Please #{signin_link} #{or_signup_link} #{to_task}"
|
@@ -2,7 +2,7 @@ RESOURCE_TYPE_REGEXP = /^([a-zA-Z][\-+\.a-zA-Z\d]*):/
|
|
2
2
|
|
3
3
|
format :html do
|
4
4
|
def link_to text=nil, opts={}
|
5
|
-
opts[:href] =
|
5
|
+
opts[:href] = path opts.delete(:path)
|
6
6
|
text = raw(text || opts[:href])
|
7
7
|
interpret_data_opts_to_link_to opts
|
8
8
|
content_tag :a, text, opts
|
@@ -18,31 +18,23 @@ end
|
|
18
18
|
|
19
19
|
format :css do
|
20
20
|
def link_to _text=nil, opts={}
|
21
|
-
card_url
|
21
|
+
card_url path(opts.delete(:path))
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
25
|
format do
|
26
26
|
def link_to text=nil, opts={}
|
27
|
-
|
28
|
-
if text &&
|
29
|
-
"#{text}[#{
|
27
|
+
path = path opts.delete(:path)
|
28
|
+
if text && path != text
|
29
|
+
"#{text}[#{path}]"
|
30
30
|
else
|
31
|
-
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def smart_link_to text, opts={}
|
36
|
-
if (linktype = [:view, :related, :card, :resource].find { |key| opts[key] })
|
37
|
-
send "link_to_#{linktype}", opts.delete(linktype), text, opts
|
38
|
-
else
|
39
|
-
send :link_to, text, opts
|
31
|
+
path
|
40
32
|
end
|
41
33
|
end
|
42
34
|
|
43
35
|
def link_to_resource resource, text=nil, opts={}
|
44
36
|
case (resource_type = resource_type resource)
|
45
|
-
when "external-link" then opts[:target]
|
37
|
+
when "external-link" then opts[:target] ||= "_blank"
|
46
38
|
when "internal-link" then resource = internal_url resource[1..-1]
|
47
39
|
end
|
48
40
|
add_class opts, resource_type
|
@@ -60,9 +52,7 @@ format do
|
|
60
52
|
|
61
53
|
def link_to_card cardish, text=nil, opts={}
|
62
54
|
opts[:path] ||= {}
|
63
|
-
name = opts[:path][:
|
64
|
-
# @fixme - need smarter mark handling
|
65
|
-
|
55
|
+
name = opts[:path][:mark] = Card::Name.cardish cardish
|
66
56
|
text ||= name.to_name.to_show @context_names
|
67
57
|
add_known_or_wanted_class opts, name
|
68
58
|
link_to text, opts
|
@@ -74,8 +64,8 @@ format do
|
|
74
64
|
add_class opts, (known ? "known-card" : "wanted-card")
|
75
65
|
end
|
76
66
|
|
77
|
-
# link to a specific view
|
78
|
-
#
|
67
|
+
# dynamic (ajax) link to a specific view
|
68
|
+
#
|
79
69
|
def link_to_view view, text, opts={}
|
80
70
|
opts.reverse_merge! path: {}, remote: true, rel: "nofollow"
|
81
71
|
opts[:path][:view] = view unless view == :home
|
@@ -90,38 +80,55 @@ format do
|
|
90
80
|
link_to_view :related, (text || name), opts
|
91
81
|
end
|
92
82
|
|
93
|
-
#
|
83
|
+
# smart_link_to is wrapper method for #link_to, #link_to_card, #link_to_view,
|
84
|
+
# #link_to_resource, and #link_to_related. If the opts argument contains
|
85
|
+
# :view, :related, :card, or :resource, it will use the respective method to
|
86
|
+
# render a link.
|
87
|
+
def smart_link_to text, opts={}
|
88
|
+
if (linktype = [:view, :related, :card, :resource].find { |key| opts[key] })
|
89
|
+
send "link_to_#{linktype}", opts.delete(linktype), text, opts
|
90
|
+
else
|
91
|
+
send :link_to, text, opts
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
# path is for generating standard card routes, eg
|
96
|
+
# [cardname]
|
97
|
+
# [cardname]?[param]=[value]
|
98
|
+
# [action]/[cardname]?[param]=[value]
|
99
|
+
|
100
|
+
# @param opts [Hash, String] a String is treated as a complete path and
|
101
|
+
# bypasses all processing
|
102
|
+
# @option opts [String, Card::Name, Integer, Symbol, Card] :mark
|
94
103
|
# @option opts [Symbol] :action card action (:create, :update, :delete)
|
95
|
-
# @option opts [Integer, String] :id
|
96
|
-
# @option opts [String, Card::Name] :name
|
97
|
-
# @option opts [String] :type
|
98
104
|
# @option opts [Hash] :card
|
99
|
-
# @
|
100
|
-
def path opts={}
|
101
|
-
|
105
|
+
# @option opts []
|
106
|
+
def path opts={}
|
107
|
+
return opts unless opts.is_a? Hash
|
108
|
+
path = new_cardtype_path(opts) || standard_path(opts)
|
102
109
|
internal_url path
|
103
110
|
end
|
104
111
|
|
105
112
|
def new_cardtype_path opts
|
106
113
|
return unless opts[:action] == :new
|
107
114
|
opts.delete :action
|
108
|
-
return unless
|
109
|
-
"new/#{
|
115
|
+
return unless opts[:mark]
|
116
|
+
"new/#{path_mark opts}"
|
110
117
|
end
|
111
118
|
|
112
|
-
def standard_path opts
|
119
|
+
def standard_path opts
|
113
120
|
standardize_action! opts
|
114
|
-
|
121
|
+
mark = path_mark opts
|
122
|
+
base = path_base opts[:action], mark
|
115
123
|
base + path_query(opts)
|
116
124
|
end
|
117
125
|
|
118
|
-
def
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
else "#{action}/"
|
126
|
+
def path_base action, mark
|
127
|
+
if action
|
128
|
+
mark.present? ? "#{action}/#{mark}" : "card/#{action}"
|
129
|
+
# the card/ prefix prevents interpreting action as cardname
|
130
|
+
else
|
131
|
+
mark
|
125
132
|
end
|
126
133
|
end
|
127
134
|
|
@@ -130,58 +137,27 @@ format do
|
|
130
137
|
opts.delete :action
|
131
138
|
end
|
132
139
|
|
133
|
-
def path_mark opts
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
end
|
139
|
-
end
|
140
|
-
|
141
|
-
def path_id opts
|
142
|
-
id = opts.delete :id
|
143
|
-
id if id.present?
|
140
|
+
def path_mark opts
|
141
|
+
return "" if opts[:action] == :create || opts.delete(:no_mark)
|
142
|
+
name = opts[:mark] ? Card::Name.cardish(opts.delete(:mark)) : card.name
|
143
|
+
add_unknown_name_to_opts name.to_name, opts
|
144
|
+
name.to_name.url_key
|
144
145
|
end
|
145
146
|
|
146
147
|
def path_query opts
|
147
|
-
finalize_card_opts opts.delete(:card), opts
|
148
148
|
opts.delete :action
|
149
149
|
opts.empty? ? "" : "?#{opts.to_param}"
|
150
150
|
end
|
151
151
|
|
152
|
-
def
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
opts[:card] =
|
158
|
-
end
|
159
|
-
|
160
|
-
def assign_path_card_opt card_opts, field, opts
|
161
|
-
optvalue = opts.delete field
|
162
|
-
return if card_opts[field] || !optvalue.present?
|
163
|
-
new_value = send "new_#{field}_in_path_opts", optvalue.to_s, opts
|
164
|
-
return unless new_value
|
165
|
-
card_opts[field] = new_value
|
166
|
-
end
|
167
|
-
|
168
|
-
def new_name_in_path_opts name, opts
|
169
|
-
if opts[:action] == :update
|
170
|
-
name if name != card.name
|
171
|
-
elsif !Card.known?(name) && name != name.to_name.url_key
|
172
|
-
name
|
173
|
-
end
|
174
|
-
end
|
175
|
-
|
176
|
-
def new_type_in_path_opts opttype, _opts
|
177
|
-
opttype if Card.known?(opttype)
|
152
|
+
def add_unknown_name_to_opts name, opts
|
153
|
+
return if opts[:card] && opts[:card][:name]
|
154
|
+
return if name.s == Card::Name.url_key_to_standard(name.url_key)
|
155
|
+
return if Card.known? name
|
156
|
+
opts[:card] ||= {}
|
157
|
+
opts[:card][:name] = name
|
178
158
|
end
|
179
159
|
|
180
160
|
def internal_url relative_path
|
181
161
|
card_path relative_path
|
182
162
|
end
|
183
|
-
|
184
|
-
def interpret_pathish pathish
|
185
|
-
pathish.is_a?(Hash) ? path(pathish) : pathish
|
186
|
-
end
|
187
163
|
end
|
@@ -139,7 +139,7 @@ format :html do
|
|
139
139
|
view :edit_rule, tags: :unknown_ok do |args|
|
140
140
|
return "not a rule" unless card.is_rule?
|
141
141
|
form_args = {
|
142
|
-
url: path(action: :update,
|
142
|
+
url: path(action: :update, no_mark: true),
|
143
143
|
html: { class: "card-form card-rule-form" }
|
144
144
|
}
|
145
145
|
if args[:remote]
|
@@ -9,7 +9,8 @@ describe Card::Content::Chunk::Link do
|
|
9
9
|
assert_args[0] << "[#{key}=\"#{val}\"]"
|
10
10
|
end
|
11
11
|
assert_args << { text: text } if text
|
12
|
-
|
12
|
+
link = render_content target, (format_args || {})
|
13
|
+
assert_view_select link, *assert_args
|
13
14
|
end
|
14
15
|
|
15
16
|
it "handles unknown cards" do
|
@@ -25,7 +25,7 @@ describe Card::Content do
|
|
25
25
|
"{{Included|open}}",
|
26
26
|
rendered: ["Some Links and includes: ",
|
27
27
|
'<a class="wanted-card" ' \
|
28
|
-
'href="/the_card
|
28
|
+
'href="/the_card">' \
|
29
29
|
"the text</a>",
|
30
30
|
", and ",
|
31
31
|
{ options: { view: "Is Included",
|
@@ -208,18 +208,26 @@ describe Card::Content do
|
|
208
208
|
|
209
209
|
describe "parse" do
|
210
210
|
def check_chunk_classes
|
211
|
-
|
212
|
-
clist =
|
211
|
+
all_classes_pass_check_proc
|
212
|
+
clist = nonstring_classes
|
213
213
|
cobj.each_chunk do |chk|
|
214
214
|
expect(chk).to be_instance_of clist.shift
|
215
215
|
end
|
216
216
|
expect(clist).to be_empty
|
217
217
|
end
|
218
218
|
|
219
|
+
def nonstring_classes
|
220
|
+
classes.select { |c| String != c }
|
221
|
+
end
|
222
|
+
|
223
|
+
def all_classes_pass_check_proc
|
224
|
+
expect(cobj.inject(classes, &@check_proc)).to eq(true)
|
225
|
+
end
|
226
|
+
|
219
227
|
it "finds all the chunks and strings" do
|
220
228
|
# note the mixed [} that are considered matching, needs some cleanup ...
|
221
229
|
@example = :nests
|
222
|
-
|
230
|
+
all_classes_pass_check_proc
|
223
231
|
end
|
224
232
|
|
225
233
|
it "gives just the chunks" do
|
@@ -229,7 +237,7 @@ describe Card::Content do
|
|
229
237
|
|
230
238
|
it "finds all the chunks links and trasclusions" do
|
231
239
|
@example = :links_and_nests
|
232
|
-
|
240
|
+
all_classes_pass_check_proc
|
233
241
|
end
|
234
242
|
|
235
243
|
it "finds uri chunks " do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: card
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.19.
|
4
|
+
version: 1.19.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ethan McCutchen
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2016-
|
14
|
+
date: 2016-10-02 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: smartname
|