headmin 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (175) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +13 -0
  3. data/.nvmrc +1 -0
  4. data/.rubocop.yml +13 -0
  5. data/.ruby-version +1 -0
  6. data/CHANGELOG.md +5 -0
  7. data/CODE_OF_CONDUCT.md +84 -0
  8. data/Gemfile +12 -0
  9. data/Gemfile.lock +43 -0
  10. data/LICENSE.txt +21 -0
  11. data/README.md +166 -0
  12. data/Rakefile +16 -0
  13. data/app/assets/images/avatar.jpg +0 -0
  14. data/app/controllers/admin/users/confirmations_controller.rb +31 -0
  15. data/app/controllers/admin/users/omniauth_callbacks_controller.rb +31 -0
  16. data/app/controllers/admin/users/passwords_controller.rb +35 -0
  17. data/app/controllers/admin/users/registrations_controller.rb +63 -0
  18. data/app/controllers/admin/users/sessions_controller.rb +28 -0
  19. data/app/controllers/admin/users/unlocks_controller.rb +31 -0
  20. data/app/controllers/concerns/headmin/acts_as_list.rb +16 -0
  21. data/app/controllers/concerns/headmin/authentication.rb +17 -0
  22. data/app/controllers/concerns/headmin/ckeditor.rb +27 -0
  23. data/app/controllers/concerns/headmin/filter.rb +5 -0
  24. data/app/controllers/concerns/headmin/pagination.rb +23 -0
  25. data/app/controllers/concerns/headmin/searchable.rb +15 -0
  26. data/app/controllers/concerns/headmin/sortable.rb +44 -0
  27. data/app/helpers/headmin/admin_helper.rb +65 -0
  28. data/app/helpers/headmin/filter_helper.rb +12 -0
  29. data/app/helpers/headmin/notification_helper.rb +31 -0
  30. data/app/views/admin/users/confirmations/new.html.erb +9 -0
  31. data/app/views/admin/users/mailer/confirmation_instructions.html.erb +5 -0
  32. data/app/views/admin/users/mailer/email_changed.html.erb +7 -0
  33. data/app/views/admin/users/mailer/password_change.html.erb +3 -0
  34. data/app/views/admin/users/mailer/reset_password_instructions.html.erb +8 -0
  35. data/app/views/admin/users/mailer/unlock_instructions.html.erb +7 -0
  36. data/app/views/admin/users/passwords/edit.html.erb +12 -0
  37. data/app/views/admin/users/passwords/new.html.erb +9 -0
  38. data/app/views/admin/users/registrations/edit.html.erb +24 -0
  39. data/app/views/admin/users/registrations/new.html.erb +11 -0
  40. data/app/views/admin/users/sessions/new.html.erb +13 -0
  41. data/app/views/admin/users/shared/_error_messages.html.erb +7 -0
  42. data/app/views/admin/users/shared/_links.html.erb +27 -0
  43. data/app/views/admin/users/unlocks/new.html.erb +10 -0
  44. data/app/views/headmin/_breadcrumbs.html.erb +23 -0
  45. data/app/views/headmin/_filters.html.erb +47 -0
  46. data/app/views/headmin/_form.html.erb +11 -0
  47. data/app/views/headmin/_heading.html.erb +9 -0
  48. data/app/views/headmin/_index.html.erb +12 -0
  49. data/app/views/headmin/_notifications.html.erb +12 -0
  50. data/app/views/headmin/_pagination.html.erb +13 -0
  51. data/app/views/headmin/_table.html.erb +13 -0
  52. data/app/views/headmin/filters/_date.html.erb +46 -0
  53. data/app/views/headmin/filters/_search.html.erb +22 -0
  54. data/app/views/headmin/filters/_select.html.erb +39 -0
  55. data/app/views/headmin/filters/filter/_button.html.erb +22 -0
  56. data/app/views/headmin/filters/filter/_menu_item.html.erb +12 -0
  57. data/app/views/headmin/filters/filter/_template.html.erb +13 -0
  58. data/app/views/headmin/forms/_actions.html.erb +32 -0
  59. data/app/views/headmin/forms/_errors.html.erb +20 -0
  60. data/app/views/headmin/forms/_group.html.erb +36 -0
  61. data/app/views/headmin/forms/fields/_checkbox.html.erb +23 -0
  62. data/app/views/headmin/forms/fields/_ckeditor.html.erb +28 -0
  63. data/app/views/headmin/forms/fields/_currency.html.erb +24 -0
  64. data/app/views/headmin/forms/fields/_date.html.erb +36 -0
  65. data/app/views/headmin/forms/fields/_email.html.erb +39 -0
  66. data/app/views/headmin/forms/fields/_file.html.erb +24 -0
  67. data/app/views/headmin/forms/fields/_image.html.erb +37 -0
  68. data/app/views/headmin/forms/fields/_label.html.erb +9 -0
  69. data/app/views/headmin/forms/fields/_multiple_select.html.erb +37 -0
  70. data/app/views/headmin/forms/fields/_password.html.erb +39 -0
  71. data/app/views/headmin/forms/fields/_repeater.html.erb +48 -0
  72. data/app/views/headmin/forms/fields/_select.html.erb +36 -0
  73. data/app/views/headmin/forms/fields/_select_tags.html.erb +32 -0
  74. data/app/views/headmin/forms/fields/_text.html.erb +39 -0
  75. data/app/views/headmin/forms/fields/_textarea.html.erb +29 -0
  76. data/app/views/headmin/forms/fields/_url.html.erb +38 -0
  77. data/app/views/headmin/forms/fields/_validation.html.erb +12 -0
  78. data/app/views/headmin/forms/fields/repeater/_row.html.erb +16 -0
  79. data/app/views/headmin/heading/_title.html.erb +24 -0
  80. data/app/views/headmin/kaminari/_first_page.html.erb +11 -0
  81. data/app/views/headmin/kaminari/_gap.html.erb +12 -0
  82. data/app/views/headmin/kaminari/_last_page.html.erb +12 -0
  83. data/app/views/headmin/kaminari/_next_page.html.erb +13 -0
  84. data/app/views/headmin/kaminari/_page.html.erb +12 -0
  85. data/app/views/headmin/kaminari/_paginator.html.erb +25 -0
  86. data/app/views/headmin/kaminari/_prev_page.html.erb +11 -0
  87. data/app/views/headmin/layout/_body.html.erb +9 -0
  88. data/app/views/headmin/layout/_content.html.erb +9 -0
  89. data/app/views/headmin/layout/_footer.html.erb +17 -0
  90. data/app/views/headmin/layout/_header.html.erb +13 -0
  91. data/app/views/headmin/layout/_main.html.erb +13 -0
  92. data/app/views/headmin/layout/_sidebar.html.erb +20 -0
  93. data/app/views/headmin/layout/dropdown/_divider.html.erb +9 -0
  94. data/app/views/headmin/layout/dropdown/_item.html.erb +17 -0
  95. data/app/views/headmin/layout/header/_account.html.erb +25 -0
  96. data/app/views/headmin/layout/header/_locale.html.erb +19 -0
  97. data/app/views/headmin/layout/sidebar/_bottom.html.erb +4 -0
  98. data/app/views/headmin/layout/sidebar/_menu.html.erb +9 -0
  99. data/app/views/headmin/layout/sidebar/menu/_account.html.erb +25 -0
  100. data/app/views/headmin/layout/sidebar/menu/_item.html.erb +16 -0
  101. data/app/views/headmin/layout/sidebar/menu/_locale.html.erb +18 -0
  102. data/app/views/headmin/table/_actions.html.erb +19 -0
  103. data/app/views/headmin/table/_body.html.erb +19 -0
  104. data/app/views/headmin/table/_foot.html.erb +15 -0
  105. data/app/views/headmin/table/_footer.html.erb +13 -0
  106. data/app/views/headmin/table/_head.html.erb +15 -0
  107. data/app/views/headmin/table/_header.html.erb +13 -0
  108. data/app/views/headmin/table/actions/_action.html.erb +10 -0
  109. data/app/views/headmin/table/actions/_delete.html.erb +8 -0
  110. data/app/views/headmin/table/actions/_export.html.erb +8 -0
  111. data/app/views/headmin/table/body/_association.html.erb +11 -0
  112. data/app/views/headmin/table/body/_boolean.erb +16 -0
  113. data/app/views/headmin/table/body/_currency.html.erb +10 -0
  114. data/app/views/headmin/table/body/_date.html.erb +11 -0
  115. data/app/views/headmin/table/body/_id.html.erb +3 -0
  116. data/app/views/headmin/table/body/_row.html.erb +9 -0
  117. data/app/views/headmin/table/body/_sort.html.erb +3 -0
  118. data/app/views/headmin/table/body/_string.html.erb +16 -0
  119. data/app/views/headmin/table/body/_text.html.erb +10 -0
  120. data/app/views/headmin/table/foot/_cell.html.erb +10 -0
  121. data/app/views/headmin/table/foot/_id.html.erb +9 -0
  122. data/app/views/headmin/table/head/_cell.html.erb +13 -0
  123. data/app/views/headmin/table/head/_empty.html.erb +1 -0
  124. data/app/views/headmin/table/head/_id.html.erb +9 -0
  125. data/app/views/headmin/table/head/_sort.html.erb +3 -0
  126. data/app/views/headmin/table/head/cell/_asc.html.erb +4 -0
  127. data/app/views/headmin/table/head/cell/_default.html.erb +7 -0
  128. data/app/views/headmin/table/head/cell/_desc.html.erb +4 -0
  129. data/app/views/layouts/admin/auth.html.erb +20 -0
  130. data/app/views/layouts/admin.html.erb +42 -0
  131. data/bin/console +15 -0
  132. data/bin/setup +8 -0
  133. data/config/locales/defaults/en.yml +215 -0
  134. data/config/locales/defaults/nl.yml +213 -0
  135. data/config/locales/devise/nl.yml +85 -0
  136. data/config/locales/en.yml +137 -0
  137. data/config/locales/nl.yml +138 -0
  138. data/dist/css/headmin.css +9874 -0
  139. data/dist/js/headmin.js +852 -0
  140. data/docs/README.md +4 -0
  141. data/docs/blocks.md +116 -0
  142. data/docs/devise.md +62 -0
  143. data/headmin.gemspec +35 -0
  144. data/lib/headmin/engine.rb +10 -0
  145. data/lib/headmin/version.rb +5 -0
  146. data/lib/headmin.rb +4 -0
  147. data/package.json +62 -0
  148. data/src/js/headmin/controllers/filter_controller.js +47 -0
  149. data/src/js/headmin/controllers/filters_controller.js +53 -0
  150. data/src/js/headmin/controllers/index_controller.js +79 -0
  151. data/src/js/headmin/controllers/repeater_controller.js +35 -0
  152. data/src/js/headmin/controllers/repeater_row_controller.js +54 -0
  153. data/src/js/headmin/controllers/table_actions_controller.js +22 -0
  154. data/src/js/headmin/controllers/table_controller.js +36 -0
  155. data/src/js/headmin/headmin.js +168 -0
  156. data/src/js/headmin.js +1 -0
  157. data/src/scss/headmin/filter.scss +33 -0
  158. data/src/scss/headmin/filters.scss +14 -0
  159. data/src/scss/headmin/form.scss +39 -0
  160. data/src/scss/headmin/general.scss +3 -0
  161. data/src/scss/headmin/layout/body.scss +6 -0
  162. data/src/scss/headmin/layout/sidebar.scss +22 -0
  163. data/src/scss/headmin/layout.scss +2 -0
  164. data/src/scss/headmin/login.scss +35 -0
  165. data/src/scss/headmin/table.scss +32 -0
  166. data/src/scss/headmin/utilities.scss +19 -0
  167. data/src/scss/headmin.scss +58 -0
  168. data/src/scss/vendor/bootstrap/variables.scss +71 -0
  169. data/src/scss/vendor/choices/cross-inverse.svg +6 -0
  170. data/src/scss/vendor/choices/cross.svg +6 -0
  171. data/src/scss/vendor/choices/custom.scss +28 -0
  172. data/src/scss/vendor/choices/variables.scss +16 -0
  173. data/webpack.config.js +30 -0
  174. data/yarn.lock +7512 -0
  175. metadata +220 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: f9f3322a28300a8474d9e3eb6de7426ffc1e29ce1d335538acecc185b7a0a622
4
+ data.tar.gz: c8ed8550f75532b996fe507407abf724f0899e0db61d1881a2320ff97a0fa0fe
5
+ SHA512:
6
+ metadata.gz: 252e757eb913f233271e7b41f474dada9913446af1ef48cc2b2d55d435e2d5b9dfab8199c18ebbb6a19cd260541ea1c1bc996bf1feecd9d8ee67a779ada5a1d3
7
+ data.tar.gz: 0d7c2ec678aea04c6317af5117d91ca622f08754a532d7baa93478925d509bf569783d828ea4b43053aca2d48c427bf6b13fd4e07701c32b8fa363a239efcf39
data/.gitignore ADDED
@@ -0,0 +1,13 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+ /node_modules/
10
+
11
+ # Ingore editors
12
+ /.idea
13
+ /headmin.iml
data/.nvmrc ADDED
@@ -0,0 +1 @@
1
+ lts/*
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.4
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 120
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-3.0.0
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.0.1] - 2021-03-14
4
+
5
+ - Initial release
@@ -0,0 +1,84 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our community a harassment-free experience for everyone, regardless of age, body size, visible or invisible disability, ethnicity, sex characteristics, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.
6
+
7
+ We pledge to act and interact in ways that contribute to an open, welcoming, diverse, inclusive, and healthy community.
8
+
9
+ ## Our Standards
10
+
11
+ Examples of behavior that contributes to a positive environment for our community include:
12
+
13
+ * Demonstrating empathy and kindness toward other people
14
+ * Being respectful of differing opinions, viewpoints, and experiences
15
+ * Giving and gracefully accepting constructive feedback
16
+ * Accepting responsibility and apologizing to those affected by our mistakes, and learning from the experience
17
+ * Focusing on what is best not just for us as individuals, but for the overall community
18
+
19
+ Examples of unacceptable behavior include:
20
+
21
+ * The use of sexualized language or imagery, and sexual attention or
22
+ advances of any kind
23
+ * Trolling, insulting or derogatory comments, and personal or political attacks
24
+ * Public or private harassment
25
+ * Publishing others' private information, such as a physical or email
26
+ address, without their explicit permission
27
+ * Other conduct which could reasonably be considered inappropriate in a
28
+ professional setting
29
+
30
+ ## Enforcement Responsibilities
31
+
32
+ Community leaders are responsible for clarifying and enforcing our standards of acceptable behavior and will take appropriate and fair corrective action in response to any behavior that they deem inappropriate, threatening, offensive, or harmful.
33
+
34
+ Community leaders have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, and will communicate reasons for moderation decisions when appropriate.
35
+
36
+ ## Scope
37
+
38
+ This Code of Conduct applies within all community spaces, and also applies when an individual is officially representing the community in public spaces. Examples of representing our community include using an official e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event.
39
+
40
+ ## Enforcement
41
+
42
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at vlamingsjef@gmail.com. All complaints will be reviewed and investigated promptly and fairly.
43
+
44
+ All community leaders are obligated to respect the privacy and security of the reporter of any incident.
45
+
46
+ ## Enforcement Guidelines
47
+
48
+ Community leaders will follow these Community Impact Guidelines in determining the consequences for any action they deem in violation of this Code of Conduct:
49
+
50
+ ### 1. Correction
51
+
52
+ **Community Impact**: Use of inappropriate language or other behavior deemed unprofessional or unwelcome in the community.
53
+
54
+ **Consequence**: A private, written warning from community leaders, providing clarity around the nature of the violation and an explanation of why the behavior was inappropriate. A public apology may be requested.
55
+
56
+ ### 2. Warning
57
+
58
+ **Community Impact**: A violation through a single incident or series of actions.
59
+
60
+ **Consequence**: A warning with consequences for continued behavior. No interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, for a specified period of time. This includes avoiding interactions in community spaces as well as external channels like social media. Violating these terms may lead to a temporary or permanent ban.
61
+
62
+ ### 3. Temporary Ban
63
+
64
+ **Community Impact**: A serious violation of community standards, including sustained inappropriate behavior.
65
+
66
+ **Consequence**: A temporary ban from any sort of interaction or public communication with the community for a specified period of time. No public or private interaction with the people involved, including unsolicited interaction with those enforcing the Code of Conduct, is allowed during this period. Violating these terms may lead to a permanent ban.
67
+
68
+ ### 4. Permanent Ban
69
+
70
+ **Community Impact**: Demonstrating a pattern of violation of community standards, including sustained inappropriate behavior, harassment of an individual, or aggression toward or disparagement of classes of individuals.
71
+
72
+ **Consequence**: A permanent ban from any sort of public interaction within the community.
73
+
74
+ ## Attribution
75
+
76
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.0,
77
+ available at https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
78
+
79
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder](https://github.com/mozilla/diversity).
80
+
81
+ [homepage]: https://www.contributor-covenant.org
82
+
83
+ For answers to common questions about this code of conduct, see the FAQ at
84
+ https://www.contributor-covenant.org/faq. Translations are available at https://www.contributor-covenant.org/translations.
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in headmin.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "minitest", "~> 5.0"
11
+
12
+ gem "rubocop", "~> 1.7"
data/Gemfile.lock ADDED
@@ -0,0 +1,43 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ headmin (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ ast (2.4.2)
10
+ minitest (5.14.4)
11
+ parallel (1.20.1)
12
+ parser (3.0.0.0)
13
+ ast (~> 2.4.1)
14
+ rainbow (3.0.0)
15
+ rake (13.0.3)
16
+ regexp_parser (2.1.1)
17
+ rexml (3.2.4)
18
+ rubocop (1.11.0)
19
+ parallel (~> 1.10)
20
+ parser (>= 3.0.0.0)
21
+ rainbow (>= 2.2.2, < 4.0)
22
+ regexp_parser (>= 1.8, < 3.0)
23
+ rexml
24
+ rubocop-ast (>= 1.2.0, < 2.0)
25
+ ruby-progressbar (~> 1.7)
26
+ unicode-display_width (>= 1.4.0, < 3.0)
27
+ rubocop-ast (1.4.1)
28
+ parser (>= 2.7.1.5)
29
+ ruby-progressbar (1.11.0)
30
+ unicode-display_width (2.0.0)
31
+
32
+ PLATFORMS
33
+ x86_64-darwin-19
34
+ x86_64-darwin-20
35
+
36
+ DEPENDENCIES
37
+ headmin!
38
+ minitest (~> 5.0)
39
+ rake (~> 13.0)
40
+ rubocop (~> 1.7)
41
+
42
+ BUNDLED WITH
43
+ 2.2.14
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2021 Jef Vlamings
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,166 @@
1
+ # Headmin
2
+ A complete library of commonly used components to build an admin interface in your Ruby on Rails project.
3
+
4
+ For information about different features: [click here](docs/README.md)
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ gem 'headmin'
12
+ ```
13
+
14
+ And then execute:
15
+
16
+ ```shell
17
+ $ bundle install
18
+ ```
19
+
20
+ Add headmin to list of node modules
21
+
22
+ ```shell
23
+ $ yarn add headmin
24
+ ```
25
+ ## Usage
26
+ Add the Headmin helpers to the Admin helper file
27
+ ```ruby
28
+ module AdminHelper
29
+ include Headmin::AdminHelper
30
+ end
31
+ ```
32
+
33
+ Import the Headmin class into your script.
34
+ ```js
35
+ import {Headmin} from 'headmin'
36
+
37
+ document.addEventListener("DOMContentLoaded", function () {
38
+ Headmin.start()
39
+ })
40
+ ```
41
+
42
+ Finally import Headmin in your stylesheet.
43
+ ```scss
44
+ @import '~headmin/src/scss/headmin.scss';
45
+ ```
46
+
47
+ ## Development
48
+ For development purposes it's helpful to have both the test project and Headmin located in the same directory.
49
+
50
+ There are 2 ways of working locally:
51
+ 1. **Configure package managers (preferred)**: setup bundler and yarn to look for local checkouts
52
+ 2. **Use relative paths**: refer to Headmin by it's relative path
53
+
54
+ ### Solution #1: Configure package managers (preferred)
55
+ This is the preferred way because you can develop locally, and deploy in a staging environment without changing configurations.
56
+
57
+ Force bundler to use the local gem with:
58
+ ```shell
59
+ bundle config local.headmin /usr/local/var/www/headmin
60
+ ```
61
+ In your Gemfile you need to refer to the feature branch you're working on
62
+ ```ruby
63
+ gem 'headmin', git: 'git@github.com:insiting/headmin.git', branch: 'feature/test'
64
+ ```
65
+
66
+ Symlink the headmin node module like this.
67
+
68
+ In your Headmin directory:
69
+ ```shell
70
+ yarn link
71
+ ```
72
+
73
+ In your project directory
74
+ ```shell
75
+ yarn link headmin
76
+ ```
77
+
78
+ ### Solution #2: Use relative paths
79
+ We don't prefer this solution because you have to switch sources regularly in Gemfile or package.json for each deployment.
80
+
81
+
82
+ In Gemfile
83
+ ```ruby
84
+ gem "headmin", path: "../headmin"
85
+ ```
86
+
87
+ In package.json
88
+ ```json
89
+ {
90
+ "dependencies": {
91
+ "bar": "file:../headmin"
92
+ }
93
+ }
94
+ ```
95
+
96
+ ## Testing
97
+ If you want to test a specific feature in a staging environment without releasing the gem, you can refer to the remote repo in your Gemfile and package.json.
98
+
99
+ In Gemfile
100
+ ```ruby
101
+ gem 'headmin', git: 'git@github.com:insiting/headmin.git', branch: 'feature/test'
102
+ ```
103
+
104
+ In package.json
105
+ ```json
106
+ {
107
+ "dependencies": {
108
+ "headmin": "ssh://git@github.com:insiting/headmin.git#feature\/test"
109
+ }
110
+ }
111
+
112
+ ```
113
+
114
+ ## Releasing
115
+ After integration a new feature of fixing a bug, first commit and push your changes.
116
+
117
+ Build the assets for production
118
+ ```shell
119
+ $ nvm use
120
+ $ yarn build
121
+ ```
122
+
123
+ Update the version number of the gem
124
+
125
+ ```shell
126
+ $ gem bump -v {patch,minor,major,...} -p
127
+ $ gem tag -p
128
+ $ gem release
129
+ ```
130
+
131
+ Use the generated version number for the node module as well
132
+ ```
133
+ // In package.json
134
+
135
+ {
136
+ "name": "headmin",
137
+ "version": "{new version number here}",
138
+ ...
139
+ }
140
+
141
+ ```
142
+
143
+ ## Deployment
144
+ Update the Headmin gem to the latest version
145
+ ```shell
146
+ $ bundle update headmin
147
+ ```
148
+
149
+ Update the Headmin node module ot the latest version
150
+ ```shell
151
+ $ yarn upgrade headmin
152
+ ```
153
+
154
+ Deploy your app as usual
155
+
156
+ ## Contributing
157
+
158
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/headmin. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[USERNAME]/headmin/blob/master/CODE_OF_CONDUCT.md).
159
+
160
+ ## License
161
+
162
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
163
+
164
+ ## Code of Conduct
165
+
166
+ Everyone interacting in the Headmin project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/headmin/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rake/testtask"
5
+
6
+ Rake::TestTask.new(:test) do |t|
7
+ t.libs << "test"
8
+ t.libs << "lib"
9
+ t.test_files = FileList["test/**/*_test.rb"]
10
+ end
11
+
12
+ require "rubocop/rake_task"
13
+
14
+ RuboCop::RakeTask.new
15
+
16
+ task default: %i[test rubocop]
Binary file
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Admin::Users::ConfirmationsController < Devise::ConfirmationsController
4
+ layout 'admin/auth'
5
+ # GET /resource/confirmation/new
6
+ # def new
7
+ # super
8
+ # end
9
+
10
+ # POST /resource/confirmation
11
+ # def create
12
+ # super
13
+ # end
14
+
15
+ # GET /resource/confirmation?confirmation_token=abcdef
16
+ # def show
17
+ # super
18
+ # end
19
+
20
+ # protected
21
+
22
+ # The path used after resending confirmation instructions.
23
+ # def after_resending_confirmation_instructions_path_for(resource_name)
24
+ # super(resource_name)
25
+ # end
26
+
27
+ # The path used after confirmation.
28
+ # def after_confirmation_path_for(resource_name, resource)
29
+ # super(resource_name, resource)
30
+ # end
31
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Admin::Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController
4
+ layout 'admin/auth'
5
+ # You should configure your model like this:
6
+ # devise :omniauthable, omniauth_providers: [:twitter]
7
+
8
+ # You should also create an action method in this controller like this:
9
+ # def twitter
10
+ # end
11
+
12
+ # More info at:
13
+ # https://github.com/heartcombo/devise#omniauth
14
+
15
+ # GET|POST /resource/auth/twitter
16
+ # def passthru
17
+ # super
18
+ # end
19
+
20
+ # GET|POST /users/auth/twitter/callback
21
+ # def failure
22
+ # super
23
+ # end
24
+
25
+ # protected
26
+
27
+ # The path used when OmniAuth fails
28
+ # def after_omniauth_failure_path_for(scope)
29
+ # super(scope)
30
+ # end
31
+ end
@@ -0,0 +1,35 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Admin::Users::PasswordsController < Devise::PasswordsController
4
+ layout 'admin/auth'
5
+ # GET /resource/password/new
6
+ # def new
7
+ # super
8
+ # end
9
+
10
+ # POST /resource/password
11
+ # def create
12
+ # super
13
+ # end
14
+
15
+ # GET /resource/password/edit?reset_password_token=abcdef
16
+ # def edit
17
+ # super
18
+ # end
19
+
20
+ # PUT /resource/password
21
+ # def update
22
+ # super
23
+ # end
24
+
25
+ # protected
26
+
27
+ # def after_resetting_password_path_for(resource)
28
+ # super(resource)
29
+ # end
30
+
31
+ # The path used after sending reset password instructions
32
+ # def after_sending_reset_password_instructions_path_for(resource_name)
33
+ # super(resource_name)
34
+ # end
35
+ end
@@ -0,0 +1,63 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Admin::Users::RegistrationsController < Devise::RegistrationsController
4
+ layout 'admin/auth'
5
+ # before_action :configure_sign_up_params, only: [:create]
6
+ # before_action :configure_account_update_params, only: [:update]
7
+
8
+ # GET /resource/sign_up
9
+ # def new
10
+ # super
11
+ # end
12
+
13
+ # POST /resource
14
+ # def create
15
+ # super
16
+ # end
17
+
18
+ # GET /resource/edit
19
+ # def edit
20
+ # super
21
+ # end
22
+
23
+ # PUT /resource
24
+ # def update
25
+ # super
26
+ # end
27
+
28
+ # DELETE /resource
29
+ # def destroy
30
+ # super
31
+ # end
32
+
33
+ # GET /resource/cancel
34
+ # Forces the session data which is usually expired after sign
35
+ # in to be expired now. This is useful if the user wants to
36
+ # cancel oauth signing in/up in the middle of the process,
37
+ # removing all OAuth session data.
38
+ # def cancel
39
+ # super
40
+ # end
41
+
42
+ # protected
43
+
44
+ # If you have extra params to permit, append them to the sanitizer.
45
+ # def configure_sign_up_params
46
+ # devise_parameter_sanitizer.permit(:sign_up, keys: [:attribute])
47
+ # end
48
+
49
+ # If you have extra params to permit, append them to the sanitizer.
50
+ # def configure_account_update_params
51
+ # devise_parameter_sanitizer.permit(:account_update, keys: [:attribute])
52
+ # end
53
+
54
+ # The path used after sign up.
55
+ # def after_sign_up_path_for(resource)
56
+ # super(resource)
57
+ # end
58
+
59
+ # The path used after sign up for inactive accounts.
60
+ # def after_inactive_sign_up_path_for(resource)
61
+ # super(resource)
62
+ # end
63
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Admin::Users::SessionsController < Devise::SessionsController
4
+ layout 'admin/auth'
5
+ # before_action :configure_sign_in_params, only: [:create]
6
+
7
+ # GET /resource/sign_in
8
+ # def new
9
+ # super
10
+ # end
11
+
12
+ # POST /resource/sign_in
13
+ # def create
14
+ # super
15
+ # end
16
+
17
+ # DELETE /resource/sign_out
18
+ # def destroy
19
+ # super
20
+ # end
21
+
22
+ # protected
23
+
24
+ # If you have extra params to permit, append them to the sanitizer.
25
+ # def configure_sign_in_params
26
+ # devise_parameter_sanitizer.permit(:sign_in, keys: [:attribute])
27
+ # end
28
+ end
@@ -0,0 +1,31 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Admin::Users::UnlocksController < Devise::UnlocksController
4
+ layout 'admin/auth'
5
+ # GET /resource/unlock/new
6
+ # def new
7
+ # super
8
+ # end
9
+
10
+ # POST /resource/unlock
11
+ # def create
12
+ # super
13
+ # end
14
+
15
+ # GET /resource/unlock?unlock_token=abcdef
16
+ # def show
17
+ # super
18
+ # end
19
+
20
+ # protected
21
+
22
+ # The path used after sending unlock password instructions
23
+ # def after_sending_unlock_instructions_path_for(resource)
24
+ # super(resource)
25
+ # end
26
+
27
+ # The path used after unlocking the resource
28
+ # def after_unlock_path_for(resource)
29
+ # super(resource)
30
+ # end
31
+ end
@@ -0,0 +1,16 @@
1
+ module Headmin
2
+ module ActsAsList
3
+ def handle_positions(model:)
4
+ position_params[:ids].each_with_index do |id, index|
5
+ model.where(id: id).update_all(position: index + 1)
6
+ end
7
+ head :no_content
8
+ end
9
+
10
+ private
11
+
12
+ def position_params
13
+ params.permit(:locale, ids: [])
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,17 @@
1
+ module Headmin
2
+ module Authentication
3
+ extend ActiveSupport::Concern
4
+
5
+ included do
6
+ alias_method :devise_current_user, :current_user
7
+ before_action :authenticate_admin!
8
+
9
+ def current_user
10
+ devise_current_user || current_admin
11
+ end
12
+ end
13
+
14
+
15
+
16
+ end
17
+ end
@@ -0,0 +1,27 @@
1
+ module Headmin
2
+ module Ckeditor
3
+ def handle_upload
4
+ blob = ActiveStorage::Blob.create_after_upload!(
5
+ io: upload_params[:upload],
6
+ filename: upload_params[:upload].original_filename,
7
+ content_type: upload_params[:upload].content_type
8
+ )
9
+ render json: {
10
+ urls: {
11
+ "default": url_for(blob.variant(resize_to_limit: [1600, 1600], quality: 75)),
12
+ "800": url_for(blob.variant(resize_to_limit: [800, 800], quality: 75)),
13
+ "1024": url_for(blob.variant(resize_to_limit: [1024, 1024], quality: 75)),
14
+ "1600": url_for(blob.variant(resize_to_limit: [1600, 1600], quality: 75))
15
+ }
16
+ }
17
+ end
18
+
19
+ private
20
+
21
+ def upload_params
22
+ params.permit(
23
+ :upload, :locale
24
+ )
25
+ end
26
+ end
27
+ end