cortex 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (342) hide show
  1. checksums.yaml +7 -0
  2. data/.babelrc +18 -0
  3. data/.codeclimate.yml +43 -0
  4. data/.csslintrc +2 -0
  5. data/.editorconfig +9 -0
  6. data/.eslintignore +1 -0
  7. data/.eslintrc.yml +277 -0
  8. data/.github/PULL_REQUEST_TEMPLATE.md +47 -0
  9. data/.gitignore +82 -0
  10. data/.npmignore +34 -0
  11. data/.postcssrc.yml +3 -0
  12. data/.rspec +3 -0
  13. data/.rubocop.yml +1156 -0
  14. data/CODE_OF_CONDUCT.md +74 -0
  15. data/CONTRIBUTING.md +58 -0
  16. data/Gemfile +101 -0
  17. data/Gemfile.lock +604 -0
  18. data/Guardfile +23 -0
  19. data/LICENSE.md +201 -0
  20. data/README.md +239 -0
  21. data/Rakefile +22 -0
  22. data/app/assets/config/cortex_manifest.js +4 -0
  23. data/app/assets/fonts/cortex/Montserrat-Light.otf +0 -0
  24. data/app/assets/fonts/cortex/Montserrat-Medium.otf +0 -0
  25. data/app/assets/fonts/cortex/Montserrat-Regular.otf +0 -0
  26. data/app/assets/fonts/cortex/Montserrat-SemiBold.otf +0 -0
  27. data/app/assets/images/cortex/favicon.ico +0 -0
  28. data/app/assets/images/cortex/icons/add.svg +59 -0
  29. data/app/assets/images/cortex/icons/blog.png +0 -0
  30. data/app/assets/images/cortex/icons/media.png +0 -0
  31. data/app/assets/images/cortex/logo.svg +43 -0
  32. data/app/assets/javascripts/cortex/application.js +17 -0
  33. data/app/assets/javascripts/cortex/authentication.js +6 -0
  34. data/app/assets/javascripts/cortex/base.js +6 -0
  35. data/app/assets/javascripts/cortex/datepicker_init.js +29 -0
  36. data/app/assets/javascripts/cortex/flash.js +7 -0
  37. data/app/assets/javascripts/cortex/form.js +6 -0
  38. data/app/assets/javascripts/cortex/media_dialogs.js +40 -0
  39. data/app/assets/javascripts/cortex/quick_links.js +13 -0
  40. data/app/assets/stylesheets/cortex/application.scss +34 -0
  41. data/app/assets/stylesheets/cortex/authentication.scss +34 -0
  42. data/app/assets/stylesheets/cortex/base.scss +4 -0
  43. data/app/assets/stylesheets/cortex/bootstrap-namespaced.scss +57 -0
  44. data/app/assets/stylesheets/cortex/components/card.scss +9 -0
  45. data/app/assets/stylesheets/cortex/components/dialog.scss +67 -0
  46. data/app/assets/stylesheets/cortex/components/flash.scss +60 -0
  47. data/app/assets/stylesheets/cortex/components/form.scss +45 -0
  48. data/app/assets/stylesheets/cortex/components/header.scss +53 -0
  49. data/app/assets/stylesheets/cortex/components/index.scss +28 -0
  50. data/app/assets/stylesheets/cortex/components/jumbo-button.scss +41 -0
  51. data/app/assets/stylesheets/cortex/components/loaders.scss +76 -0
  52. data/app/assets/stylesheets/cortex/components/notes.scss +26 -0
  53. data/app/assets/stylesheets/cortex/components/sidebar.scss +120 -0
  54. data/app/assets/stylesheets/cortex/components/table.scss +7 -0
  55. data/app/assets/stylesheets/cortex/components/tenant-switcher.scss +209 -0
  56. data/app/assets/stylesheets/cortex/components/ui.scss +119 -0
  57. data/app/assets/stylesheets/cortex/demo.scss +140 -0
  58. data/app/assets/stylesheets/cortex/directives/aspect-ratio.scss +9 -0
  59. data/app/assets/stylesheets/cortex/helpers.scss +1701 -0
  60. data/app/assets/stylesheets/cortex/layout.scss +21 -0
  61. data/app/assets/stylesheets/cortex/material-icons.scss +13 -0
  62. data/app/assets/stylesheets/cortex/variables/_colors.scss +46 -0
  63. data/app/assets/stylesheets/cortex/variables/_material-overrides.scss +1 -0
  64. data/app/assets/stylesheets/cortex/variables/_typography.scss +114 -0
  65. data/app/cells/cortex/application_cell.rb +8 -0
  66. data/app/cells/cortex/content_type/nav.haml +5 -0
  67. data/app/cells/cortex/content_type_cell.rb +10 -0
  68. data/app/cells/cortex/field_cell.rb +35 -0
  69. data/app/cells/cortex/index/content_item/column.haml +4 -0
  70. data/app/cells/cortex/index/content_item_cell.rb +37 -0
  71. data/app/cells/cortex/index/index.haml +5 -0
  72. data/app/cells/cortex/index/table_body.haml +11 -0
  73. data/app/cells/cortex/index/table_headers.haml +5 -0
  74. data/app/cells/cortex/index_cell.rb +53 -0
  75. data/app/cells/cortex/wizard/column/show.haml +10 -0
  76. data/app/cells/cortex/wizard/column_cell.rb +21 -0
  77. data/app/cells/cortex/wizard/field/show.haml +30 -0
  78. data/app/cells/cortex/wizard/field_cell.rb +29 -0
  79. data/app/cells/cortex/wizard/plugin/show.haml +1 -0
  80. data/app/cells/cortex/wizard/plugin_cell.rb +28 -0
  81. data/app/cells/cortex/wizard/show.haml +1 -0
  82. data/app/cells/cortex/wizard/step/show.haml +2 -0
  83. data/app/cells/cortex/wizard/step_cell.rb +17 -0
  84. data/app/cells/cortex/wizard_cell.rb +15 -0
  85. data/app/containers/cortex/transaction_container.rb +23 -0
  86. data/app/controllers/concerns/cortex/decoratable.rb +16 -0
  87. data/app/controllers/cortex/admin_controller.rb +7 -0
  88. data/app/controllers/cortex/application_controller.rb +19 -0
  89. data/app/controllers/cortex/authentication/passwords_controller.rb +3 -0
  90. data/app/controllers/cortex/authentication/sessions_controller.rb +3 -0
  91. data/app/controllers/cortex/content_items_controller.rb +75 -0
  92. data/app/controllers/cortex/content_types_controller.rb +19 -0
  93. data/app/controllers/cortex/dashboards_controller.rb +7 -0
  94. data/app/controllers/cortex/graphql_controller.rb +40 -0
  95. data/app/controllers/cortex/tenants_controller.rb +12 -0
  96. data/app/devise/cortex/authentication_failure.rb +12 -0
  97. data/app/graphql/cortex/cortex_schema.rb +8 -0
  98. data/app/graphql/cortex/interfaces/.keep +0 -0
  99. data/app/graphql/cortex/mutations/.keep +0 -0
  100. data/app/graphql/cortex/types/content_item_type.rb +31 -0
  101. data/app/graphql/cortex/types/content_type_type.rb +23 -0
  102. data/app/graphql/cortex/types/contract_type.rb +10 -0
  103. data/app/graphql/cortex/types/date_time_type.rb +8 -0
  104. data/app/graphql/cortex/types/field_item_type.rb +15 -0
  105. data/app/graphql/cortex/types/field_type.rb +18 -0
  106. data/app/graphql/cortex/types/mutation_type.rb +5 -0
  107. data/app/graphql/cortex/types/query_type.rb +45 -0
  108. data/app/graphql/cortex/types/tenant_type.rb +19 -0
  109. data/app/graphql/cortex/types/user_type.rb +20 -0
  110. data/app/helpers/cortex/application_helper.rb +75 -0
  111. data/app/helpers/cortex/cells/association_helper.rb +25 -0
  112. data/app/helpers/cortex/content_item_helper.rb +106 -0
  113. data/app/helpers/cortex/dashboard_helper.rb +19 -0
  114. data/app/helpers/cortex/popup_helper.rb +27 -0
  115. data/app/jobs/cortex/application_job.rb +4 -0
  116. data/app/mailers/cortex/application_mailer.rb +6 -0
  117. data/app/mailers/cortex/password_reset_mailer.rb +13 -0
  118. data/app/models/concerns/cortex/belongs_to_tenant.rb +13 -0
  119. data/app/models/concerns/cortex/has_firstname_lastname.rb +11 -0
  120. data/app/models/concerns/cortex/has_gravatar.rb +18 -0
  121. data/app/models/concerns/cortex/searchable.rb +11 -0
  122. data/app/models/concerns/cortex/searchable_content_item.rb +31 -0
  123. data/app/models/concerns/cortex/searchable_content_item_for_content_type.rb +52 -0
  124. data/app/models/concerns/cortex/searchable_content_type.rb +11 -0
  125. data/app/models/cortex/application_record.rb +17 -0
  126. data/app/models/cortex/content_item.rb +71 -0
  127. data/app/models/cortex/content_type.rb +27 -0
  128. data/app/models/cortex/contentable_decorator.rb +8 -0
  129. data/app/models/cortex/contract.rb +12 -0
  130. data/app/models/cortex/decorator.rb +13 -0
  131. data/app/models/cortex/field.rb +36 -0
  132. data/app/models/cortex/field_item.rb +54 -0
  133. data/app/models/cortex/field_type.rb +44 -0
  134. data/app/models/cortex/permission.rb +11 -0
  135. data/app/models/cortex/role.rb +12 -0
  136. data/app/models/cortex/tenant.rb +41 -0
  137. data/app/models/cortex/user.rb +77 -0
  138. data/app/operations/cortex/database_transact_operation.rb +17 -0
  139. data/app/operations/cortex/execute_content_item_state_change_operation.rb +16 -0
  140. data/app/operations/cortex/parse_content_item_field_items_operation.rb +18 -0
  141. data/app/operations/cortex/persist_content_item_operation.rb +12 -0
  142. data/app/policies/cortex/application_policy.rb +55 -0
  143. data/app/policies/cortex/content_item_policy.rb +49 -0
  144. data/app/policies/cortex/content_type_policy.rb +38 -0
  145. data/app/transactions/concerns/cortex/content_itemable.rb +15 -0
  146. data/app/transactions/concerns/cortex/field_item_transactor.rb +28 -0
  147. data/app/transactions/concerns/cortex/widget_parsable.rb +19 -0
  148. data/app/transactions/cortex/application_transaction.rb +5 -0
  149. data/app/transactions/cortex/create_content_item_transaction.rb +35 -0
  150. data/app/transactions/cortex/get_content_item_transaction.rb +4 -0
  151. data/app/transactions/cortex/get_content_items_for_content_type_transaction.rb +34 -0
  152. data/app/transactions/cortex/get_publish_state_transaction.rb +28 -0
  153. data/app/transactions/cortex/new_field_item_transaction.rb +16 -0
  154. data/app/transactions/cortex/update_content_item_transaction.rb +45 -0
  155. data/app/transactions/cortex/update_field_item_transaction.rb +23 -0
  156. data/app/types/cortex/application_types.rb +21 -0
  157. data/app/types/cortex/content_item_transaction_type.rb +10 -0
  158. data/app/types/cortex/core_types.rb +5 -0
  159. data/app/types/cortex/transaction_type.rb +5 -0
  160. data/app/views/cortex/authentication/passwords/new.html.haml +13 -0
  161. data/app/views/cortex/authentication/sessions/new.html.haml +20 -0
  162. data/app/views/cortex/authentication/shared/_links.html.haml +19 -0
  163. data/app/views/cortex/content_items/_form.html.haml +13 -0
  164. data/app/views/cortex/content_items/_grid.html.haml +1 -0
  165. data/app/views/cortex/content_items/edit.html.haml +2 -0
  166. data/app/views/cortex/content_items/index.html.haml +4 -0
  167. data/app/views/cortex/content_items/new.html.haml +2 -0
  168. data/app/views/cortex/content_types/index.html.haml +2 -0
  169. data/app/views/cortex/content_types/new.html.haml +0 -0
  170. data/app/views/cortex/dashboards/index.html.haml +6 -0
  171. data/app/views/cortex/graphql/ide.haml +1 -0
  172. data/app/views/cortex/partials/_breadcrumb.html.haml +2 -0
  173. data/app/views/cortex/partials/_cortex_redux_state.html.haml +1 -0
  174. data/app/views/cortex/partials/_flash.html.haml +25 -0
  175. data/app/views/cortex/partials/_media_dialogs.html.haml +13 -0
  176. data/app/views/cortex/partials/_navigation.html.haml +15 -0
  177. data/app/views/cortex/partials/_notes.html.haml +17 -0
  178. data/app/views/cortex/partials/_quick_links.html.haml +22 -0
  179. data/app/views/cortex/partials/_sidebar.html.haml +7 -0
  180. data/app/views/cortex/partials/_topbar.html.haml +5 -0
  181. data/app/views/cortex/partials/_user_control.html.haml +7 -0
  182. data/app/views/cortex/partials/authentication/_header.html.haml +4 -0
  183. data/app/views/cortex/partials/trackers/_google_analytics.html.haml +10 -0
  184. data/app/views/cortex/partials/trackers/_qualtrics.html.haml +10 -0
  185. data/app/views/cortex/password_reset_mailer/send_password_reset.html.erb +5 -0
  186. data/app/views/cortex/password_reset_mailer/send_password_reset.text.erb +5 -0
  187. data/app/views/layouts/cortex/application.html.haml +30 -0
  188. data/app/views/layouts/cortex/devise.html.haml +19 -0
  189. data/app/views/layouts/cortex/mailer.html.erb +13 -0
  190. data/app/views/layouts/cortex/mailer.text.erb +1 -0
  191. data/bin/rails +25 -0
  192. data/config/config.yml +22 -0
  193. data/config/initializers/devise.rb +35 -0
  194. data/config/initializers/elasticsearch.rb +3 -0
  195. data/config/initializers/filter_parameter_logging.rb +4 -0
  196. data/config/initializers/flipper.rb +16 -0
  197. data/config/initializers/graphiql.rb +51 -0
  198. data/config/initializers/inflections.rb +16 -0
  199. data/config/initializers/load_config.rb +16 -0
  200. data/config/initializers/mime_types.rb +5 -0
  201. data/config/initializers/plugins.rb +17 -0
  202. data/config/initializers/react_on_rails.rb +15 -0
  203. data/config/initializers/rolify.rb +9 -0
  204. data/config/initializers/tag_parsers.rb +5 -0
  205. data/config/locales/devise.en.yml +64 -0
  206. data/config/routes.rb +41 -0
  207. data/cortex.gemspec +84 -0
  208. data/db/migrate/0_enable_pgcrypto_extension.rb +5 -0
  209. data/db/migrate/10_create_fields.rb +15 -0
  210. data/db/migrate/11_create_content_items.rb +14 -0
  211. data/db/migrate/12_create_field_items.rb +12 -0
  212. data/db/migrate/13_create_field_types.rb +5 -0
  213. data/db/migrate/1_create_users.rb +14 -0
  214. data/db/migrate/2_create_tenants.rb +26 -0
  215. data/db/migrate/3_add_devise_to_users.rb +49 -0
  216. data/db/migrate/4_create_roles.rb +15 -0
  217. data/db/migrate/5_create_permissions.rb +16 -0
  218. data/db/migrate/6_create_flipper_tables.rb +20 -0
  219. data/db/migrate/7_create_contracts.rb +11 -0
  220. data/db/migrate/8_create_decorators.rb +21 -0
  221. data/db/migrate/9_create_content_types.rb +17 -0
  222. data/db/seeds.rb +40 -0
  223. data/db/seeds.yml +33 -0
  224. data/lib/assets/.keep +0 -0
  225. data/lib/breadcrumbs/title_builder.rb +12 -0
  226. data/lib/cortex.rb +4 -0
  227. data/lib/cortex/engine.rb +41 -0
  228. data/lib/cortex/version.rb +3 -0
  229. data/lib/helpers/utility_helper.rb +7 -0
  230. data/lib/tasks/cortex_tasks.rake +13 -0
  231. data/lib/tasks/elasticsearch_tasks.rake +1 -0
  232. data/node_package/.babelrc +26 -0
  233. data/node_package/src/components/side_bar/environment_flag.jsx +21 -0
  234. data/node_package/src/components/side_bar/tenant_list.jsx +65 -0
  235. data/node_package/src/components/wizard/column.jsx +29 -0
  236. data/node_package/src/components/wizard/field.jsx +22 -0
  237. data/node_package/src/components/wizard/step.jsx +20 -0
  238. data/node_package/src/constants/tenant_switcher.jsx +17 -0
  239. data/node_package/src/constants/type_constants.jsx +12 -0
  240. data/node_package/src/constants/wizard.jsx +9 -0
  241. data/node_package/src/containers/layout.jsx +33 -0
  242. data/node_package/src/containers/tenant_switcher_container.jsx +115 -0
  243. data/node_package/src/containers/wizard_container.jsx +28 -0
  244. data/node_package/src/elements/loaders.jsx +7 -0
  245. data/node_package/src/helpers/formatting.jsx +5 -0
  246. data/node_package/src/helpers/tenant_ancestry.jsx +14 -0
  247. data/node_package/src/helpers/tenant_lookup.jsx +23 -0
  248. data/node_package/src/index.jsx +21 -0
  249. data/node_package/src/reducers/index.jsx +13 -0
  250. data/node_package/src/reducers/rails_context_reducer.jsx +5 -0
  251. data/node_package/src/reducers/tenant_switcher_reducer.jsx +74 -0
  252. data/node_package/src/reducers/wizard_reducer.jsx +32 -0
  253. data/node_package/src/services/rails_api_service.jsx +13 -0
  254. data/node_package/src/store/store.jsx +15 -0
  255. data/package.json +66 -0
  256. data/spec/dummy/Rakefile +7 -0
  257. data/spec/dummy/app/assets/config/manifest.js +4 -0
  258. data/spec/dummy/app/assets/javascripts/application.js +2 -0
  259. data/spec/dummy/app/assets/stylesheets/application.scss +2 -0
  260. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  261. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  262. data/spec/dummy/app/javascript/packs/application.js +8 -0
  263. data/spec/dummy/app/javascript/packs/cortex.jsx +1 -0
  264. data/spec/dummy/app/jobs/application_job.rb +2 -0
  265. data/spec/dummy/app/mailers/application_mailer.rb +4 -0
  266. data/spec/dummy/app/views/layouts/application.html.haml +11 -0
  267. data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
  268. data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
  269. data/spec/dummy/bin/bundle +105 -0
  270. data/spec/dummy/bin/rails +4 -0
  271. data/spec/dummy/bin/rake +4 -0
  272. data/spec/dummy/bin/rspec +17 -0
  273. data/spec/dummy/bin/setup +38 -0
  274. data/spec/dummy/bin/update +29 -0
  275. data/spec/dummy/bin/webpack +29 -0
  276. data/spec/dummy/bin/webpack-dev-server +29 -0
  277. data/spec/dummy/bin/yarn +11 -0
  278. data/spec/dummy/config.ru +7 -0
  279. data/spec/dummy/config/apollo_engine_proxy.yml +23 -0
  280. data/spec/dummy/config/application.rb +21 -0
  281. data/spec/dummy/config/boot.rb +11 -0
  282. data/spec/dummy/config/cable.yml +9 -0
  283. data/spec/dummy/config/config.yml +22 -0
  284. data/spec/dummy/config/database.yml +22 -0
  285. data/spec/dummy/config/environment.rb +5 -0
  286. data/spec/dummy/config/environments/development.rb +74 -0
  287. data/spec/dummy/config/environments/production.rb +103 -0
  288. data/spec/dummy/config/environments/staging.rb +103 -0
  289. data/spec/dummy/config/environments/test.rb +65 -0
  290. data/spec/dummy/config/initializers/application_controller_renderer.rb +6 -0
  291. data/spec/dummy/config/initializers/assets.rb +14 -0
  292. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  293. data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
  294. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  295. data/spec/dummy/config/initializers/inflections.rb +16 -0
  296. data/spec/dummy/config/initializers/load_config.rb +9 -0
  297. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  298. data/spec/dummy/config/initializers/react_on_rails.rb +41 -0
  299. data/spec/dummy/config/initializers/secret_token.rb +12 -0
  300. data/spec/dummy/config/initializers/sentry.rb +6 -0
  301. data/spec/dummy/config/initializers/session_store.rb +7 -0
  302. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  303. data/spec/dummy/config/locales/en.yml +8 -0
  304. data/spec/dummy/config/newrelic.yml +224 -0
  305. data/spec/dummy/config/puma.rb +47 -0
  306. data/spec/dummy/config/routes.rb +5 -0
  307. data/spec/dummy/config/secrets.yml +32 -0
  308. data/spec/dummy/config/sidekiq.yml +9 -0
  309. data/spec/dummy/config/webpack/development.js +3 -0
  310. data/spec/dummy/config/webpack/environment.js +3 -0
  311. data/spec/dummy/config/webpack/production.js +3 -0
  312. data/spec/dummy/config/webpack/test.js +3 -0
  313. data/spec/dummy/config/webpacker.yml +66 -0
  314. data/spec/dummy/db/migrate/20180118233001_enable_pgcrypto_extension.cortex.rb +6 -0
  315. data/spec/dummy/db/migrate/20180118233002_create_users.cortex.rb +15 -0
  316. data/spec/dummy/db/migrate/20180118233003_create_tenants.cortex.rb +27 -0
  317. data/spec/dummy/db/migrate/20180118233004_add_devise_to_users.cortex.rb +50 -0
  318. data/spec/dummy/db/migrate/20180118233005_create_roles.cortex.rb +16 -0
  319. data/spec/dummy/db/migrate/20180118233006_create_permissions.cortex.rb +17 -0
  320. data/spec/dummy/db/migrate/20180118233007_create_flipper_tables.cortex.rb +21 -0
  321. data/spec/dummy/db/migrate/20180118233008_create_contracts.cortex.rb +12 -0
  322. data/spec/dummy/db/migrate/20180118233009_create_decorators.cortex.rb +22 -0
  323. data/spec/dummy/db/migrate/20180118233010_create_content_types.cortex.rb +18 -0
  324. data/spec/dummy/db/migrate/20180118233011_create_fields.cortex.rb +16 -0
  325. data/spec/dummy/db/migrate/20180118233012_create_content_items.cortex.rb +15 -0
  326. data/spec/dummy/db/migrate/20180118233013_create_field_items.cortex.rb +13 -0
  327. data/spec/dummy/db/migrate/20180118233014_create_field_types.cortex.rb +6 -0
  328. data/spec/dummy/db/schema.rb +258 -0
  329. data/spec/dummy/db/seeds.rb +1 -0
  330. data/spec/dummy/lib/tasks/content_types_tasks.rake +31 -0
  331. data/spec/dummy/lib/tasks/employer/blog_tasks.rake +345 -0
  332. data/spec/dummy/package.json +28 -0
  333. data/spec/dummy/public/404.html +67 -0
  334. data/spec/dummy/public/422.html +67 -0
  335. data/spec/dummy/public/500.html +66 -0
  336. data/spec/dummy/public/robots.txt +5 -0
  337. data/spec/dummy/spec/javascripts/support/jasmine.yml +50 -0
  338. data/spec/dummy/yarn.lock +6615 -0
  339. data/spec/rails_helper.rb +57 -0
  340. data/spec/spec_helper.rb +96 -0
  341. data/yarn.lock +6032 -0
  342. metadata +1061 -0
@@ -0,0 +1,4 @@
1
+ module Cortex
2
+ class GetContentItemTransaction < Cortex::ApplicationTransaction
3
+ end
4
+ end
@@ -0,0 +1,34 @@
1
+ require 'elasticsearch/dsl'
2
+
3
+ module Cortex
4
+ class GetContentItemsForContentTypeTransaction < Cortex::ApplicationTransaction
5
+ include Elasticsearch::DSL
6
+
7
+ step :search
8
+
9
+ def search(params)
10
+ tenant_id = params[:args][:tenant_id] || params[:active_tenant].id
11
+ content_type_id = params[:content_type].id
12
+
13
+ definition = Elasticsearch::DSL::Search.search {
14
+ query do
15
+ bool do
16
+ filter do
17
+ term tenant_id: tenant_id
18
+ end
19
+ filter do
20
+ term content_type_id: content_type_id
21
+ end
22
+ end
23
+ end
24
+ sort created_at: {
25
+ order: 'desc'
26
+ }
27
+ }
28
+
29
+ results = Cortex::ContentItem.search(definition, index: params[:content_type].content_items_index_name)
30
+ # TODO: basic pagination
31
+ Success(results.records)
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,28 @@
1
+ # TODO: The entire Publish system needs to be reworked to avoid hardcoded references and data integrity issues
2
+
3
+ module Cortex
4
+ class GetPublishStateTransaction < Cortex::ApplicationTransaction
5
+ step :sort_field_items
6
+ step :process
7
+
8
+ def sort_field_items(content_item)
9
+ sorted_field_items = content_item.field_items.select do |field_item|
10
+ field_item.field.field_type_instance.is_a?(DateTimeFieldType) && !field_item.field.metadata["state"].nil?
11
+ end.sort_by {|field_item| field_item.data["timestamp"]}.reverse
12
+
13
+ Success({
14
+ sorted_field_items: sorted_field_items,
15
+ content_item: content_item
16
+ })
17
+ end
18
+
19
+ def process(input)
20
+ timestamp_field_item = input[:sorted_field_items].find do |field_item|
21
+ field_item.data['timestamp'].present? && DateTime.now > DateTime.parse(field_item.data["timestamp"])
22
+ end
23
+
24
+ active_state = timestamp_field_item ? timestamp_field_item.field.metadata["state"] : input[:content_item].state.titleize
25
+ Success(active_state)
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,16 @@
1
+ module Cortex
2
+ class NewFieldItemTransaction < Cortex::ApplicationTransaction
3
+ include Cortex::FieldItemTransactor
4
+
5
+ step :init
6
+ step :process_plugin_transaction
7
+
8
+ def init(field_item_attributes)
9
+ Success(Cortex::FieldItem.new(field_item_attributes))
10
+ end
11
+
12
+ def process_plugin_transaction(field_item)
13
+ Success(transact_new(field_item) || field_item)
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,45 @@
1
+ module Cortex
2
+ class UpdateContentItemTransaction < Cortex::ApplicationTransaction
3
+ include Dry::Transaction(container: Cortex::TransactionContainer)
4
+ include Cortex::ContentItemable
5
+
6
+ around :database_transact, with: "cortex.database_transact"
7
+ step :init
8
+ step :process
9
+ step :latest_history_patch
10
+ step :parse_content_item_field_items, with: "cortex.parse_content_item_field_items"
11
+ step :persist_content_item, with: "cortex.persist_content_item"
12
+ step :execute_content_item_state_change, with: "cortex.execute_content_item_state_change"
13
+
14
+ def init(input)
15
+ Success(ContentItemTransactionType.new(input))
16
+ end
17
+
18
+ def process(input)
19
+ if input.content_item
20
+ content_item = input.content_item
21
+ else
22
+ content_item = ContentItem.find(input.id)
23
+ field_items_attributes(input.content_item_params).each do |_key, field_item_attributes|
24
+ content_item.field_items << UpdateFieldItemTransaction.new.call(field_item_attributes).value!
25
+ end
26
+
27
+ input.content_item_params.delete('field_items_attributes')
28
+ content_item.assign_attributes(input.content_item_params)
29
+ end
30
+
31
+ Success({
32
+ content_item: content_item,
33
+ current_user: input.current_user
34
+ })
35
+ end
36
+
37
+ def latest_history_patch(input)
38
+ history_patch = {}
39
+ history_patch.merge! last_updated_by(input[:current_user])
40
+
41
+ input[:content_item].assign_attributes(history_patch)
42
+ Success(input[:content_item])
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,23 @@
1
+ module Cortex
2
+ class UpdateFieldItemTransaction < Cortex::ApplicationTransaction
3
+ include Cortex::FieldItemTransactor
4
+
5
+ step :init
6
+ step :process_plugin_transaction
7
+
8
+ def init(field_item_attributes)
9
+ field_item = FieldItem.find_by_id(field_item_attributes['id'])
10
+
11
+ if field_item
12
+ field_item.assign_attributes(field_item_attributes)
13
+ Success(field_item)
14
+ else
15
+ Failure(:not_found)
16
+ end
17
+ end
18
+
19
+ def process_plugin_transaction(field_item)
20
+ Success(transact_update(field_item) || field_item)
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,21 @@
1
+ module Cortex
2
+ module ApplicationTypes
3
+ User = Dry::Types::Definition.new(::Cortex::User)
4
+ Users = CoreTypes::Strict::Array.of(ApplicationTypes::User)
5
+
6
+ ContentType = Dry::Types::Definition.new(::Cortex::ContentType)
7
+ ContentTypes = CoreTypes::Strict::Array.of(ApplicationTypes::ContentType)
8
+
9
+ ContentItem = Dry::Types::Definition.new(::Cortex::ContentItem)
10
+ ContentItems = CoreTypes::Strict::Array.of(ApplicationTypes::ContentItem)
11
+
12
+ FieldType = Dry::Types::Definition.new(::Cortex::FieldType)
13
+ FieldTypes = CoreTypes::Strict::Array.of(ApplicationTypes::FieldType)
14
+
15
+ FieldItem = Dry::Types::Definition.new(::Cortex::UpdateFieldItemTransaction)
16
+ FieldItems = CoreTypes::Strict::Array.of(ApplicationTypes::FieldItem)
17
+
18
+ Field = Dry::Types::Definition.new(::Cortex::Field)
19
+ Fields = CoreTypes::Strict::Array.of(ApplicationTypes::Field)
20
+ end
21
+ end
@@ -0,0 +1,10 @@
1
+ module Cortex
2
+ class ContentItemTransactionType < TransactionType
3
+ attribute :id, CoreTypes::Strict::String.optional.meta(omittable: true)
4
+ attribute :content_type, ApplicationTypes::ContentType
5
+ attribute :content_item, ApplicationTypes::ContentItem.optional.meta(omittable: true)
6
+ attribute :content_item_params, CoreTypes::Coercible::Hash.optional.meta(omittable: true)
7
+ attribute :current_user, ApplicationTypes::User
8
+ attribute :state, CoreTypes::Strict::String.optional.meta(omittable: true)
9
+ end
10
+ end
@@ -0,0 +1,5 @@
1
+ module Cortex
2
+ module CoreTypes
3
+ include Dry::Types.module
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ module Cortex
2
+ class TransactionType < Dry::Struct
3
+ attr_reader :errors
4
+ end
5
+ end
@@ -0,0 +1,13 @@
1
+ .mdl-color-text--grey-800.mdl-cell.mdl-cell--4-col.mdl-cell--12-col-tablet
2
+ .mdl-grid.mdl-card
3
+ .mdl-cell.mdl-cell--12-col
4
+ %h2 Forgot your password?
5
+ = form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f|
6
+ = devise_error_messages!
7
+ .field
8
+ = f.label :email
9
+ %br/
10
+ = f.email_field :email, autofocus: true
11
+ .actions
12
+ = f.submit "Send me reset password instructions"
13
+ = render 'cortex/authentication/shared/links'
@@ -0,0 +1,20 @@
1
+ .mdl-cell.mdl-cell--4-col.mdl-cell--12-col-tablet
2
+ .mdl-grid.mdl-card
3
+ .mdl-cell.mdl-cell--12-col
4
+ = form_for(resource, as: resource_name, url: session_path(resource_name)) do |f|
5
+ .mdl-textfield.mdl-js-textfield
6
+ = f.email_field :email, autofocus: true, class: 'mdl-textfield__input'
7
+ = f.label :email, class: 'mdl-textfield__label'
8
+ .mdl-textfield.mdl-js-textfield
9
+ = f.password_field :password, autocomplete: "off", class: 'mdl-textfield__input'
10
+ = f.label :password, class: 'mdl-textfield__label'
11
+ - if devise_mapping.rememberable?
12
+ = f.label :remember_me, class: 'mdl-switch mdl-js-switch mdl-js-ripple-effect' do
13
+ = f.check_box :remember_me, value: true, class: 'mdl-switch__input'
14
+ %span.mdl-switch__label
15
+ Keep me logged in
16
+ %br/
17
+ %br/
18
+
19
+ = f.submit "Log in", class: 'mdl-button mdl-js-button mdl-button--raised mdl-button--colored'
20
+ = render 'cortex/authentication/shared/links'
@@ -0,0 +1,19 @@
1
+ - if controller_name != 'sessions'
2
+ = link_to "Log in", new_session_path(resource_name), class: 'mdl-button mdl-js-button mdl-js-ripple-effect'
3
+ %br/
4
+ - if devise_mapping.registerable? && controller_name != 'registrations'
5
+ = link_to "Sign up", new_registration_path(resource_name), class: 'mdl-button mdl-js-button mdl-js-ripple-effect'
6
+ %br/
7
+ - if devise_mapping.recoverable? && controller_name != 'passwords' && controller_name != 'registrations'
8
+ = link_to "Forgot your password?", new_password_path(resource_name), class: 'mdl-button mdl-js-button mdl-js-ripple-effect'
9
+ %br/
10
+ - if devise_mapping.confirmable? && controller_name != 'confirmations'
11
+ = link_to "Didn't receive confirmation instructions?", new_confirmation_path(resource_name), class: 'mdl-button mdl-js-button mdl-js-ripple-effect'
12
+ %br/
13
+ - if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks'
14
+ = link_to "Didn't receive unlock instructions?", new_unlock_path(resource_name), class: 'mdl-button mdl-js-button mdl-js-ripple-effect'
15
+ %br/
16
+ - if devise_mapping.omniauthable?
17
+ - resource_class.omniauth_providers.each do |provider|
18
+ = link_to "Sign in with #{OmniAuth::Utils.camelize(provider)}", omniauth_authorize_path(resource_name, provider), class: 'mdl-button mdl-js-button mdl-js-ripple-effect'
19
+ %br/
@@ -0,0 +1,13 @@
1
+ = form_for [@content_type, @content_item], html: { multipart: true } do |form|
2
+ = form.hidden_field :creator_id, value: current_user.id
3
+ = form.hidden_field :content_type_id, value: @content_type.id
4
+ -# TODO: remove conditional once cortex plugins fields are properly converted
5
+ - if @content_type.name == 'Media'
6
+ = react_component('CortexApp', props: { temporary_render: 'Wizard' })
7
+ - else
8
+ = cell(Cortex::WizardCell, @wizard, context: { content_item: @content_item, form: form }).()
9
+
10
+ %footer.mdl-grid
11
+ .mdl-cell.mdl-cell--12-col
12
+ = form.button 'Save Now', value: @content_item.state || 'draft', name: 'content_item[state]', class: 'mdl-button form-button--submission mdl-js-button mdl-button--raised mdl-button--success mdl-js-ripple-effect', type: 'submit'
13
+ = link_to 'Cancel', content_type_content_items_path(@content_type), class: 'mdl-button mdl-js-button mdl-button--cb mdl-js-ripple-effect'
@@ -0,0 +1 @@
1
+ = cell(Cortex::IndexCell, @index, context: { content_type: content_type, content_items: @content_items }).(:index)
@@ -0,0 +1,2 @@
1
+ %section
2
+ = render "form"
@@ -0,0 +1,4 @@
1
+ = link_to new_content_type_content_item_path(content_type), id: "view-source", class: "mdl-button mdl-js-button mdl-button--fab mdl-js-ripple-effect mdl-button--colored" do
2
+ %i.material-icons add
3
+
4
+ = render 'grid'
@@ -0,0 +1,2 @@
1
+ %section
2
+ = render "form"
@@ -0,0 +1,2 @@
1
+ = link_to new_content_type_path, id: "view-source", class: "mdl-button mdl-js-button mdl-button--fab mdl-js-ripple-effect mdl-button--colored" do
2
+ %i.material-icons add
File without changes
@@ -0,0 +1,6 @@
1
+ = render 'cortex/partials/quick_links'
2
+
3
+ - unless news_feed.blank?
4
+ .mdl-grid
5
+ .mdl-cell.mdl-cell--12-col
6
+ = render 'cortex/partials/notes'
@@ -0,0 +1 @@
1
+ %iframe{src: graphiql_path, frameborder: 0, width: '100%', height: '100%'}
@@ -0,0 +1,2 @@
1
+ %span.mdl-layout-title
2
+ = render_breadcrumbs
@@ -0,0 +1 @@
1
+ = redux_store('CortexStore', props: cortex_props )
@@ -0,0 +1,25 @@
1
+ - flash.each do |key, value|
2
+ - unless value == 'You need to sign in or sign up before continuing.'
3
+ - if flash['warning']
4
+ .mdl-snackbar.snackbar__error.mdl-snackbar--active.flash--warning{ 'aria-atomic' => 'true', 'aria-live' => 'assertive', 'aria-relevant' => 'text' }
5
+ %i.mdl-snackbar__close.material-icons close
6
+ .mdl-snackbar__text
7
+ %p.flash--header__text
8
+ Oops! Please review the following fields for errors:
9
+ %ul
10
+ - value.each do |err|
11
+ %li
12
+ %i.material-icons error_outline
13
+ = err
14
+ %button.mdl-snackbar__action{ type: 'button' }
15
+ - elsif flash['success']
16
+ .mdl-snackbar.mdl-js-snackbar.snackbar__message.mdl-snackbar--active.flash--success{ 'aria-atomic' => 'true', 'aria-live' => 'assertive', 'aria-relevant' => 'text' }
17
+ .mdl-snackbar__text
18
+ %i.material-icons check
19
+ = value
20
+ %button.mdl-snackbar__action{ type: 'button' }
21
+ - else
22
+ .mdl-snackbar.mdl-js-snackbar.mdl-snackbar--active{ 'aria-atomic' => 'true', 'aria-live' => 'assertive', 'aria-relevant' => 'text' }
23
+ .mdl-snackbar__text
24
+ = value
25
+ %button.mdl-snackbar__action{ type: 'button' }
@@ -0,0 +1,13 @@
1
+ - if @content_item
2
+ %dialog.mdl-dialog#wysiwyg
3
+ %h4.mdl-dialog__title Insert Media
4
+ .mdl-dialog__content
5
+ = cell(Cortex::IndexCell, media_index, context: { content_type: content_type, content_items: media_content_items, popup: 'wysiwyg' }).(:index)
6
+ .mdl-dialog__actions
7
+ .mdl-button.mdl-js-button.mdl-button--raised.close-dialog Close
8
+ %dialog.mdl-dialog#featured
9
+ %h4.mdl-dialog__title Select Media
10
+ .mdl-dialog__content
11
+ = cell(Cortex::IndexCell, media_index, context: { content_type: content_type, content_items: media_image_content_items, popup: 'featured' }).(:index)
12
+ .mdl-dialog__actions
13
+ .mdl-button.mdl-js-button.mdl-button--raised.close-dialog Close
@@ -0,0 +1,15 @@
1
+ %nav.demo-navigation.mdl-navigation
2
+ = link_to dashboards_path, class: "mdl-navigation__link #{'active' if current_page?(dashboards_path) }" do
3
+ %i.material-icons{role: 'presentation'}> dashboard
4
+ %span.nav__item-name
5
+ Dashboard
6
+ = cell(Cortex::ContentTypeCell, collection: current_user.active_tenant.all_up_organization_for(Cortex::ContentType)).(:nav)
7
+ .mdl-layout-spacer
8
+ = link_to graphql_ide_path, class: 'mdl-navigation__link' do
9
+ %i.material-icons{role: 'presentation'} code
10
+ %span.nav__item-name
11
+ GraphQL IDE
12
+ = link_to 'https://docs.cortexcms.org/', class: 'mdl-navigation__link', target: '_blank' do
13
+ %i.material-icons{role: 'presentation'} help_outline
14
+ %span.nav__item-name
15
+ Documentation
@@ -0,0 +1,17 @@
1
+ %table.notes.mdl-data-table.mdl-js-data-table
2
+ %thead
3
+ %tr
4
+ %th.mdl-data-table__cell--non-numeric
5
+ %i.material-icons.f-left.m-r-5 content_paste
6
+ %span.notes__header Notes
7
+ %th
8
+ %tbody
9
+ - news_feed.each do |post|
10
+ %tr
11
+ %td.mdl-data-table__cell--non-numeric
12
+ = post.body.html_safe
13
+ %td
14
+ - post.tags.each do |tag|
15
+ %span.mdl-chip
16
+ %span.mdl-chip__text
17
+ = tag
@@ -0,0 +1,22 @@
1
+ %section.quick-links.mdl-grid
2
+ - if employer_blog_content_type
3
+ .mdl-cell.mdl-cell--6-col
4
+ = link_to new_content_type_content_item_path(employer_blog_content_type) do
5
+ .jumbo-button
6
+ %span.jumbo-button__content
7
+ %p.jumbo-button__content__icon
8
+ = image_tag 'cortex/icons/blog.png'
9
+ %p.jumbo-button__content__add
10
+ = image_tag 'cortex/icons/add.svg'
11
+ %p Create a New Post
12
+
13
+ - if media_content_type
14
+ .mdl-cell.mdl-cell--6-col
15
+ = link_to new_content_type_content_item_path(media_content_type) do
16
+ .jumbo-button
17
+ %span.jumbo-button__content
18
+ %p.jumbo-button__content__icon
19
+ = image_tag 'cortex/icons/media.png'
20
+ %p.jumbo-button__content__add
21
+ = image_tag 'cortex/icons/add.svg'
22
+ %p Upload Media
@@ -0,0 +1,7 @@
1
+ .layout__sidebar.mdl-layout__drawer
2
+ %header.sidebar__header
3
+ = link_to cortex.root_path, class: 'sidebar__root-link' do
4
+ = image_tag 'cortex/logo.svg', class: 'sidebar__brand-logo'
5
+ %h1.sidebar__brand-name Cortex
6
+ = render 'cortex/partials/navigation'
7
+ = react_component('CortexApp', props: { temporary_render: 'TenantSwitcher' })
@@ -0,0 +1,5 @@
1
+ %header.mdl-layout__header
2
+ .mdl-layout__header-row
3
+ = render 'cortex/partials/breadcrumb'
4
+ .mdl-layout-spacer
5
+ = render 'cortex/partials/user_control'