plug 0.1.14 → 0.1.21
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 +5 -5
- data/README.md +37 -1
- data/app/assets/javascripts/plug/application.js +5 -0
- data/app/assets/javascripts/plug/trix-core.js +12 -0
- data/app/assets/stylesheets/plug/application.scss +4 -1
- data/app/assets/stylesheets/plug/blocks/_menu.scss +11 -0
- data/app/assets/stylesheets/plug/blocks/_state.scss +4 -2
- data/app/assets/stylesheets/plug/milligram.scss +632 -599
- data/app/assets/stylesheets/plug/trix-overrides.scss +8 -0
- data/app/assets/stylesheets/plug/trix.scss +374 -0
- data/app/controllers/plug/api/api_controller.rb +7 -0
- data/app/controllers/plug/api/site_notices_controller.rb +21 -0
- data/app/controllers/plug/application_controller.rb +2 -0
- data/app/controllers/plug/features_controller.rb +3 -5
- data/app/controllers/plug/site_notices_controller.rb +69 -0
- data/app/models/plug/concerns/model_helpers.rb +45 -0
- data/app/models/plug/feature.rb +1 -25
- data/app/models/plug/resources/site_notice.rb +17 -0
- data/app/models/plug/site_notice.rb +6 -0
- data/app/services/plug/task_execution_service.rb +18 -0
- data/app/views/plug/features/index.html.haml +18 -15
- data/app/views/plug/shared/_head.html.haml +1 -1
- data/app/views/plug/shared/_nav.html.haml +8 -5
- data/app/views/plug/site_notices/_form.html.haml +26 -0
- data/app/views/plug/site_notices/edit.html.haml +5 -0
- data/app/views/plug/site_notices/index.html.haml +41 -0
- data/app/views/plug/site_notices/new.html.haml +7 -0
- data/config/routes.rb +11 -1
- data/db/migrate/20180403024712_create_plug_site_notices.rb +15 -0
- data/db/migrate/20180424015828_add_theme_to_plug_site_notice.rb +5 -0
- data/lib/generators/plug/templates/plug.rb +1 -0
- data/lib/plug/configuration.rb +3 -1
- data/lib/plug/version.rb +1 -1
- metadata +38 -8
@@ -0,0 +1,45 @@
|
|
1
|
+
require 'active_support/concern'
|
2
|
+
|
3
|
+
module Plug
|
4
|
+
module Concerns
|
5
|
+
module ModelHelpers
|
6
|
+
extend ActiveSupport::Concern
|
7
|
+
|
8
|
+
included do
|
9
|
+
include AASM
|
10
|
+
|
11
|
+
# Validations
|
12
|
+
validates :name, presence: { message: "#{self.humanized_class_name} name is required" },
|
13
|
+
uniqueness: { message: "#{self.humanized_class_name} name must be unique", case_sensitive: false }
|
14
|
+
validates :state, presence: { message: "#{self.humanized_class_name} state is required" }
|
15
|
+
|
16
|
+
# Callbacks
|
17
|
+
before_save { self.slug = name.parameterize }
|
18
|
+
|
19
|
+
# Scopes
|
20
|
+
scope :slug_and_name, ->(arg) { where('slug = ? OR name = ?', arg, arg) }
|
21
|
+
|
22
|
+
# States
|
23
|
+
aasm column: :state do
|
24
|
+
state :enabled, initial: true
|
25
|
+
state :disabled
|
26
|
+
|
27
|
+
event :enable do
|
28
|
+
transitions from: :disabled, to: :enabled
|
29
|
+
end
|
30
|
+
|
31
|
+
event :disable do
|
32
|
+
transitions from: :enabled, to: :disabled
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
|
38
|
+
module ClassMethods
|
39
|
+
def humanized_class_name
|
40
|
+
self.name.demodulize.underscore.humanize.capitalize
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
data/app/models/plug/feature.rb
CHANGED
@@ -1,30 +1,6 @@
|
|
1
1
|
module Plug
|
2
2
|
class Feature < ApplicationRecord
|
3
3
|
include AASM
|
4
|
-
|
5
|
-
# Validations
|
6
|
-
validates :name, presence: { message: 'Feature name is required' },
|
7
|
-
uniqueness: { message: 'Feature name must be unique', case_sensitive: false }
|
8
|
-
validates :state, presence: { message: 'Feature state is required' }
|
9
|
-
|
10
|
-
# Callbacks
|
11
|
-
before_save { self.slug = name.parameterize }
|
12
|
-
|
13
|
-
# Scopes
|
14
|
-
scope :slug_and_name, ->(arg) { where('slug = ? OR name = ?', arg, arg) }
|
15
|
-
|
16
|
-
# States
|
17
|
-
aasm column: :state do
|
18
|
-
state :enabled, initial: true
|
19
|
-
state :disabled
|
20
|
-
|
21
|
-
event :enable do
|
22
|
-
transitions from: :disabled, to: :enabled
|
23
|
-
end
|
24
|
-
|
25
|
-
event :disable do
|
26
|
-
transitions from: :enabled, to: :disabled
|
27
|
-
end
|
28
|
-
end
|
4
|
+
include Plug::Concerns::ModelHelpers
|
29
5
|
end
|
30
6
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Plug
|
2
|
+
module Resources
|
3
|
+
class SiteNotice < ActiveResource::Base
|
4
|
+
include Plug::Concerns::Themeable
|
5
|
+
|
6
|
+
self.site = Plug.api_path
|
7
|
+
|
8
|
+
def enabled?
|
9
|
+
state == 'enabled'
|
10
|
+
end
|
11
|
+
|
12
|
+
def disabled?
|
13
|
+
state == 'disabled'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rake'
|
2
|
+
|
3
|
+
module Plug
|
4
|
+
class TaskExecutionService
|
5
|
+
attr_reader :name
|
6
|
+
|
7
|
+
def initialize(name: nil)
|
8
|
+
raise 'Task name is required' if name.nil?
|
9
|
+
|
10
|
+
@name = name
|
11
|
+
end
|
12
|
+
|
13
|
+
def call
|
14
|
+
Rails.application.load_tasks
|
15
|
+
Rake::Task[name].execute
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -1,15 +1,15 @@
|
|
1
|
-
|
2
|
-
.
|
3
|
-
- if notice
|
4
|
-
%p.notice= sanitize(notice)
|
1
|
+
- if notice
|
2
|
+
%p.notice= sanitize(notice)
|
5
3
|
|
6
|
-
|
7
|
-
|
4
|
+
- if alert
|
5
|
+
%p.alert= sanitize(alert)
|
8
6
|
|
9
|
-
|
10
|
-
|
11
|
-
|
7
|
+
.row
|
8
|
+
.column
|
9
|
+
= render partial: 'task', collection: Plug.buttons
|
12
10
|
|
11
|
+
.row
|
12
|
+
.column
|
13
13
|
.clearfix
|
14
14
|
.float-left
|
15
15
|
%h4 Features
|
@@ -19,10 +19,13 @@
|
|
19
19
|
%table
|
20
20
|
%thead
|
21
21
|
%tr
|
22
|
-
%th Name
|
22
|
+
%th{ width: 200 } Name
|
23
23
|
%th Description
|
24
|
-
%th Slug
|
25
|
-
%th State
|
24
|
+
%th{ width: 200 } Slug
|
25
|
+
%th{ width: 150, align: 'center' } State
|
26
|
+
|
27
|
+
- if Plug.allow_delete
|
28
|
+
%th Actions
|
26
29
|
|
27
30
|
%tbody
|
28
31
|
- @features.each do |feature|
|
@@ -30,11 +33,11 @@
|
|
30
33
|
%td= link_to feature.name, edit_feature_path(feature), class: 'strong'
|
31
34
|
%td= feature.description
|
32
35
|
%td= feature.slug
|
33
|
-
%td
|
36
|
+
%td{ width: 150, align: 'center' }
|
34
37
|
- if feature.state == 'enabled'
|
35
|
-
%i.fas.fa-check-circle.fa-2x.
|
38
|
+
%i.fas.fa-check-circle.fa-2x.state.state--enabled
|
36
39
|
- else
|
37
|
-
%i.fas.fa-times-circle.fa-2x.
|
40
|
+
%i.fas.fa-times-circle.fa-2x.state.state--disabled
|
38
41
|
|
39
42
|
- if Plug.allow_delete
|
40
43
|
%td= link_to 'Destroy', feature, method: :delete, data: { confirm: 'Are you sure?' }
|
@@ -1,6 +1,9 @@
|
|
1
1
|
%nav.clearfix.nav
|
2
|
-
.
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
2
|
+
.float-left
|
3
|
+
%h3
|
4
|
+
= link_to 'plug', plug.root_path, class: 'nav__logo'
|
5
|
+
%small /unplug features
|
6
|
+
.float-right
|
7
|
+
%ul.menu
|
8
|
+
%li= link_to 'Features', plug.root_path
|
9
|
+
%li= link_to 'Site Notices', plug.site_notices_path
|
@@ -0,0 +1,26 @@
|
|
1
|
+
= form_for @site_notice do |f|
|
2
|
+
- if @site_notice.errors.any?
|
3
|
+
#error_explanation
|
4
|
+
%h2= "#{pluralize(@site_notice.errors.count, "error")} prohibited this feature from being saved:"
|
5
|
+
%ul
|
6
|
+
- @site_notice.errors.full_messages.each do |message|
|
7
|
+
%li= message
|
8
|
+
|
9
|
+
.field
|
10
|
+
= f.label :name
|
11
|
+
= f.text_field :name
|
12
|
+
.field
|
13
|
+
= f.label :notice
|
14
|
+
= f.hidden_field :notice
|
15
|
+
%trix-editor{ input: 'site_notice_notice' }
|
16
|
+
.field
|
17
|
+
= f.label :state
|
18
|
+
= f.select :state, ['enabled', 'disabled']
|
19
|
+
.field
|
20
|
+
= f.label :theme
|
21
|
+
= f.select :theme, Plug.themes
|
22
|
+
.actions.clearfix
|
23
|
+
.float-left
|
24
|
+
= link_to 'Back', site_notices_path, class: 'button'
|
25
|
+
.float-right
|
26
|
+
= f.submit 'Save'
|
@@ -0,0 +1,41 @@
|
|
1
|
+
.row
|
2
|
+
.column
|
3
|
+
- if notice
|
4
|
+
%p.notice= sanitize(notice)
|
5
|
+
|
6
|
+
- if alert
|
7
|
+
%p.alert= sanitize(alert)
|
8
|
+
|
9
|
+
.clearfix
|
10
|
+
.float-left
|
11
|
+
%h4 Site Notices
|
12
|
+
.float-right
|
13
|
+
= link_to 'New Site Notice', new_site_notice_path, class: 'button'
|
14
|
+
|
15
|
+
%table
|
16
|
+
%thead
|
17
|
+
%tr
|
18
|
+
%th{ width: 200 } Name
|
19
|
+
%th Notice
|
20
|
+
%th{ width: 200 } Slug
|
21
|
+
%th{ width: 150, align: 'center' } State
|
22
|
+
|
23
|
+
- if Plug.allow_delete
|
24
|
+
%th Actions
|
25
|
+
|
26
|
+
%tbody
|
27
|
+
- @site_notices.each do |site_notice|
|
28
|
+
%tr
|
29
|
+
%td= link_to site_notice.name, edit_site_notice_path(site_notice), class: 'strong'
|
30
|
+
%td= site_notice.notice.html_safe
|
31
|
+
%td= site_notice.slug
|
32
|
+
%td{ width: 150, align: 'center' }
|
33
|
+
- if site_notice.state == 'enabled'
|
34
|
+
%i.fas.fa-check-circle.fa-2x.state.state--enabled
|
35
|
+
- else
|
36
|
+
%i.fas.fa-times-circle.fa-2x.state.state--disabled
|
37
|
+
|
38
|
+
- if Plug.allow_delete
|
39
|
+
%td= link_to 'Destroy', site_notice, method: :delete, data: { confirm: 'Are you sure?' }
|
40
|
+
|
41
|
+
|
data/config/routes.rb
CHANGED
@@ -1,6 +1,16 @@
|
|
1
1
|
Plug::Engine.routes.draw do
|
2
2
|
root to: 'features#index'
|
3
3
|
|
4
|
-
|
4
|
+
# Features
|
5
5
|
resources :features, except: :show
|
6
|
+
|
7
|
+
# Site notices
|
8
|
+
resources :site_notices, except: :show
|
9
|
+
|
10
|
+
namespace :api, defaults: { format: :json } do
|
11
|
+
get '/site_notices/:slug', to: 'site_notices#show'
|
12
|
+
get '/site_notices', to: 'site_notices#index'
|
13
|
+
end
|
14
|
+
|
15
|
+
post '/task', to: 'features#task_execution', as: :task_execution
|
6
16
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class CreatePlugSiteNotices < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :plug_site_notices do |t|
|
4
|
+
t.string :name
|
5
|
+
t.string :slug
|
6
|
+
t.text :notice
|
7
|
+
t.string :state
|
8
|
+
|
9
|
+
t.timestamps
|
10
|
+
end
|
11
|
+
|
12
|
+
add_index :plug_site_notices, :name
|
13
|
+
add_index :plug_site_notices, :slug
|
14
|
+
end
|
15
|
+
end
|
data/lib/plug/configuration.rb
CHANGED
data/lib/plug/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: plug
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.21
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ben
|
@@ -9,22 +9,22 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2020-06-08 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - "
|
18
|
+
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version:
|
20
|
+
version: '0'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- - "
|
25
|
+
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version:
|
27
|
+
version: '0'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: sass-rails
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -81,6 +81,20 @@ dependencies:
|
|
81
81
|
- - ">="
|
82
82
|
- !ruby/object:Gem::Version
|
83
83
|
version: '0'
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: activeresource
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
type: :runtime
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '0'
|
84
98
|
- !ruby/object:Gem::Dependency
|
85
99
|
name: sqlite3
|
86
100
|
requirement: !ruby/object:Gem::Requirement
|
@@ -194,9 +208,11 @@ files:
|
|
194
208
|
- app/assets/images/favicon.png
|
195
209
|
- app/assets/javascripts/plug/application.js
|
196
210
|
- app/assets/javascripts/plug/features.js
|
211
|
+
- app/assets/javascripts/plug/trix-core.js
|
197
212
|
- app/assets/stylesheets/plug/_settings.scss
|
198
213
|
- app/assets/stylesheets/plug/application.scss
|
199
214
|
- app/assets/stylesheets/plug/blocks/_alert.scss
|
215
|
+
- app/assets/stylesheets/plug/blocks/_menu.scss
|
200
216
|
- app/assets/stylesheets/plug/blocks/_nav.scss
|
201
217
|
- app/assets/stylesheets/plug/blocks/_notice.scss
|
202
218
|
- app/assets/stylesheets/plug/blocks/_state.scss
|
@@ -207,14 +223,23 @@ files:
|
|
207
223
|
- app/assets/stylesheets/plug/normalize.scss
|
208
224
|
- app/assets/stylesheets/plug/partials/_main.scss
|
209
225
|
- app/assets/stylesheets/plug/partials/_utils.scss
|
226
|
+
- app/assets/stylesheets/plug/trix-overrides.scss
|
227
|
+
- app/assets/stylesheets/plug/trix.scss
|
210
228
|
- app/assets/stylesheets/plug/variables/_colors.scss
|
211
229
|
- app/assets/stylesheets/plug/variables/_typography.scss
|
230
|
+
- app/controllers/plug/api/api_controller.rb
|
231
|
+
- app/controllers/plug/api/site_notices_controller.rb
|
212
232
|
- app/controllers/plug/application_controller.rb
|
213
233
|
- app/controllers/plug/features_controller.rb
|
234
|
+
- app/controllers/plug/site_notices_controller.rb
|
214
235
|
- app/helpers/plug/application_helper.rb
|
215
236
|
- app/mailers/plug/application_mailer.rb
|
216
237
|
- app/models/plug/application_record.rb
|
238
|
+
- app/models/plug/concerns/model_helpers.rb
|
217
239
|
- app/models/plug/feature.rb
|
240
|
+
- app/models/plug/resources/site_notice.rb
|
241
|
+
- app/models/plug/site_notice.rb
|
242
|
+
- app/services/plug/task_execution_service.rb
|
218
243
|
- app/views/layouts/plug/application.html.haml
|
219
244
|
- app/views/plug/features/_form.html.haml
|
220
245
|
- app/views/plug/features/_task.html.haml
|
@@ -223,9 +248,15 @@ files:
|
|
223
248
|
- app/views/plug/features/new.html.haml
|
224
249
|
- app/views/plug/shared/_head.html.haml
|
225
250
|
- app/views/plug/shared/_nav.html.haml
|
251
|
+
- app/views/plug/site_notices/_form.html.haml
|
252
|
+
- app/views/plug/site_notices/edit.html.haml
|
253
|
+
- app/views/plug/site_notices/index.html.haml
|
254
|
+
- app/views/plug/site_notices/new.html.haml
|
226
255
|
- config/routes.rb
|
227
256
|
- db/migrate/20171207020316_create_plug_features.rb
|
228
257
|
- db/migrate/20180128202026_add_notice_to_plug_features.rb
|
258
|
+
- db/migrate/20180403024712_create_plug_site_notices.rb
|
259
|
+
- db/migrate/20180424015828_add_theme_to_plug_site_notice.rb
|
229
260
|
- lib/generators/plug/install_generator.rb
|
230
261
|
- lib/generators/plug/templates/plug.rb
|
231
262
|
- lib/plug.rb
|
@@ -253,8 +284,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
253
284
|
- !ruby/object:Gem::Version
|
254
285
|
version: '0'
|
255
286
|
requirements: []
|
256
|
-
|
257
|
-
rubygems_version: 2.6.11
|
287
|
+
rubygems_version: 3.0.3
|
258
288
|
signing_key:
|
259
289
|
specification_version: 4
|
260
290
|
summary: Rails engine that can plug/unplug features
|