card 1.19.1 → 1.19.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (205) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +3 -3
  3. data/VERSION +1 -1
  4. data/db/migrate_core_cards/20160908154210_add_trash_card.rb +7 -0
  5. data/lib/card.rb +2 -2
  6. data/lib/card/act_manager.rb +143 -0
  7. data/lib/card/act_manager/stage.rb +56 -0
  8. data/lib/card/act_manager/stage_director.rb +313 -0
  9. data/lib/card/act_manager/subdirector_array.rb +43 -0
  10. data/lib/card/set.rb +1 -0
  11. data/lib/card/set/i18n_scope.rb +52 -0
  12. data/lib/card/subcards.rb +2 -3
  13. data/lib/cardio.rb +4 -4
  14. data/mod/admin/set/self/admin.rb +1 -2
  15. data/mod/admin/set/self/trash.rb +29 -0
  16. data/mod/core/set/abstract/code_file.rb +5 -25
  17. data/mod/core/set/all/actify.rb +35 -0
  18. data/mod/core/set/all/fetch.rb +12 -15
  19. data/mod/core/set/all/i18n.rb +9 -0
  20. data/mod/core/set/all/phases.rb +1 -1
  21. data/mod/core/set/all/stages.rb +2 -2
  22. data/mod/developer/set/all/event_viz.rb +2 -1
  23. data/mod/email/set/all/notify.rb +1 -1
  24. data/mod/history/lib/card/act.rb +1 -1
  25. data/mod/history/lib/card/action.rb +1 -1
  26. data/mod/history/set/all/history.rb +1 -1
  27. data/mod/machines/set/abstract/machine.rb +1 -1
  28. data/mod/machines/spec/set/type/coffeescript_spec.rb +1 -1
  29. data/mod/machines/spec/set/type/css_spec.rb +1 -1
  30. data/mod/machines/spec/set/type/javascript_spec.rb +1 -1
  31. data/mod/machines/spec/set/type/scss_spec.rb +1 -1
  32. data/mod/machines/spec/set/type/skin_spec.rb +1 -1
  33. data/mod/machines/spec/{lib/shared_machine_examples.rb → shared_examples/machine.rb} +15 -24
  34. data/mod/machines/spec/{lib/shared_machine_input_examples.rb → shared_examples/machine_input.rb} +0 -0
  35. data/mod/settings/spec/set/right/script_spec.rb +1 -1
  36. data/mod/settings/spec/set/right/style_spec.rb +1 -4
  37. data/mod/solid_cache/set/abstract/solid_cache.rb +1 -1
  38. data/spec/lib/card/content_spec.rb +118 -132
  39. data/spec/lib/card/i18n_spec.rb +6 -7
  40. data/spec/lib/card/query_spec.rb +5 -4
  41. data/spec/lib/card/stage_director_spec.rb +1 -1
  42. data/spec/spec_helper.rb +3 -4
  43. data/tmpsets/set/{mod002-core → mod001-core}/abstract/code_file.rb +0 -0
  44. data/tmpsets/set/{mod002-core → mod001-core}/all/actify.rb +0 -0
  45. data/tmpsets/set/{mod002-core → mod001-core}/all/active_card.rb +0 -0
  46. data/tmpsets/set/{mod002-core → mod001-core}/all/collection.rb +0 -0
  47. data/tmpsets/set/{mod002-core → mod001-core}/all/content.rb +0 -0
  48. data/tmpsets/set/{mod002-core → mod001-core}/all/erb.rb +0 -0
  49. data/tmpsets/set/{mod002-core → mod001-core}/all/event.rb +0 -0
  50. data/tmpsets/set/{mod002-core → mod001-core}/all/export.rb +0 -0
  51. data/tmpsets/set/{mod002-core → mod001-core}/all/fetch.rb +12 -14
  52. data/tmpsets/set/{mod002-core → mod001-core}/all/haml.rb +0 -0
  53. data/tmpsets/set/{mod002-core → mod001-core}/all/initialize.rb +0 -0
  54. data/tmpsets/set/{mod002-core → mod001-core}/all/location_history.rb +0 -0
  55. data/tmpsets/set/{mod002-core → mod001-core}/all/name.rb +0 -0
  56. data/tmpsets/set/{mod002-core → mod001-core}/all/name_validations.rb +0 -0
  57. data/tmpsets/set/{mod002-core → mod001-core}/all/pattern.rb +0 -0
  58. data/tmpsets/set/{mod002-core → mod001-core}/all/permissions.rb +0 -0
  59. data/tmpsets/set/{mod002-core → mod001-core}/all/phases.rb +0 -0
  60. data/tmpsets/set/{mod002-core → mod001-core}/all/references.rb +0 -0
  61. data/tmpsets/set/{mod002-core → mod001-core}/all/rules.rb +0 -0
  62. data/tmpsets/set/{mod002-core → mod001-core}/all/stages.rb +0 -0
  63. data/tmpsets/set/{mod002-core → mod001-core}/all/states.rb +0 -0
  64. data/tmpsets/set/{mod002-core → mod001-core}/all/subcards.rb +0 -0
  65. data/tmpsets/set/{mod002-core → mod001-core}/all/templating.rb +0 -0
  66. data/tmpsets/set/{mod002-core → mod001-core}/all/tracked_attributes.rb +0 -0
  67. data/tmpsets/set/{mod002-core → mod001-core}/all/trash.rb +0 -50
  68. data/tmpsets/set/{mod002-core → mod001-core}/all/type.rb +0 -0
  69. data/tmpsets/set/{mod002-core → mod001-core}/all/utils.rb +33 -0
  70. data/tmpsets/set/{mod002-core → mod001-core}/all/view_cache.rb +0 -0
  71. data/tmpsets/set/{mod003-history → mod002-history}/all/actions.rb +0 -0
  72. data/tmpsets/set/{mod003-history → mod002-history}/all/content_history.rb +0 -0
  73. data/tmpsets/set/{mod003-history → mod002-history}/all/history.rb +0 -0
  74. data/tmpsets/set/{mod004-basic_formats → mod003-basic_formats}/all/all_css.rb +0 -0
  75. data/tmpsets/set/{mod004-basic_formats → mod003-basic_formats}/all/all_csv.rb +0 -0
  76. data/tmpsets/set/{mod004-basic_formats → mod003-basic_formats}/all/all_js.rb +0 -0
  77. data/tmpsets/set/{mod004-basic_formats → mod003-basic_formats}/all/base.rb +0 -0
  78. data/tmpsets/set/{mod004-basic_formats → mod003-basic_formats}/all/file.rb +0 -0
  79. data/tmpsets/set/{mod004-basic_formats → mod003-basic_formats}/all/json.rb +0 -0
  80. data/tmpsets/set/{mod004-basic_formats → mod003-basic_formats}/all/rss.rb +0 -0
  81. data/tmpsets/set/{mod004-basic_formats → mod003-basic_formats}/all/text.rb +0 -0
  82. data/tmpsets/set/{mod004-basic_formats → mod003-basic_formats}/self/01_head/javascript.rb +0 -0
  83. data/tmpsets/set/{mod004-basic_formats → mod003-basic_formats}/self/head.rb +1 -1
  84. data/tmpsets/set/{mod005-pointer → mod004-pointer}/abstract/01_pointer.rb +0 -0
  85. data/tmpsets/set/{mod005-pointer → mod004-pointer}/abstract/01_pointer/edit.rb +0 -0
  86. data/tmpsets/set/{mod005-pointer → mod004-pointer}/abstract/code_pointer.rb +0 -0
  87. data/tmpsets/set/{mod005-pointer → mod004-pointer}/self/script_editors.rb +0 -0
  88. data/tmpsets/set/{mod005-pointer → mod004-pointer}/self/script_mods.rb +0 -0
  89. data/tmpsets/set/{mod005-pointer → mod004-pointer}/self/script_pointer_config.rb +0 -0
  90. data/tmpsets/set/{mod005-pointer → mod004-pointer}/type/pointer.rb +0 -0
  91. data/tmpsets/set/{mod006-ace_editor → mod005-ace_editor}/abstract/ace_editor.rb +0 -0
  92. data/tmpsets/set/{mod006-ace_editor → mod005-ace_editor}/self/script_ace.rb +0 -0
  93. data/tmpsets/set/{mod006-ace_editor → mod005-ace_editor}/self/script_ace_config.rb +0 -0
  94. data/tmpsets/set/{mod007-prosemirror_editor → mod006-prosemirror_editor}/abstract/prosemirror_editor.rb +0 -0
  95. data/tmpsets/set/{mod007-prosemirror_editor → mod006-prosemirror_editor}/self/script_prosemirror.rb +0 -0
  96. data/tmpsets/set/{mod007-prosemirror_editor → mod006-prosemirror_editor}/self/script_prosemirror_config.rb +0 -0
  97. data/tmpsets/set/{mod009-solid_cache → mod008-solid_cache}/abstract/solid_cache.rb +1 -1
  98. data/tmpsets/set/{mod009-solid_cache → mod008-solid_cache}/all/solid_cache.rb +0 -0
  99. data/tmpsets/set/{mod009-solid_cache → mod008-solid_cache}/right/solid_cache.rb +0 -0
  100. data/tmpsets/set/{mod010-basic_types → mod009-basic_types}/type/html.rb +0 -0
  101. data/tmpsets/set/{mod010-basic_types → mod009-basic_types}/type/plain_text.rb +0 -0
  102. data/tmpsets/set/{mod011-machines → mod010-machines}/abstract/script.rb +0 -0
  103. data/tmpsets/set/{mod011-machines → mod010-machines}/all/reset_machines.rb +0 -0
  104. data/tmpsets/set/{mod011-machines → mod010-machines}/right/machine_cache.rb +0 -0
  105. data/tmpsets/set/{mod011-machines → mod010-machines}/right/machine_input.rb +0 -0
  106. data/tmpsets/set/{mod011-machines → mod010-machines}/right/machine_output.rb +1 -9
  107. data/tmpsets/set/{mod011-machines → mod010-machines}/self/script_card_menu.rb +0 -0
  108. data/tmpsets/set/{mod011-machines → mod010-machines}/self/script_html5shiv_printshiv.rb +0 -0
  109. data/tmpsets/set/{mod011-machines → mod010-machines}/self/script_jquery.rb +0 -0
  110. data/tmpsets/set/{mod011-machines → mod010-machines}/self/script_jquery_helper.rb +0 -0
  111. data/tmpsets/set/{mod011-machines → mod010-machines}/self/script_slot.rb +0 -0
  112. data/tmpsets/set/{mod011-machines → mod010-machines}/self/style_bootstrap_compatible.rb +0 -0
  113. data/tmpsets/set/{mod011-machines → mod010-machines}/self/style_cards.rb +0 -0
  114. data/tmpsets/set/{mod011-machines → mod010-machines}/self/style_jquery_ui_smoothness.rb +0 -0
  115. data/tmpsets/set/{mod011-machines → mod010-machines}/type/coffee_script.rb +6 -2
  116. data/tmpsets/set/{mod011-machines → mod010-machines}/type/css.rb +2 -2
  117. data/tmpsets/set/{mod011-machines → mod010-machines}/type/java_script.rb +2 -2
  118. data/tmpsets/set/{mod011-machines → mod010-machines}/type/scss.rb +0 -0
  119. data/tmpsets/set/{mod011-machines → mod010-machines}/type/skin.rb +2 -2
  120. data/tmpsets/set/{mod012-settings → mod011-settings}/abstract/permission.rb +0 -0
  121. data/tmpsets/set/{mod012-settings → mod011-settings}/right/add_help.rb +0 -0
  122. data/tmpsets/set/{mod012-settings → mod011-settings}/right/comment.rb +0 -0
  123. data/tmpsets/set/{mod012-settings → mod011-settings}/right/create.rb +0 -0
  124. data/tmpsets/set/{mod012-settings → mod011-settings}/right/default.rb +0 -0
  125. data/tmpsets/set/{mod012-settings → mod011-settings}/right/delete.rb +0 -0
  126. data/tmpsets/set/{mod012-settings → mod011-settings}/right/help.rb +0 -0
  127. data/tmpsets/set/{mod012-settings → mod011-settings}/right/read.rb +0 -0
  128. data/tmpsets/set/{mod012-settings → mod011-settings}/right/script.rb +1 -1
  129. data/tmpsets/set/{mod012-settings → mod011-settings}/right/structure.rb +0 -0
  130. data/tmpsets/set/{mod012-settings → mod011-settings}/right/style.rb +1 -1
  131. data/tmpsets/set/{mod012-settings → mod011-settings}/right/update.rb +0 -0
  132. data/tmpsets/set/{mod012-settings → mod011-settings}/self/accountable.rb +0 -0
  133. data/tmpsets/set/{mod012-settings → mod011-settings}/self/add_help.rb +0 -0
  134. data/tmpsets/set/{mod012-settings → mod011-settings}/self/autoname.rb +0 -0
  135. data/tmpsets/set/{mod012-settings → mod011-settings}/self/captcha.rb +0 -0
  136. data/tmpsets/set/{mod012-settings → mod011-settings}/self/create.rb +0 -0
  137. data/tmpsets/set/{mod012-settings → mod011-settings}/self/default.rb +0 -0
  138. data/tmpsets/set/{mod012-settings → mod011-settings}/self/default_html_view.rb +0 -0
  139. data/tmpsets/set/{mod012-settings → mod011-settings}/self/delete.rb +0 -0
  140. data/tmpsets/set/{mod012-settings → mod011-settings}/self/follow_fields.rb +0 -0
  141. data/tmpsets/set/{mod012-settings → mod011-settings}/self/help.rb +0 -0
  142. data/tmpsets/set/{mod012-settings → mod011-settings}/self/input.rb +0 -0
  143. data/tmpsets/set/{mod012-settings → mod011-settings}/self/layout.rb +0 -0
  144. data/tmpsets/set/{mod012-settings → mod011-settings}/self/on_create.rb +0 -0
  145. data/tmpsets/set/{mod012-settings → mod011-settings}/self/on_delete.rb +0 -0
  146. data/tmpsets/set/{mod012-settings → mod011-settings}/self/on_update.rb +0 -0
  147. data/tmpsets/set/{mod012-settings → mod011-settings}/self/options.rb +0 -0
  148. data/tmpsets/set/{mod012-settings → mod011-settings}/self/options_label.rb +0 -0
  149. data/tmpsets/set/{mod012-settings → mod011-settings}/self/read.rb +0 -0
  150. data/tmpsets/set/{mod012-settings → mod011-settings}/self/recent_settings.rb +0 -0
  151. data/tmpsets/set/{mod012-settings → mod011-settings}/self/script.rb +0 -0
  152. data/tmpsets/set/{mod012-settings → mod011-settings}/self/structure.rb +0 -0
  153. data/tmpsets/set/{mod012-settings → mod011-settings}/self/style.rb +0 -0
  154. data/tmpsets/set/{mod012-settings → mod011-settings}/self/table_of_contents.rb +0 -0
  155. data/tmpsets/set/{mod012-settings → mod011-settings}/self/thanks.rb +0 -0
  156. data/tmpsets/set/{mod012-settings → mod011-settings}/self/update.rb +0 -0
  157. data/tmpsets/set/{mod012-settings → mod011-settings}/type/setting.rb +0 -0
  158. data/tmpsets/set/{mod013-email → mod012-email}/all/email_html.rb +0 -0
  159. data/tmpsets/set/{mod013-email → mod012-email}/all/email_text.rb +0 -0
  160. data/tmpsets/set/{mod013-email → mod012-email}/all/follow.rb +0 -0
  161. data/tmpsets/set/{mod013-email → mod012-email}/all/notify.rb +0 -0
  162. data/tmpsets/set/{mod013-email → mod012-email}/all/observer.rb +0 -0
  163. data/tmpsets/set/{mod013-email → mod012-email}/right/bcc.rb +0 -0
  164. data/tmpsets/set/{mod013-email → mod012-email}/right/cc.rb +0 -0
  165. data/tmpsets/set/{mod013-email → mod012-email}/right/follow.rb +0 -0
  166. data/tmpsets/set/{mod013-email → mod012-email}/right/follow_fields.rb +0 -0
  167. data/tmpsets/set/{mod013-email → mod012-email}/right/followers.rb +0 -0
  168. data/tmpsets/set/{mod013-email → mod012-email}/right/following.rb +0 -0
  169. data/tmpsets/set/{mod013-email → mod012-email}/right/from.rb +0 -0
  170. data/tmpsets/set/{mod013-email → mod012-email}/right/html_message.rb +0 -0
  171. data/tmpsets/set/{mod013-email → mod012-email}/right/to.rb +0 -0
  172. data/tmpsets/set/{mod013-email → mod012-email}/self/always.rb +0 -0
  173. data/tmpsets/set/{mod013-email → mod012-email}/self/created.rb +0 -0
  174. data/tmpsets/set/{mod013-email → mod012-email}/self/edited.rb +0 -0
  175. data/tmpsets/set/{mod013-email → mod012-email}/self/follow.rb +0 -0
  176. data/tmpsets/set/{mod013-email → mod012-email}/self/follow_defaults.rb +0 -0
  177. data/tmpsets/set/{mod013-email → mod012-email}/self/never.rb +0 -0
  178. data/tmpsets/set/{mod013-email → mod012-email}/type/email_template.rb +0 -0
  179. data/tmpsets/set/{mod013-email → mod012-email}/type_plus_right/user/follow.rb +8 -4
  180. data/tmpsets/set/mod016-standard/all/links.rb +2 -2
  181. data/tmpsets/set/mod018-bootstrap/all/bootstrap/table.rb +1 -1
  182. data/tmpsets/set/mod018-bootstrap/self/bootswatch_shared.rb +1 -1
  183. metadata +149 -163
  184. data/lib/card/director_register.rb +0 -101
  185. data/lib/card/stage.rb +0 -106
  186. data/lib/card/stage_director.rb +0 -310
  187. data/lib/card/subdirector_array.rb +0 -43
  188. data/tmpsets/set/mod001-admin/self/admin.rb +0 -130
  189. data/tmpsets/set/mod001-admin/self/admin_info.rb +0 -110
  190. data/tmpsets/set/mod001-admin/self/version.rb +0 -15
  191. data/tmpsets/set/mod002-core/all/debug.rb +0 -30
  192. data/tmpsets/set/mod002-core/all/update_read_rules.rb +0 -91
  193. data/tmpsets/set/mod011-machines/abstract/machine.rb +0 -277
  194. data/tmpsets/set/mod011-machines/abstract/machine_input.rb +0 -83
  195. data/tmpsets/set/mod014-developer/all/event_viz.rb +0 -59
  196. data/tmpsets/set/mod014-developer/all/view_viz.rb +0 -30
  197. data/tmpsets/set/mod014-developer/right/debug.rb +0 -96
  198. data/tmpsets/set/mod015-carrierwave/abstract/attachment.rb +0 -118
  199. data/tmpsets/set/mod015-carrierwave/abstract/attachment/paths.rb +0 -57
  200. data/tmpsets/set/mod015-carrierwave/abstract/attachment/storage_type.rb +0 -326
  201. data/tmpsets/set/mod015-carrierwave/abstract/attachment/upload_cache.rb +0 -84
  202. data/tmpsets/set/mod015-carrierwave/all/file_utils.rb +0 -35
  203. data/tmpsets/set/mod015-carrierwave/self/admin.rb +0 -30
  204. data/tmpsets/set/mod015-carrierwave/type/file.rb +0 -158
  205. data/tmpsets/set/mod015-carrierwave/type/image.rb +0 -97
@@ -1,43 +0,0 @@
1
- class Card
2
- class SubdirectorArray < Array
3
- def self.initialize_with_subcards parent
4
- dir_array = new(parent)
5
- parent.card.subcards.each_card do |subcard|
6
- dir_array.add subcard
7
- end
8
- dir_array
9
- end
10
-
11
- def initialize parent
12
- @parent = parent
13
- super()
14
- end
15
-
16
- def add card, opts={}
17
- if card.is_a? Card::StageDirector
18
- card = card.card
19
- end
20
- each { |dir| return dir if dir.card == card }
21
- dir = Card::DirectorRegister.fetch card, parent: @parent
22
- dir.main = false
23
- dir.parent = @parent
24
- dir.transact_in_stage = opts[:transact_in_stage]
25
- self << dir
26
- dir
27
- end
28
-
29
- alias_method :delete_director, :delete
30
-
31
- def delete card
32
- if card.is_a? Card::StageDirector
33
- delete_director card
34
- else
35
- delete_if { |dir| dir.card == card }
36
- end
37
- end
38
-
39
- def add_director dir
40
- add dir.card
41
- end
42
- end
43
- end
@@ -1,130 +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
- # collect arrays of the form
5
- # [task symbol, { execute_policy: block, stats_policy: block }]
6
- basket :tasks
7
-
8
- event :admin_tasks, :initialize, on: :update do
9
- return unless (task = Env.params[:task])
10
- raise Card::Error::PermissionDenied, self unless Auth.always_ok?
11
-
12
- case task.to_sym
13
- when :clear_cache then Card::Cache.reset_all
14
- when :repair_references then Card::Reference.repair_all
15
- when :clear_view_cache then Card::Cache::ViewCache.reset
16
- when :delete_old_revisions then Card::Action.delete_old
17
- when :repair_permissions then Card.repair_all_permissions
18
- when :clear_solid_cache then Card.clear_solid_cache
19
- when :clear_machine_cache then Card.reset_all_machines
20
- else
21
- task_data = tasks.find { |h| h[:name].to_sym == task }
22
- task_data[:execute_policy].call if task_data
23
- end
24
- abort :success
25
- end
26
-
27
- format :html do
28
- view :core do |_args|
29
- stats = card_stats
30
- stats += cache_stats
31
- stats += memory_stats
32
- card.tasks.each do |task|
33
- stats += Array.wrap task[:stats]
34
- end
35
- table_content = stats.map { |args| stat_row(args) }
36
- table table_content, header: %w(Stat Value Action)
37
- end
38
-
39
- def card_stats
40
- [
41
- { title: "cards",
42
- count: Card.where(trash: false) },
43
- { title: "actions",
44
- count: Card::Action,
45
- link_text: "delete old",
46
- task: "delete_old_revisions" },
47
- { title: "references",
48
- count: Card::Reference,
49
- link_text: "repair all",
50
- task: "repair_references" }
51
- ]
52
- end
53
-
54
- def cache_stats
55
- stats = [
56
- { title: "solid cache",
57
- count: solid_cache_count, unit: " cards",
58
- link_text: "clear cache",
59
- task: "clear_solid_cache" },
60
- { title: "machine cache",
61
- count: machine_cache_count, unit: " cards",
62
- link_text: "clear cache",
63
- task: "clear_machine_cache" }
64
- ]
65
- return stats unless Card.config.view_cache
66
- stats << { title: "view cache",
67
- count: Card::Cache::ViewCache,
68
- link_text: "clear view cache",
69
- task: "clear_view_cache" }
70
- end
71
-
72
- def memory_stats
73
- oldmem = session[:memory]
74
- session[:memory] = newmem = card.profile_memory
75
- stats = [
76
- { title: "memory now",
77
- count: newmem, unit: "M",
78
- link_text: "clear cache", task: "clear_cache" }
79
- ]
80
- return stats unless oldmem
81
- stats << { title: "memory prev", count: oldmem, unit: "M" }
82
- stats << { title: "memory diff", count: newmem - oldmem, unit: "M" }
83
- stats
84
- end
85
-
86
- def stat_row args={}
87
- res = [(args[:title] || "")]
88
- res << "#{count(args[:count])}#{args[:unit]}"
89
- return res unless args[:task]
90
- path = card_path("update/:admin?task=#{args[:task]}")
91
- res << link_to(args[:link_text] || args[:task], path)
92
- res
93
- end
94
-
95
- def count counter
96
- counter = counter.call if counter.is_a?(Proc)
97
- counter.respond_to?(:count) ? counter.count : counter
98
- end
99
-
100
- def solid_cache_count
101
- Card.search right: { codename: "solid_cache" }, return: "count"
102
- end
103
-
104
- def machine_cache_count
105
- Card.search right: { codename: "machine_cache" }, return: "count"
106
- end
107
-
108
- def delete_sessions_link months
109
- link_to months,
110
- card_path("update/:admin?task=delete_old_sessions&months=#{months}")
111
- end
112
- end
113
-
114
- def current_memory_usage
115
- `ps -o rss= -p #{Process.pid}`.to_i
116
- end
117
-
118
- def profile_memory &block
119
- before = current_memory_usage
120
- if block_given?
121
- instance_eval(&block)
122
- else
123
- before = 0
124
- end
125
- (current_memory_usage - before) / 1024.to_i
126
- end
127
-
128
-
129
- # ~~ below autogenerated; above pulled from /Users/ethan/dev/wagn/gem/card/mod/admin/set/self/admin.rb ~~
130
- 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.admin.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.admin.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.admin.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.admin.set.self.admin_info"))
55
- end
56
- # 'Instructions'
57
- instructions = I18n.t(:instructions,
58
- scope: "mod.admin.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.admin.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.admin.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.admin.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.admin.set.self.admin_info"),
95
- [
96
- # "1. Go to #{card_link :captcha}"
97
- I18n.t(:howto_go,
98
- scope: "mod.admin.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.admin.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;
@@ -1,15 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
- class Card; module Set; class Self; module Version; extend Card::Set
3
- # ~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/admin/set/self/version.rb ~~
4
- # -*- encoding : utf-8 -*-
5
- require_dependency "card/version"
6
-
7
- view :raw do |_args|
8
- Card::Version.release
9
- end
10
-
11
- view :core, :raw
12
-
13
-
14
- # ~~ below autogenerated; above pulled from /Users/ethan/dev/wagn/gem/card/mod/admin/set/self/version.rb ~~
15
- end;end;end;end;
@@ -1,30 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
- class Card; module Set; class All; module Debug; extend Card::Set
3
- # ~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/core/set/all/debug.rb ~~
4
- def to_s
5
- "#<#{self.class.name}[#{debug_type}]#{attributes['name']}>"
6
- end
7
-
8
- def inspect
9
- tags = []
10
- tags << "trash" if trash
11
- tags << "new" if new_card?
12
- tags << "frozen" if frozen?
13
- tags << "readonly" if readonly?
14
- tags << "virtual" if @virtual
15
- tags << "set_mods_loaded" if @set_mods_loaded
16
-
17
- error_messages = errors.any? ? "<E*#{errors.full_messages * ', '}*>" : ""
18
-
19
- "#<Card##{id}[#{debug_type}](#{name})#{error_messages}{#{tags * ','}}"
20
- end
21
-
22
- private
23
-
24
- def debug_type
25
- "#{type_code || ''}:#{type_id}"
26
- end
27
-
28
-
29
- # ~~ below autogenerated; above pulled from /Users/ethan/dev/wagn/gem/card/mod/core/set/all/debug.rb ~~
30
- end;end;end;end;
@@ -1,91 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
- class Card; module Set; class All; module UpdateReadRules; extend Card::Set
3
- # ~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/core/set/all/update_read_rules.rb ~~
4
-
5
- # FIXME: the following don't really belong here, but they have to come after
6
- # the reference stuff. we need to organize a bit!
7
-
8
- event :update_ruled_cards, :finalize do
9
- if is_rule?
10
- # warn "updating ruled cards for #{name}"
11
- self.class.clear_rule_cache
12
- set = rule_set
13
-
14
- if right_id == Card::ReadID && (name_changed? || trash_changed?)
15
- update_read_ruled_cards set
16
- end
17
- end
18
- end
19
-
20
- def update_read_rules_not_overridden_by_narrower_rules cur_index,
21
- rule_class_index, set
22
- set.item_cards(limit: 0).each_with_object(::Set.new) do |item_card, in_set|
23
- in_set << item_card.key
24
- next if cur_index < rule_class_index
25
- item_card.update_read_rule
26
- end
27
- end
28
-
29
- def update_read_rules_of_set_members set
30
- return ::Set.new if trash || !(class_id = id_of_set_class(set))
31
- rule_class_ids = set_patterns.map(&:pattern_id)
32
- Auth.as_bot do
33
- if (rule_class_index = rule_class_ids.index(class_id))
34
- cur_index = rule_class_ids.index Card[read_rule_class].id
35
- update_read_rules_not_overridden_by_narrower_rules cur_index,
36
- rule_class_index, set
37
- else
38
- warn "No current rule index #{class_id}, #{rule_class_ids.inspect}"
39
- ::Set.new
40
- end
41
- end
42
- end
43
-
44
- def id_of_set_class set
45
- set && (set_class = set.tag) && set_class.id
46
- end
47
-
48
- def update_read_ruled_cards set
49
- self.class.clear_read_rule_cache
50
- Card.cache.reset # maybe be more surgical, just Auth.user related
51
- expire # probably shouldn't be necessary,
52
- # but was sometimes getting cached version when card should be in the
53
- # trash. could be related to other bugs?
54
-
55
- updated = update_read_rules_of_set_members set
56
-
57
- # then find all cards with me as read_rule_id that were not just updated
58
- # and regenerate their read_rules
59
- return if new_card?
60
- Card.search(read_rule_id: id) do |card|
61
- card.update_read_rule unless updated.include?(card.key)
62
- end
63
- end
64
-
65
- event :process_read_rule_update_queue, :finalize do
66
- Array.wrap(@read_rule_update_queue).each(&:update_read_rule)
67
- @read_rule_update_queue = []
68
- end
69
-
70
- event :expire_related, :finalize do
71
- subcards.keys.each do |key|
72
- Card.cache.soft.delete key
73
- end
74
- expire # FIXME: where do we put this. Here it deletes @stage
75
- reset_patterns
76
- if is_structure?
77
- structuree_names.each do |name|
78
- Card.expire name
79
- end
80
- end
81
- end
82
-
83
- event :expire_related_names, before: :expire_related, changed: :name do
84
- # FIXME: look for opportunities to avoid instantiating the following
85
- descendants.each(&:expire)
86
- name_referers.each(&:expire)
87
- end
88
-
89
-
90
- # ~~ below autogenerated; above pulled from /Users/ethan/dev/wagn/gem/card/mod/core/set/all/update_read_rules.rb ~~
91
- end;end;end;end;
@@ -1,277 +0,0 @@
1
- # -*- encoding : utf-8 -*-
2
- class Card; module Set; class Abstract; module Machine; extend Card::Set
3
- # ~~ above autogenerated; below pulled from /Users/ethan/dev/wagn/gem/card/mod/machines/set/abstract/machine.rb ~~
4
- # ## What are Machines?
5
- # {Machine} and {MachineInput} together implement a kind of observer pattern.
6
- # {Machine} processes a collection of input cards to generate an output card
7
- # (a {Set::Type::File} card by default). If one of the input cards is changed
8
- # the output card will be updated.
9
- #
10
- # The classic example: A style card observes a collection of css and sccs card
11
- # to generate a file card with a css file that contains the assembled
12
- # compressed css.
13
- #
14
- # ## Using Machines
15
- # Include the Machine module in the card set that is supposed to produce the
16
- # output card. If the output card should be automatically updated when a input
17
- # card is changed the input card has to be in a set that includes the
18
- # MachineInput module.
19
- #
20
- # The default machine:
21
- #
22
- # - uses its item cards as input cards or the card itself if there are no
23
- # item cards;
24
- # - can be changed by passing a block to collect_input_cards
25
- # - takes the raw view of the input cards to generate the output;
26
- # - can be changed by passing a block to machine_input (in the input card
27
- # set)
28
- # - stores the output as a .txt file in the '+machine output' card;
29
- # - can be changed by passing a filetype and/or a block to
30
- # store_machine_output
31
- #
32
- #
33
- # ## How does it work?
34
- # Machine cards have a '+machine input' and a '+machine output' card. The
35
- # '+machine input' card is a pointer to all input cards. Including the
36
- # MachineInput module creates an 'on: save' event that runs the machines of
37
- # all cards that are linked to that card via the +machine input pointer.
38
- module MachineClassMethods
39
- attr_accessor :output_config
40
-
41
- def collect_input_cards &block
42
- define_method :engine_input, &block
43
- end
44
-
45
- def prepare_machine_input &block
46
- define_method :before_engine, &block
47
- end
48
-
49
- def machine_engine &block
50
- define_method :engine, &block
51
- end
52
-
53
- def store_machine_output args={}, &block
54
- output_config.merge!(args)
55
- return unless block_given?
56
- define_method :after_engine, &block
57
- end
58
- end
59
-
60
- class << self
61
- def included host_class
62
- host_class.extend(MachineClassMethods)
63
- host_class.output_config = { filetype: "txt" }
64
-
65
- # for compatibility with old migrations
66
- return unless Codename[:machine_output]
67
-
68
- host_class.card_accessor :machine_output, type: :file
69
- host_class.card_accessor :machine_input, type: :pointer
70
-
71
- set_default_machine_behaviour host_class
72
- define_machine_views host_class
73
- define_machine_events host_class
74
- end
75
-
76
- def define_machine_events host_class
77
- event_suffix = host_class.name.tr ":", "_"
78
- event_name = "reset_machine_output_#{event_suffix}".to_sym
79
- host_class.event event_name, after: :expire_related, on: :save do
80
- reset_machine_output
81
- end
82
- end
83
-
84
- def define_machine_views host_class
85
- host_class.format do
86
- view :machine_output_url do |_args|
87
- machine_output_url
88
- end
89
- end
90
- end
91
-
92
- def set_default_machine_behaviour host_class
93
- set_default_input_collection_method host_class
94
- set_default_input_preparation_method host_class
95
- set_default_output_storage_method host_class
96
- host_class.machine_engine { |input| input }
97
- end
98
-
99
- def set_default_input_preparation_method host_class
100
- host_class.prepare_machine_input {}
101
- end
102
-
103
- def set_default_output_storage_method host_class
104
- host_class.store_machine_output do |output|
105
- filetype = host_class.output_config[:filetype]
106
- file = Tempfile.new [id.to_s, ".#{filetype}"]
107
- file.write output
108
- file.rewind
109
- Card::Auth.as_bot do
110
- p = machine_output_card
111
- p.file = file
112
- p.save!
113
- end
114
- file.close
115
- file.unlink
116
- end
117
- end
118
-
119
- def set_default_input_collection_method host_class
120
- host_class.collect_input_cards do
121
- # traverse through all levels of pointers and
122
- # collect all item cards as input
123
- items = [self]
124
- new_input = []
125
- already_extended = {} # avoid loops
126
- loop_limit = 5
127
- until items.empty?
128
- item = items.shift
129
- next if item.trash || already_extended[item.id].to_i > loop_limit
130
- if item.item_cards == [item] # no pointer card
131
- new_input << item
132
- else
133
- # item_cards instantiates non-existing cards
134
- # we don't want those
135
- items.insert(0, item.item_cards.reject(&:unknown?))
136
- items.flatten!
137
-
138
- new_input << item if item != self && item.known?
139
- already_extended[item] = already_extended[item].to_i + 1
140
- end
141
- end
142
- new_input
143
- end
144
- end
145
- end
146
-
147
- def run_machine joint="\n"
148
- before_engine
149
- output =
150
- input_item_cards.map do |input_card|
151
- run_engine input_card
152
- end.select(&:present?).join(joint)
153
- after_engine output
154
- end
155
-
156
- def run_engine input_card
157
- return if input_card.is_a? Card::Set::Type::Pointer
158
- if (cached = fetch_cache_card(input_card))
159
- return cached.content
160
- end
161
-
162
- input = if input_card.respond_to? :machine_input
163
- input_card.machine_input
164
- else
165
- input_card.format._render_raw
166
- end
167
- output = engine(input)
168
- cache_output_part input_card, output
169
- output
170
- end
171
-
172
- def fetch_cache_card input_card, new=nil
173
- new &&= { type_id: PlainTextID }
174
- Card.fetch input_card.name, name, :machine_cache, new: new
175
- end
176
-
177
- def cache_output_part input_card, output
178
- Auth.as_bot do
179
- cache_card = fetch_cache_card(input_card, true)
180
- cache_card.update_attributes! content: output
181
- end
182
- end
183
-
184
- def reset_machine_output
185
- Auth.as_bot do
186
- (moc = machine_output_card) && moc.real? && moc.delete!
187
- update_input_card
188
- end
189
- end
190
-
191
- def update_machine_output
192
- lock do
193
- update_input_card
194
- run_machine
195
- end
196
- end
197
-
198
- def make_machine_output_coded mod=:machines
199
- update_machine_output
200
- Auth.as_bot do
201
- output_codename =
202
- machine_output_card.cardname.parts.map do |part|
203
- Card[part].codename || Card[part].cardname.safe_key
204
- end.join '_'
205
- machine_output_card.update_attributes! codename: output_codename,
206
- storage_type: :coded,
207
- mod: mod
208
- end
209
- end
210
-
211
- def regenerate_machine_output
212
- lock do
213
- run_machine
214
- end
215
- end
216
-
217
- def lock
218
- if ok?(:read) && !(was_already_locked = locked?)
219
- Auth.as_bot do
220
- lock!
221
- yield
222
- end
223
- end
224
- ensure
225
- unlock! unless was_already_locked
226
- end
227
-
228
- def lock_cache_key
229
- "UPDATE-LOCK:#{key}"
230
- end
231
-
232
- def locked?
233
- Card.cache.read lock_cache_key
234
- end
235
-
236
- def lock!
237
- Card.cache.write lock_cache_key, true
238
- end
239
-
240
- def unlock!
241
- Card.cache.write lock_cache_key, false
242
- end
243
-
244
- def update_input_card
245
- if DirectorRegister.running_act?
246
- input_card = attach_subcard! machine_input_card
247
- input_card.content = ""
248
- engine_input.each { |input| input_card << input }
249
- else
250
- machine_input_card.items = engine_input
251
- end
252
- end
253
-
254
- def input_item_cards
255
- machine_input_card.item_cards
256
- end
257
-
258
- def machine_output_url
259
- ensure_machine_output
260
- machine_output_card.file.url # (:default, timestamp: false)
261
- # to get rid of additional number in url
262
- end
263
-
264
- def machine_output_path
265
- ensure_machine_output
266
- machine_output_card.file.path
267
- end
268
-
269
- def ensure_machine_output
270
- output = fetch trait: :machine_output
271
- return if output && output.selected_content_action_id
272
- update_machine_output
273
- end
274
-
275
-
276
- # ~~ below autogenerated; above pulled from /Users/ethan/dev/wagn/gem/card/mod/machines/set/abstract/machine.rb ~~
277
- end;end;end;end;