tolaria 1.0.0
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/.gitignore +66 -0
- data/.yardopts +4 -0
- data/CNAME +1 -0
- data/CONTRIBUTING.md +32 -0
- data/Gemfile +2 -0
- data/LICENSE.md +9 -0
- data/README.md +538 -0
- data/Rakefile +52 -0
- data/app/assets/fonts/admin/fontawesome.eot +0 -0
- data/app/assets/fonts/admin/fontawesome.svg +565 -0
- data/app/assets/fonts/admin/fontawesome.ttf +0 -0
- data/app/assets/fonts/admin/fontawesome.woff +0 -0
- data/app/assets/fonts/admin/fontawesome.woff2 +0 -0
- data/app/assets/images/admin/columbia_banner.png +0 -0
- data/app/assets/images/admin/favicon.ico +0 -0
- data/app/assets/images/admin/noise.png +0 -0
- data/app/assets/images/admin/select_arrows.svg +1 -0
- data/app/assets/javascripts/admin/admin.js +4 -0
- data/app/assets/javascripts/admin/base.js +12 -0
- data/app/assets/javascripts/admin/lib/backbone.js +1888 -0
- data/app/assets/javascripts/admin/lib/jquery.chosen.js +1272 -0
- data/app/assets/javascripts/admin/lib/jquery.js +10361 -0
- data/app/assets/javascripts/admin/lib/jquery.selection.js +352 -0
- data/app/assets/javascripts/admin/lib/moment.js +3103 -0
- data/app/assets/javascripts/admin/lib/no.js +6 -0
- data/app/assets/javascripts/admin/lib/underscore.js +1570 -0
- data/app/assets/javascripts/admin/models/composer_buttons.js +45 -0
- data/app/assets/javascripts/admin/models/rails_meta.js +4 -0
- data/app/assets/javascripts/admin/views/field_with_errors.js +19 -0
- data/app/assets/javascripts/admin/views/fields/attachment_field.js +32 -0
- data/app/assets/javascripts/admin/views/fields/has_many.js +64 -0
- data/app/assets/javascripts/admin/views/fields/image_association_select.js +31 -0
- data/app/assets/javascripts/admin/views/fields/markdown_composer.js +167 -0
- data/app/assets/javascripts/admin/views/fields/searchable_select.js +70 -0
- data/app/assets/javascripts/admin/views/fields/slug_field.js +38 -0
- data/app/assets/javascripts/admin/views/fields/swatch_field.js +55 -0
- data/app/assets/javascripts/admin/views/fields/timestamp_field.js +80 -0
- data/app/assets/javascripts/admin/views/flash_message.js +18 -0
- data/app/assets/javascripts/admin/views/form_orchestrator.js +41 -0
- data/app/assets/javascripts/admin/views/navigation.js +20 -0
- data/app/assets/javascripts/admin/views/resource_form.js +18 -0
- data/app/assets/javascripts/admin/views/search_form.js +20 -0
- data/app/assets/javascripts/admin/views/sessions.js +109 -0
- data/app/assets/javascripts/admin/views/virtual_form.js +47 -0
- data/app/assets/stylesheets/admin/_base.scss +5 -0
- data/app/assets/stylesheets/admin/_reset.scss +149 -0
- data/app/assets/stylesheets/admin/_root.scss +63 -0
- data/app/assets/stylesheets/admin/admin.scss +4 -0
- data/app/assets/stylesheets/admin/components/_blank_slate.scss +44 -0
- data/app/assets/stylesheets/admin/components/_buttons.scss +82 -0
- data/app/assets/stylesheets/admin/components/_flash_message.scss +64 -0
- data/app/assets/stylesheets/admin/components/_footer.scss +9 -0
- data/app/assets/stylesheets/admin/components/_header.scss +107 -0
- data/app/assets/stylesheets/admin/components/_index_table.scss +120 -0
- data/app/assets/stylesheets/admin/components/_main.scss +68 -0
- data/app/assets/stylesheets/admin/components/_markdown_body.scss +109 -0
- data/app/assets/stylesheets/admin/components/_navigation.scss +110 -0
- data/app/assets/stylesheets/admin/components/_pagination.scss +36 -0
- data/app/assets/stylesheets/admin/components/_pill.scss +11 -0
- data/app/assets/stylesheets/admin/components/_resource_form.scss +222 -0
- data/app/assets/stylesheets/admin/components/_search_form.scss +36 -0
- data/app/assets/stylesheets/admin/components/_sessions.scss +152 -0
- data/app/assets/stylesheets/admin/components/_show_table.scss +67 -0
- data/app/assets/stylesheets/admin/components/forms/_attachment_field.scss +59 -0
- data/app/assets/stylesheets/admin/components/forms/_chosen.scss +478 -0
- data/app/assets/stylesheets/admin/components/forms/_image_association_select.scss +20 -0
- data/app/assets/stylesheets/admin/components/forms/_markdown_composer.scss +149 -0
- data/app/assets/stylesheets/admin/components/forms/_nested_fields.scss +63 -0
- data/app/assets/stylesheets/admin/components/forms/_searchable_select.scss +8 -0
- data/app/assets/stylesheets/admin/components/forms/_slug_field.scss +20 -0
- data/app/assets/stylesheets/admin/components/forms/_swatch_field.scss +47 -0
- data/app/assets/stylesheets/admin/components/forms/_timestamp_field.scss +15 -0
- data/app/assets/stylesheets/admin/components/help_link.scss +6 -0
- data/app/assets/stylesheets/admin/mixins/_clearfix.scss +18 -0
- data/app/assets/stylesheets/admin/mixins/_min_max_width.scss +11 -0
- data/app/assets/stylesheets/admin/mixins/_rgbb.scss +7 -0
- data/app/assets/stylesheets/admin/mixins/_visuallyhidden.scss +33 -0
- data/app/assets/stylesheets/admin/settings/_animations.scss +21 -0
- data/app/assets/stylesheets/admin/settings/_breakpoints.scss +2 -0
- data/app/assets/stylesheets/admin/settings/_colors.scss +32 -0
- data/app/assets/stylesheets/admin/settings/_fonts.scss +31 -0
- data/app/assets/stylesheets/admin/settings/_icons.scss +1658 -0
- data/app/controllers/admin/admin_controller.rb +21 -0
- data/app/controllers/admin/sessions_controller.rb +112 -0
- data/app/controllers/tolaria/resource_controller.rb +132 -0
- data/app/controllers/tolaria/tolaria_controller.rb +40 -0
- data/app/helpers/admin/table_helper.rb +175 -0
- data/app/helpers/admin/view_helper.rb +76 -0
- data/app/mailers/passcode_mailer.rb +11 -0
- data/app/models/administrator.rb +146 -0
- data/app/views/admin/administrators/_form.html.erb +16 -0
- data/app/views/admin/administrators/_index.html.erb +20 -0
- data/app/views/admin/administrators/_search.html.erb +5 -0
- data/app/views/admin/administrators/_show.html.erb +14 -0
- data/app/views/admin/help/help_link.html.erb +16 -0
- data/app/views/admin/session/form.html.erb +52 -0
- data/app/views/admin/shared/_flash_messages.html.erb +42 -0
- data/app/views/admin/shared/_footer.html.erb +8 -0
- data/app/views/admin/shared/_head.html.erb +11 -0
- data/app/views/admin/shared/_header.html.erb +43 -0
- data/app/views/admin/shared/_navigation.html.erb +47 -0
- data/app/views/admin/shared/_skiplinks.html.erb +0 -0
- data/app/views/admin/shared/forms/_attachment_field.html.erb +17 -0
- data/app/views/admin/shared/forms/_has_many.html.erb +14 -0
- data/app/views/admin/shared/forms/_has_many_header.html.erb +19 -0
- data/app/views/admin/shared/forms/_image_association_select.html.erb +6 -0
- data/app/views/admin/shared/forms/_image_field.html.erb +19 -0
- data/app/views/admin/shared/forms/_markdown_composer.html.erb +29 -0
- data/app/views/admin/shared/forms/_searchable_select.html.erb +3 -0
- data/app/views/admin/shared/forms/_slug_field.html.erb +9 -0
- data/app/views/admin/shared/forms/_swatch_field.html.erb +4 -0
- data/app/views/admin/shared/forms/_timestamp_field.html.erb +19 -0
- data/app/views/admin/tolaria_resource/_form_buttons.html.erb +10 -0
- data/app/views/admin/tolaria_resource/_index_table.html.erb +73 -0
- data/app/views/admin/tolaria_resource/_search_form.html.erb +32 -0
- data/app/views/admin/tolaria_resource/_show_buttons.html.erb +13 -0
- data/app/views/admin/tolaria_resource/edit.html.erb +34 -0
- data/app/views/admin/tolaria_resource/index.html.erb +36 -0
- data/app/views/admin/tolaria_resource/new.html.erb +1 -0
- data/app/views/admin/tolaria_resource/show.html.erb +52 -0
- data/app/views/kaminari/admin/_first_page.html.erb +9 -0
- data/app/views/kaminari/admin/_last_page.html.erb +9 -0
- data/app/views/kaminari/admin/_next_page.html.erb +9 -0
- data/app/views/kaminari/admin/_page.html.erb +17 -0
- data/app/views/kaminari/admin/_paginator.html.erb +21 -0
- data/app/views/kaminari/admin/_prev_page.html.erb +9 -0
- data/app/views/layouts/admin/admin.html.erb +21 -0
- data/app/views/layouts/admin/sessions.html.erb +12 -0
- data/app/views/passcode_mailer/passcode.text.erb +5 -0
- data/lib/generators/tolaria/install/install_generator.rb +21 -0
- data/lib/generators/tolaria/install/templates/administrators_migration.rb +31 -0
- data/lib/generators/tolaria/install/templates/tolaria_initializer.rb +93 -0
- data/lib/tasks/admin.rake +32 -0
- data/lib/tolaria.rb +27 -0
- data/lib/tolaria/active_record.rb +55 -0
- data/lib/tolaria/admin.rb +4 -0
- data/lib/tolaria/categories.rb +21 -0
- data/lib/tolaria/config.rb +40 -0
- data/lib/tolaria/default_config.rb +74 -0
- data/lib/tolaria/engine.rb +23 -0
- data/lib/tolaria/form_buildable.rb +203 -0
- data/lib/tolaria/help_links.rb +78 -0
- data/lib/tolaria/introspection.rb +13 -0
- data/lib/tolaria/manage.rb +57 -0
- data/lib/tolaria/managed_class.rb +90 -0
- data/lib/tolaria/markdown.rb +28 -0
- data/lib/tolaria/random_tokens.rb +16 -0
- data/lib/tolaria/reload.rb +21 -0
- data/lib/tolaria/routes.rb +33 -0
- data/lib/tolaria/version.rb +13 -0
- data/test/demo/Rakefile +4 -0
- data/test/demo/app/assets/javascripts/application.js +1 -0
- data/test/demo/app/assets/stylesheets/application.scss +1 -0
- data/test/demo/app/controllers/application_controller.rb +5 -0
- data/test/demo/app/controllers/concerns/.keep +0 -0
- data/test/demo/app/controllers/homepage_controller.rb +4 -0
- data/test/demo/app/helpers/application_helper.rb +2 -0
- data/test/demo/app/mailers/.keep +0 -0
- data/test/demo/app/models/.keep +0 -0
- data/test/demo/app/models/blog_post.rb +43 -0
- data/test/demo/app/models/footnote.rb +5 -0
- data/test/demo/app/models/image.rb +19 -0
- data/test/demo/app/models/legal_page.rb +24 -0
- data/test/demo/app/models/miscellany.rb +12 -0
- data/test/demo/app/models/topic.rb +22 -0
- data/test/demo/app/models/video.rb +16 -0
- data/test/demo/app/views/admin/blog_posts/_form.html.erb +48 -0
- data/test/demo/app/views/admin/blog_posts/_search.html.erb +5 -0
- data/test/demo/app/views/admin/help/markdown-help.md +95 -0
- data/test/demo/app/views/admin/images/_form.html.erb +26 -0
- data/test/demo/app/views/admin/legal_pages/_form.html.erb +15 -0
- data/test/demo/app/views/admin/topics/_form.html.erb +3 -0
- data/test/demo/app/views/admin/videos/_form.html.erb +11 -0
- data/test/demo/app/views/homepage/homepage.html.erb +3 -0
- data/test/demo/app/views/layouts/application.html.erb +14 -0
- data/test/demo/bin/bundle +3 -0
- data/test/demo/bin/rails +4 -0
- data/test/demo/bin/rake +4 -0
- data/test/demo/bin/setup +29 -0
- data/test/demo/config.ru +4 -0
- data/test/demo/config/application.rb +26 -0
- data/test/demo/config/boot.rb +4 -0
- data/test/demo/config/database.yml +18 -0
- data/test/demo/config/environment.rb +3 -0
- data/test/demo/config/environments/development.rb +43 -0
- data/test/demo/config/environments/test.rb +44 -0
- data/test/demo/config/initializers/assets.rb +11 -0
- data/test/demo/config/initializers/cookies_serializer.rb +2 -0
- data/test/demo/config/initializers/filter_parameter_logging.rb +3 -0
- data/test/demo/config/initializers/inflections.rb +17 -0
- data/test/demo/config/initializers/markdown.rb +44 -0
- data/test/demo/config/initializers/secret_token.rb +2 -0
- data/test/demo/config/initializers/session_store.rb +2 -0
- data/test/demo/config/initializers/tolaria.rb +17 -0
- data/test/demo/config/initializers/wrap_parameters.rb +14 -0
- data/test/demo/config/routes.rb +4 -0
- data/test/demo/db/migrate/20150601202901_create_administrators.rb +31 -0
- data/test/demo/db/migrate/20150603204006_add_testing_models.rb +27 -0
- data/test/demo/db/migrate/20150609232013_create_footnotes.rb +10 -0
- data/test/demo/db/migrate/20150610135235_create_additional_demo_objects.rb +50 -0
- data/test/demo/db/schema.rb +112 -0
- data/test/demo/log/.keep +0 -0
- data/test/demo/public/404.html +67 -0
- data/test/demo/public/422.html +67 -0
- data/test/demo/public/500.html +66 -0
- data/test/demo/public/favicon.ico +0 -0
- data/test/integration/help_link_test.rb +73 -0
- data/test/integration/interface_test.rb +63 -0
- data/test/integration/router_test.rb +73 -0
- data/test/integration/session_test.rb +88 -0
- data/test/test_helper.rb +58 -0
- data/test/unit/configuration_test.rb +21 -0
- data/test/unit/managed_classes_test.rb +54 -0
- data/test/unit/markdown_test.rb +12 -0
- data/test/unit/menu_test.rb +32 -0
- data/test/unit/random_tokens_test.rb +13 -0
- data/tolaria.gemspec +35 -0
- metadata +499 -0
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
<li><%= link_to "First", url, class:"button -page-first" %></li>
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
<li><%= link_to "Last", url, class:"button -page-last" %></li>
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
<li><%= link_to "Next", url, class:"button -page-next" %></li>
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
<li>
|
|
11
|
+
<% rel = "next" if page.next? %>
|
|
12
|
+
<% rel = "prev" if page.prev? %>
|
|
13
|
+
<%= link_to page, url, {
|
|
14
|
+
class: (page.current?? "button -primary -page-current" : "button -page"),
|
|
15
|
+
rel: rel,
|
|
16
|
+
} %>
|
|
17
|
+
</li>
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
<ol class="pagination">
|
|
11
|
+
<%= first_page_tag unless current_page.first? %>
|
|
12
|
+
<%= prev_page_tag unless current_page.first? %>
|
|
13
|
+
<% each_page do |page| -%>
|
|
14
|
+
<% if page.left_outer? || page.right_outer? || page.inside_window? -%>
|
|
15
|
+
<%= page_tag page %>
|
|
16
|
+
<% end -%>
|
|
17
|
+
<% end -%>
|
|
18
|
+
<%= next_page_tag unless current_page.last? %>
|
|
19
|
+
<%= last_page_tag unless current_page.last? %>
|
|
20
|
+
</ol>
|
|
21
|
+
<% end -%>
|
|
@@ -0,0 +1,9 @@
|
|
|
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
|
+
<li><%= link_to "Prev", url, class:"button -page-prev" %></li>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html class="no-js">
|
|
3
|
+
<%= render "admin/shared/head" %>
|
|
4
|
+
<body class="admin">
|
|
5
|
+
|
|
6
|
+
<%= render "admin/shared/skiplinks" %>
|
|
7
|
+
<%= render "admin/shared/header" %>
|
|
8
|
+
<%= render "admin/shared/flash_messages" %>
|
|
9
|
+
|
|
10
|
+
<div class="application-container">
|
|
11
|
+
<%= render "admin/shared/navigation" %>
|
|
12
|
+
<div id="main" class="main" role="main">
|
|
13
|
+
<%= yield %>
|
|
14
|
+
</div>
|
|
15
|
+
</div>
|
|
16
|
+
|
|
17
|
+
<%= render "admin/shared/footer" %>
|
|
18
|
+
<%= javascript_include_tag "admin/admin" %>
|
|
19
|
+
|
|
20
|
+
</body>
|
|
21
|
+
</html>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<%= render "admin/shared/head" %>
|
|
4
|
+
<body class="admin-session">
|
|
5
|
+
<%= render "admin/shared/skiplinks" %>
|
|
6
|
+
<div class="header-stripe">
|
|
7
|
+
<div class="header-stripe-inner"></div>
|
|
8
|
+
</div>
|
|
9
|
+
<%= yield %>
|
|
10
|
+
<%= javascript_include_tag "admin/admin" %>
|
|
11
|
+
</body>
|
|
12
|
+
</html>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
require "rails/generators/migration"
|
|
2
|
+
|
|
3
|
+
module Tolaria
|
|
4
|
+
class InstallGenerator < ::Rails::Generators::Base
|
|
5
|
+
include Rails::Generators::Migration
|
|
6
|
+
source_root File.expand_path("../templates", __FILE__)
|
|
7
|
+
|
|
8
|
+
def install
|
|
9
|
+
copy_file "tolaria_initializer.rb", "config/initializers/tolaria.rb"
|
|
10
|
+
migration_template "administrators_migration.rb", "db/migrate/create_administrators.rb"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def self.next_migration_number(dirname)
|
|
14
|
+
if ActiveRecord::Base.timestamped_migrations
|
|
15
|
+
Time.current.utc.strftime("%Y%m%d%H%M%S")
|
|
16
|
+
else
|
|
17
|
+
"%.3d" % (current_migration_number(dirname) + 1)
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
class CreateAdministrators < ActiveRecord::Migration
|
|
2
|
+
def change
|
|
3
|
+
|
|
4
|
+
create_table :administrators, force:true do |t|
|
|
5
|
+
|
|
6
|
+
t.timestamps null:false
|
|
7
|
+
|
|
8
|
+
# The email used to log into this account
|
|
9
|
+
t.string :email, null:false, index:true
|
|
10
|
+
|
|
11
|
+
# Visible information about this account
|
|
12
|
+
t.string :name, null:false
|
|
13
|
+
t.string :organization, null:false
|
|
14
|
+
|
|
15
|
+
# Passcode and authentication system fields
|
|
16
|
+
|
|
17
|
+
t.string :passcode, limit:60, null:false
|
|
18
|
+
t.datetime :passcode_expires_at, null:false
|
|
19
|
+
|
|
20
|
+
t.string :auth_token, limit:32, null:false, index:true
|
|
21
|
+
|
|
22
|
+
t.datetime :account_unlocks_at, null:false
|
|
23
|
+
t.integer :lockout_strikes, null:false, default:0
|
|
24
|
+
|
|
25
|
+
t.integer :total_strikes, null:false, default:0
|
|
26
|
+
t.integer :sessions_created, null:false, default:0
|
|
27
|
+
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# Configuration for Tolaria, the admin framework for making people happy.
|
|
2
|
+
|
|
3
|
+
Tolaria.configure do |config|
|
|
4
|
+
|
|
5
|
+
# The name of the company or group using this admin interface.
|
|
6
|
+
# Used in system navigation, HTML page titles, and the copyright line.
|
|
7
|
+
config.company_name = "Company Name"
|
|
8
|
+
|
|
9
|
+
# Tolaria sends authentication emails. Set the value of the From header here.
|
|
10
|
+
# This is NOT a trivial choice, you might have to get this address
|
|
11
|
+
# whitelisted by your target companies.
|
|
12
|
+
config.from_address = "Rails <tolaria@example.org>"
|
|
13
|
+
|
|
14
|
+
# Redirect the administrator to this route by default when logging in
|
|
15
|
+
# or when no other redirect makes sense.
|
|
16
|
+
config.default_redirect = :admin_administrators
|
|
17
|
+
|
|
18
|
+
# You can assign models to a category to group them on the navigation menu.
|
|
19
|
+
# Add/modify categories by changing the array below.
|
|
20
|
+
# Categories will be in the same order in the menu as they are here.
|
|
21
|
+
config.menu_categories = [
|
|
22
|
+
# "Syndication",
|
|
23
|
+
# "Pages",
|
|
24
|
+
"Settings",
|
|
25
|
+
]
|
|
26
|
+
|
|
27
|
+
# Tolaria does not come bundled with a Markdown processing strategy.
|
|
28
|
+
# You must provide a string that names a Ruby constant that can process Markdown.
|
|
29
|
+
# The constant must respond to render(document), returning a string of HTML.
|
|
30
|
+
# For example: if you provide "MyMarkDownRenderer", Tolaria will
|
|
31
|
+
# call MyMarkdownRenderer.render(document)
|
|
32
|
+
# If you leave this setting nil, Tolaria will assume that you do not
|
|
33
|
+
# plan to use the markdown_composer form field.
|
|
34
|
+
config.markdown_renderer = nil
|
|
35
|
+
|
|
36
|
+
# You can provide documentation links in the interface header by
|
|
37
|
+
# configuring them below. Add hashes to the array, with these keys:
|
|
38
|
+
#
|
|
39
|
+
# To render a Markdown file, provide a `:title`, the URL fragment `:slug`
|
|
40
|
+
# and a `:markdown_file` path to your Markdown document. The system
|
|
41
|
+
# will automatically draw a route to this view for you and present your file,
|
|
42
|
+
# using the renderer configured in config.markdown_renderer
|
|
43
|
+
#
|
|
44
|
+
# To link to an arbitrary route or URL, provide a `:title` and a `:link_to`.
|
|
45
|
+
# Examples below:
|
|
46
|
+
#
|
|
47
|
+
# config.help_links << {
|
|
48
|
+
# title: "Markdown Reference",
|
|
49
|
+
# slug: "markdown-reference",
|
|
50
|
+
# markdown_file: "/path/to/your/file.md",
|
|
51
|
+
# }
|
|
52
|
+
#
|
|
53
|
+
# config.help_links << {
|
|
54
|
+
# title: "Style Guide",
|
|
55
|
+
# link_to: "http://example.org/styleguide",
|
|
56
|
+
# }
|
|
57
|
+
|
|
58
|
+
# Tolaria attempts to convert model instances to a pretty “display”
|
|
59
|
+
# string for presenting in forms, titles, and listings.
|
|
60
|
+
# You can define `admin_name` on your model to set the string yourself,
|
|
61
|
+
# or you can append your own preferred methods to the front
|
|
62
|
+
# of Tolaria’s list like so:
|
|
63
|
+
# config.display_name_methods.unshift(:method_name)
|
|
64
|
+
|
|
65
|
+
# The number of items on each page when paginating models.
|
|
66
|
+
# Raising this too high might make page loading very slow.
|
|
67
|
+
# config.page_size = 15
|
|
68
|
+
|
|
69
|
+
# ---------------------------------------------------------------------------
|
|
70
|
+
# Change the following passcode and account paranoia settings with caution.
|
|
71
|
+
# Defaults are shown in comments.
|
|
72
|
+
# ---------------------------------------------------------------------------
|
|
73
|
+
|
|
74
|
+
# The length of time, in seconds, that emailed passcodes should be valid.
|
|
75
|
+
# It is STRONGLY RECOMMENDED that you keep this under 30 minutes.
|
|
76
|
+
# config.passcode_lifespan = 10.minutes
|
|
77
|
+
|
|
78
|
+
# The number of times an administrator can flunk their passcode challenge
|
|
79
|
+
# or request a token before Tolaria rate-limits/locks their account.
|
|
80
|
+
# config.lockout_threshold = 10
|
|
81
|
+
|
|
82
|
+
# The length of time that an administrator’s account is disabled after
|
|
83
|
+
# they trip the lockout threshold. There is no unlock strategy besides time.
|
|
84
|
+
# For emergencies, you can manually call unlock_account! on the relevant administrator.
|
|
85
|
+
# config.lockout_duration = 1.hour
|
|
86
|
+
|
|
87
|
+
# The cost factor for bcrypt. Raising this number will increase the
|
|
88
|
+
# wall clock time bcrypt takes to hash a passphrase.
|
|
89
|
+
# It is VERY DANGEROUS to set this below 10 for production code.
|
|
90
|
+
# Use 1 in test mode to speed up your test suite.
|
|
91
|
+
# config.bcrypt_cost = Rails.env.test?? 1 : 13
|
|
92
|
+
|
|
93
|
+
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
namespace :admin do
|
|
2
|
+
|
|
3
|
+
desc "Add a new Tolaria Administrator from the command line"
|
|
4
|
+
task :create => :environment do
|
|
5
|
+
|
|
6
|
+
@administrator = Administrator.new
|
|
7
|
+
|
|
8
|
+
STDOUT.puts "Enter the new administrator’s credentials. All fields are required."
|
|
9
|
+
|
|
10
|
+
STDOUT.print "Email address: "
|
|
11
|
+
@administrator.email = STDIN.gets.chomp
|
|
12
|
+
|
|
13
|
+
STDOUT.print "Full name: "
|
|
14
|
+
@administrator.name = STDIN.gets.chomp
|
|
15
|
+
|
|
16
|
+
STDOUT.print "Organization: "
|
|
17
|
+
@administrator.organization = STDIN.gets.chomp
|
|
18
|
+
|
|
19
|
+
if @administrator.save
|
|
20
|
+
STDOUT.puts %{The administrator "#{@administrator.name}" <#{@administrator.email}> was successfully created.}
|
|
21
|
+
exit(true)
|
|
22
|
+
else
|
|
23
|
+
STDOUT.puts "Your changes couldn’t be saved:"
|
|
24
|
+
@administrator.errors.full_messages.each do |message|
|
|
25
|
+
STDOUT.puts message
|
|
26
|
+
end
|
|
27
|
+
exit(false)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
end
|
data/lib/tolaria.rb
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
require "securerandom"
|
|
2
|
+
require "digest/md5"
|
|
3
|
+
|
|
4
|
+
require "rails"
|
|
5
|
+
require "sass"
|
|
6
|
+
require "sass-rails"
|
|
7
|
+
require "bcrypt"
|
|
8
|
+
require "kaminari"
|
|
9
|
+
require "ransack"
|
|
10
|
+
|
|
11
|
+
require "tolaria/version"
|
|
12
|
+
require "tolaria/engine"
|
|
13
|
+
require "tolaria/config"
|
|
14
|
+
require "tolaria/default_config"
|
|
15
|
+
require "tolaria/random_tokens"
|
|
16
|
+
require "tolaria/admin"
|
|
17
|
+
|
|
18
|
+
require "tolaria/reload"
|
|
19
|
+
require "tolaria/managed_class"
|
|
20
|
+
require "tolaria/manage"
|
|
21
|
+
require "tolaria/active_record"
|
|
22
|
+
require "tolaria/help_links"
|
|
23
|
+
require "tolaria/routes"
|
|
24
|
+
require "tolaria/introspection"
|
|
25
|
+
require "tolaria/categories"
|
|
26
|
+
require "tolaria/markdown"
|
|
27
|
+
require "tolaria/form_buildable"
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
# Adds a new DSL method to ActiveRecord model definition, allowing the
|
|
2
|
+
# developer to configure a model to manage with Tolaria.
|
|
3
|
+
# The developer passes a hash of configuration options which are
|
|
4
|
+
# forwarded as keyword arguments to Tolaria.manage
|
|
5
|
+
|
|
6
|
+
class ActiveRecord::Base
|
|
7
|
+
|
|
8
|
+
# Register a model with Tolaria and allow administrators to manage it
|
|
9
|
+
# in the admin interface. Accepts one named parameter, +using+
|
|
10
|
+
# which should be a Hash of options below.
|
|
11
|
+
#
|
|
12
|
+
# #### Options
|
|
13
|
+
#
|
|
14
|
+
# - `:category` - The navigation category to use for this resource.
|
|
15
|
+
# Should be one of the configured labels in Tolaria.config.menu_categories.
|
|
16
|
+
# The default is `"Settings"`.
|
|
17
|
+
# - `:priority` - The priority for this item in its menu category.
|
|
18
|
+
# Items with lower priority are sorted first.
|
|
19
|
+
# The default is 10.
|
|
20
|
+
# - `:icon` - The Font Awesome icon to use for this model.
|
|
21
|
+
# Should be one of the names on the Font Awesome site at
|
|
22
|
+
# http://fortawesome.github.io/Font-Awesome/icons/
|
|
23
|
+
# The default is `"file-o"`.
|
|
24
|
+
# - `:permitted_params` - A array of parameter names to pass to
|
|
25
|
+
# `params.permit()` for this model/form.
|
|
26
|
+
# The default is an empty array. You will need to set this option to
|
|
27
|
+
# match the fields you included on your admin form.
|
|
28
|
+
# - `:default_order` - The default `order()` for sorting this
|
|
29
|
+
# model when no other sorting is happening.
|
|
30
|
+
# The default is `"id DESC"`.
|
|
31
|
+
# - `:paginated` - If `true`, Tolaria will apply the default
|
|
32
|
+
# pagination controls/system to the model. Set to `false` to disable.
|
|
33
|
+
# The default is `true`.
|
|
34
|
+
# - `:allowed_actions` - The router actions to draw for this model.
|
|
35
|
+
# Only set this value yourself if you are overriding or forbidding some
|
|
36
|
+
# route construction.
|
|
37
|
+
# Tolaria will pass this array as the `only:` option to the router.
|
|
38
|
+
# The default includes all CRUD actions:
|
|
39
|
+
# `[:index, :show, :new, :create, :edit, :update, :destroy]`
|
|
40
|
+
def self.manage_with_tolaria(using:{})
|
|
41
|
+
@tolaria_management_options = using
|
|
42
|
+
if Tolaria.safe_management
|
|
43
|
+
generate_tolaria_bindings!
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
# Instructs Tolaria to start managing the model and create the correct controllers.
|
|
48
|
+
# You shouldn't call this method directly.
|
|
49
|
+
def self.generate_tolaria_bindings!
|
|
50
|
+
if @tolaria_management_options.present?
|
|
51
|
+
Tolaria.manage(self, **@tolaria_management_options)
|
|
52
|
+
end
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
module Tolaria
|
|
2
|
+
|
|
3
|
+
# Returns the developer-configured categories for constructing
|
|
4
|
+
# the nav menu, in addition to any unexpected categories from
|
|
5
|
+
# configured managed classes.
|
|
6
|
+
def self.categories
|
|
7
|
+
(self.config.menu_categories + self.managed_classes.collect(&:category)).uniq
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
# Returns all of the managed classes for the given +category+,
|
|
11
|
+
# sorted by their priority
|
|
12
|
+
def self.classes_for_category(category)
|
|
13
|
+
classes = Tolaria.managed_classes.select do |managed_class|
|
|
14
|
+
managed_class.category == category
|
|
15
|
+
end
|
|
16
|
+
classes.sort_by do |klass|
|
|
17
|
+
[klass.priority, klass.model_name.human]
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
module Tolaria
|
|
2
|
+
|
|
3
|
+
# Tolaria’s config is a class so that an exception is raised
|
|
4
|
+
# if you try to configure a key that doesn't exist. See default_config.rb
|
|
5
|
+
class Configuration
|
|
6
|
+
attr_accessor :bcrypt_cost
|
|
7
|
+
attr_accessor :company_name
|
|
8
|
+
attr_accessor :default_redirect
|
|
9
|
+
attr_accessor :display_name_methods
|
|
10
|
+
attr_accessor :from_address
|
|
11
|
+
attr_accessor :help_links
|
|
12
|
+
attr_accessor :lockout_duration
|
|
13
|
+
attr_accessor :lockout_threshold
|
|
14
|
+
attr_accessor :markdown_renderer
|
|
15
|
+
attr_accessor :menu_categories
|
|
16
|
+
attr_accessor :page_size
|
|
17
|
+
attr_accessor :passcode_lifespan
|
|
18
|
+
attr_accessor :permitted_params
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
# Returns Tolaria’s configuration as an object
|
|
22
|
+
def self.config
|
|
23
|
+
if block_given?
|
|
24
|
+
raise ArgumentError, "You passed a block to Tolaria.config but such a block will be ignored. Did you mean to call Tolaria.configure instead?"
|
|
25
|
+
end
|
|
26
|
+
@configuration ||= Tolaria::Configuration.new
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
# Configure Tolaria, block-style. Use something similar to:
|
|
30
|
+
#
|
|
31
|
+
# Tolaria.configure do |config|
|
|
32
|
+
# # Assign to config properties here
|
|
33
|
+
# end
|
|
34
|
+
#
|
|
35
|
+
def self.configure(&block)
|
|
36
|
+
yield @configuration ||= Tolaria::Configuration.new
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
end
|
|
40
|
+
|