tybo 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/views/shared/_pagination.html.erb +44 -33
- data/lib/generators/bo/templates/index.html.erb +1 -1
- data/lib/generators/bo/templates/item.html.erb +15 -13
- data/lib/generators/bo/utils/files/fr.json +4 -1
- data/lib/generators/bo/utils/translations.rb +14 -43
- data/lib/generators/bo_namespace/utils/files/en.json +1 -1
- data/lib/generators/bo_namespace/utils/files/fr.json +1 -1
- data/lib/generators/bo_namespace/utils/translations.rb +10 -10
- data/lib/generators/tybo_install/templates/tailwind.config.js +1 -1
- data/lib/generators/tybo_install/tybo_install_generator.rb +0 -2
- data/lib/generators/tybo_install/utils/files/en.json +5 -2
- data/lib/generators/tybo_install/utils/files/fr.json +4 -1
- data/lib/generators/tybo_install/utils/translations.rb +34 -28
- data/lib/tybo/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 22d6c0fae60eed0eb777ab4adeffa5556470941180567062546ab55613ca50ba
|
4
|
+
data.tar.gz: c93f5582d498f8a941dbff97d72907ac9b5de9d15d7f51221503ebb7a72d0ed9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e6f65e79c9fff3d70cff9f097799dbcfb72e980577a991080197ac4279f4b0dd6ae867e283f371c83f3bc0ba7269cfe32b21c6d8a049d0bb58f8e357462d65d2
|
7
|
+
data.tar.gz: 8d1584568c6f3df187741547e83bc54c68abe08db27cf9109c8bb1a74db65af71e63cb918b66c0e906ba0987659bdf5300764ab89ca8ab540fc3fe61fa679cfa
|
@@ -1,34 +1,45 @@
|
|
1
|
-
<%
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
1
|
+
<% if pagy.next || pagy.prev %>
|
2
|
+
<% link = pagy_link_proc(pagy) %>
|
3
|
+
<div class="flex items-center justify-between bg-white py-3">
|
4
|
+
<div class="hidden sm:flex sm:flex-1 sm:items-center sm:justify-between">
|
5
|
+
<div>
|
6
|
+
<p class="text-sm text-gray-700">
|
7
|
+
<%= I18n.t('bo.pagy.showing').capitalize %>
|
8
|
+
<span class="font-bold text-tybo"><%= pagy.from %></span>
|
9
|
+
<%= I18n.t('bo.pagy.to') %>
|
10
|
+
<span class="font-bold text-tybo"><%= pagy.to %></span>
|
11
|
+
<%= I18n.t('bo.pagy.of') %>
|
12
|
+
<span class="font-bold text-tybo"><%= pagy.count %></span>
|
13
|
+
<%= I18n.t('bo.pagy.results') %>
|
14
|
+
</p>
|
15
|
+
</div>
|
16
|
+
<div>
|
17
|
+
<nav class="isolate inline-flex -space-x-px rounded-md shadow-sm" aria-label="Pagination">
|
18
|
+
<% if pagy.prev %>
|
19
|
+
<a href="<%= pagy_url_for(pagy, pagy.prev) %>" aria-label="precedent" class="relative inline-flex items-center rounded-l-md px-2 py-2 text-gray-400 ring-1 ring-inset ring-gray-300 hover:bg-gray-50 focus:z-20 focus:outline-offset-0">
|
20
|
+
<svg class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
|
21
|
+
<path fill-rule="evenodd" d="M12.79 5.23a.75.75 0 01-.02 1.06L8.832 10l3.938 3.71a.75.75 0 11-1.04 1.08l-4.5-4.25a.75.75 0 010-1.08l4.5-4.25a.75.75 0 011.06.02z" clip-rule="evenodd" />
|
22
|
+
</svg>
|
23
|
+
</a>
|
24
|
+
<% end %>
|
25
|
+
<% pagy.series.each do |item| %>
|
26
|
+
<% if item.is_a?(Integer) %>
|
27
|
+
<%== link.call(item, item.to_s, 'class="relative inline-flex items-center px-4 py-2 text-sm font-semibold text-gray-900 ring-1 ring-inset ring-gray-300 hover:bg-gray-50 focus:z-20 focus:outline-offset-0"') %>
|
28
|
+
<% elsif item.is_a?(String) %>
|
29
|
+
<span class="relative z-10 inline-flex items-center bg-tybo-600 px-4 py-2 text-sm font-semibold text-white focus:z-20 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-tybo-600"><%= item %></span>
|
30
|
+
<% elsif item == :gap %>
|
31
|
+
<span class="relative inline-flex items-center px-4 py-2 text-sm font-semibold text-gray-700 ring-1 ring-inset ring-gray-300 focus:outline-offset-0">...</span>
|
32
|
+
<% end %>
|
33
|
+
<% end %>
|
34
|
+
<% if pagy.next %>
|
35
|
+
<a href="<%= pagy_url_for(pagy, pagy.next) %>" aria-label="suivant" class="relative inline-flex items-center rounded-r-md px-2 py-2 text-gray-400 ring-1 ring-inset ring-gray-300 hover:bg-gray-50 focus:z-20 focus:outline-offset-0">
|
36
|
+
<svg class="h-5 w-5" viewBox="0 0 20 20" fill="currentColor" aria-hidden="true">
|
37
|
+
<path fill-rule="evenodd" d="M7.21 14.77a.75.75 0 01.02-1.06L11.168 10 7.23 6.29a.75.75 0 111.04-1.08l4.5 4.25a.75.75 0 010 1.08l-4.5 4.25a.75.75 0 01-1.06-.02z" clip-rule="evenodd" />
|
38
|
+
</svg>
|
39
|
+
</a>
|
40
|
+
<% end %>
|
41
|
+
</nav>
|
42
|
+
</div>
|
7
43
|
</div>
|
8
|
-
|
9
|
-
|
10
|
-
<%== link.call(pagy.prev, I18n.t('bo.nav.prev'), 'aria-label="previous" class="hidden"') %>
|
11
|
-
</div>
|
12
|
-
<% end -%>
|
13
|
-
<% if pagy.next -%>
|
14
|
-
<% pagy.series.each do |item|
|
15
|
-
# series example: [1, :gap, 7, 8, "9", 10, 11, :gap, 36] -%>
|
16
|
-
<% if item.is_a?(Integer) -%>
|
17
|
-
<%== link.call(item, item, 'class="inline-flex h-10 items-center rounded-md border border-gray-300 bg-white px-4 hover:bg-gray-100 focus:border-tybo-600 focus:outline-none focus:ring-2 focus:ring-tybo-600 focus:ring-opacity-25 focus:ring-offset-1 focus:ring-offset-tybo-600"') %>
|
18
|
-
<% elsif item.is_a?(String) -%>
|
19
|
-
<%== link.call(item, item, 'class="inline-flex h-10 items-center rounded-md border border-tybo-600 bg-white px-4 ring-1 ring-tybo-600 hover:bg-gray-100 focus:border-tybo-600 focus:outline-none focus:ring-2 focus:ring-tybo-600 focus:ring-opacity-25 focus:ring-offset-1 focus:ring-offset-tybo-600"') %>
|
20
|
-
<% elsif item == :gap -%>
|
21
|
-
<span class="inline-flex h-10 items-center px-1.5 text-gray-500">
|
22
|
-
<%== I18n.t('bo.nav.gap') %>
|
23
|
-
</span>
|
24
|
-
<% end -%>
|
25
|
-
<% end -%>
|
26
|
-
<div class="flex min-w-0 flex-1 justify-end">
|
27
|
-
<%== link.call(pagy.next, I18n.t('bo.nav.next'), 'aria-label="next" class="inline-flex h-10 items-center rounded-md border border-gray-300 bg-white px-4 hover:bg-gray-100 focus:border-tybo-600 focus:outline-none focus:ring-2 focus:ring-tybo-600 focus:ring-opacity-25 focus:ring-offset-1 focus:ring-offset-tybo-600"') %>
|
28
|
-
</div>
|
29
|
-
<% else -%>
|
30
|
-
<div class="flex min-w-0 flex-1 justify-end">
|
31
|
-
<%== link.call(pagy.next, I18n.t('bo.nav.next'), 'aria-label="next" class="hidden"') %>
|
32
|
-
</div>
|
33
|
-
<% end -%>
|
34
|
-
</nav>
|
44
|
+
</div>
|
45
|
+
<% end %>
|
@@ -10,7 +10,7 @@
|
|
10
10
|
<!-- Search Bar -->
|
11
11
|
<%%= render('search_bar') %>
|
12
12
|
<!-- Table -->
|
13
|
-
<%%= turbo_frame_tag "<%= class_name.underscore.pluralize %>",
|
13
|
+
<%%= turbo_frame_tag "<%= class_name.underscore.pluralize %>", class: "shadow overflow-hidden rounded border-b border-gray-200" do %>
|
14
14
|
<%%= render('table') %>
|
15
15
|
<div class="py-2">
|
16
16
|
<%%== render partial: 'shared/pagination', locals: { pagy: @pagy } %>
|
@@ -1,14 +1,16 @@
|
|
1
|
-
<%%=
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
1
|
+
<%%= turbo_frame_tag "<%= class_name.pluralize.underscore %>", target: '_top' do %>
|
2
|
+
<%%= render(FormComponent.new(item: <%= class_name.underscore %>)) do |form| %>
|
3
|
+
<%% current_page = if <%= class_name.underscore %>.persisted?
|
4
|
+
{ label: I18n.t('bo.show'), path: <%= "#{options[:namespace]}_#{class_name.underscore}_path(#{class_name.underscore})"%> }
|
5
|
+
else
|
6
|
+
{ label: I18n.t('bo.<%= class_name.underscore %>.new').capitalize, path: <%= "new_#{options[:namespace]}_#{class_name.underscore}_path" %> }
|
7
|
+
end
|
8
|
+
form.with_title(<%= class_name.underscore %>.persisted? ? <%= class_name.underscore %>.<%=bo_model_title(bo_model)%> : I18n.t('bo.<%= class_name.underscore %>.new').capitalize)
|
9
|
+
form.with_breadcrumb([
|
10
|
+
{ label: I18n.t('bo.<%= class_name.underscore %>.others').capitalize, path: <%= "#{options[:namespace]}_#{class_name.pluralize.underscore}_path"%> },
|
11
|
+
current_page
|
12
|
+
]) %>
|
13
|
+
<br>
|
14
|
+
<%%= render "form", <%= class_name.underscore %>: @<%= class_name.underscore %> %>
|
15
|
+
<%% end %>
|
14
16
|
<%% end %>
|
@@ -1,45 +1,16 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
def create_translations
|
4
|
-
%w[en fr].each do |
|
5
|
-
locale_file = "config/locales/bo.#{
|
6
|
-
unless File.exist?(locale_file)
|
7
|
-
File.write(locale_file, {
|
8
|
-
local => {
|
9
|
-
'bo' => {
|
10
|
-
'filters' => find_existing_translation('filters', local),
|
11
|
-
'details' => find_existing_translation('details', local),
|
12
|
-
'to' => find_existing_translation('to', local),
|
13
|
-
'confirm_delete' => find_existing_translation('confirm_delete', local),
|
14
|
-
'record' => {
|
15
|
-
'created' => find_existing_translation('created', local),
|
16
|
-
'updated' => find_existing_translation('updated', local),
|
17
|
-
'destroyed' => find_existing_translation('destroyed', local),
|
18
|
-
'show' => find_existing_translation('show', local),
|
19
|
-
},
|
20
|
-
'nav' => {
|
21
|
-
'prev' => find_existing_translation('prev', local),
|
22
|
-
'next' => find_existing_translation('next', local),
|
23
|
-
'gap' => find_existing_translation('gap', local)
|
24
|
-
},
|
25
|
-
'devise' => {
|
26
|
-
'password' => find_existing_translation('password', local),
|
27
|
-
'new' => find_existing_translation('new', local),
|
28
|
-
'forgot_password' => find_existing_translation('forgot_password', local),
|
29
|
-
}
|
30
|
-
}
|
31
|
-
}
|
32
|
-
}.to_yaml)
|
33
|
-
end
|
34
|
-
|
4
|
+
%w[en fr].each do |locale|
|
5
|
+
locale_file = "config/locales/bo.#{locale}.yml"
|
35
6
|
yaml_string = File.open locale_file
|
36
7
|
data = YAML.load yaml_string
|
37
|
-
data[
|
38
|
-
'one' => find_existing_translation(bo_model.to_s.downcase,
|
39
|
-
'others' => find_existing_translation(bo_model.to_s.pluralize.downcase,
|
40
|
-
'new' => find_existing_translation(nil,
|
41
|
-
'subtitle' => find_existing_translation("list of #{bo_model.to_s.pluralize.downcase}",
|
42
|
-
'attributes' => model_attributes(data,
|
8
|
+
data[locale]['bo'][file_name.underscore] = {
|
9
|
+
'one' => find_existing_translation(bo_model.to_s.downcase, locale),
|
10
|
+
'others' => find_existing_translation(bo_model.to_s.pluralize.downcase, locale),
|
11
|
+
'new' => find_existing_translation(nil, locale),
|
12
|
+
'subtitle' => find_existing_translation("list of #{bo_model.to_s.pluralize.downcase}", locale),
|
13
|
+
'attributes' => model_attributes(data, locale)
|
43
14
|
|
44
15
|
}
|
45
16
|
output = YAML.dump data
|
@@ -47,17 +18,17 @@ def create_translations
|
|
47
18
|
end
|
48
19
|
end
|
49
20
|
|
50
|
-
def model_attributes(data,
|
51
|
-
hash = data.dig(
|
21
|
+
def model_attributes(data, locale)
|
22
|
+
hash = data.dig(locale, 'bo', file_name.underscore, 'attributes') || {}
|
52
23
|
model_columns.each do |col|
|
53
|
-
hash[col.to_s] ||= find_existing_translation(col,
|
24
|
+
hash[col.to_s] ||= find_existing_translation(col, locale)
|
54
25
|
end
|
55
26
|
hash
|
56
27
|
end
|
57
28
|
|
58
|
-
def find_existing_translation(col,
|
59
|
-
return col.to_s.humanize.capitalize if
|
29
|
+
def find_existing_translation(col, locale)
|
30
|
+
return col.to_s.humanize.capitalize if locale == 'en'
|
60
31
|
|
61
|
-
json = JSON.parse(File.read("#{__dir__}/files/#{
|
32
|
+
json = JSON.parse(File.read("#{__dir__}/files/#{locale}.json"))
|
62
33
|
json[col.to_s]
|
63
34
|
end
|
@@ -1,20 +1,20 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
def create_translations
|
4
|
-
%w[en fr].each do |
|
5
|
-
locale_file = "config/locales/bo.#{
|
4
|
+
%w[en fr].each do |locale|
|
5
|
+
locale_file = "config/locales/bo.#{locale}.yml"
|
6
6
|
yaml_string = File.open locale_file
|
7
7
|
data = YAML.load yaml_string
|
8
|
-
if data[
|
9
|
-
data[
|
8
|
+
if data[locale]['bo']['devise']['sign_in_as']
|
9
|
+
data[locale]['bo']['devise']['sign_in_as'].merge!(
|
10
10
|
{
|
11
|
-
"#{singular_name}" => find_existing_translation("sign_in_as_#{singular_name.downcase}",
|
11
|
+
"#{singular_name}" => find_existing_translation("sign_in_as_#{singular_name.downcase}", locale)
|
12
12
|
}
|
13
13
|
)
|
14
14
|
else
|
15
|
-
data[
|
15
|
+
data[locale]['bo']['devise'].merge!(
|
16
16
|
'sign_in_as' => {
|
17
|
-
"#{singular_name}" => find_existing_translation("sign_in_as_#{singular_name.downcase}",
|
17
|
+
"#{singular_name}" => find_existing_translation("sign_in_as_#{singular_name.downcase}", locale)
|
18
18
|
}
|
19
19
|
)
|
20
20
|
end
|
@@ -24,16 +24,16 @@ def create_translations
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
-
def find_existing_translation(col,
|
27
|
+
def find_existing_translation(col, locale)
|
28
28
|
json = {
|
29
29
|
sign_in_as_administrator:{
|
30
30
|
fr: "Espace administrateur",
|
31
31
|
en: "Namespace administrator"
|
32
32
|
},
|
33
33
|
sign_in_as_user: {
|
34
|
-
fr: "Espace
|
34
|
+
fr: "Espace utilisateur",
|
35
35
|
en: "Namespace user"
|
36
36
|
}
|
37
37
|
}
|
38
|
-
json.dig(col.to_sym,
|
38
|
+
json.dig(col.to_sym, locale.to_sym)
|
39
39
|
end
|
@@ -46,7 +46,5 @@ class TyboInstallGenerator < Rails::Generators::Base
|
|
46
46
|
"application.register('dropdown', Dropdown)\napplication.register('flash', Flash)\napplication.register('search-form', SearchForm)\napplication.register('ts--search', TsSearch)\napplication.register('ts--select', TsSelect)\n"
|
47
47
|
end
|
48
48
|
end
|
49
|
-
|
50
|
-
private
|
51
49
|
end
|
52
50
|
|
@@ -14,7 +14,7 @@
|
|
14
14
|
"full_name": "Full name",
|
15
15
|
"updated": "Updated",
|
16
16
|
"created": "Created",
|
17
|
-
"destroyed": "
|
17
|
+
"destroyed": "Deleted",
|
18
18
|
"filters": "Filters",
|
19
19
|
"confirm_delete": "Are you sure?",
|
20
20
|
"details": "Details",
|
@@ -27,5 +27,8 @@
|
|
27
27
|
"remember_me": "Remember me?",
|
28
28
|
"sign_in": "Sign in",
|
29
29
|
"send_me_reset_password_instructions": "Send me reset password instructions",
|
30
|
-
"save": "Save"
|
30
|
+
"save": "Save",
|
31
|
+
"showing": "Showing",
|
32
|
+
"of": "of",
|
33
|
+
"results": "results"
|
31
34
|
}
|
@@ -27,5 +27,8 @@
|
|
27
27
|
"remember_me": "Se souvenir de moi ?",
|
28
28
|
"sign_in": "Connexion",
|
29
29
|
"send_me_reset_password_instructions": "Réinitialiser mon mot de passe",
|
30
|
-
"save": "Sauvegarder"
|
30
|
+
"save": "Sauvegarder",
|
31
|
+
"showing": "Affichage de",
|
32
|
+
"of": "de",
|
33
|
+
"results": "resultats"
|
31
34
|
}
|
@@ -1,43 +1,49 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
def create_base_translation_files
|
4
|
-
%w[en fr].each do |
|
5
|
-
locale_file = "config/locales/bo.#{
|
4
|
+
%w[en fr].each do |locale|
|
5
|
+
locale_file = "config/locales/bo.#{locale}.yml"
|
6
6
|
File.write(locale_file, {
|
7
|
-
|
7
|
+
locale => {
|
8
8
|
'bo' => {
|
9
|
-
'filters' => find_existing_translation('filters',
|
10
|
-
'show' => find_existing_translation('show',
|
11
|
-
'to' => find_existing_translation('to',
|
12
|
-
'confirm_delete' => find_existing_translation('confirm_delete',
|
9
|
+
'filters' => find_existing_translation('filters', locale),
|
10
|
+
'show' => find_existing_translation('show', locale),
|
11
|
+
'to' => find_existing_translation('to', locale),
|
12
|
+
'confirm_delete' => find_existing_translation('confirm_delete', locale),
|
13
13
|
'record' => {
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
'created' => find_existing_translation('created', locale),
|
15
|
+
'updated' => find_existing_translation('updated', locale),
|
16
|
+
'destroyed' => find_existing_translation('destroyed', locale),
|
17
17
|
},
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
18
|
+
'nav' => {
|
19
|
+
'prev' => find_existing_translation('prev', locale),
|
20
|
+
'next' => find_existing_translation('next', locale),
|
21
|
+
'gap' => find_existing_translation('gap', locale)
|
22
|
+
},
|
23
|
+
'pagy' => {
|
24
|
+
'showing' => find_existing_translation('showing', locale),
|
25
|
+
'to' => find_existing_translation('to', locale),
|
26
|
+
'of' => find_existing_translation('of', locale),
|
27
|
+
'show' => find_existing_translation('show', locale),
|
28
|
+
'results' => find_existing_translation('results', locale)
|
29
|
+
},
|
30
|
+
'devise' => {
|
31
|
+
'password' => find_existing_translation('password', locale),
|
32
|
+
'forgot_password' => find_existing_translation('forgot_password', locale),
|
33
|
+
'reset_password_instructions' => find_existing_translation('reset_password_instructions', locale),
|
34
|
+
'remember_me' => find_existing_translation('remember_me', locale),
|
35
|
+
'sign_in' => find_existing_translation('sign_in', locale),
|
36
|
+
'send_me_reset_password_instructions' => find_existing_translation('send_me_reset_password_instructions', locale),
|
37
|
+
'save' => find_existing_translation('save', locale),
|
32
38
|
}
|
33
39
|
}
|
34
|
-
}
|
35
|
-
|
40
|
+
}
|
41
|
+
}.to_yaml)
|
36
42
|
end
|
37
43
|
end
|
38
44
|
|
39
|
-
def find_existing_translation(col,
|
40
|
-
json = JSON.parse(File.read("#{__dir__}/files/#{
|
45
|
+
def find_existing_translation(col, locale)
|
46
|
+
json = JSON.parse(File.read("#{__dir__}/files/#{locale}.json"))
|
41
47
|
json[col.to_s]
|
42
48
|
end
|
43
49
|
|
data/lib/tybo/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tybo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michel Delpierre
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2023-05-
|
12
|
+
date: 2023-05-24 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|