moirai 0.3.1 → 0.4.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.
- checksums.yaml +4 -4
- data/.semaphore/semaphore.yml +33 -1
- data/CHANGELOG.md +16 -0
- data/README.md +10 -10
- data/app/views/application_mailer/test.html.erb +1 -0
- data/lib/moirai/engine.rb +9 -39
- data/lib/moirai/translation_helper.rb +37 -0
- data/lib/moirai/version.rb +1 -1
- data/lib/moirai.rb +1 -1
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c5a4c92d52a38c7cbae4d8216b9421d15f6b2db58328ef8f8df5b46da0c97785
|
4
|
+
data.tar.gz: c23ab52e4a50ee7478abdf41cee44fe04daa7760c1f69179cc7195ca58f70ead
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1afbdd4d152ddc16ce221e2918092feb2a0e2437af4bce78163b5b2fc9973ebe504b8f42650ffebe56b982f3f646c0602cd9b50c68e17b48c08552b7eed26fd8
|
7
|
+
data.tar.gz: 78dfa1fafe07d6a51ee10d3afe111767d3ede63cb254b408c44745369aa5a27c5e84922f613e4b7ccdfe8610aa9f7894fe6d07f8f833404c8d0a40a1b90da5bd
|
data/.semaphore/semaphore.yml
CHANGED
@@ -9,9 +9,10 @@ auto_cancel:
|
|
9
9
|
when: "true"
|
10
10
|
|
11
11
|
blocks:
|
12
|
-
- name:
|
12
|
+
- name: linter
|
13
13
|
execution_time_limit:
|
14
14
|
minutes: 10
|
15
|
+
dependencies: []
|
15
16
|
task:
|
16
17
|
secrets:
|
17
18
|
- name: moirai
|
@@ -26,6 +27,21 @@ blocks:
|
|
26
27
|
- name: linter
|
27
28
|
commands:
|
28
29
|
- bundle exec standardrb
|
30
|
+
- name: tests sqlite
|
31
|
+
execution_time_limit:
|
32
|
+
minutes: 10
|
33
|
+
dependencies: []
|
34
|
+
task:
|
35
|
+
secrets:
|
36
|
+
- name: moirai
|
37
|
+
prologue:
|
38
|
+
commands:
|
39
|
+
- checkout --use-cache
|
40
|
+
- cache restore
|
41
|
+
- bundle config set path 'vendor/bundle'
|
42
|
+
- bundle install -j 4
|
43
|
+
- cache store
|
44
|
+
jobs:
|
29
45
|
- name: tests sqlite
|
30
46
|
env_vars:
|
31
47
|
- name: TARGET_DB
|
@@ -35,6 +51,22 @@ blocks:
|
|
35
51
|
commands:
|
36
52
|
- bin/rails db:create db:schema:load
|
37
53
|
- bin/check
|
54
|
+
- name: tests postgres
|
55
|
+
execution_time_limit:
|
56
|
+
minutes: 10
|
57
|
+
dependencies:
|
58
|
+
- 'tests sqlite'
|
59
|
+
task:
|
60
|
+
secrets:
|
61
|
+
- name: moirai
|
62
|
+
prologue:
|
63
|
+
commands:
|
64
|
+
- checkout --use-cache
|
65
|
+
- cache restore
|
66
|
+
- bundle config set path 'vendor/bundle'
|
67
|
+
- bundle install -j 4
|
68
|
+
- cache store
|
69
|
+
jobs:
|
38
70
|
- name: tests postgres
|
39
71
|
env_vars:
|
40
72
|
- name: TARGET_DB
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,19 @@
|
|
1
|
+
## 0.4.1
|
2
|
+
|
3
|
+
* Fix bug when the string is not a string, but a boolean
|
4
|
+
|
5
|
+
## 0.4.0 - Breaking Changes ⚠️
|
6
|
+
|
7
|
+
* Inline editing is now disabled by default. To enable it, specify the following in `application.rb`:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
config.moirai.enable_inline_editing = ->(params:) { your_options_here }
|
11
|
+
```
|
12
|
+
|
13
|
+
move in here the conditions you had previously defined in the helper.
|
14
|
+
|
15
|
+
* Moirai now works also in emails. That's why we have a breaking change.
|
16
|
+
|
1
17
|
## 0.3.1
|
2
18
|
|
3
19
|
* Fixes a problem when running a rake command and no database exists yet using postgres. ([@coorasse][])
|
data/README.md
CHANGED
@@ -50,21 +50,21 @@ on the application.
|
|
50
50
|
|
51
51
|
### Inline editing
|
52
52
|
|
53
|
-
By default, inline editing is disabled. To enable it,
|
54
|
-
|
55
|
-
If you want to only allow specific users to perform inline editing, you can override the `moirai_edit_enabled?` method
|
56
|
-
in your application helper.
|
53
|
+
By default, inline editing is disabled. To enable it, specify the following in `application.rb`:
|
57
54
|
|
58
55
|
```ruby
|
56
|
+
config.moirai.enable_inline_editing = ->(params:) { params[:moirai] == 'true' }
|
57
|
+
```
|
59
58
|
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
59
|
+
If you set `moirai=true` query parameter in the URL, inline editing will appear in your page.
|
60
|
+
|
61
|
+
You probably want to only allow specific users to perform inline editing, this is an example of how you can do it:
|
62
|
+
|
63
|
+
```ruby
|
64
|
+
config.moirai.enable_inline_editing = ->(params:) { (params[:moirai] == 'true') && current_user&.admin? }
|
65
65
|
```
|
66
66
|
|
67
|
-
You also need to have the moirai_translations_controller.js Stimulus Controller initialized.
|
67
|
+
You also need to have the moirai_translations_controller.js Stimulus Controller initialized. Read below how to:
|
68
68
|
|
69
69
|
#### Importmap
|
70
70
|
|
@@ -0,0 +1 @@
|
|
1
|
+
<%= t('email.welcome') %>
|
data/lib/moirai/engine.rb
CHANGED
@@ -8,6 +8,8 @@ module Moirai
|
|
8
8
|
generator.orm :active_record
|
9
9
|
end
|
10
10
|
|
11
|
+
config.moirai = ActiveSupport::OrderedOptions.new
|
12
|
+
|
11
13
|
config.after_initialize do
|
12
14
|
I18n.original_backend = I18n.backend
|
13
15
|
table_created =
|
@@ -25,47 +27,15 @@ module Moirai
|
|
25
27
|
end
|
26
28
|
end
|
27
29
|
|
28
|
-
|
29
|
-
|
30
|
+
initializer "rails_api_logger.config" do
|
31
|
+
config.moirai.each do |name, value|
|
32
|
+
Moirai.public_send(:"#{name}=", value)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
30
36
|
initializer "moirai.override_translation_helper" do
|
31
37
|
ActiveSupport.on_load(:action_view) do
|
32
|
-
|
33
|
-
alias_method :original_translate, :translate
|
34
|
-
|
35
|
-
def translate(key, **options)
|
36
|
-
value = original_translate(key, **options)
|
37
|
-
|
38
|
-
is_missing_translation = value.include?('class="translation_missing"')
|
39
|
-
if value.is_a?(String) && is_missing_translation
|
40
|
-
value = extract_inner_content(value)
|
41
|
-
end
|
42
|
-
|
43
|
-
if moirai_edit_enabled?
|
44
|
-
@key_finder ||= Moirai::KeyFinder.new
|
45
|
-
|
46
|
-
render(partial: "moirai/translation_files/form",
|
47
|
-
locals: {key: scope_key_by_partial(key),
|
48
|
-
locale: I18n.locale,
|
49
|
-
is_missing_translation: is_missing_translation,
|
50
|
-
value: value})
|
51
|
-
else
|
52
|
-
value
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
alias_method :t, :translate
|
57
|
-
|
58
|
-
def moirai_edit_enabled?
|
59
|
-
params[:moirai] == "true"
|
60
|
-
end
|
61
|
-
|
62
|
-
private
|
63
|
-
|
64
|
-
def extract_inner_content(html)
|
65
|
-
match = html.match(/<[^>]+>([^<]*)<\/[^>]+>/)
|
66
|
-
match ? match[1] : nil
|
67
|
-
end
|
68
|
-
end
|
38
|
+
require "moirai/translation_helper"
|
69
39
|
end
|
70
40
|
end
|
71
41
|
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
module ActionView::Helpers::TranslationHelper # rubocop:disable Lint/ConstantDefinitionInBlock
|
2
|
+
alias_method :original_translate, :translate
|
3
|
+
|
4
|
+
def translate(key, **)
|
5
|
+
value = original_translate(key, **)
|
6
|
+
|
7
|
+
is_missing_translation = value.is_a?(String) && value.include?('class="translation_missing"')
|
8
|
+
if is_missing_translation
|
9
|
+
value = extract_inner_content(value)
|
10
|
+
end
|
11
|
+
|
12
|
+
if moirai_edit_enabled?
|
13
|
+
@key_finder ||= Moirai::KeyFinder.new
|
14
|
+
|
15
|
+
render(partial: "moirai/translation_files/form",
|
16
|
+
locals: {key: scope_key_by_partial(key),
|
17
|
+
locale: I18n.locale,
|
18
|
+
is_missing_translation: is_missing_translation,
|
19
|
+
value: value})
|
20
|
+
else
|
21
|
+
value
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
alias_method :t, :translate
|
26
|
+
|
27
|
+
def moirai_edit_enabled?
|
28
|
+
Moirai.enable_inline_editing.call(params: defined?(params) ? params : {})
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def extract_inner_content(html)
|
34
|
+
match = html.match(/<[^>]+>([^<]*)<\/[^>]+>/)
|
35
|
+
match ? match[1] : nil
|
36
|
+
end
|
37
|
+
end
|
data/lib/moirai/version.rb
CHANGED
data/lib/moirai.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: moirai
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alessandro Rodi
|
@@ -65,6 +65,7 @@ files:
|
|
65
65
|
- app/models/moirai/translation.rb
|
66
66
|
- app/models/moirai/translation_dumper.rb
|
67
67
|
- app/models/moirai/translation_file_handler.rb
|
68
|
+
- app/views/application_mailer/test.html.erb
|
68
69
|
- app/views/layouts/moirai/application.html.erb
|
69
70
|
- app/views/moirai/translation_files/_form.html.erb
|
70
71
|
- app/views/moirai/translation_files/index.html.erb
|
@@ -85,6 +86,7 @@ files:
|
|
85
86
|
- lib/moirai.rb
|
86
87
|
- lib/moirai/engine.rb
|
87
88
|
- lib/moirai/pull_request_creator.rb
|
89
|
+
- lib/moirai/translation_helper.rb
|
88
90
|
- lib/moirai/version.rb
|
89
91
|
- moirai.gemspec
|
90
92
|
homepage: https://github.com/renuo/moirai
|