11# Tiny Admin
22
3+ [ ![ Gem Version] ( https://badge.fury.io/rb/tiny_admin.svg )] ( https://badge.fury.io/rb/tiny_admin ) [ ![ Linters] ( https://github.com/blocknotes/tiny_admin/actions/workflows/linters.yml/badge.svg )] ( https://github.com/blocknotes/tiny_admin/actions/workflows/linters.yml ) [ ![ Specs Rails 7.0] ( https://github.com/blocknotes/tiny_admin/actions/workflows/specs_rails_70.yml/badge.svg )] ( https://github.com/blocknotes/tiny_admin/actions/workflows/specs_rails_70.yml )
4+
35A compact and composable dashboard component for Ruby.
46
57The main features are:
@@ -14,7 +16,7 @@ Please ⭐ if you like it.
1416
1517## Install
1618
17- - Add to your Gemfile: ` gem 'tiny_admin' `
19+ - Add to your Gemfile: ` gem 'tiny_admin', '~> 0.1' `
1820- Mount the app in a route (check some examples with: Hanami, Rails, Roda and standalone in [ extra] ( extra ) )
1921- Configure the dashboard using ` TinyAdmin.configure ` and/or ` TinyAdmin.configure_from_file ` (see [ configuration] ( #configuration ) below)
2022
@@ -53,10 +55,98 @@ Components available:
5355## Configuration
5456
5557TinyAdmin can be configured using a YAML file and/or programmatically.
56-
5758See [ extra] ( extra ) folder for some usage examples.
5859
59- Sample:
60+ The following options are supported:
61+
62+ ` root ` (Hash): define the root section of the admin, properties:
63+ - ` title ` (String): root section's title;
64+ - ` page ` (String): a view object to render;
65+ - ` redirect ` (String): alternative to _ page_ option - redirects to a specific slug;
66+
67+ Example:
68+
69+ ``` yml
70+ root :
71+ title : MyAdmin
72+ redirect : posts
73+ ` ` `
74+
75+ ` authentication` (Hash): define the authentication method, properties:
76+ - `plugin` (String) : a plugin class to use (ex. `TinyAdmin::Plugins::SimpleAuth`);
77+ - `password` (String) : a password hash used by _SimpleAuth_ plugin (generated with `Digest::SHA512.hexdigest("some password")`).
78+
79+ Example :
80+
81+ ` ` ` yml
82+ authentication:
83+ plugin: TinyAdmin::Plugins::SimpleAuth
84+ password: 'f1891cea80fc05e433c943254c6bdabc159577a02a7395dfebbfbc4f7661d4af56f2d372131a45936de40160007368a56ef216a30cb202c66d3145fd24380906'
85+ ` ` `
86+
87+ `sections` (Array of hashes) : define the admin sections, properties:
88+ - `slug` (String) : section reference identifier;
89+ - `name` (String) : section's title;
90+ - `type` (String) : the type of section: `url`, `page` or `resource`;
91+ - other properties depends on the section's type.
92+
93+ For _url_ sections :
94+ - `url` (String) : the URL to load when clicking on the section's menu item;
95+ - `options` (Hash) : properties:
96+ + `target` (String) : link _target_ attributes (ex. `_blank`).
97+
98+ Example :
99+
100+ ` ` ` yml
101+ slug: google
102+ name: Google.it
103+ type: url
104+ url: https://www.google.it
105+ options:
106+ target: '_blank'
107+ ` ` `
108+
109+ For _page_ sections :
110+ - `page` (String) : a view object to render.
111+
112+ Example :
113+
114+ ` ` ` yml
115+ slug: stats
116+ name: Stats
117+ type: page
118+ page: Admin::Stats
119+ ` ` `
120+
121+ For _resource_ sections :
122+ - `model` (String) : the class to use to fetch the data on an item of a collection;
123+ - `repository` (String) : the class to get the properties related to the model;
124+ - `index` (Hash) : collection's action options;
125+ - `show` (Hash) : detail's action options;
126+ - `collection_actions` (Array of hashes) : custom collection's actions;
127+ - `member_actions` (Array of hashes) : custom details's actions;
128+ - `only` (Array of strings) : list of supported actions (ex. `index`);
129+ - `options` (Array of strings) : resource options (ex. `hidden`).
130+
131+ Example :
132+
133+ ` ` ` yml
134+ slug: posts
135+ name: Posts
136+ type: resource
137+ model: Post
138+ ` ` `
139+
140+ `style_links` (Array of hashes) : list of styles files to include, properties:
141+ - `href` (String) : URL for the style file;
142+ - `rel` (String) : type of style file.
143+
144+ `scripts` (Array of hashes) : list of scripts to include, properties:
145+ - `src` (String) : source URL for the script.
146+
147+ `extra_styles` (String) : inline CSS styles.
148+
149+ # ## Sample
60150
61151` ` ` rb
62152# config/initializers/tiny_admin.rb
0 commit comments