card 1.20.1 → 1.20.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/card.gemspec +2 -2
  4. data/db/migrate_core_cards/20160811115836_rename_stats_to_admin.rb +2 -2
  5. data/db/migrate_core_cards/20170209132834_email_test_context.rb +47 -0
  6. data/db/migrate_core_cards/data/mailer/follower_notification_email.html +1 -1
  7. data/db/migrate_core_cards/data/mailer/follower_notification_email.txt +1 -1
  8. data/db/migrate_core_cards/data/mailer/mail_config.json +1 -1
  9. data/db/seed/new/card_actions.yml +699 -771
  10. data/db/seed/new/card_acts.yml +64 -616
  11. data/db/seed/new/card_changes.yml +9222 -25055
  12. data/db/seed/new/card_references.yml +767 -606
  13. data/db/seed/new/cards.yml +2125 -1829
  14. data/db/seed/test/fixtures/card_actions.yml +1713 -1825
  15. data/db/seed/test/fixtures/card_acts.yml +341 -893
  16. data/db/seed/test/fixtures/card_changes.yml +20868 -36801
  17. data/db/seed/test/fixtures/card_references.yml +1516 -1250
  18. data/db/seed/test/fixtures/cards.yml +3194 -2898
  19. data/db/version_core_cards.txt +1 -1
  20. data/lib/card/env/location.rb +1 -1
  21. data/lib/card/format/content.rb +1 -1
  22. data/lib/card/format/nest/subformat.rb +2 -1
  23. data/lib/card/format/render.rb +19 -1
  24. data/lib/card/mailer.rb +5 -2
  25. data/lib/card/model/save_helper.rb +15 -4
  26. data/lib/card/name.rb +1 -45
  27. data/lib/card/name/fields_and_traits.rb +10 -9
  28. data/lib/card/name/{variants.rb → name_variants.rb} +1 -1
  29. data/lib/card/query.rb +28 -2
  30. data/lib/card/query/helpers.rb +1 -0
  31. data/lib/card/query/interpretation.rb +1 -0
  32. data/lib/card/query/relational_attributes.rb +27 -5
  33. data/lib/card/query/sql_statement.rb +1 -1
  34. data/lib/card/tasks/card/create.rake +177 -0
  35. data/mod/carrierwave/set/type/file.rb +1 -1
  36. data/mod/carrierwave/set/type/image.rb +9 -2
  37. data/mod/core/chunk/reference.rb +1 -1
  38. data/mod/core/set/all/assign_attributes.rb +14 -14
  39. data/mod/core/set/all/collection.rb +1 -1
  40. data/mod/core/set/all/fetch.rb +4 -0
  41. data/mod/core/set/all/haml.rb +82 -3
  42. data/mod/core/set/all/name.rb +7 -6
  43. data/mod/core/set/all/references.rb +1 -1
  44. data/mod/core/set/all/subcards.rb +4 -0
  45. data/mod/core/set_pattern/07_type_plus_right.rb +1 -1
  46. data/mod/core/spec/set/all/{tracked_attributes_spec.rb → assign_attributes_spec.rb} +1 -1
  47. data/mod/email/set/abstract/test_context.rb +26 -0
  48. data/mod/email/set/all/notify.rb +10 -5
  49. data/mod/email/set/right/html_message.rb +2 -0
  50. data/mod/email/set/right/subject.rb +1 -0
  51. data/mod/email/set/right/text_message.rb +1 -0
  52. data/mod/history/set/all/content_history.rb +2 -1
  53. data/mod/machines/set/type/coffee_script.rb +1 -1
  54. data/mod/pointer/set/abstract/01_pointer/edit.rb +10 -7
  55. data/mod/pointer/spec/set/type/pointer_spec.rb +2 -2
  56. data/mod/standard/set/abstract/wql_search.rb +1 -1
  57. data/mod/standard/set/all/rich_html/form.rb +128 -169
  58. data/mod/standard/set/all/rich_html/form_elements.rb +52 -0
  59. data/mod/standard/set/all/rich_html/formgroup.rb +34 -0
  60. data/mod/standard/set/type/session.rb +2 -8
  61. data/mod/standard/set/type/toggle.rb +23 -3
  62. data/mod/standard/spec/set/type/email_template/email_config_spec.rb +24 -13
  63. data/mod/standard/spec/set/type/toggle_spec.rb +13 -2
  64. data/spec/lib/card/name_spec.rb +1 -224
  65. data/spec/lib/card/query_spec.rb +56 -1
  66. data/spec/lib/card/stage_director_spec.rb +19 -0
  67. data/spec/support/helper/render_helper.rb +2 -0
  68. data/tmpsets/set/mod001-core/all/actify.rb +6 -5
  69. data/tmpsets/set/mod001-core/all/fetch.rb +12 -14
  70. data/tmpsets/set/mod001-core/all/name.rb +1 -1
  71. data/tmpsets/set/mod001-core/all/permissions.rb +22 -12
  72. data/tmpsets/set/mod001-core/all/tracked_attributes.rb +0 -76
  73. data/tmpsets/set/mod001-core/all/utils.rb +3 -40
  74. data/tmpsets/set/mod002-history/all/history.rb +2 -1
  75. data/tmpsets/set/mod008-solid_cache/abstract/solid_cache.rb +1 -1
  76. metadata +15 -17
  77. data/tmpsets/set/mod013-carrierwave/abstract/attachment.rb +0 -282
  78. data/tmpsets/set/mod013-carrierwave/type/file.rb +0 -155
  79. data/tmpsets/set/mod013-carrierwave/type/image.rb +0 -96
  80. data/tmpsets/set/mod014-admin/self/admin.rb +0 -113
  81. data/tmpsets/set/mod014-admin/self/admin_info.rb +0 -110
  82. data/tmpsets/set/mod014-admin/self/version.rb +0 -15
  83. data/tmpsets/set/mod015-developer/all/event_viz.rb +0 -59
  84. data/tmpsets/set/mod015-developer/all/view_viz.rb +0 -30
  85. data/tmpsets/set/mod015-developer/right/debug.rb +0 -96
@@ -1,155 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
- class Card; module Set; class Type; module File; extend Card::Set
3
- # ~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/carrierwave/set/type/file.rb ~~
4
- attachment :file, uploader: CarrierWave::FileCardUploader
5
-
6
- module SelectedAction
7
- def select_action_by_params params
8
- # skip action table lookups for current revision
9
- rev_id = params[:rev_id]
10
- super unless rev_id && rev_id == last_content_action_id
11
- end
12
-
13
- def last_content_action_id
14
- # find action id from content (saves lookups)
15
- db_content.to_s.split(%r{[/\.]})[1]
16
- end
17
- end
18
- include SelectedAction
19
-
20
- format do
21
- view :source do |_args|
22
- card.attachment.url
23
- end
24
-
25
- view :core do |args|
26
- handle_source args do |source|
27
- card_url source
28
- end
29
- end
30
-
31
- def handle_source args
32
- source = _render_source args
33
- source ? yield(source) : ""
34
- rescue
35
- "File Error"
36
- end
37
- end
38
-
39
- format :file do
40
- # returns send_file args. not in love with this...
41
- view :core do |_args|
42
- # this means we only support known formats. dislike.
43
- if (_format = card.attachment_format(params[:format]))
44
- if params[:explicit_file] && (r = controller.response)
45
- r.headers["Expires"] = 1.year.from_now.httpdate
46
- # currently using default "private", because proxy servers could block
47
- # needed permission checks
48
- # r.headers["Cache-Control"] = "public"
49
- end
50
-
51
- # formerly supported redirecting to correct file format
52
- # elsif ![format, 'file'].member? params[:format]
53
- # path = request.fullpath.sub( /\.#{params[:format]}\b/, '.' + format )
54
- # return redirect_to(path) #card.attachment.url(style) )
55
-
56
- file = selected_file_version
57
- [file.path,
58
- {
59
- type: file.content_type,
60
- filename: "#{card.cardname.safe_key}#{file.extension}",
61
- x_sendfile: true,
62
- disposition: (params[:format] == "file" ? "attachment" : "inline")
63
- }]
64
- else
65
- _render_not_found
66
- end
67
- end
68
-
69
- def selected_file_version
70
- card.attachment
71
- end
72
- end
73
-
74
- format :html do
75
- view :core do |args|
76
- handle_source args do |source|
77
- "<a href=\"#{source}\">Download #{showname args[:title]}</a>"
78
- end
79
- end
80
-
81
- view :editor do |args|
82
- file_chooser args
83
- end
84
-
85
- def preview _args
86
- ""
87
- end
88
-
89
- view :preview_editor, tags: :unknown_ok do |args|
90
- cached_upload_card_name = Card::Env.params[:attachment_upload]
91
- cached_upload_card_name.gsub!(/\[\w+\]$/, "[action_id_of_cached_upload]")
92
- <<-HTML
93
- <div class="chosen-file">
94
- <input type="hidden" name="#{cached_upload_card_name}"
95
- value="#{card.selected_action_id}">
96
- <table role="presentation" class="table table-striped">
97
- <tbody class="files">
98
- <tr class="template-download fade in">
99
- <td>
100
- <span class="preview">
101
- #{preview(args)}
102
- </span>
103
- </td>
104
- <td>
105
- <p class="name">
106
- #{card.original_filename}
107
- </p>
108
- </td>
109
- <td>
110
- <span class="size">
111
- #{number_to_human_size(card.attachment.size)}
112
- </span>
113
- </td>
114
- <td class="pull-right">
115
- <button class="btn btn-danger delete cancel-upload"
116
- data-type="DELETE">
117
- <i class="glyphicon glyphicon-trash"></i>
118
- <span>Delete</span>
119
- </button>
120
- </td>
121
- </tr>
122
- </tbody>
123
- </table>
124
- </div>
125
- HTML
126
- end
127
-
128
- def file_chooser args
129
- <<-HTML
130
- <div class="choose-file">
131
- #{preview(args)}
132
- <span class="btn btn-success fileinput-button">
133
- <i class="glyphicon glyphicon-cloud-upload"></i>
134
- <span>
135
- #{card.new_card? ? 'Add' : 'Replace'} #{card.attachment_name}...
136
- </span>
137
- <input class="file-upload slotter form-control" type="file"
138
- name="card[#{card.type_code}]" id="card_#{card.type_code}">
139
- #{hidden_field_tag 'attachment_type_id', card.type_id}
140
- #{hidden_field card.attachment_name, class: 'attachment_card_name',
141
- value: ''}
142
- #{hidden_field_tag 'file_card_name', card.cardname.url_key}
143
- </span>
144
- </div>
145
- <div id="progress" class="progress" style="display: none;">
146
- <div class="progress-bar progress-bar-success" style="width: 0%;"></div>
147
- </div>
148
- <div class="chosen-file"></div>
149
- HTML
150
- end
151
- end
152
-
153
-
154
- # ~~ below autogenerated; above pulled from /Users/ethan/dev/wagn/gem/card/mod/carrierwave/set/type/file.rb ~~
155
- end;end;end;end;
@@ -1,96 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
- class Card; module Set; class Type; module Image; extend Card::Set
3
- # ~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/carrierwave/set/type/image.rb ~~
4
- attachment :image, uploader: CarrierWave::ImageCardUploader
5
-
6
- include File::SelectedAction
7
-
8
- format do
9
- include File::Format
10
-
11
- view :closed_content do |_args|
12
- _render_core size: :icon
13
- end
14
-
15
- view :source do |args|
16
- style =
17
- case
18
- when @mode == :closed then :icon
19
- when args[:size] then args[:size].to_sym
20
- when main? then :large
21
- else :medium
22
- end
23
- style = :original if style.to_sym == :full
24
- if style == :original
25
- card.image.url
26
- else
27
- card.image.versions[style].url
28
- end
29
- end
30
- end
31
-
32
- format :html do
33
- include File::HtmlFormat
34
-
35
- view :core do |args|
36
- handle_source args do |source|
37
- if source == "missing"
38
- "<!-- image missing #{@card.name} -->"
39
- else
40
- image_tag(source)
41
- end
42
- end
43
- end
44
-
45
- def preview args
46
- if !card.new_card? || card.preliminary_upload?
47
- content_tag :div, _render_core(args.merge(size: :medium)).html_safe,
48
- class: "attachment-preview",
49
- id: "#{card.attachment.filename}-preview"
50
- end
51
- end
52
-
53
- view :content_changes do |args|
54
- out = ""
55
- size = args[:diff_type] == :summary ? :icon : :medium
56
- if !args[:hide_diff] && args[:action] &&
57
- (last_change = card.last_change_on(:db_content, before: args[:action]))
58
- card.selected_action_id = last_change.card_action_id
59
- out << Card::Content::Diff.render_deleted_chunk(_render_core(size: size))
60
- end
61
- card.selected_action_id = args[:action].id
62
- out << Card::Content::Diff.render_added_chunk(_render_core(size: size))
63
- out
64
- end
65
- end
66
-
67
- format :css do
68
- view :core do |_args|
69
- render_source
70
- end
71
-
72
- view :content do |_args| # why is this necessary?
73
- render_core
74
- end
75
- end
76
-
77
- format :file do
78
- include File::FileFormat
79
-
80
- view :style do |args| # should this be in model?
81
- ["", "full"].member?(args[:style].to_s) ? :original : args[:style]
82
- end
83
-
84
- def selected_file_version
85
- style = _render_style(style: params[:size]).to_sym
86
- if style && style != :original
87
- card.attachment.versions[style]
88
- else
89
- card.attachment
90
- end
91
- end
92
- end
93
-
94
-
95
- # ~~ below autogenerated; above pulled from /Users/ethan/dev/wagn/gem/card/mod/carrierwave/set/type/image.rb ~~
96
- end;end;end;end;
@@ -1,113 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
- class Card; module Set; class Self; module Admin; extend Card::Set
3
- # ~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/admin/set/self/admin.rb ~~
4
- event :admin_tasks, :initialize, on: :update do
5
- return unless (task = Env.params[:task])
6
- raise Card::Error::PermissionDenied.new(self) unless Auth.always_ok?
7
-
8
- case task.to_sym
9
- when :clear_cache then Card::Cache.reset_all
10
- when :repair_references then Card::Reference.repair_all
11
- when :empty_trash then Card.empty_trash
12
- when :clear_view_cache then Card::Cache::ViewCache.reset
13
- when :delete_old_revisions then Card::Action.delete_old
14
- when :repair_permissions then Card.repair_all_permissions
15
- when :clear_solid_cache then Card.clear_solid_cache
16
- when :clear_machine_cache then Card.reset_all_machines
17
- end
18
- abort :success
19
- end
20
-
21
- format :html do
22
- view :core do |_args|
23
- stats = card_stats
24
- stats += cache_stats
25
- stats += memory_stats
26
- table_content = stats.map { |args| stat_row(*args) }
27
- table table_content, header: %w(Stat Value Action)
28
- end
29
-
30
- def card_stats
31
- [
32
- ["cards", { count: Card.where(trash: false) }],
33
- ["trashed cards", { count: Card.where(trash: true),
34
- link_text: "delete all", task: "empty_trash" }],
35
- ["actions", { count: Card::Action,
36
- link_text: "delete old",
37
- task: "delete_old_revisions" }],
38
- ["references", { count: Card::Reference,
39
- link_text: "repair all", task: "repair_references" }]
40
- ]
41
- end
42
-
43
- def cache_stats
44
- stats = [
45
- ["solid cache", { count: solid_cache_count, unit: " cards",
46
- link_text: "clear cache",
47
- task: "clear_solid_cache" }],
48
- ["machine cache", { count: machine_cache_count, unit: " cards",
49
- link_text: "clear cache",
50
- task: "clear_machine_cache" }]
51
- ]
52
- return stats unless Card.config.view_cache
53
- stats <<
54
- ["view cache", { count: Card::Cache::ViewCache,
55
- link_text: "clear view cache",
56
- task: "clear_view_cache" }]
57
- stats
58
- end
59
-
60
- def memory_stats
61
- oldmem = session[:memory]
62
- session[:memory] = newmem = card.profile_memory
63
- stats = [
64
- ["memory now", { count: newmem, unit: "M",
65
- link_text: "clear cache", task: "clear_cache" }]
66
- ]
67
- return stats unless oldmem
68
- stats << ["memory prev", { count: oldmem, unit: "M" }]
69
- stats << ["memory diff", { count: newmem - oldmem, unit: "M" }]
70
- stats
71
- end
72
-
73
- def stat_row name, args={}
74
- res = [name]
75
- args[:count] = args[:count].count if args[:count].respond_to?(:count)
76
- res << "#{args[:count]}#{args[:unit]}"
77
- return res unless args[:task]
78
- path = card_path("update/:admin?task=#{args[:task]}")
79
- res << link_to(args[:link_text] || args[:task], path)
80
- res
81
- end
82
-
83
- def solid_cache_count
84
- Card.search right: { codename: "solid_cache" }, return: "count"
85
- end
86
-
87
- def machine_cache_count
88
- Card.search right: { codename: "machine_cache" }, return: "count"
89
- end
90
-
91
- def delete_sessions_link months
92
- link_to months,
93
- card_path("update/:admin?task=delete_old_sessions&months=#{months}")
94
- end
95
- end
96
-
97
- def current_memory_usage
98
- `ps -o rss= -p #{Process.pid}`.to_i
99
- end
100
-
101
- def profile_memory &block
102
- before = current_memory_usage
103
- if block_given?
104
- instance_eval(&block)
105
- else
106
- before = 0
107
- end
108
- (current_memory_usage - before) / 1024.to_i
109
- end
110
-
111
-
112
- # ~~ below autogenerated; above pulled from /Users/ethan/dev/wagn/gem/card/mod/admin/set/self/admin.rb ~~
113
- end;end;end;end;
@@ -1,110 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
- class Card; module Set; class Self; module AdminInfo; extend Card::Set
3
- # ~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/admin/set/self/admin_info.rb ~~
4
- def clean_html?
5
- false
6
- end
7
-
8
- format :html do
9
- view :core do
10
- warnings = []
11
- if Card.config.action_mailer.perform_deliveries == false
12
- warnings << email_warning
13
- end
14
- if Card.config.recaptcha_public_key ==
15
- Card::Auth::Permissions::RECAPTCHA_DEFAULTS[:recaptcha_public_key] &&
16
- card.rule(:captcha) == "1"
17
- warnings << recaptcha_warning
18
- end
19
- return "" if warnings.empty?
20
- alert :warning, dismissible: true do
21
- render_warning_list warnings
22
- end
23
- end
24
-
25
- def render_warning_list warnings
26
- # 'ADMINISTRATOR WARNING'
27
- admin_warn = I18n.t(:admin_warn,
28
- scope: "mod.standard.set.self.admin_info")
29
- "<h6>#{admin_warn}</h6>".html_safe + list_group(
30
- warnings,
31
- items: { class: "list-group-item-warning" }
32
- )
33
- end
34
-
35
- def email_warning
36
- # "Email delivery is turned off."
37
- # "Change settings in config/application.rb to send sign up notifications."
38
- I18n.t(:email_off,
39
- scope: "mod.standard.set.self.admin_info",
40
- path: "config/application.rb")
41
- end
42
-
43
- def recaptcha_warning
44
- warning =
45
- if Card::Env.localhost?
46
- # %(Your captcha is currently working with temporary settings.
47
- # This is fine for a local installation, but you will need new
48
- # recaptcha keys if you want to make this site public.)
49
- I18n.t(:captcha_temp, scope: "mod.standard.set.self.admin_info")
50
- else
51
- # %(You are configured to use [[*captcha]], but for that to work
52
- # you need new recaptcha keys.)
53
- process_content(I18n.t(:captcha_keys,
54
- scope: "mod.standard.set.self.admin_info"))
55
- end
56
- # 'Instructions'
57
- instructions = I18n.t(:instructions,
58
- scope: "mod.standard.set.self.admin_info")
59
- <<-HTML
60
- <p>
61
- #{warning}
62
- </p>
63
- <h4>#{instructions}</h4>
64
- #{howto_add_new_recaptcha_keys}
65
- #{howto_turn_captcha_off}
66
- HTML
67
- end
68
-
69
- def instructions title, steps
70
- steps = list_group steps
71
- "#{title}#{steps}"
72
- end
73
-
74
- def howto_add_new_recaptcha_keys
75
- instructions(
76
- # 'How to add new recaptcha keys:'
77
- I18n.t(:howto_add_keys, scope: "mod.standard.set.self.admin_info"),
78
- [
79
- # "1. Register your domain at #{web_link 'http://google.com/recaptcha'}"
80
- I18n.t(:howto_register,
81
- scope: "mod.standard.set.self.admin_info",
82
- recaptcha_link: web_link("http://google.com/recaptcha")),
83
- # "2. Add your keys to #{card_link :recaptcha_settings}"
84
- I18n.t(:howto_add,
85
- scope: "mod.standard.set.self.admin_info",
86
- recaptcha_settings: card_link(:recaptcha_settings))
87
- ]
88
- )
89
- end
90
-
91
- def howto_turn_captcha_off
92
- instructions(
93
- # 'How to turn captcha off:'
94
- I18n.t(:howto_turn_off, scope: "mod.standard.set.self.admin_info"),
95
- [
96
- # "1. Go to #{card_link :captcha}"
97
- I18n.t(:howto_go,
98
- scope: "mod.standard.set.self.admin_info",
99
- captcha_card: card_link(:captcha)),
100
- # '2. Update all *captcha rules to "no".'
101
- I18n.t(:howto_update,
102
- scope: "mod.standard.set.self.admin_info")
103
- ]
104
- )
105
- end
106
- end
107
-
108
-
109
- # ~~ below autogenerated; above pulled from /Users/ethan/dev/wagn/gem/card/mod/admin/set/self/admin_info.rb ~~
110
- end;end;end;end;