ditty 0.7.1 → 0.10.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 +4 -4
- data/.env.test +2 -0
- data/.gitignore +3 -0
- data/.pryrc +2 -0
- data/.rubocop.yml +24 -8
- data/.travis.yml +4 -8
- data/CNAME +1 -0
- data/Dockerfile +18 -0
- data/Gemfile.ci +0 -15
- data/Rakefile +5 -4
- data/Readme.md +24 -2
- data/_config.yml +1 -0
- data/config.ru +4 -4
- data/ditty.gemspec +31 -20
- data/docs/CNAME +1 -0
- data/docs/_config.yml +1 -0
- data/docs/index.md +34 -0
- data/exe/ditty +2 -0
- data/lib/ditty.rb +30 -4
- data/lib/ditty/cli.rb +38 -5
- data/lib/ditty/components/ditty.rb +82 -0
- data/lib/ditty/controllers/application_controller.rb +267 -0
- data/lib/ditty/controllers/{audit_logs.rb → audit_logs_controller.rb} +5 -7
- data/lib/ditty/controllers/{auth.rb → auth_controller.rb} +56 -32
- data/lib/ditty/controllers/{component.rb → component_controller.rb} +35 -24
- data/lib/ditty/controllers/{main.rb → main_controller.rb} +7 -7
- data/lib/ditty/controllers/roles_controller.rb +23 -0
- data/lib/ditty/controllers/user_login_traits_controller.rb +46 -0
- data/lib/ditty/controllers/{users.rb → users_controller.rb} +17 -20
- data/lib/ditty/db.rb +9 -5
- data/lib/ditty/emails/base.rb +48 -34
- data/lib/ditty/generators/crud_generator.rb +114 -0
- data/lib/ditty/generators/migration_generator.rb +26 -0
- data/lib/ditty/generators/project_generator.rb +52 -0
- data/lib/ditty/helpers/authentication.rb +6 -5
- data/lib/ditty/helpers/component.rb +11 -2
- data/lib/ditty/helpers/pundit.rb +24 -8
- data/lib/ditty/helpers/response.rb +38 -15
- data/lib/ditty/helpers/views.rb +48 -6
- data/lib/ditty/listener.rb +44 -14
- data/lib/ditty/memcached.rb +8 -0
- data/lib/ditty/middleware/accept_extension.rb +4 -2
- data/lib/ditty/middleware/error_catchall.rb +4 -2
- data/lib/ditty/models/audit_log.rb +1 -0
- data/lib/ditty/models/base.rb +13 -0
- data/lib/ditty/models/identity.rb +10 -7
- data/lib/ditty/models/role.rb +2 -0
- data/lib/ditty/models/user.rb +40 -3
- data/lib/ditty/models/user_login_trait.rb +17 -0
- data/lib/ditty/policies/audit_log_policy.rb +6 -6
- data/lib/ditty/policies/role_policy.rb +3 -3
- data/lib/ditty/policies/user_login_trait_policy.rb +45 -0
- data/lib/ditty/policies/user_policy.rb +3 -3
- data/lib/ditty/rubocop.rb +3 -0
- data/lib/ditty/seed.rb +2 -0
- data/lib/ditty/services/authentication.rb +31 -15
- data/lib/ditty/services/email.rb +22 -12
- data/lib/ditty/services/logger.rb +30 -13
- data/lib/ditty/services/pagination_wrapper.rb +9 -5
- data/lib/ditty/services/settings.rb +19 -7
- data/lib/ditty/tasks/ditty.rake +127 -0
- data/lib/ditty/tasks/omniauth-ldap.rake +43 -0
- data/lib/ditty/templates/.gitignore +5 -0
- data/lib/ditty/templates/.rspec +2 -0
- data/lib/ditty/templates/.rubocop.yml +7 -0
- data/lib/ditty/templates/Rakefile +12 -0
- data/lib/ditty/templates/application.rb +12 -0
- data/lib/ditty/templates/config.ru +37 -0
- data/lib/ditty/templates/controller.rb.erb +64 -0
- data/lib/ditty/templates/env.example +4 -0
- data/lib/ditty/templates/lib/project.rb.erb +5 -0
- data/lib/ditty/templates/migration.rb.erb +7 -0
- data/lib/ditty/templates/model.rb.erb +26 -0
- data/lib/ditty/templates/pids/.empty_directory +0 -0
- data/lib/ditty/templates/policy.rb.erb +48 -0
- data/{public → lib/ditty/templates/public}/browserconfig.xml +0 -0
- data/lib/ditty/templates/public/css/sb-admin-2.min.css +10 -0
- data/lib/ditty/templates/public/css/styles.css +13 -0
- data/lib/ditty/templates/public/favicon.ico +0 -0
- data/{public → lib/ditty/templates/public}/images/apple-icon.png +0 -0
- data/{public → lib/ditty/templates/public}/images/favicon-16x16.png +0 -0
- data/{public → lib/ditty/templates/public}/images/favicon-32x32.png +0 -0
- data/{public → lib/ditty/templates/public}/images/launcher-icon-1x.png +0 -0
- data/{public → lib/ditty/templates/public}/images/launcher-icon-2x.png +0 -0
- data/{public → lib/ditty/templates/public}/images/launcher-icon-4x.png +0 -0
- data/{public → lib/ditty/templates/public}/images/mstile-150x150.png +0 -0
- data/{public → lib/ditty/templates/public}/images/safari-pinned-tab.svg +0 -0
- data/lib/ditty/templates/public/js/sb-admin-2.min.js +7 -0
- data/lib/ditty/templates/public/js/scripts.js +1 -0
- data/{public/manifest.json → lib/ditty/templates/public/manifest.json.erb} +2 -2
- data/lib/ditty/templates/settings.yml.erb +19 -0
- data/lib/ditty/templates/sidekiq.rb +18 -0
- data/lib/ditty/templates/sidekiq.yml +9 -0
- data/lib/ditty/templates/spec_helper.rb +43 -0
- data/lib/ditty/templates/type.rb.erb +21 -0
- data/lib/ditty/templates/views/display.haml.tt +20 -0
- data/lib/ditty/templates/views/edit.haml.tt +10 -0
- data/lib/ditty/templates/views/form.haml.tt +11 -0
- data/lib/ditty/templates/views/index.haml.tt +29 -0
- data/lib/ditty/templates/views/new.haml.tt +10 -0
- data/lib/ditty/version.rb +1 -1
- data/lib/rubocop/cop/ditty/call_services_directly.rb +42 -0
- data/migrate/20181209_add_user_login_traits.rb +16 -0
- data/migrate/20181209_extend_audit_log.rb +12 -0
- data/migrate/20190220_add_parent_id_to_roles.rb +9 -0
- data/spec/ditty/api_spec.rb +51 -0
- data/spec/ditty/controllers/roles_spec.rb +67 -0
- data/spec/ditty/controllers/user_login_traits_spec.rb +72 -0
- data/spec/ditty/controllers/users_spec.rb +72 -0
- data/spec/ditty/emails/base_spec.rb +76 -0
- data/spec/ditty/emails/forgot_password_spec.rb +20 -0
- data/spec/ditty/helpers/component_spec.rb +85 -0
- data/spec/ditty/models/user_spec.rb +36 -0
- data/spec/ditty/services/email_spec.rb +36 -0
- data/spec/ditty/services/logger_spec.rb +68 -0
- data/spec/ditty/services/settings_spec.rb +63 -0
- data/spec/ditty_spec.rb +9 -0
- data/spec/factories.rb +46 -0
- data/spec/fixtures/logger.yml +17 -0
- data/spec/fixtures/section.yml +3 -0
- data/spec/fixtures/settings.yml +8 -0
- data/spec/spec_helper.rb +51 -0
- data/spec/support/api_shared_examples.rb +250 -0
- data/spec/support/crud_shared_examples.rb +145 -0
- data/views/403.haml +2 -0
- data/views/404.haml +2 -4
- data/views/500.haml +11 -0
- data/views/audit_logs/index.haml +32 -28
- data/views/auth/forgot_password.haml +32 -16
- data/views/auth/identity.haml +14 -13
- data/views/auth/ldap.haml +17 -0
- data/views/auth/login.haml +23 -17
- data/views/auth/register.haml +20 -18
- data/views/auth/register_identity.haml +27 -12
- data/views/auth/reset_password.haml +36 -19
- data/views/blank.haml +43 -0
- data/views/emails/forgot_password.haml +1 -1
- data/views/emails/layouts/action.haml +10 -6
- data/views/emails/layouts/alert.haml +2 -1
- data/views/emails/layouts/billing.haml +2 -1
- data/views/embedded.haml +17 -11
- data/views/error.haml +8 -3
- data/views/index.haml +1 -1
- data/views/layout.haml +45 -30
- data/views/partials/actions.haml +15 -14
- data/views/partials/content_tag.haml +0 -0
- data/views/partials/delete_form.haml +1 -1
- data/views/partials/filter_control.haml +2 -2
- data/views/partials/footer.haml +13 -5
- data/views/partials/form_control.haml +30 -19
- data/views/partials/form_tag.haml +1 -1
- data/views/partials/navitems.haml +42 -0
- data/views/partials/notifications.haml +12 -8
- data/views/partials/pager.haml +44 -25
- data/views/partials/search.haml +15 -11
- data/views/partials/sidebar.haml +15 -37
- data/views/partials/sort_ui.haml +2 -0
- data/views/partials/timespan_selector.haml +64 -0
- data/views/partials/topbar.haml +53 -0
- data/views/partials/user_associations.haml +32 -0
- data/views/quick_start.haml +23 -0
- data/views/roles/display.haml +27 -6
- data/views/roles/edit.haml +3 -3
- data/views/roles/form.haml +1 -0
- data/views/roles/index.haml +23 -14
- data/views/roles/new.haml +2 -2
- data/views/user_login_traits/display.haml +32 -0
- data/views/user_login_traits/edit.haml +10 -0
- data/views/user_login_traits/form.haml +5 -0
- data/views/user_login_traits/index.haml +28 -0
- data/views/user_login_traits/new.haml +10 -0
- data/views/users/display.haml +15 -16
- data/views/users/edit.haml +3 -3
- data/views/users/form.haml +0 -0
- data/views/users/index.haml +31 -24
- data/views/users/login_traits.haml +25 -0
- data/views/users/new.haml +2 -2
- data/views/users/profile.haml +17 -15
- data/views/users/user.haml +1 -1
- metadata +314 -76
- data/lib/ditty/components/app.rb +0 -77
- data/lib/ditty/controllers/application.rb +0 -175
- data/lib/ditty/controllers/roles.rb +0 -16
- data/lib/ditty/rake_tasks.rb +0 -102
- data/views/partials/navbar.haml +0 -23
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e785b1b4a84258a46e98753a5de394897bc6d002b88d2fc6629b30b33b52614e
|
|
4
|
+
data.tar.gz: '094a55847cc4ec09bf1dc9307c9efcffa5b59b498fd407de5950e656e5a5e516'
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: fa7d54c43ac02d1f04a690f2bca5a529b3c65eefa0f287ab44594910bca2b8022656b58e2aef805a52307364481c35be2ba1b1e4b3a97b3450cab1b9acb27d1f
|
|
7
|
+
data.tar.gz: 847143f0f0d20c67b3451a86e780ec44b914210ceec4498c9218ebc05f7f7277107b1998ca5f273aad0ad1ad45ceb051b81204fe87e6cb91e88ee2ef6af7b49c
|
data/.env.test
ADDED
data/.gitignore
CHANGED
data/.pryrc
CHANGED
data/.rubocop.yml
CHANGED
|
@@ -1,12 +1,28 @@
|
|
|
1
|
-
|
|
1
|
+
require:
|
|
2
|
+
- rubocop-rspec
|
|
3
|
+
- rubocop-performance
|
|
4
|
+
- rubocop-thread_safety
|
|
5
|
+
- rubocop-sequel
|
|
6
|
+
AllCops:
|
|
7
|
+
NewCops: enable
|
|
8
|
+
TargetRubyVersion: 2.7.1
|
|
9
|
+
Exclude:
|
|
10
|
+
- migrate/**/*
|
|
11
|
+
Layout/LineLength:
|
|
2
12
|
Max: 120
|
|
3
|
-
|
|
4
|
-
Style/NumericPredicate:
|
|
5
|
-
Enabled: false
|
|
6
|
-
|
|
7
13
|
Layout/LeadingCommentSpace:
|
|
8
14
|
Exclude:
|
|
9
15
|
- 'config.ru'
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
16
|
+
Layout/EndOfLine:
|
|
17
|
+
EnforcedStyle: lf
|
|
18
|
+
Layout/MultilineMethodCallIndentation:
|
|
19
|
+
EnforcedStyle: indented
|
|
20
|
+
IndentationWidth: 2
|
|
21
|
+
Layout/IndentationConsistency:
|
|
22
|
+
EnforcedStyle: indented_internal_methods
|
|
23
|
+
Layout/EndAlignment:
|
|
24
|
+
EnforcedStyleAlignWith: variable
|
|
25
|
+
Metrics/MethodLength:
|
|
26
|
+
CountAsOne: ['array', 'heredoc', 'hash']
|
|
27
|
+
Style/Documentation:
|
|
28
|
+
Enabled: false
|
data/.travis.yml
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
sudo: false
|
|
2
2
|
language: ruby
|
|
3
3
|
rvm:
|
|
4
|
-
-
|
|
5
|
-
- 2.
|
|
6
|
-
- 2.
|
|
7
|
-
- 2.2.6
|
|
4
|
+
- 3.0
|
|
5
|
+
- 2.7
|
|
6
|
+
- 2.6
|
|
8
7
|
gemfile: Gemfile.ci
|
|
9
8
|
env:
|
|
10
|
-
global:
|
|
11
|
-
- CC_TEST_REPORTER_ID=289860573c6284a8e277de86848caba84d840be49e35f3601bcd672ab40d1e35
|
|
12
|
-
- DATABASE_CLEANER_ALLOW_REMOTE_DATABASE_URL=true
|
|
13
9
|
matrix:
|
|
14
10
|
- DATABASE_URL="sqlite::memory:" RACK_ENV=test
|
|
15
11
|
before_install:
|
|
@@ -21,7 +17,7 @@ before_script:
|
|
|
21
17
|
- bundle exec rake ditty:prep
|
|
22
18
|
script:
|
|
23
19
|
- bundle exec rake
|
|
24
|
-
- bundle exec rubocop --fail-level W lib views
|
|
20
|
+
- bundle exec rubocop --fail-level W lib views spec
|
|
25
21
|
after_script:
|
|
26
22
|
- ./cc-test-reporter after-build --exit-code $TRAVIS_TEST_RESULT
|
|
27
23
|
after_success:
|
data/CNAME
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ditty.io
|
data/Dockerfile
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
FROM ruby:2.5.3-alpine3.8
|
|
2
|
+
LABEL maintainer: "Sergey Shkarupa <s.shkarupa@gmail.com>"
|
|
3
|
+
|
|
4
|
+
RUN apk add --no-cache \
|
|
5
|
+
build-base \
|
|
6
|
+
less \
|
|
7
|
+
git \
|
|
8
|
+
libxml2-dev \
|
|
9
|
+
libxslt-dev \
|
|
10
|
+
sqlite-dev \
|
|
11
|
+
sqlite-doc \
|
|
12
|
+
sqlite-libs \
|
|
13
|
+
&& gem install bundler:1.17.3
|
|
14
|
+
|
|
15
|
+
WORKDIR /usr/src/app
|
|
16
|
+
|
|
17
|
+
COPY . ./
|
|
18
|
+
RUN bundle install --jobs=$(nproc) --no-cache --clean
|
data/Gemfile.ci
CHANGED
|
@@ -2,18 +2,3 @@
|
|
|
2
2
|
source 'https://rubygems.org'
|
|
3
3
|
|
|
4
4
|
gemspec
|
|
5
|
-
|
|
6
|
-
gem 'rubocop'
|
|
7
|
-
gem 'simplecov', '~> 0.13.0'
|
|
8
|
-
gem 'sqlite3'
|
|
9
|
-
|
|
10
|
-
if RUBY_VERSION < '2.1'
|
|
11
|
-
gem 'sidekiq', '3.0.0'
|
|
12
|
-
gem 'activesupport', '<4.0.0'
|
|
13
|
-
gem 'omniauth', '~>1.4.2'
|
|
14
|
-
elsif RUBY_VERSION < '2.2.0'
|
|
15
|
-
gem 'sidekiq', '4.0.0'
|
|
16
|
-
gem 'activesupport', '<5.0.0'
|
|
17
|
-
else
|
|
18
|
-
gem 'activesupport'
|
|
19
|
-
end
|
data/Rakefile
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'rake'
|
|
4
|
-
require 'bundler/gem_tasks'
|
|
5
|
-
require 'ditty/rake_tasks'
|
|
6
|
-
|
|
7
4
|
require 'ditty'
|
|
8
|
-
require 'ditty/components/
|
|
5
|
+
require 'ditty/components/ditty'
|
|
6
|
+
|
|
7
|
+
Ditty.component :ditty
|
|
9
8
|
|
|
9
|
+
Ditty::Components.tasks
|
|
10
|
+
require 'bundler/gem_tasks' if File.exist? 'ditty.gemspec'
|
|
10
11
|
begin
|
|
11
12
|
require 'rspec/core/rake_task'
|
|
12
13
|
RSpec::Core::RakeTask.new(:spec)
|
data/Readme.md
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
[](https://travis-ci.org/EagerELK/ditty)
|
|
2
2
|
[](https://codeclimate.com/github/EagerELK/ditty)
|
|
3
3
|
[](https://codeclimate.com/github/EagerELK/ditty/coverage)
|
|
4
|
+
[](http://inch-ci.org/github/EagerELK/ditty)
|
|
4
5
|
|
|
5
6
|
# Ditty
|
|
6
7
|
|
|
@@ -33,12 +34,33 @@ gem install ditty
|
|
|
33
34
|
|
|
34
35
|
1. Add the components to your rack config file. See the included [`config.ru`](https://github.com/EagerELK/ditty/blob/master/config.ru) file for an example setup
|
|
35
36
|
2. Set the DB connection as the `DATABASE_URL` ENV variable: `DATABASE_URL=sqlite://development.db`
|
|
37
|
+
3. Prepare the Ditty folder: `bundle exec ditty prep`
|
|
36
38
|
3. Run the Ditty migrations: `bundle exec ditty migrate`
|
|
37
39
|
4. Run the Ditty server: `bundle exec ditty server`
|
|
38
40
|
|
|
39
|
-
|
|
41
|
+
### Components
|
|
40
42
|
|
|
41
|
-
The application can now be further extended by creating components.
|
|
43
|
+
The application can now be further extended by creating [components](https://github.com/EagerELK/ditty/wiki/Creating-a-Component).
|
|
44
|
+
|
|
45
|
+
### Rubocop Cops
|
|
46
|
+
|
|
47
|
+
Ditty provides a number of [Rubocop](https://github.com/rubocop-hq/rubocop) cops
|
|
48
|
+
to ensure that the Ditty framework is used correctly. Enable this by adding the
|
|
49
|
+
following to your `.rubocop.yml` file:
|
|
50
|
+
|
|
51
|
+
```yaml
|
|
52
|
+
require: ditty/rubocop
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
You can run Ditty specific cops as follows:
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
bundle exec rubocop --only Ditty
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Adding the `-a` flag to the invocation will automatically fix some of the issues
|
|
62
|
+
for you, but, as always, ensure you have a working copy of your code before
|
|
63
|
+
running this.
|
|
42
64
|
|
|
43
65
|
## Development
|
|
44
66
|
|
data/_config.yml
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
theme: jekyll-theme-architect
|
data/config.ru
CHANGED
|
@@ -6,14 +6,14 @@ use Rack::Session::Cookie,
|
|
|
6
6
|
# :secure=>!TEST_MODE, # Uncomment if only allowing https:// access
|
|
7
7
|
secret: File.read('.session_secret')
|
|
8
8
|
|
|
9
|
-
require 'ditty/components/
|
|
10
|
-
Ditty.component :
|
|
9
|
+
require 'ditty/components/ditty'
|
|
10
|
+
Ditty.component :ditty
|
|
11
11
|
|
|
12
12
|
require 'ditty/services/authentication'
|
|
13
13
|
use OmniAuth::Builder do
|
|
14
|
-
Ditty::Services::Authentication.config.each do |prov, config|
|
|
14
|
+
::Ditty::Services::Authentication.config.each do |prov, config|
|
|
15
15
|
provider prov, *config[:arguments]
|
|
16
16
|
end
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
-
run Rack::URLMap.new Ditty::Components.routes
|
|
19
|
+
run Rack::URLMap.new ::Ditty::Components.routes
|
data/ditty.gemspec
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
lib = File.expand_path('
|
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
|
4
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
5
5
|
require 'ditty/version'
|
|
6
6
|
|
|
7
7
|
Gem::Specification.new do |spec|
|
|
8
8
|
spec.name = 'ditty'
|
|
9
|
-
spec.version = Ditty::VERSION
|
|
9
|
+
spec.version = ::Ditty::VERSION
|
|
10
10
|
spec.authors = ['Jurgens du Toit']
|
|
11
11
|
spec.email = ['jrgns@jadeit.co.za']
|
|
12
12
|
|
|
@@ -15,38 +15,49 @@ Gem::Specification.new do |spec|
|
|
|
15
15
|
spec.homepage = 'https://github.com/eagerelk/ditty'
|
|
16
16
|
spec.license = 'MIT'
|
|
17
17
|
|
|
18
|
-
spec.files = `git ls-files -z`.split("\x0")
|
|
18
|
+
spec.files = `git ls-files -z`.split("\x0") #.reject { |f| f.match(%r{^(test|spec|features)/}) }
|
|
19
19
|
spec.bindir = 'exe'
|
|
20
20
|
spec.executables = ['ditty']
|
|
21
21
|
spec.require_paths = ['lib']
|
|
22
22
|
|
|
23
|
-
spec.add_development_dependency 'bundler', '
|
|
24
|
-
spec.add_development_dependency '
|
|
23
|
+
spec.add_development_dependency 'bundler', '>= 1'
|
|
24
|
+
spec.add_development_dependency 'dotenv'
|
|
25
|
+
spec.add_development_dependency 'database_cleaner', '~> 1.0'
|
|
25
26
|
spec.add_development_dependency 'factory_bot'
|
|
26
|
-
spec.add_development_dependency '
|
|
27
|
+
spec.add_development_dependency 'faker'
|
|
27
28
|
spec.add_development_dependency 'racksh'
|
|
29
|
+
spec.add_development_dependency 'rack-test'
|
|
28
30
|
spec.add_development_dependency 'rspec', '~> 3.0'
|
|
31
|
+
spec.add_development_dependency 'rubocop'
|
|
32
|
+
spec.add_development_dependency 'rubocop-performance'
|
|
33
|
+
spec.add_development_dependency 'rubocop-rspec'
|
|
34
|
+
spec.add_development_dependency 'rubocop-sequel'
|
|
35
|
+
spec.add_development_dependency 'rubocop-thread_safety'
|
|
36
|
+
spec.add_development_dependency 'simplecov', '~> 0.13.0'
|
|
37
|
+
spec.add_development_dependency 'sqlite3'
|
|
29
38
|
spec.add_development_dependency 'timecop'
|
|
30
39
|
|
|
31
|
-
spec.add_dependency 'activesupport', '>=
|
|
32
|
-
spec.add_dependency 'bcrypt', '
|
|
33
|
-
spec.add_dependency '
|
|
34
|
-
spec.add_dependency '
|
|
35
|
-
spec.add_dependency '
|
|
40
|
+
spec.add_dependency 'activesupport', '>= 6'
|
|
41
|
+
spec.add_dependency 'bcrypt', '>= 3.1'
|
|
42
|
+
spec.add_dependency 'browser', '>= 5.3'
|
|
43
|
+
spec.add_dependency 'dotenv', '>= 2'
|
|
44
|
+
spec.add_dependency 'haml', '>= 5.1.2'
|
|
45
|
+
spec.add_dependency 'logger', '>= 1.0'
|
|
36
46
|
spec.add_dependency 'mail', '>= 1.7'
|
|
47
|
+
spec.add_dependency 'oga', '>= 2.14'
|
|
37
48
|
spec.add_dependency 'omniauth', '~> 1.0'
|
|
38
49
|
spec.add_dependency 'omniauth-identity', '~> 1.0'
|
|
39
50
|
spec.add_dependency 'pundit', '~> 1.0'
|
|
40
|
-
spec.add_dependency 'rack-contrib', '
|
|
41
|
-
spec.add_dependency 'rack_csrf', '
|
|
42
|
-
spec.add_dependency 'rake', '
|
|
43
|
-
spec.add_dependency 'sequel', '>=
|
|
44
|
-
spec.add_dependency 'sinatra', '>= 2.
|
|
45
|
-
spec.add_dependency 'sinatra-contrib', '
|
|
46
|
-
spec.add_dependency 'sinatra-flash', '
|
|
47
|
-
spec.add_dependency 'sinatra-param', '
|
|
48
|
-
spec.add_dependency 'tilt', '>= 2'
|
|
51
|
+
spec.add_dependency 'rack-contrib', '>= 2.0'
|
|
52
|
+
spec.add_dependency 'rack_csrf', '>= 2.0'
|
|
53
|
+
spec.add_dependency 'rake', '>= 13.0'
|
|
54
|
+
spec.add_dependency 'sequel', '>= 5.0'
|
|
55
|
+
spec.add_dependency 'sinatra', '>= 2.1'
|
|
56
|
+
spec.add_dependency 'sinatra-contrib', '>= 2.0'
|
|
57
|
+
spec.add_dependency 'sinatra-flash', '>= 0.3'
|
|
58
|
+
spec.add_dependency 'sinatra-param', '>= 1.6'
|
|
49
59
|
spec.add_dependency 'thor', '>= 0.20'
|
|
60
|
+
spec.add_dependency 'tilt', '>= 2'
|
|
50
61
|
spec.add_dependency 'will_paginate', '>= 3.1'
|
|
51
62
|
spec.add_dependency 'wisper', '~> 2.0'
|
|
52
63
|
end
|
data/docs/CNAME
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ditty.io
|
data/docs/_config.yml
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
theme: jekyll-theme-architect
|
data/docs/index.md
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
# Ditty.io
|
|
2
|
+
|
|
3
|
+
Ditty is a Web Application Framework built on top of the [Sinatra](http://sinatrarb.com/) framework.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Add these lines to your application's Gemfile:
|
|
8
|
+
|
|
9
|
+
```ruby
|
|
10
|
+
gem 'ditty'
|
|
11
|
+
gem 'sqlite3'
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
You can replace `sqlite3` with a DB adapter of your choice.
|
|
15
|
+
|
|
16
|
+
And then execute:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
bundle install
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Or install it yourself as:
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
gem install ditty
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Usage
|
|
29
|
+
|
|
30
|
+
1. Add the components to your rack config file. See the included [`config.ru`](https://github.com/EagerELK/ditty/blob/master/config.ru) file for an example setup
|
|
31
|
+
2. Set the DB connection as the `DATABASE_URL` ENV variable: `DATABASE_URL=sqlite://development.db`
|
|
32
|
+
3. Prepare the Ditty folder: `bundle exec ditty prep`
|
|
33
|
+
3. Run the Ditty migrations: `bundle exec ditty migrate`
|
|
34
|
+
4. Run the Ditty server: `bundle exec ditty server`
|
data/exe/ditty
CHANGED
data/lib/ditty.rb
CHANGED
|
@@ -6,6 +6,8 @@ require 'ditty/services/logger'
|
|
|
6
6
|
module Ditty
|
|
7
7
|
class ComponentError < StandardError; end
|
|
8
8
|
|
|
9
|
+
class TemplateNotFoundError < StandardError; end
|
|
10
|
+
|
|
9
11
|
# A thread safe cache class, offering only #[] and #[]= methods,
|
|
10
12
|
# each protected by a mutex.
|
|
11
13
|
# Ripped off from Roda - https://github.com/jeremyevans/roda
|
|
@@ -30,6 +32,10 @@ module Ditty
|
|
|
30
32
|
@mutex.synchronize { @hash.map(&block) }
|
|
31
33
|
end
|
|
32
34
|
|
|
35
|
+
def each(&block)
|
|
36
|
+
@mutex.synchronize { @hash.each(&block) }
|
|
37
|
+
end
|
|
38
|
+
|
|
33
39
|
def inject(memo, &block)
|
|
34
40
|
@mutex.synchronize { @hash.inject(memo, &block) }
|
|
35
41
|
end
|
|
@@ -37,6 +43,10 @@ module Ditty
|
|
|
37
43
|
def each_with_object(memo, &block)
|
|
38
44
|
@mutex.synchronize { @hash.each_with_object(memo, &block) }
|
|
39
45
|
end
|
|
46
|
+
|
|
47
|
+
def key?(key)
|
|
48
|
+
@hash.key? key
|
|
49
|
+
end
|
|
40
50
|
end
|
|
41
51
|
|
|
42
52
|
# Ripped off from Roda - https://github.com/jeremyevans/roda
|
|
@@ -52,17 +62,23 @@ module Ditty
|
|
|
52
62
|
h = @components
|
|
53
63
|
unless (component = h[name])
|
|
54
64
|
require "ditty/components/#{name}"
|
|
55
|
-
|
|
65
|
+
unless (component = h[name])
|
|
66
|
+
raise ComponentError, "Component #{name} did not register itself correctly in Ditty::Components"
|
|
67
|
+
end
|
|
56
68
|
end
|
|
57
69
|
component
|
|
58
70
|
end
|
|
59
71
|
|
|
72
|
+
def self.component?(name)
|
|
73
|
+
@components.key? name
|
|
74
|
+
end
|
|
75
|
+
|
|
60
76
|
# Register the given component with Component, so that it can be loaded using #component
|
|
61
77
|
# with a symbol. Should be used by component files. Example:
|
|
62
78
|
#
|
|
63
79
|
# Ditty::Components.register_component(:component_name, ComponentModule)
|
|
64
80
|
def self.register_component(name, mod)
|
|
65
|
-
Ditty::Services::Logger.
|
|
81
|
+
::Ditty::Services::Logger.info "Registering #{mod} as #{name}"
|
|
66
82
|
@components[name] = mod
|
|
67
83
|
end
|
|
68
84
|
|
|
@@ -80,9 +96,9 @@ module Ditty
|
|
|
80
96
|
|
|
81
97
|
# Return an ordered list of navigation items:
|
|
82
98
|
# `[{order:0, link:'/users/', text:'Users'}, {order:1, link:'/roles/', text:'Roles'}]
|
|
83
|
-
def self.navigation
|
|
99
|
+
def self.navigation(request)
|
|
84
100
|
nav = components.each_with_object([]) do |comp, memo|
|
|
85
|
-
memo.concat comp[1].navigation if comp[1].respond_to?(:navigation)
|
|
101
|
+
memo.concat comp[1].navigation(request) if comp[1].respond_to?(:navigation)
|
|
86
102
|
end
|
|
87
103
|
nav.sort_by { |v| v[:order] }
|
|
88
104
|
end
|
|
@@ -111,6 +127,15 @@ module Ditty
|
|
|
111
127
|
end
|
|
112
128
|
end
|
|
113
129
|
|
|
130
|
+
def self.tasks
|
|
131
|
+
require 'rake'
|
|
132
|
+
require 'rake/tasklib'
|
|
133
|
+
require 'ditty/db' unless defined? DB
|
|
134
|
+
components.each do |_name, comp|
|
|
135
|
+
comp.tasks if comp.respond_to?(:tasks)
|
|
136
|
+
end
|
|
137
|
+
end
|
|
138
|
+
|
|
114
139
|
module Base
|
|
115
140
|
module ClassMethods
|
|
116
141
|
# Load a new component into the current class. A component can be a module
|
|
@@ -121,6 +146,7 @@ module Ditty
|
|
|
121
146
|
# Component.component :csrf
|
|
122
147
|
def component(component, *args, &block)
|
|
123
148
|
raise ComponentError, 'Cannot add a component to a frozen Component class' if frozen?
|
|
149
|
+
|
|
124
150
|
component = Components.load_component(component) if component.is_a?(Symbol)
|
|
125
151
|
include(component::InstanceMethods) if defined?(component::InstanceMethods)
|
|
126
152
|
extend(component::ClassMethods) if defined?(component::ClassMethods)
|