administrate_tailwind_theme 0.0.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 +7 -0
- data/.rubocop.yml +33 -0
- data/.ruby-version +1 -0
- data/.rubycritic.yml +5 -0
- data/CODE_OF_CONDUCT.md +84 -0
- data/LICENSE.txt +21 -0
- data/README.md +104 -0
- data/Rakefile +10 -0
- data/administrate_tailwind_theme.gemspec +33 -0
- data/app/assets/config/administrate_tailwind_theme_manifest.js +2 -0
- data/app/assets/images/administrate/tailwind/theme/.keep +0 -0
- data/app/assets/javascripts/administrate-tailwind-theme.js +1 -0
- data/app/assets/stylesheets/administrate-tailwind-theme.css +0 -0
- data/app/controllers/.keep +0 -0
- data/app/controllers/concerns/.keep +0 -0
- data/app/helpers/.keep +0 -0
- data/app/helpers/application_helper.rb +4 -0
- data/app/jobs/.keep +0 -0
- data/app/mailers/.keep +0 -0
- data/app/models/.keep +0 -0
- data/app/models/concerns/.keep +0 -0
- data/app/views/.keep +0 -0
- data/app/views/admin/application/_flashes.html.erb +29 -0
- data/app/views/admin/application/_icons.html.erb +13 -0
- data/app/views/admin/application/_javascript.html.erb +21 -0
- data/app/views/admin/application/_navigation.html.erb +39 -0
- data/app/views/admin/application/_stylesheet.html.erb +14 -0
- data/app/views/administrate/application/_collection.html.erb +78 -0
- data/app/views/administrate/application/_collection_header_actions.html.erb +5 -0
- data/app/views/administrate/application/_collection_item_actions.html.erb +22 -0
- data/app/views/administrate/application/_flashes.html.erb +35 -0
- data/app/views/administrate/application/_form.html.erb +58 -0
- data/app/views/administrate/application/_icons.html.erb +13 -0
- data/app/views/administrate/application/_index_header.html.erb +28 -0
- data/app/views/administrate/application/_javascript.html.erb +21 -0
- data/app/views/administrate/application/_navigation.html.erb +27 -0
- data/app/views/administrate/application/_pagination.html.erb +1 -0
- data/app/views/administrate/application/_search.html.erb +21 -0
- data/app/views/administrate/application/_stylesheet.html.erb +14 -0
- data/app/views/administrate/application/edit.html.erb +42 -0
- data/app/views/administrate/application/index.html.erb +49 -0
- data/app/views/administrate/application/new.html.erb +43 -0
- data/app/views/administrate/application/show.html.erb +71 -0
- data/app/views/administrate/navigation/icons/_comments.html.erb +4 -0
- data/app/views/administrate/navigation/icons/_messages.html.erb +4 -0
- data/app/views/administrate/navigation/icons/_users.erb +6 -0
- data/app/views/fields/belongs_to/_form.html.erb +29 -0
- data/app/views/fields/belongs_to/_index.html.erb +27 -0
- data/app/views/fields/belongs_to/_show.html.erb +28 -0
- data/app/views/fields/boolean/_form.html.erb +24 -0
- data/app/views/fields/boolean/_index.html.erb +19 -0
- data/app/views/fields/boolean/_show.html.erb +24 -0
- data/app/views/fields/boolean_emoji/_form.html.erb +7 -0
- data/app/views/fields/boolean_emoji/_index.html.erb +1 -0
- data/app/views/fields/boolean_emoji/_show.html.erb +3 -0
- data/app/views/fields/country_emoji/_form.html.erb +6 -0
- data/app/views/fields/country_emoji/_index.html.erb +1 -0
- data/app/views/fields/country_emoji/_show.html.erb +3 -0
- data/app/views/fields/date/_form.html.erb +23 -0
- data/app/views/fields/date/_index.html.erb +21 -0
- data/app/views/fields/date/_show.html.erb +23 -0
- data/app/views/fields/date_time/_form.html.erb +23 -0
- data/app/views/fields/date_time/_index.html.erb +21 -0
- data/app/views/fields/date_time/_show.html.erb +23 -0
- data/app/views/fields/email/_form.html.erb +23 -0
- data/app/views/fields/email/_index.html.erb +18 -0
- data/app/views/fields/email/_show.html.erb +20 -0
- data/app/views/fields/has_many/_form.html.erb +29 -0
- data/app/views/fields/has_many/_index.html.erb +19 -0
- data/app/views/fields/has_many/_show.html.erb +39 -0
- data/app/views/fields/has_one/_form.html.erb +39 -0
- data/app/views/fields/has_one/_index.html.erb +24 -0
- data/app/views/fields/has_one/_show.html.erb +48 -0
- data/app/views/fields/number/_form.html.erb +23 -0
- data/app/views/fields/number/_index.html.erb +19 -0
- data/app/views/fields/number/_show.html.erb +21 -0
- data/app/views/fields/password/_form.html.erb +23 -0
- data/app/views/fields/password/_index.html.erb +18 -0
- data/app/views/fields/password/_show.html.erb +20 -0
- data/app/views/fields/polymorphic/_form.html.erb +29 -0
- data/app/views/fields/polymorphic/_index.html.erb +27 -0
- data/app/views/fields/polymorphic/_show.html.erb +32 -0
- data/app/views/fields/select/_form.html.erb +31 -0
- data/app/views/fields/select/_index.html.erb +16 -0
- data/app/views/fields/select/_show.html.erb +18 -0
- data/app/views/fields/string/_form.html.erb +24 -0
- data/app/views/fields/string/_index.html.erb +18 -0
- data/app/views/fields/string/_show.html.erb +21 -0
- data/app/views/fields/text/_form.html.erb +22 -0
- data/app/views/fields/text/_index.html.erb +18 -0
- data/app/views/fields/text/_show.html.erb +20 -0
- data/app/views/fields/time/_form.html.erb +22 -0
- data/app/views/fields/time/_index.html.erb +19 -0
- data/app/views/fields/time/_show.html.erb +21 -0
- data/app/views/fields/url/_form.html.erb +23 -0
- data/app/views/fields/url/_index.html.erb +20 -0
- data/app/views/fields/url/_show.html.erb +22 -0
- data/app/views/kaminari/_first_page.html.erb +11 -0
- data/app/views/kaminari/_gap.html.erb +8 -0
- data/app/views/kaminari/_last_page.html.erb +11 -0
- data/app/views/kaminari/_next_page.html.erb +11 -0
- data/app/views/kaminari/_page.html.erb +12 -0
- data/app/views/kaminari/_paginator.html.erb +25 -0
- data/app/views/kaminari/_prev_page.html.erb +11 -0
- data/app/views/layouts/admin/application.html.erb +40 -0
- data/config/routes.rb +4 -0
- data/lib/administrate/field/boolean_emoji.rb +13 -0
- data/lib/administrate/field/country_emoji.rb +30 -0
- data/lib/administrate_tailwind_theme/engine.rb +15 -0
- data/lib/administrate_tailwind_theme/version.rb +5 -0
- data/lib/administrate_tailwind_theme/view_generator.rb +49 -0
- data/lib/administrate_tailwind_theme/view_helper.rb +22 -0
- data/lib/administrate_tailwind_theme.rb +9 -0
- data/lib/generators/administrate_tailwind_theme/install/USAGE +10 -0
- data/lib/generators/administrate_tailwind_theme/install/install_generator.rb +35 -0
- data/lib/generators/administrate_tailwind_theme/views/edit_generator.rb +18 -0
- data/lib/generators/administrate_tailwind_theme/views/field_generator.rb +52 -0
- data/lib/generators/administrate_tailwind_theme/views/form_generator.rb +17 -0
- data/lib/generators/administrate_tailwind_theme/views/index_generator.rb +18 -0
- data/lib/generators/administrate_tailwind_theme/views/layout_generator.rb +26 -0
- data/lib/generators/administrate_tailwind_theme/views/navigation_generator.rb +17 -0
- data/lib/generators/administrate_tailwind_theme/views/new_generator.rb +18 -0
- data/lib/generators/administrate_tailwind_theme/views/show_generator.rb +17 -0
- data/lib/generators/administrate_tailwind_theme/views/views_generator.rb +17 -0
- data/lib/tasks/administrate_tailwind/theme_tasks.rake +5 -0
- metadata +235 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<%#
|
|
2
|
+
# Select Show Partial
|
|
3
|
+
|
|
4
|
+
This partial renders a selectable text attribute,
|
|
5
|
+
to be displayed on a resource's show page.
|
|
6
|
+
|
|
7
|
+
## Local variables:
|
|
8
|
+
|
|
9
|
+
- `field`:
|
|
10
|
+
An instance of [Administrate::Field::Select][1].
|
|
11
|
+
A wrapper around the attribute pulled from the database.
|
|
12
|
+
|
|
13
|
+
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/Select
|
|
14
|
+
%>
|
|
15
|
+
|
|
16
|
+
<div class="bg-gray-50 p-3 rounded-md shadow-sm">
|
|
17
|
+
<%= field.data %>
|
|
18
|
+
</div>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<%#
|
|
2
|
+
# String Form Partial
|
|
3
|
+
|
|
4
|
+
This partial renders an input element for a string attribute.
|
|
5
|
+
By default, the input is a text field.
|
|
6
|
+
|
|
7
|
+
## Local variables:
|
|
8
|
+
|
|
9
|
+
- `f`:
|
|
10
|
+
A Rails form generator, used to help create the appropriate input fields.
|
|
11
|
+
- `field`:
|
|
12
|
+
An instance of [Administrate::Field::String][1].
|
|
13
|
+
A wrapper around the String pulled from the database.
|
|
14
|
+
|
|
15
|
+
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/String
|
|
16
|
+
%>
|
|
17
|
+
|
|
18
|
+
<div class="mb-4">
|
|
19
|
+
<%= f.label field.attribute, class: "block text-sm font-medium text-gray-700" %>
|
|
20
|
+
<div class="mt-1">
|
|
21
|
+
<%= f.text_field field.attribute, class: "shadow-sm focus:ring-indigo-500 focus:border-indigo-500 block w-full sm:text-sm border-gray-300 rounded-md" %>
|
|
22
|
+
</div>
|
|
23
|
+
</div>
|
|
24
|
+
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<%#
|
|
2
|
+
# String Index Partial
|
|
3
|
+
|
|
4
|
+
This partial renders a string attribute
|
|
5
|
+
to be displayed on a resource's index page.
|
|
6
|
+
|
|
7
|
+
By default, the attribute is rendered as a truncated string.
|
|
8
|
+
|
|
9
|
+
## Local variables:
|
|
10
|
+
|
|
11
|
+
- `field`:
|
|
12
|
+
An instance of [Administrate::Field::String][1].
|
|
13
|
+
A wrapper around the String pulled from the database.
|
|
14
|
+
|
|
15
|
+
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/String
|
|
16
|
+
%>
|
|
17
|
+
|
|
18
|
+
<%= field.truncate %>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<%#
|
|
2
|
+
# String Show Partial
|
|
3
|
+
|
|
4
|
+
This partial renders a string attribute,
|
|
5
|
+
to be displayed on a resource's show page.
|
|
6
|
+
|
|
7
|
+
By default, the attribute is rendered as text with whitespace preserved.
|
|
8
|
+
|
|
9
|
+
## Local variables:
|
|
10
|
+
|
|
11
|
+
- `field`:
|
|
12
|
+
An instance of [Administrate::Field::String][1].
|
|
13
|
+
A wrapper around the String pulled from the database.
|
|
14
|
+
|
|
15
|
+
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/String
|
|
16
|
+
%>
|
|
17
|
+
|
|
18
|
+
<div class="bg-gray-50 p-3 rounded-md shadow-sm">
|
|
19
|
+
<%= field.data %>
|
|
20
|
+
</div>
|
|
21
|
+
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<%#
|
|
2
|
+
# Text Form Partial
|
|
3
|
+
|
|
4
|
+
This partial renders a textarea element for a text attribute.
|
|
5
|
+
|
|
6
|
+
## Local variables:
|
|
7
|
+
|
|
8
|
+
- `f`:
|
|
9
|
+
A Rails form generator, used to help create the appropriate input fields.
|
|
10
|
+
- `field`:
|
|
11
|
+
An instance of [Administrate::Field::Text][1].
|
|
12
|
+
A wrapper around the Text pulled from the database.
|
|
13
|
+
|
|
14
|
+
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/Text
|
|
15
|
+
%>
|
|
16
|
+
|
|
17
|
+
<div class="mb-4">
|
|
18
|
+
<%= f.label field.attribute, class: "block text-sm font-medium text-gray-700" %>
|
|
19
|
+
<div class="mt-1">
|
|
20
|
+
<%= f.text_area field.attribute, class: "shadow-sm focus:ring-indigo-500 focus:border-indigo-500 block w-full sm:text-sm border-gray-300 rounded-md" %>
|
|
21
|
+
</div>
|
|
22
|
+
</div>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<%#
|
|
2
|
+
# Text Index Partial
|
|
3
|
+
|
|
4
|
+
This partial renders a text attribute
|
|
5
|
+
to be displayed on a resource's index page.
|
|
6
|
+
|
|
7
|
+
By default, the attribute is rendered as a truncated string.
|
|
8
|
+
|
|
9
|
+
## Local variables:
|
|
10
|
+
|
|
11
|
+
- `field`:
|
|
12
|
+
An instance of [Administrate::Field::Text][1].
|
|
13
|
+
A wrapper around the Text pulled from the database.
|
|
14
|
+
|
|
15
|
+
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/Text
|
|
16
|
+
%>
|
|
17
|
+
|
|
18
|
+
<%= field.truncate %>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<%#
|
|
2
|
+
# Text Show Partial
|
|
3
|
+
|
|
4
|
+
This partial renders a text attribute,
|
|
5
|
+
to be displayed on a resource's show page.
|
|
6
|
+
|
|
7
|
+
By default, the attribute is rendered as text with whitespace preserved.
|
|
8
|
+
|
|
9
|
+
## Local variables:
|
|
10
|
+
|
|
11
|
+
- `field`:
|
|
12
|
+
An instance of [Administrate::Field::Text][1].
|
|
13
|
+
A wrapper around the Text pulled from the database.
|
|
14
|
+
|
|
15
|
+
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/Text
|
|
16
|
+
%>
|
|
17
|
+
|
|
18
|
+
<div class="bg-gray-50 p-3 rounded-md shadow-sm">
|
|
19
|
+
<%= field.data %>
|
|
20
|
+
</div>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<%#
|
|
2
|
+
# Time Form Partial
|
|
3
|
+
|
|
4
|
+
This partial renders an input element for time attributes.
|
|
5
|
+
|
|
6
|
+
## Local variables:
|
|
7
|
+
|
|
8
|
+
- `f`:
|
|
9
|
+
A Rails form generator, used to help create the appropriate input fields.
|
|
10
|
+
- `field`:
|
|
11
|
+
An instance of [Administrate::Field::Time][1].
|
|
12
|
+
A wrapper around the tmie attributes pulled from the model.
|
|
13
|
+
|
|
14
|
+
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/Time
|
|
15
|
+
%>
|
|
16
|
+
|
|
17
|
+
<div class="mb-4">
|
|
18
|
+
<%= f.label field.attribute, class: "block text-sm font-medium text-gray-700" %>
|
|
19
|
+
<div class="mt-1">
|
|
20
|
+
<%= f.time_field field.attribute, step: 1, class: "shadow-sm focus:ring-indigo-500 focus:border-indigo-500 block w-full sm:text-sm border-gray-300 rounded-md" %>
|
|
21
|
+
</div>
|
|
22
|
+
</div>
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
<%#
|
|
2
|
+
# Time Index Partial
|
|
3
|
+
|
|
4
|
+
This partial renders an time attribute
|
|
5
|
+
to be displayed on a resource's index page.
|
|
6
|
+
|
|
7
|
+
By default, the attribute is rendered as a text tag.
|
|
8
|
+
|
|
9
|
+
## Local variables:
|
|
10
|
+
|
|
11
|
+
- `field`:
|
|
12
|
+
An instance of [Administrate::Field::Time][1].
|
|
13
|
+
A wrapper around the time attributes pulled from the model.
|
|
14
|
+
|
|
15
|
+
%>
|
|
16
|
+
|
|
17
|
+
<% if field.data %>
|
|
18
|
+
<%= field.time %>
|
|
19
|
+
<% end %>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<%#
|
|
2
|
+
# Time Show Partial
|
|
3
|
+
|
|
4
|
+
This partial renders an time attribute,
|
|
5
|
+
to be displayed on a resource's show page.
|
|
6
|
+
|
|
7
|
+
By default, the attribute is rendered as a text tag.
|
|
8
|
+
|
|
9
|
+
## Local variables:
|
|
10
|
+
|
|
11
|
+
- `field`:
|
|
12
|
+
An instance of [Administrate::Field::Time][1].
|
|
13
|
+
A wrapper around the time attributes pulled from the model.
|
|
14
|
+
|
|
15
|
+
%>
|
|
16
|
+
|
|
17
|
+
<% if field.data %>
|
|
18
|
+
<div class="bg-gray-50 p-3 rounded-md shadow-sm">
|
|
19
|
+
<%= field.data %>
|
|
20
|
+
</div>
|
|
21
|
+
<% end %>
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
<%#
|
|
2
|
+
# Url Form Partial
|
|
3
|
+
|
|
4
|
+
This partial renders an input element for URL.
|
|
5
|
+
By default, the input is a text box.
|
|
6
|
+
|
|
7
|
+
## Local variables:
|
|
8
|
+
|
|
9
|
+
- `f`:
|
|
10
|
+
A Rails form generator, used to help create the appropriate input fields.
|
|
11
|
+
- `field`:
|
|
12
|
+
An instance of [Administrate::Field::Url][1].
|
|
13
|
+
A wrapper around the URL pulled from the database.
|
|
14
|
+
|
|
15
|
+
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/Url
|
|
16
|
+
%>
|
|
17
|
+
|
|
18
|
+
<div class="mb-4">
|
|
19
|
+
<%= f.label field.attribute, class: "block text-sm font-medium text-gray-700" %>
|
|
20
|
+
<div class="mt-1">
|
|
21
|
+
<%= f.url_field field.attribute, class: "shadow-sm focus:ring-indigo-500 focus:border-indigo-500 block w-full sm:text-sm border-gray-300 rounded-md" %>
|
|
22
|
+
</div>
|
|
23
|
+
</div>
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<%#
|
|
2
|
+
# Url Index Partial
|
|
3
|
+
|
|
4
|
+
This partial renders a URL address,
|
|
5
|
+
to be displayed on a resource's index page.
|
|
6
|
+
|
|
7
|
+
By default, the value is rendered as an `a` element.
|
|
8
|
+
|
|
9
|
+
## Local variables:
|
|
10
|
+
|
|
11
|
+
- `field`:
|
|
12
|
+
An instance of [Administrate::Field::Url][1].
|
|
13
|
+
A wrapper around the email pulled from the database.
|
|
14
|
+
|
|
15
|
+
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/Url
|
|
16
|
+
%>
|
|
17
|
+
|
|
18
|
+
<%= content_tag :a, href: field.data, **field.html_options do %>
|
|
19
|
+
<%= field.data %>
|
|
20
|
+
<% end %>
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<%#
|
|
2
|
+
# Url Show Partial
|
|
3
|
+
|
|
4
|
+
This partial renders a URL address,
|
|
5
|
+
to be displayed on a resource's show page.
|
|
6
|
+
|
|
7
|
+
By default, the value is rendered as an `a` element.
|
|
8
|
+
|
|
9
|
+
## Local variables:
|
|
10
|
+
|
|
11
|
+
- `field`:
|
|
12
|
+
An instance of [Administrate::Field::Url][1].
|
|
13
|
+
A wrapper around the email pulled from the database.
|
|
14
|
+
|
|
15
|
+
[1]: http://www.rubydoc.info/gems/administrate/Administrate/Field/Url
|
|
16
|
+
%>
|
|
17
|
+
|
|
18
|
+
<div class="bg-gray-50 p-3 rounded-md shadow-sm">
|
|
19
|
+
<%= content_tag :a, href: field.data, **field.html_options do %>
|
|
20
|
+
<%= field.data %>
|
|
21
|
+
<% end %>
|
|
22
|
+
</div>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<%# Link to the "First" page
|
|
2
|
+
- available local variables
|
|
3
|
+
url: url to the first page
|
|
4
|
+
current_page: a page object for the currently displayed page
|
|
5
|
+
total_pages: total number of pages
|
|
6
|
+
per_page: number of items to fetch per page
|
|
7
|
+
remote: data-remote
|
|
8
|
+
-%>
|
|
9
|
+
<span class="first text-blue-500 hover:text-blue-700 disabled:text-gray-400">
|
|
10
|
+
<%= link_to_unless current_page.first?, t('views.pagination.first').html_safe, url, remote: remote %>
|
|
11
|
+
</span>
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
<%# Non-link tag that stands for skipped pages...
|
|
2
|
+
- available local variables
|
|
3
|
+
current_page: a page object for the currently displayed page
|
|
4
|
+
total_pages: total number of pages
|
|
5
|
+
per_page: number of items to fetch per page
|
|
6
|
+
remote: data-remote
|
|
7
|
+
-%>
|
|
8
|
+
<span class="page gap text-gray-500"><%= t('views.pagination.truncate').html_safe %></span>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<%# Link to the "Last" page
|
|
2
|
+
- available local variables
|
|
3
|
+
url: url to the last page
|
|
4
|
+
current_page: a page object for the currently displayed page
|
|
5
|
+
total_pages: total number of pages
|
|
6
|
+
per_page: number of items to fetch per page
|
|
7
|
+
remote: data-remote
|
|
8
|
+
-%>
|
|
9
|
+
<span class="last text-blue-500 hover:text-blue-700 disabled:text-gray-400">
|
|
10
|
+
<%= link_to_unless current_page.last?, t('views.pagination.last').html_safe, url, remote: remote %>
|
|
11
|
+
</span>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<%# Link to the "Next" page
|
|
2
|
+
- available local variables
|
|
3
|
+
url: url to the next page
|
|
4
|
+
current_page: a page object for the currently displayed page
|
|
5
|
+
total_pages: total number of pages
|
|
6
|
+
per_page: number of items to fetch per page
|
|
7
|
+
remote: data-remote
|
|
8
|
+
-%>
|
|
9
|
+
<span class="next text-blue-500 hover:text-blue-700 disabled:text-gray-400">
|
|
10
|
+
<%= link_to_unless current_page.last?, t('views.pagination.next').html_safe, url, rel: 'next', remote: remote %>
|
|
11
|
+
</span>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<%# Link showing page number
|
|
2
|
+
- available local variables
|
|
3
|
+
page: a page object for "this" page
|
|
4
|
+
url: url to this page
|
|
5
|
+
current_page: a page object for the currently displayed page
|
|
6
|
+
total_pages: total number of pages
|
|
7
|
+
per_page: number of items to fetch per page
|
|
8
|
+
remote: data-remote
|
|
9
|
+
-%>
|
|
10
|
+
<span class="page <%= 'current bg-blue-500 text-white' if page.current? %> hover:bg-blue-700 text-blue-500 hover:text-white border border-blue-500 rounded-md px-2">
|
|
11
|
+
<%= link_to_unless page.current?, page, url, {remote: remote, rel: page.rel} %>
|
|
12
|
+
</span>
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<%# The container tag
|
|
2
|
+
- available local variables
|
|
3
|
+
current_page: a page object for the currently displayed page
|
|
4
|
+
total_pages: total number of pages
|
|
5
|
+
per_page: number of items to fetch per page
|
|
6
|
+
remote: data-remote
|
|
7
|
+
paginator: the paginator that renders the pagination tags inside
|
|
8
|
+
-%>
|
|
9
|
+
<%= paginator.render do -%>
|
|
10
|
+
<nav class="pagination flex items-center justify-center gap-4" role="navigation" aria-label="pager">
|
|
11
|
+
<%= first_page_tag unless current_page.first? %>
|
|
12
|
+
<%= prev_page_tag unless current_page.first? %>
|
|
13
|
+
<% each_page do |page| -%>
|
|
14
|
+
<% if page.display_tag? -%>
|
|
15
|
+
<%= page_tag page %>
|
|
16
|
+
<% elsif !page.was_truncated? -%>
|
|
17
|
+
<%= gap_tag %>
|
|
18
|
+
<% end -%>
|
|
19
|
+
<% end -%>
|
|
20
|
+
<% unless current_page.out_of_range? %>
|
|
21
|
+
<%= next_page_tag unless current_page.last? %>
|
|
22
|
+
<%= last_page_tag unless current_page.last? %>
|
|
23
|
+
<% end %>
|
|
24
|
+
</nav>
|
|
25
|
+
<% end -%>
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
<%# Link to the "Previous" page
|
|
2
|
+
- available local variables
|
|
3
|
+
url: url to the previous page
|
|
4
|
+
current_page: a page object for the currently displayed page
|
|
5
|
+
total_pages: total number of pages
|
|
6
|
+
per_page: number of items to fetch per page
|
|
7
|
+
remote: data-remote
|
|
8
|
+
-%>
|
|
9
|
+
<span class="prev text-blue-500 hover:text-blue-700 disabled:text-gray-400">
|
|
10
|
+
<%= link_to_unless current_page.first?, t('views.pagination.previous').html_safe, url, rel: 'prev', remote: remote %>
|
|
11
|
+
</span>
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
<%#
|
|
2
|
+
# Application Layout
|
|
3
|
+
|
|
4
|
+
This view template is used as the layout
|
|
5
|
+
for every page that Administrate generates.
|
|
6
|
+
|
|
7
|
+
By default, it renders:
|
|
8
|
+
- Navigation
|
|
9
|
+
- Content for a search bar
|
|
10
|
+
(if provided by a `content_for` block in a nested page)
|
|
11
|
+
- Flashes
|
|
12
|
+
- Links to stylesheets and JavaScripts
|
|
13
|
+
%>
|
|
14
|
+
|
|
15
|
+
<!DOCTYPE html>
|
|
16
|
+
<html lang="<%= I18n.locale %>">
|
|
17
|
+
<head>
|
|
18
|
+
<meta charset="utf-8">
|
|
19
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
20
|
+
<title><%= content_for(:title) || "Administrate" %> - <%= application_title %></title>
|
|
21
|
+
<%= csrf_meta_tags %>
|
|
22
|
+
<%= csp_meta_tag %>
|
|
23
|
+
|
|
24
|
+
<%= stylesheet_link_tag 'tailwind', 'data-turbo-track': 'reload' %>
|
|
25
|
+
<%= stylesheet_link_tag 'administrate-tailwind-theme', 'data-turbo-track': 'reload' %>
|
|
26
|
+
<%= javascript_include_tag 'administrate-tailwind-theme', 'data-turbo-track': 'reload', defer: true %>
|
|
27
|
+
|
|
28
|
+
</head>
|
|
29
|
+
<body class="bg-gray-100">
|
|
30
|
+
<%= render "navigation" %>
|
|
31
|
+
<!-- Main Content -->
|
|
32
|
+
<div class="p-4 sm:ml-64">
|
|
33
|
+
<%= render "flashes" %>
|
|
34
|
+
<main class="container mx-auto px-6 py-8">
|
|
35
|
+
<%= yield %>
|
|
36
|
+
</main>
|
|
37
|
+
</div>
|
|
38
|
+
<%= render "javascript" %>
|
|
39
|
+
</body>
|
|
40
|
+
</html>
|
data/config/routes.rb
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'iso_country_codes'
|
|
4
|
+
require 'administrate/field/string'
|
|
5
|
+
|
|
6
|
+
module Administrate
|
|
7
|
+
module Field
|
|
8
|
+
class CountryEmoji < Administrate::Field::String
|
|
9
|
+
def to_emoji
|
|
10
|
+
iso2_to_flag_emoji(data)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def to_s
|
|
14
|
+
data
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
private
|
|
18
|
+
|
|
19
|
+
def iso2_to_flag_emoji(iso2)
|
|
20
|
+
return if iso2.nil?
|
|
21
|
+
|
|
22
|
+
iso2 = iso2.upcase
|
|
23
|
+
emoji = iso2.chars.map { |char| (char.ord + 127_397).chr(Encoding::UTF_8) }.join
|
|
24
|
+
entry = ::IsoCountryCodes.find(iso2)
|
|
25
|
+
|
|
26
|
+
"#{emoji} (#{entry.name})"
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative 'view_helper'
|
|
4
|
+
|
|
5
|
+
module AdministrateTailwindTheme
|
|
6
|
+
class Engine < ::Rails::Engine
|
|
7
|
+
initializer 'administrate_tailwind_theme.assets.precompile' do |app|
|
|
8
|
+
app.config.assets.precompile += %w[administrate-tailwind-theme.js administrate-tailwind-theme.css]
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
ActiveSupport.on_load :action_view do
|
|
12
|
+
include AdministrateTailwindTheme::ViewHelper
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'rails/generators/base'
|
|
4
|
+
require 'administrate/generator_helpers'
|
|
5
|
+
require 'administrate/namespace'
|
|
6
|
+
|
|
7
|
+
module AdministrateTailwindTheme
|
|
8
|
+
class ViewGenerator < Rails::Generators::Base
|
|
9
|
+
include Administrate::GeneratorHelpers
|
|
10
|
+
class_option(
|
|
11
|
+
:namespace,
|
|
12
|
+
type: :string,
|
|
13
|
+
desc: 'Namespace where the admin dashboards live',
|
|
14
|
+
default: 'admin'
|
|
15
|
+
)
|
|
16
|
+
|
|
17
|
+
def self.template_source_path
|
|
18
|
+
File.expand_path(
|
|
19
|
+
'../../app/views/administrate/application',
|
|
20
|
+
__dir__
|
|
21
|
+
)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
private
|
|
25
|
+
|
|
26
|
+
def namespace
|
|
27
|
+
options[:namespace]
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def copy_resource_template(template_name)
|
|
31
|
+
template_file = "#{template_name}.html.erb"
|
|
32
|
+
|
|
33
|
+
copy_file(
|
|
34
|
+
template_file,
|
|
35
|
+
"app/views/#{namespace}/#{resource_path}/#{template_file}"
|
|
36
|
+
)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def resource_path
|
|
40
|
+
args.first.try(:underscore).try(:pluralize) || BaseResourcePath.new
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
class BaseResourcePath
|
|
44
|
+
def to_s
|
|
45
|
+
'application'
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
end
|
|
49
|
+
end
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module AdministrateTailwindTheme
|
|
4
|
+
module ViewHelper
|
|
5
|
+
def flash_types(key)
|
|
6
|
+
case key.to_sym
|
|
7
|
+
when :notice
|
|
8
|
+
'Notice'
|
|
9
|
+
when :alert
|
|
10
|
+
'Alert'
|
|
11
|
+
when :error
|
|
12
|
+
'Error'
|
|
13
|
+
else
|
|
14
|
+
key.to_s.humanize
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def icon?(resource)
|
|
19
|
+
lookup_context.find_all("administrate/navigation/icons/_#{resource}").any?
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
Description:
|
|
2
|
+
AdministrateTailwindTheme installer
|
|
3
|
+
|
|
4
|
+
Example:
|
|
5
|
+
bin/rails generate administrate_tailwind_theme:install
|
|
6
|
+
|
|
7
|
+
This will:
|
|
8
|
+
- create a new initializer: administrate_tailwind_theme
|
|
9
|
+
- create a new SCSS stylesheet: administrate-tailwind-theme.scss
|
|
10
|
+
- append the necessary assets to: config/initializers/assets.rb
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module AdministrateTailwindTheme
|
|
4
|
+
class InstallGenerator < Rails::Generators::Base
|
|
5
|
+
source_root File.expand_path('templates', __dir__)
|
|
6
|
+
|
|
7
|
+
def create_initializer
|
|
8
|
+
initializer 'administrate_tailwind_theme.rb', <<~FILE
|
|
9
|
+
require 'administrate'
|
|
10
|
+
Administrate::Engine.stylesheets.clear # required to remove Administrate base styles
|
|
11
|
+
FILE
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def create_or_update_administrate_layout
|
|
15
|
+
tailwind_config_path = 'config/tailwind.config.js'
|
|
16
|
+
|
|
17
|
+
insert_tailwind_config(tailwind_config_path)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
private
|
|
21
|
+
|
|
22
|
+
def insert_tailwind_config(file_path)
|
|
23
|
+
js_import = "\nconst execSync = require('child_process').execSync;"
|
|
24
|
+
child_process = "\nconst output = execSync('bundle show administrate_tailwind_theme', { encoding: 'utf-8' });"
|
|
25
|
+
config = "\n output.trim() + '/app/views/**/*.{erb,haml,html,rb}',"
|
|
26
|
+
|
|
27
|
+
insert_into_file file_path, js_import,
|
|
28
|
+
after: "const defaultTheme = require('tailwindcss/defaultTheme')"
|
|
29
|
+
insert_into_file file_path, child_process,
|
|
30
|
+
after: "const execSync = require('child_process').execSync;"
|
|
31
|
+
insert_into_file file_path, config,
|
|
32
|
+
after: 'content: ['
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require 'administrate_tailwind_theme/view_generator'
|
|
4
|
+
|
|
5
|
+
module AdministrateTailwindTheme
|
|
6
|
+
module Generators
|
|
7
|
+
module Views
|
|
8
|
+
class EditGenerator < AdministrateTailwindTheme::ViewGenerator
|
|
9
|
+
source_root template_source_path
|
|
10
|
+
|
|
11
|
+
def copy_edit
|
|
12
|
+
copy_resource_template('edit')
|
|
13
|
+
copy_resource_template('_form')
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|