card 1.16.15 → 1.17.0
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/config/initializers/recaptcha.rb +21 -4
- data/db/migrate_core_cards/20130823192433_add_style_cards.rb +1 -1
- data/db/migrate_core_cards/20140512155840_add_script_cards.rb +1 -1
- data/db/migrate_core_cards/20140629222005_add_email_cards.rb +2 -2
- data/db/migrate_core_cards/20150202143810_import_bootstrap_layout.rb +1 -1
- data/db/migrate_core_cards/20150528084659_add_session_cardtype.rb +1 -1
- data/db/migrate_core_cards/20150610180019_add_recaptcha_key_and_admin_info_cards.rb +63 -0
- data/db/migrate_core_cards/20150724123438_update_file_and_image_cards.rb +1 -1
- data/db/migrate_core_cards/20150903130006_attachment_upload_cards.rb +1 -1
- data/db/schema.rb +1 -1
- data/db/seed/new/card_actions.yml +602 -394
- data/db/seed/new/card_acts.yml +595 -1
- data/db/seed/new/card_changes.yml +26282 -10262
- data/db/seed/new/card_references.yml +1252 -1084
- data/db/seed/new/cards.yml +1899 -1423
- data/db/seed/test/fixtures/card_actions.yml +1653 -1413
- data/db/seed/test/fixtures/card_acts.yml +1063 -445
- data/db/seed/test/fixtures/card_changes.yml +29674 -13637
- data/db/seed/test/fixtures/card_references.yml +1976 -1815
- data/db/seed/test/fixtures/cards.yml +3194 -2719
- data/lib/card.rb +14 -13
- data/lib/card/auth.rb +10 -6
- data/lib/card/cache.rb +58 -120
- data/lib/card/cache/persistent.rb +50 -0
- data/lib/card/cache/temporary.rb +38 -0
- data/lib/card/chunk.rb +34 -25
- data/lib/card/content.rb +3 -3
- data/lib/card/env.rb +3 -0
- data/lib/card/format.rb +56 -53
- data/lib/card/migration.rb +6 -2
- data/lib/card/name.rb +9 -1
- data/lib/card/query.rb +1 -1
- data/lib/card/reference.rb +17 -11
- data/lib/card/set.rb +1 -1
- data/lib/card/subcards.rb +6 -6
- data/lib/card/view_cache.rb +45 -28
- data/lib/generators/card/migration/templates/card_migration.erb +1 -2
- data/mod/01_core/chunk/include.rb +71 -48
- data/mod/01_core/chunk/link.rb +6 -3
- data/mod/01_core/chunk/query_reference.rb +38 -29
- data/mod/01_core/chunk/reference.rb +23 -24
- data/mod/01_core/set/all/collection.rb +1 -1
- data/mod/01_core/set/all/fetch.rb +39 -12
- data/mod/01_core/set/all/permissions.rb +2 -4
- data/mod/01_core/set/all/references.rb +50 -75
- data/mod/01_core/set/all/rules.rb +19 -18
- data/mod/01_core/set/all/subcards.rb +1 -1
- data/mod/01_core/set/all/templating.rb +31 -88
- data/mod/01_core/set/all/tracked_attributes.rb +7 -14
- data/mod/01_core/set/all/utils.rb +77 -66
- data/mod/01_core/set_pattern/07_type_plus_right.rb +6 -3
- data/mod/01_core/spec/set/all/fetch_spec.rb +148 -96
- data/mod/01_core/spec/set/all/templating_spec.rb +49 -40
- data/mod/01_core/spec/set/all/trash_spec.rb +1 -1
- data/mod/01_history/set/all/actions.rb +1 -1
- data/mod/02_basic_types/set/all/base.rb +13 -7
- data/mod/02_basic_types/set/all/rss.rb +17 -22
- data/mod/02_basic_types/set/type/plain_text.rb +5 -2
- data/mod/02_basic_types/spec/set/all/base_spec.rb +1 -0
- data/mod/02_basic_types/spec/set/all/rss_spec.rb +7 -6
- data/mod/03_machines/lib/javascript/wagn.js.coffee +22 -9
- data/mod/03_machines/set/right/machine_output.rb +1 -1
- data/mod/04_settings/lib/card/setting.rb +45 -31
- data/mod/04_settings/set/right/structure.rb +47 -1
- data/mod/04_settings/set/self/default_html_view.rb +2 -0
- data/mod/04_settings/set/self/follow_fields.rb +2 -0
- data/mod/04_settings/set/self/recent_settings.rb +1 -1
- data/mod/05_standard/file/favicon/image-icon.png +0 -0
- data/mod/05_standard/file/favicon/image-large.png +0 -0
- data/mod/05_standard/file/favicon/image-medium.png +0 -0
- data/mod/05_standard/file/favicon/image-original.png +0 -0
- data/mod/05_standard/file/favicon/image-small.png +0 -0
- data/mod/05_standard/set/all/links.rb +27 -26
- data/mod/05_standard/set/all/rich_html/editing.rb +1 -1
- data/mod/05_standard/set/all/rich_html/toolbar.rb +1 -1
- data/mod/05_standard/set/rstar/rules.rb +20 -325
- data/mod/05_standard/set/rstar/rules_editor.rb +362 -0
- data/mod/05_standard/set/self/admin_info.rb +82 -0
- data/mod/05_standard/set/self/all.rb +16 -10
- data/mod/05_standard/set/self/head.rb +20 -19
- data/mod/05_standard/set/type/signup.rb +0 -1
- data/mod/05_standard/spec/set/all/account_spec.rb +44 -43
- data/mod/05_standard/spec/set/right/account_spec.rb +4 -2
- data/mod/05_standard/spec/set/type/search_type_spec.rb +8 -0
- data/mod/05_standard/spec/set/type/signup_spec.rb +24 -17
- data/mod/06_bootstrap/set/all/bootstrap/helper.rb +1 -1
- data/spec/lib/card/cache_spec.rb +64 -70
- data/spec/lib/card/content_spec.rb +236 -150
- data/spec/lib/card/reference_spec.rb +22 -38
- data/spec/lib/card/subcards_spec.rb +38 -0
- data/spec/lib/card/view_cache_spec.rb +8 -0
- data/spec/spec_helper.rb +1 -1
- data/tmpsets/set/mod001-01_core/all/collection.rb +77 -74
- data/tmpsets/set/mod001-01_core/all/content.rb +14 -16
- data/tmpsets/set/mod001-01_core/all/fetch.rb +137 -110
- data/tmpsets/set/mod001-01_core/all/name.rb +58 -40
- data/tmpsets/set/mod001-01_core/all/pattern.rb +12 -11
- data/tmpsets/set/mod001-01_core/all/permissions.rb +125 -117
- data/tmpsets/set/mod001-01_core/all/phases.rb +2 -1
- data/tmpsets/set/mod001-01_core/all/references.rb +52 -77
- data/tmpsets/set/mod001-01_core/all/rules.rb +47 -53
- data/tmpsets/set/mod001-01_core/all/templating.rb +31 -87
- data/tmpsets/set/mod001-01_core/all/tracked_attributes.rb +12 -21
- data/tmpsets/set/mod001-01_core/all/trash.rb +4 -1
- data/tmpsets/set/mod001-01_core/all/type.rb +23 -21
- data/tmpsets/set/mod001-01_core/all/utils.rb +80 -64
- data/tmpsets/set/mod002-01_history/all/actions.rb +20 -16
- data/tmpsets/set/mod002-01_history/all/history.rb +18 -13
- data/tmpsets/set/mod003-02_basic_types/all/base.rb +37 -10
- data/tmpsets/set/mod003-02_basic_types/all/rss.rb +17 -22
- data/tmpsets/set/mod003-02_basic_types/type/plain_text.rb +5 -2
- data/tmpsets/set/mod003-02_basic_types/type/pointer.rb +51 -39
- data/tmpsets/set/mod004-03_machines/right/machine_output.rb +10 -6
- data/tmpsets/set/mod005-04_settings/abstract/permission.rb +10 -5
- data/tmpsets/set/mod005-04_settings/right/structure.rb +47 -1
- data/tmpsets/set/mod005-04_settings/self/recent_settings.rb +1 -0
- data/tmpsets/set/mod005-04_settings/type/setting.rb +4 -1
- data/tmpsets/set/mod006-05_email/all/follow.rb +45 -54
- data/tmpsets/set/mod006-05_email/all/notify.rb +88 -73
- data/tmpsets/set/mod006-05_email/right/followers.rb +17 -14
- data/tmpsets/set/mod006-05_email/self/follow_defaults.rb +22 -18
- data/tmpsets/set/mod006-05_email/type/email_template.rb +1 -1
- data/tmpsets/set/mod007-05_standard/abstract/attachment.rb +94 -67
- data/tmpsets/set/mod007-05_standard/all/account.rb +18 -20
- data/tmpsets/set/mod007-05_standard/all/comment.rb +51 -29
- data/tmpsets/set/mod007-05_standard/all/error.rb +129 -99
- data/tmpsets/set/mod007-05_standard/all/links.rb +27 -26
- data/tmpsets/set/mod007-05_standard/all/rich_html/content.rb +115 -103
- data/tmpsets/set/mod007-05_standard/all/rich_html/editing.rb +112 -78
- data/tmpsets/set/mod007-05_standard/all/rich_html/form.rb +123 -81
- data/tmpsets/set/mod007-05_standard/all/rich_html/modal.rb +15 -58
- data/tmpsets/set/mod007-05_standard/all/rich_html/toolbar.rb +2 -2
- data/tmpsets/set/mod007-05_standard/right/account.rb +71 -75
- data/tmpsets/set/mod007-05_standard/right/email.rb +16 -13
- data/tmpsets/set/mod007-05_standard/right/password.rb +20 -12
- data/tmpsets/set/mod007-05_standard/right/status.rb +2 -2
- data/tmpsets/set/mod007-05_standard/right/token.rb +49 -2
- data/tmpsets/set/mod007-05_standard/rstar/rules.rb +20 -325
- data/tmpsets/set/mod007-05_standard/self/all.rb +16 -10
- data/tmpsets/set/mod007-05_standard/self/head.rb +76 -62
- data/tmpsets/set/mod007-05_standard/self/search.rb +45 -22
- data/tmpsets/set/mod007-05_standard/self/signin.rb +14 -12
- data/tmpsets/set/mod007-05_standard/type/cardtype.rb +13 -11
- data/tmpsets/set/mod007-05_standard/type/file.rb +1 -1
- data/tmpsets/set/mod007-05_standard/type/search_type.rb +3 -2
- data/tmpsets/set/mod007-05_standard/type/set.rb +20 -16
- data/tmpsets/set/mod007-05_standard/type/signup.rb +19 -25
- data/tmpsets/set/mod007-05_standard/type/user.rb +1 -1
- data/tmpsets/set/mod008-06_bootstrap/all/bootstrap/helper.rb +1 -1
- data/tmpsets/set_pattern/106-type_plus_right.rb +6 -3
- metadata +11 -2
@@ -1,111 +1,120 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
2
|
|
3
3
|
describe Card::Set::All::Templating do
|
4
|
-
|
5
|
-
|
6
|
-
it "for User+*type+*structure should return all Users" do
|
4
|
+
describe '#structurees' do
|
5
|
+
it 'for User+*type+*structure should return all Users' do
|
7
6
|
Card::Auth.as_bot do
|
8
|
-
c=Card.create
|
7
|
+
c = Card.create name: 'User+*type+*structure'
|
9
8
|
users
|
10
9
|
|
11
|
-
expect(c.structuree_names.sort).to eq(
|
10
|
+
expect(c.structuree_names.sort).to eq(
|
11
|
+
['Big Brother', 'Joe Admin', 'Joe Camel', 'Joe User', 'John',
|
12
|
+
'Narcissist', 'No Count', 'Optic fan', 'Sample User', 'Sara',
|
13
|
+
'Sunglasses fan', 'u1', 'u2', 'u3'
|
14
|
+
])
|
12
15
|
end
|
13
16
|
end
|
14
17
|
end
|
15
18
|
|
16
|
-
|
17
|
-
#TESTME
|
18
|
-
end
|
19
|
-
|
20
|
-
|
21
|
-
describe "with right structure" do
|
19
|
+
describe 'with right structure' do
|
22
20
|
before do
|
23
21
|
Card::Auth.as_bot do
|
24
|
-
@bt = Card.create! name:
|
22
|
+
@bt = Card.create! name: 'birthday+*right+*structure',
|
23
|
+
type: 'Date',
|
24
|
+
content: 'Today!'
|
25
25
|
end
|
26
|
-
@jb = Card.create! name:
|
26
|
+
@jb = Card.create! name: 'Jim+birthday'
|
27
27
|
end
|
28
28
|
|
29
|
-
it
|
29
|
+
it 'should have default content' do
|
30
30
|
expect(@jb.format._render_raw).to eq('Today!')
|
31
31
|
end
|
32
32
|
|
33
|
-
it
|
33
|
+
it 'should change type and content with template' do
|
34
34
|
Card::Auth.as_bot do
|
35
|
-
@bt.content =
|
35
|
+
@bt.content = 'Tomorrow'
|
36
36
|
@bt.type = 'Phrase'
|
37
37
|
@bt.save!
|
38
38
|
end
|
39
|
-
jb = @jb.refresh
|
40
|
-
expect(jb.format.render
|
39
|
+
jb = @jb.refresh true
|
40
|
+
expect(jb.format.render :raw).to eq('Tomorrow')
|
41
41
|
expect(jb.type_id).to eq(Card::PhraseID)
|
42
42
|
end
|
43
43
|
|
44
|
-
it
|
44
|
+
it 'should have type and content overridden by (new) type_plus_right set' do
|
45
45
|
Card::Auth.as_bot do
|
46
|
-
Card.create! name: 'Basic+birthday+*type plus right+*structure',
|
46
|
+
Card.create! name: 'Basic+birthday+*type plus right+*structure',
|
47
|
+
type: 'PlainText',
|
48
|
+
content: 'Yesterday'
|
47
49
|
end
|
48
|
-
jb = @jb.refresh
|
50
|
+
jb = @jb.refresh true
|
49
51
|
expect(jb.raw_content).to eq('Yesterday')
|
50
52
|
expect(jb.type_id).to eq(Card::PlainTextID)
|
51
53
|
end
|
52
54
|
end
|
53
55
|
|
54
|
-
|
55
|
-
describe "with right default" do
|
56
|
+
describe 'with right default' do
|
56
57
|
before do
|
57
58
|
Card::Auth.as_bot do
|
58
|
-
@bt = Card.create! name:
|
59
|
+
@bt = Card.create! name: 'birthday+*right+*default',
|
60
|
+
type: 'Date',
|
61
|
+
content: 'Today!'
|
59
62
|
end
|
60
63
|
@bb = Card.new name: 'Bob+birthday'
|
61
|
-
@jb = Card.create! name:
|
64
|
+
@jb = Card.create! name: 'Jim+birthday'
|
62
65
|
end
|
63
66
|
|
64
|
-
it
|
67
|
+
it 'should have default cardtype' do
|
65
68
|
expect(@jb.type_code).to eq(:date)
|
66
69
|
end
|
67
70
|
|
68
|
-
it
|
71
|
+
it 'should have default content' do
|
69
72
|
expect(Card['Jim+birthday'].content).to eq('Today!')
|
70
73
|
end
|
71
74
|
|
72
|
-
it
|
73
|
-
pb = Card.new name:
|
75
|
+
it 'should apply to new cards' do
|
76
|
+
pb = Card.new name: 'Pete+birthday'
|
74
77
|
expect(pb.raw_content).to eq('Today!')
|
75
78
|
expect(pb.content).to eq('Today!')
|
76
79
|
end
|
77
80
|
end
|
78
81
|
|
79
|
-
describe
|
82
|
+
describe 'with type structure' do
|
80
83
|
before do
|
81
84
|
Card::Auth.as_bot do
|
82
|
-
@dt = Card.create! name:
|
85
|
+
@dt = Card.create! name: 'Date+*type+*structure',
|
86
|
+
type: 'Basic',
|
87
|
+
content: 'Tomorrow'
|
83
88
|
end
|
84
89
|
end
|
85
90
|
|
86
|
-
it
|
87
|
-
|
91
|
+
it 'should return templated content even if content is passed in' do
|
92
|
+
new_date_card = Card.new type: 'Date', content: ''
|
93
|
+
expect(new_date_card.format._render(:raw)).to eq('Tomorrow')
|
88
94
|
end
|
89
95
|
|
90
96
|
describe 'and right structure' do
|
91
97
|
before do
|
92
98
|
Card::Auth.as_bot do
|
93
|
-
Card.create name:
|
94
|
-
@bt = Card.create! name:
|
99
|
+
Card.create name: 'Jim+birthday', content: 'Yesterday'
|
100
|
+
@bt = Card.create! name: 'birthday+*right+*structure',
|
101
|
+
type: 'Date',
|
102
|
+
content: 'Today'
|
95
103
|
end
|
96
104
|
end
|
97
105
|
|
98
|
-
it
|
106
|
+
it '*right setting should override *type setting' do
|
99
107
|
expect(Card['Jim+birthday'].raw_content).to eq('Today')
|
100
108
|
end
|
101
109
|
|
102
|
-
it
|
103
|
-
|
110
|
+
it 'should defer to normal content ' \
|
111
|
+
"when *structure rule's content is (exactly) '_self'" do
|
112
|
+
Card::Auth.as_bot do
|
113
|
+
Card.create! name: 'Jim+birthday+*self+*structure', content: '_self'
|
114
|
+
end
|
104
115
|
expect(Card['Jim+birthday'].raw_content).to eq('Yesterday')
|
105
116
|
end
|
106
117
|
end
|
107
118
|
end
|
108
|
-
|
109
119
|
end
|
110
120
|
|
111
|
-
|
@@ -46,7 +46,7 @@ def delete_old_actions
|
|
46
46
|
Card::TRACKED_FIELDS.each do |field|
|
47
47
|
# assign previous changes on each tracked field to the last action
|
48
48
|
if (la = last_action) && !la.change_for(field).present? &&
|
49
|
-
(last_change = last_change_on
|
49
|
+
(last_change = last_change_on field)
|
50
50
|
# last_change comes as readonly record
|
51
51
|
last_change = Card::Change.find(last_change.id)
|
52
52
|
last_change.update_attributes!(card_action_id: last_action_id)
|
@@ -6,8 +6,7 @@ format do
|
|
6
6
|
end
|
7
7
|
|
8
8
|
# NAME VIEWS
|
9
|
-
|
10
|
-
view :name, simple_args do |args|
|
9
|
+
view :name, closed: true, perms: :none do |args|
|
11
10
|
return card.name unless args[:variant]
|
12
11
|
args[:variant].split(/[\s,]+/).inject(card.name) do |name, variant|
|
13
12
|
case variant.to_sym
|
@@ -30,11 +29,18 @@ format do
|
|
30
29
|
end
|
31
30
|
end
|
32
31
|
end
|
33
|
-
|
34
|
-
view(:
|
35
|
-
view(:linkname,
|
36
|
-
view(:url,
|
37
|
-
|
32
|
+
|
33
|
+
view(:key, closed: true, perms: :none) { card.key }
|
34
|
+
view(:linkname, closed: true, perms: :none) { card.cardname.url_key }
|
35
|
+
view(:url, closed: true, perms: :none) { card_url _render_linkname }
|
36
|
+
|
37
|
+
view :title, closed: true, perms: :none do |args|
|
38
|
+
args[:title] || card.name
|
39
|
+
end
|
40
|
+
|
41
|
+
view :url_link, closed: true, perms: :none do
|
42
|
+
web_link card_url(_render_linkname)
|
43
|
+
end
|
38
44
|
|
39
45
|
view :link, closed: true, perms: :none do |args|
|
40
46
|
card_link(
|
@@ -1,7 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
1
|
format :rss do
|
4
|
-
|
5
2
|
attr_accessor :xml
|
6
3
|
|
7
4
|
def initialize card, args
|
@@ -15,10 +12,10 @@ format :rss do
|
|
15
12
|
end
|
16
13
|
|
17
14
|
# FIXME: integrate this with common XML features when it is added
|
18
|
-
view :feed do
|
15
|
+
view :feed do
|
19
16
|
begin
|
20
|
-
@xml.instruct! :xml, version:
|
21
|
-
@xml.rss version:
|
17
|
+
@xml.instruct! :xml, version: '1.0'
|
18
|
+
@xml.rss version: '2.0' do
|
22
19
|
@xml.channel do
|
23
20
|
@xml.title render_feed_title
|
24
21
|
@xml.description render_feed_description
|
@@ -35,41 +32,39 @@ format :rss do
|
|
35
32
|
[card]
|
36
33
|
end
|
37
34
|
|
38
|
-
view :feed_body do |
|
35
|
+
view :feed_body do |_args|
|
39
36
|
render_feed_item_list
|
40
37
|
end
|
41
38
|
|
42
39
|
view :feed_item_list do |args|
|
43
40
|
raw_feed_items(args).each do |item|
|
44
41
|
@xml.item do
|
45
|
-
|
42
|
+
# FIXME: yuck.
|
43
|
+
subformat(item).render_feed_item view_changes: (card.id == RecentID)
|
46
44
|
end
|
47
45
|
end
|
48
46
|
end
|
49
47
|
|
50
|
-
|
51
|
-
|
52
|
-
Card.setting(:title) + " : " + card.name.gsub(/^\*/,'')
|
48
|
+
view :feed_title do
|
49
|
+
Card.global_setting(:title) + ' : ' + card.name.gsub(/^\*/,'')
|
53
50
|
end
|
54
51
|
|
55
52
|
view :feed_item do |args|
|
56
53
|
@xml.title card.name
|
57
54
|
add_name_context
|
58
55
|
@xml.description render((args[:view_changes] ? :change : :open_content))
|
59
|
-
@xml.pubDate card.revised_at.to_s(:rfc822) #updated_at fails on virtual
|
56
|
+
@xml.pubDate card.revised_at.to_s(:rfc822) # updated_at fails on virtual
|
57
|
+
# cards, because not all to_s's take args (just actual dates)
|
60
58
|
@xml.link render_url
|
61
59
|
@xml.guid render_url
|
62
60
|
end
|
63
61
|
|
62
|
+
view :feed_description do '' end
|
63
|
+
view :comment_box do '' end
|
64
|
+
view :menu do '' end
|
64
65
|
|
65
|
-
view :
|
66
|
-
view :
|
67
|
-
view :
|
68
|
-
|
69
|
-
|
70
|
-
view :open, { view: :titled, mod: All::Base::Format }
|
71
|
-
view :content, { view: :core, mod: All::Base::Format }
|
72
|
-
view :open_content, { view: :core, mod: All::Base::Format }
|
73
|
-
view :closed, { view: :link, mod: All::Base::Format }
|
74
|
-
|
66
|
+
view :open, view: :titled, mod: All::Base::Format
|
67
|
+
view :content, view: :core, mod: All::Base::Format
|
68
|
+
view :open_content, view: :core, mod: All::Base::Format
|
69
|
+
view :closed, view: :link, mod: All::Base::Format
|
75
70
|
end
|
@@ -1,10 +1,13 @@
|
|
1
1
|
format :html do
|
2
2
|
|
3
3
|
view :editor do |args|
|
4
|
-
text_area :content,
|
4
|
+
text_area :content,
|
5
|
+
rows: 5,
|
6
|
+
class: 'card-content',
|
7
|
+
'data-card-type-code' => card.type_code
|
5
8
|
end
|
6
9
|
|
7
10
|
view :core do |args|
|
8
|
-
process_content_object(
|
11
|
+
process_content_object(CGI.escapeHTML _render_raw)
|
9
12
|
end
|
10
13
|
end
|
@@ -2,20 +2,21 @@
|
|
2
2
|
|
3
3
|
describe Card::Set::All::Rss do
|
4
4
|
it 'should render recent.rss' do
|
5
|
-
rendered = Card[:recent].format(:rss).show(
|
5
|
+
rendered = Card[:recent].format(:rss).show(nil, {})
|
6
6
|
expect(rendered).to match(/xml/)
|
7
7
|
end
|
8
8
|
|
9
9
|
it 'should handle faulty search queries' do
|
10
|
-
bad_search = Card.create! name: 'Bad Search',
|
10
|
+
bad_search = Card.create! name: 'Bad Search',
|
11
|
+
type: 'Search', content: 'not no search'
|
11
12
|
rendered = bad_search.format(:rss).render_feed_body
|
12
|
-
expect(rendered).to have_tag(
|
13
|
+
expect(rendered).to have_tag('item', text: /JSON::ParserError/)
|
13
14
|
end
|
14
15
|
|
15
16
|
it 'should handle bad queries' do
|
16
|
-
bad_search = Card.create! :
|
17
|
+
bad_search = Card.create! name: 'Bad Search',
|
18
|
+
type: 'Search', content: '{"found_by":"home"}'
|
17
19
|
rendered = bad_search.format(:rss).render_feed_body
|
18
|
-
expect(rendered).to have_tag(
|
20
|
+
expect(rendered).to have_tag('item', text: /Card::BadQuery/)
|
19
21
|
end
|
20
|
-
|
21
22
|
end
|
@@ -81,7 +81,7 @@ jQuery.fn.extend {
|
|
81
81
|
if status == 409 #edit conflict
|
82
82
|
@slot().find('.current_revision_id').val @slot().find('.new-current-revision-id').text()
|
83
83
|
else if status == 449
|
84
|
-
@slot().find('
|
84
|
+
@slot().find('g-recaptcha').reloadCaptcha()
|
85
85
|
|
86
86
|
notify: (message) ->
|
87
87
|
slot = @slot()
|
@@ -106,7 +106,10 @@ jQuery.fn.extend {
|
|
106
106
|
|
107
107
|
isMain: -> @slot().parent('#main')[0]
|
108
108
|
|
109
|
-
|
109
|
+
reloadCaptcha: ->
|
110
|
+
this[0].empty()
|
111
|
+
grecaptcha.render this[0],
|
112
|
+
sitekey: wagn.recaptchaKey
|
110
113
|
|
111
114
|
autosave: ->
|
112
115
|
slot = @slot()
|
@@ -189,9 +192,12 @@ $(window).ready ->
|
|
189
192
|
opt.url = wagn.prepUrl opt.url, $(this).slot()
|
190
193
|
|
191
194
|
if $(this).is('form')
|
192
|
-
if wagn.recaptchaKey and $(this).attr('recaptcha')=='on' and !($(this).find('.recaptcha
|
193
|
-
|
194
|
-
|
195
|
+
if wagn.recaptchaKey and $(this).attr('recaptcha')=='on' and !($(this).find('.g-recaptcha')[0])
|
196
|
+
if $('.g-recaptcha')[0] # if there is already a recaptcha on the page then we don't have to load the recaptcha script
|
197
|
+
addCaptcha(this)
|
198
|
+
else
|
199
|
+
initCaptcha(this)
|
200
|
+
return false
|
195
201
|
|
196
202
|
if data = $(this).data 'file-data'
|
197
203
|
# NOTE - this entire solution is temporary.
|
@@ -337,11 +343,18 @@ $(window).ready ->
|
|
337
343
|
# }
|
338
344
|
|
339
345
|
|
340
|
-
|
341
|
-
|
342
|
-
|
346
|
+
initCaptcha = (form)->
|
347
|
+
recapDiv = $("<div class='g-recaptcha' data-sitekey='#{wagn.recaptchaKey}'></div>")
|
348
|
+
$(form).children().last().after recapDiv
|
349
|
+
recapUri = "https://www.google.com/recaptcha/api.js"
|
350
|
+
$.getScript recapUri # renders the first element with "g-recaptcha" class when loaded
|
351
|
+
|
352
|
+
# call this if the recaptcha script is already initialized (via initCaptcha)
|
353
|
+
addCaptcha = (form)->
|
354
|
+
recapDiv = $('<div class="g-recaptcha"></div>')
|
343
355
|
$(form).children().last().after recapDiv
|
344
|
-
|
356
|
+
grecaptcha.render recapDiv,
|
357
|
+
sitekey: wagn.recaptchaKey
|
345
358
|
|
346
359
|
snakeCase = (str)->
|
347
360
|
str.replace /([a-z])([A-Z])/g, (match)-> match[0] + '_' + match[1].toLowerCase()
|
@@ -9,7 +9,7 @@ end
|
|
9
9
|
format do
|
10
10
|
view :not_found do |args|
|
11
11
|
if update_machine_output_live?
|
12
|
-
Card::Cache.
|
12
|
+
Card::Cache.reset_all # FIXME: wow, this is overkill, no?
|
13
13
|
root.error_status = 302
|
14
14
|
card.left.update_machine_output
|
15
15
|
card_path card.left.machine_output_url
|
@@ -1,29 +1,34 @@
|
|
1
1
|
# -*- encoding : utf-8 -*-
|
2
2
|
|
3
|
-
|
4
3
|
class Card
|
5
|
-
|
6
|
-
#
|
4
|
+
# Used to extend setting modules like Card::Set::Self::Create in the
|
5
|
+
# settings mod
|
7
6
|
module Setting
|
8
7
|
# Let M = Card::Setting (module)
|
9
8
|
# E = Card::Set::Self::Create (module extended with M)
|
10
|
-
# O = Card[
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
9
|
+
# O = Card['*create'] (object)
|
10
|
+
# accessible in E
|
11
|
+
attr_accessor :codename
|
12
|
+
# accessible in E and M
|
13
|
+
mattr_accessor :groups, :group_names, :user_specific
|
14
|
+
def self.extended host_class
|
15
|
+
# accessible in E and O
|
16
|
+
host_class.mattr_accessor :restricted_to_type, :rule_type_editable
|
15
17
|
end
|
16
18
|
|
17
19
|
@@group_names = {
|
18
|
-
templating:
|
19
|
-
permission:
|
20
|
-
webpage:
|
21
|
-
pointer:
|
22
|
-
editing_cue:
|
23
|
-
event:
|
24
|
-
other:
|
20
|
+
templating: 'Templating',
|
21
|
+
permission: 'Permissions',
|
22
|
+
webpage: 'Webpage',
|
23
|
+
pointer: 'Pointer',
|
24
|
+
editing_cue: 'Editing cues',
|
25
|
+
event: 'Events',
|
26
|
+
other: 'Other',
|
27
|
+
config: 'Config'
|
25
28
|
}
|
26
|
-
@@groups = @@group_names.keys.each_with_object({})
|
29
|
+
@@groups = @@group_names.keys.each_with_object({}) do |key, groups|
|
30
|
+
groups[key] = []
|
31
|
+
end
|
27
32
|
@@user_specific = ::Set.new
|
28
33
|
|
29
34
|
def self.user_specific? codename
|
@@ -35,34 +40,43 @@ class Card
|
|
35
40
|
end
|
36
41
|
|
37
42
|
# usage:
|
38
|
-
# setting_opts group:
|
39
|
-
# position:
|
43
|
+
# setting_opts group: :permission | :event | ...
|
44
|
+
# position: <Fixnum> (starting at 1, default: add to end)
|
40
45
|
# rule_type_editable: true | false (default: false)
|
41
46
|
# restricted_to_type: <cardtype> | [ <cardtype>, ...]
|
42
47
|
def setting_opts opts
|
43
48
|
group = opts[:group] || :other
|
44
49
|
@@groups[group] ||= []
|
45
|
-
|
46
|
-
|
47
|
-
|
50
|
+
set_position group, opts[:position]
|
51
|
+
|
52
|
+
@codename = opts[:codename] ||
|
53
|
+
name.match(/::(\w+)$/)[1].underscore.to_sym
|
54
|
+
self.rule_type_editable = opts[:rule_type_editable]
|
55
|
+
self.restricted_to_type =
|
56
|
+
if opts[:restricted_to_type]
|
57
|
+
type_ids = [opts[:restricted_to_type]].flatten.map do |cardtype|
|
58
|
+
to_type_id(cardtype)
|
59
|
+
end
|
60
|
+
::Set.new(type_ids)
|
61
|
+
end
|
62
|
+
return unless opts[:user_specific]
|
63
|
+
@@user_specific << @codename
|
64
|
+
end
|
65
|
+
|
66
|
+
def set_position group, pos
|
67
|
+
if pos
|
68
|
+
if @@groups[group][pos - 1]
|
69
|
+
@@groups[group].insert(pos - 1, self)
|
48
70
|
else
|
49
|
-
@@groups[group][
|
71
|
+
@@groups[group][pos - 1] = self
|
50
72
|
end
|
51
73
|
else
|
52
74
|
@@groups[group] << self
|
53
75
|
end
|
54
|
-
|
55
|
-
@codename = opts[:codename] || self.name.match(/::(\w+)$/)[1].underscore.to_sym
|
56
|
-
self.rule_type_editable = opts[:rule_type_editable]
|
57
|
-
self.restricted_to_type = opts[:restricted_to_type] ? ::Set.new([opts[:restricted_to_type]].flatten.map{ |cardtype| to_type_id(cardtype) }) : false
|
58
|
-
if opts[:user_specific]
|
59
|
-
@@user_specific << @codename
|
60
|
-
end
|
61
76
|
end
|
62
77
|
|
63
78
|
def applies_to_cardtype type_id
|
64
|
-
!
|
79
|
+
!restricted_to_type || restricted_to_type.include?(type_id)
|
65
80
|
end
|
66
81
|
end
|
67
82
|
end
|
68
|
-
|