Skip to content

Commit 16fe7a4

Browse files
author
Mattia Roccoberton
committed
Bump to version 0.5.0
1 parent 90a0574 commit 16fe7a4

File tree

3 files changed

+130
-44
lines changed

3 files changed

+130
-44
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22

33
A compact and composable dashboard component for Ruby
44

5+
## 0.5.0
6+
7+
- feat: customize index entries links
8+
- feat: support config Objects for sections
9+
- feat: internal improvements
10+
511
## 0.4.0
612

713
- feat: introduce a Support class for attributes' formatters

README.md

Lines changed: 123 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ Please ⭐ if you like it.
1616

1717
## Install
1818

19-
- Add to your Gemfile: `gem 'tiny_admin', '~> 0.4'`
19+
- Add to your Gemfile: `gem 'tiny_admin', '~> 0.5'`
2020
- Mount the app in a route (check some examples with: Hanami, Rails, Roda and standalone in [extra](extra))
2121
+ in Rails, update _config/routes.rb_: `mount TinyAdmin::Router => '/admin'`
22-
- Configure the dashboard using `TinyAdmin.configure` and/or `TinyAdmin.configure_from_file` (see [configuration](#configuration) below):
22+
- Configure the dashboard using `TinyAdmin.configure` and/or `TinyAdmin.configure_from_file` with a YAML config file (see [configuration](#configuration) below):
2323

2424
```rb
2525
TinyAdmin.configure do |settings|
@@ -35,32 +35,37 @@ end
3535
### Authentication
3636

3737
Plugins available:
38-
- _SimpleAuth_: session authentication based on Warden (`warden` gem must be included in the Gemfile) using a password hash provided via config or via environment variable (`ADMIN_PASSWORD_HASH`);
39-
- _NoAuth_: no authentication.
38+
39+
- **SimpleAuth**: a session authentication based on Warden (`warden` gem must be included in the Gemfile) using a password hash provided via config or via environment variable (`ADMIN_PASSWORD_HASH`). _Disclaimer: this plugin is provided as example, if you need a secure authentication I suggest to create your own._
40+
41+
- **NoAuth**: no authentication.
4042

4143
### Repository
4244

4345
Plugin available:
44-
- _ActiveRecordRepository_: isolates the query layer to expose the resources in the admin interface.
46+
47+
- **ActiveRecordRepository**: isolates the query layer to expose the resources in the admin interface.
4548

4649
### View pages
4750

4851
Pages available:
49-
- _Root_: define how to present the content in the main page of the interface;
50-
- _PageNotFound_: define how to present pages not found;
51-
- _RecordNotFound_: define how to present record not found page;
52-
- _SimpleAuthLogin_: define how to present the login form for SimpleAuth plugin;
53-
- _Index_: define how to present a collection of items;
54-
- _Show_: define how to present the details of an item.
52+
53+
- **Root**: define how to present the content in the main page of the interface;
54+
- **PageNotFound**: define how to present pages not found;
55+
- **RecordNotFound**: define how to present record not found page;
56+
- **SimpleAuthLogin**: define how to present the login form for SimpleAuth plugin;
57+
- **Index**: define how to present a collection of items;
58+
- **Show**: define how to present the details of an item.
5559

5660
### View components
5761

5862
Components available:
59-
- _FiltersForm_: define how to present the filters form in the resource collection pages;
60-
- _Flash_: define how to present the flash messages;
61-
- _Head_: define how to present the Head tag;
62-
- _Navbar_: define how to present the navbar (the default one uses the Bootstrap structure);
63-
- _Pagination_: define how to present the pagination of a collection.
63+
64+
- **FiltersForm**: define how to present the filters form in the resource collection pages;
65+
- **Flash**: define how to present the flash messages;
66+
- **Head**: define how to present the Head tag;
67+
- **Navbar**: define how to present the navbar (the default one uses the Bootstrap structure);
68+
- **Pagination**: define how to present the pagination of a collection.
6469

6570
## Configuration
6671

@@ -70,9 +75,10 @@ See [extra](extra) folder for some usage examples.
7075
The following options are supported:
7176

7277
`root` (Hash): define the root section of the admin, properties:
73-
- `title` (String): root section's title;
74-
- `page` (String): a view object to render;
75-
- `redirect` (String): alternative to _page_ option - redirects to a specific slug;
78+
79+
- `title` (String): root section's title;
80+
- `page` (String): a view object to render;
81+
- `redirect` (String): alternative to _page_ option - redirects to a specific slug;
7682

7783
Example:
7884

@@ -88,9 +94,21 @@ root:
8894

8995
`record_not_found` (String): a view object to render when a missing record is requested.
9096

97+
`style_links` (Array of hashes): list of styles files to include, properties:
98+
99+
- `href` (String): URL for the style file;
100+
- `rel` (String): type of style file.
101+
102+
`scripts` (Array of hashes): list of scripts to include, properties:
103+
104+
- `src` (String): source URL for the script.
105+
106+
`extra_styles` (String): inline CSS styles.
107+
91108
`authentication` (Hash): define the authentication method, properties:
92-
- `plugin` (String): a plugin class to use (ex. `TinyAdmin::Plugins::SimpleAuth`);
93-
- `password` (String): a password hash used by _SimpleAuth_ plugin (generated with `Digest::SHA512.hexdigest("some password")`).
109+
110+
- `plugin` (String): a plugin class to use (ex. `TinyAdmin::Plugins::SimpleAuth`);
111+
- `password` (String): a password hash used by _SimpleAuth_ plugin (generated with `Digest::SHA512.hexdigest("some password")`).
94112

95113
Example:
96114

@@ -101,15 +119,17 @@ authentication:
101119
```
102120

103121
`sections` (Array of hashes): define the admin sections, properties:
104-
- `slug` (String): section reference identifier;
105-
- `name` (String): section's title;
106-
- `type` (String): the type of section: `url`, `page` or `resource`;
107-
- other properties depends on the section's type.
122+
123+
- `slug` (String): section reference identifier;
124+
- `name` (String): section's title;
125+
- `type` (String): the type of section: `url`, `page` or `resource`;
126+
- other properties depends on the section's type.
108127

109128
For _url_ sections:
110-
- `url` (String): the URL to load when clicking on the section's menu item;
111-
- `options` (Hash): properties:
112-
+ `target` (String): link _target_ attributes (ex. `_blank`).
129+
130+
- `url` (String): the URL to load when clicking on the section's menu item;
131+
- `options` (Hash): properties:
132+
+ `target` (String): link _target_ attributes (ex. `_blank`).
113133

114134
Example:
115135

@@ -123,7 +143,8 @@ options:
123143
```
124144

125145
For _page_ sections:
126-
- `page` (String): a view object to render.
146+
147+
- `page` (String): a view object to render.
127148

128149
Example:
129150

@@ -135,14 +156,15 @@ page: Admin::Stats
135156
```
136157

137158
For _resource_ sections:
138-
- `model` (String): the class to use to fetch the data on an item of a collection;
139-
- `repository` (String): the class to get the properties related to the model;
140-
- `index` (Hash): collection's action options;
141-
- `show` (Hash): detail's action options;
142-
- `collection_actions` (Array of hashes): custom collection's actions;
143-
- `member_actions` (Array of hashes): custom details's actions;
144-
- `only` (Array of strings): list of supported actions (ex. `index`);
145-
- `options` (Array of strings): resource options (ex. `hidden`).
159+
160+
- `model` (String): the class to use to fetch the data on an item of a collection;
161+
- `repository` (String): the class to get the properties related to the model;
162+
- `index` (Hash): collection's action options (see below);
163+
- `show` (Hash): detail's action options (see below);
164+
- `collection_actions` (Array of hashes): custom collection's actions;
165+
- `member_actions` (Array of hashes): custom details's actions;
166+
- `only` (Array of strings): list of supported actions (ex. `index`);
167+
- `options` (Array of strings): resource options (ex. `hidden`).
146168

147169
Example:
148170

@@ -153,14 +175,72 @@ type: resource
153175
model: Post
154176
```
155177

156-
`style_links` (Array of hashes): list of styles files to include, properties:
157-
- `href` (String): URL for the style file;
158-
- `rel` (String): type of style file.
178+
#### Resource index options
159179

160-
`scripts` (Array of hashes): list of scripts to include, properties:
161-
- `src` (String): source URL for the script.
180+
The Index hash supports the following options:
162181

163-
`extra_styles` (String): inline CSS styles.
182+
- `attributes` (Array): fields to expose in the resource list page;
183+
- `filters` (Array): filter the current listing;
184+
- `links` (Array): custom member actions to expose for each list's entry (defined in _member_actions_);
185+
- `pagination` (Integer): max pages size;
186+
- `sort` (Array): sort options to pass to the listing query.
187+
188+
Example:
189+
190+
```yml
191+
index:
192+
sort:
193+
- id DESC
194+
pagination: 10
195+
attributes:
196+
- id
197+
- author: call, name
198+
- position: round, 1
199+
- field: author_id
200+
header: The author
201+
link_to: authors
202+
call: author, name
203+
filters:
204+
- title
205+
- field: state
206+
type: select
207+
values:
208+
- published
209+
- draft
210+
- archived
211+
links:
212+
- show
213+
- author_posts
214+
- csv_export
215+
```
216+
217+
#### Resource show options
218+
219+
The Show hash supports the following options:
220+
221+
- `attributes` (Array): fields to expose in the resource details page.
222+
223+
Example:
224+
225+
```yml
226+
show:
227+
attributes:
228+
# Expose the id column
229+
- id
230+
# Expose the title column, calling `downcase` support method
231+
- title: downcase
232+
# Expose the category column, calling `upcase` support method
233+
- category: upcase
234+
# Expose the position column, calling `format` support method with argument %f
235+
- position: format, %f
236+
# Expose the position created_at, calling `strftime` support method with argument %Y%m%d %H:%M
237+
- created_at: strftime, %Y%m%d %H:%M
238+
# Expose the author_id column, with a custom header label, linked to authors section and calling author.name to get the value
239+
- field: author_id
240+
header: The author
241+
link_to: authors
242+
call: author, name
243+
```
164244
165245
### Sample
166246

lib/tiny_admin/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# frozen_string_literal: true
22

33
module TinyAdmin
4-
VERSION = '0.4.0'
4+
VERSION = '0.5.0'
55
end

0 commit comments

Comments
 (0)