dokno 1.0.0 → 1.3.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 +4 -4
- data/README.md +6 -6
- data/app/assets/javascripts/dokno.js +79 -27
- data/app/assets/stylesheets/dokno/application.css +1 -1
- data/app/controllers/dokno/application_controller.rb +3 -0
- data/app/controllers/dokno/articles_controller.rb +22 -8
- data/app/controllers/dokno/categories_controller.rb +15 -2
- data/app/controllers/dokno/user_concern.rb +5 -3
- data/app/helpers/dokno/application_helper.rb +1 -3
- data/app/models/dokno/article.rb +87 -38
- data/app/models/dokno/category.rb +39 -15
- data/app/views/dokno/_article_formatting.html.erb +17 -18
- data/app/views/dokno/_article_panel.html.erb +16 -18
- data/app/views/dokno/_panel_formatting.html.erb +47 -57
- data/app/views/dokno/articles/_article_form.html.erb +47 -6
- data/app/views/dokno/articles/show.html.erb +45 -39
- data/app/views/dokno/categories/_category_form.html.erb +6 -1
- data/app/views/dokno/categories/index.html.erb +40 -37
- data/app/views/layouts/dokno/application.html.erb +34 -9
- data/app/views/partials/_category_header.html.erb +29 -0
- data/app/views/partials/_form_errors.html.erb +0 -1
- data/app/views/partials/_logs.html.erb +7 -5
- data/app/views/partials/_pagination.html.erb +20 -18
- data/config/routes.rb +1 -1
- data/db/migrate/20201203190330_baseline.rb +4 -4
- data/db/migrate/20201211192306_add_review_due_at_to_articles.rb +6 -0
- data/db/migrate/20201213165700_add_starred_to_article.rb +5 -0
- data/lib/dokno/config/config.rb +53 -40
- data/lib/dokno/engine.rb +4 -4
- data/lib/dokno/version.rb +1 -1
- data/lib/generators/dokno/templates/config/initializers/dokno.rb +18 -5
- metadata +87 -17
data/config/routes.rb
CHANGED
@@ -3,8 +3,8 @@ Dokno::Engine.routes.draw do
|
|
3
3
|
resources :articles
|
4
4
|
|
5
5
|
get '/(:cat_code)', to: 'categories#index', as: :article_index
|
6
|
+
get '/up_for_review', to: 'categories#index', as: :up_for_review
|
6
7
|
get 'article_panel/(:slug)', to: 'articles#panel', as: :panel
|
7
|
-
post 'article_log', to: 'articles#article_log', as: :article_log
|
8
8
|
post 'article_preview', to: 'articles#preview', as: :preview
|
9
9
|
post 'article_status', to: 'articles#status', as: :status
|
10
10
|
root 'categories#index'
|
@@ -13,12 +13,12 @@ class Baseline < ActiveRecord::Migration[6.0]
|
|
13
13
|
t.string "slug"
|
14
14
|
t.string "title"
|
15
15
|
t.text "markdown"
|
16
|
-
t.datetime "created_at", precision: 6, null: false
|
17
|
-
t.datetime "updated_at", precision: 6, null: false
|
18
16
|
t.text "summary"
|
19
17
|
t.boolean "active", default: true
|
20
18
|
t.bigint "views", default: 0
|
21
19
|
t.datetime "last_viewed_at"
|
20
|
+
t.datetime "created_at", precision: 6, null: false
|
21
|
+
t.datetime "updated_at", precision: 6, null: false
|
22
22
|
t.index ["slug"], name: "index_dokno_articles_on_slug", unique: true
|
23
23
|
end
|
24
24
|
|
@@ -32,10 +32,10 @@ class Baseline < ActiveRecord::Migration[6.0]
|
|
32
32
|
|
33
33
|
create_table "dokno_categories", force: :cascade do |t|
|
34
34
|
t.string "name"
|
35
|
-
t.datetime "created_at", precision: 6, null: false
|
36
|
-
t.datetime "updated_at", precision: 6, null: false
|
37
35
|
t.bigint "category_id"
|
38
36
|
t.string "code", null: false
|
37
|
+
t.datetime "created_at", precision: 6, null: false
|
38
|
+
t.datetime "updated_at", precision: 6, null: false
|
39
39
|
t.index ["category_id"], name: "index_dokno_categories_on_category_id"
|
40
40
|
t.index ["code"], name: "index_dokno_categories_on_code", unique: true
|
41
41
|
t.index ["name"], name: "index_dokno_categories_on_name", unique: true
|
data/lib/dokno/config/config.rb
CHANGED
@@ -1,4 +1,8 @@
|
|
1
1
|
module Dokno
|
2
|
+
module Error
|
3
|
+
class Config < StandardError; end
|
4
|
+
end
|
5
|
+
|
2
6
|
def self.configure
|
3
7
|
yield config
|
4
8
|
config.validate
|
@@ -8,62 +12,71 @@ module Dokno
|
|
8
12
|
@config ||= Config.new
|
9
13
|
end
|
10
14
|
|
11
|
-
def self.config=(val)
|
12
|
-
@config = val
|
13
|
-
end
|
14
|
-
|
15
15
|
class Config
|
16
|
-
#
|
17
|
-
|
16
|
+
# Dokno configuration options
|
17
|
+
#
|
18
|
+
# app_name (String)
|
19
|
+
# Host app name for display within the mounted dashboard
|
20
|
+
# tag_whitelist (Enumerable)
|
21
|
+
# Determines which HTML tags are allowed in Article markdown
|
22
|
+
# attr_whitelist (Enumerable)
|
23
|
+
# Determines which HTML attributes are allowed in Article markdown
|
24
|
+
# app_user_object (String)
|
25
|
+
# Host app's user object
|
26
|
+
# app_user_auth_method (Symbol)
|
27
|
+
# Host app's user object method to be used for edit authorization.
|
28
|
+
# Should return boolean
|
29
|
+
# app_user_name_method (Symbol)
|
30
|
+
# Host app's user object method that returns the authenticated user's name or other
|
31
|
+
# identifier that will be included in change log events.
|
32
|
+
# Should return a string
|
33
|
+
# article_review_period (ActiveSupport::Duration)
|
34
|
+
# The amount of time before articles should be reviewed for accuracy/relevance
|
35
|
+
# article_review_prompt_days (Integer)
|
36
|
+
# The number of days prior to an article being up for review that users should be prompted
|
18
37
|
|
19
|
-
|
38
|
+
attr_accessor :app_name
|
20
39
|
attr_accessor :tag_whitelist
|
21
|
-
|
22
|
-
# (Enumerable) Determines which HTML attributes are allowed in Article markdown
|
23
40
|
attr_accessor :attr_whitelist
|
24
|
-
|
25
|
-
# (String) Host application's user object
|
26
41
|
attr_accessor :app_user_object
|
27
|
-
|
28
|
-
# (Symbol) Host application's user object method that should be used to authorize users to edit Dokno data
|
29
|
-
# Should return boolean.
|
30
42
|
attr_accessor :app_user_auth_method
|
31
|
-
|
32
|
-
# (Symbol) Host application's user object method that should return the authenticated user's name or other
|
33
|
-
# identifier that will be included in change log events. Should return a string.
|
34
43
|
attr_accessor :app_user_name_method
|
44
|
+
attr_accessor :article_review_period
|
45
|
+
attr_accessor :article_review_prompt_days
|
35
46
|
|
36
47
|
# Defaults
|
37
|
-
TAG_WHITELIST
|
38
|
-
ATTR_WHITELIST
|
39
|
-
APP_USER_OBJECT
|
40
|
-
APP_USER_AUTH_METHOD
|
41
|
-
APP_USER_NAME_METHOD
|
48
|
+
TAG_WHITELIST = %w[code img h1 h2 h3 h4 h5 h6 a em u i b strong ol ul li table thead tbody tfoot tr th td blockquote hr br p]
|
49
|
+
ATTR_WHITELIST = %w[src alt title href target]
|
50
|
+
APP_USER_OBJECT = 'current_user'
|
51
|
+
APP_USER_AUTH_METHOD = :admin?
|
52
|
+
APP_USER_NAME_METHOD = :name
|
53
|
+
ARTICLE_REVIEW_PERIOD = 1.year
|
54
|
+
ARTICLE_REVIEW_PROMPT_DAYS = 30
|
42
55
|
|
43
56
|
def initialize
|
44
|
-
self.app_name
|
45
|
-
self.tag_whitelist
|
46
|
-
self.attr_whitelist
|
47
|
-
self.app_user_object
|
48
|
-
self.app_user_auth_method
|
49
|
-
self.app_user_name_method
|
57
|
+
self.app_name = Rails.application.class.module_parent.name.underscore.humanize.upcase
|
58
|
+
self.tag_whitelist = TAG_WHITELIST
|
59
|
+
self.attr_whitelist = ATTR_WHITELIST
|
60
|
+
self.app_user_object = APP_USER_OBJECT
|
61
|
+
self.app_user_auth_method = APP_USER_AUTH_METHOD
|
62
|
+
self.app_user_name_method = APP_USER_NAME_METHOD
|
63
|
+
self.article_review_period = ARTICLE_REVIEW_PERIOD
|
64
|
+
self.article_review_prompt_days = ARTICLE_REVIEW_PROMPT_DAYS
|
50
65
|
end
|
51
66
|
|
52
67
|
def validate
|
53
|
-
|
54
|
-
|
68
|
+
validate_config_option(option: 'tag_whitelist', expected_class: Enumerable, example: '%w[a p strong]')
|
69
|
+
validate_config_option(option: 'attr_whitelist', expected_class: Enumerable, example: '%w[class href]')
|
70
|
+
validate_config_option(option: 'app_user_object', expected_class: String, example: 'current_user')
|
71
|
+
validate_config_option(option: 'app_user_auth_method', expected_class: Symbol, example: ':admin?')
|
72
|
+
validate_config_option(option: 'app_user_name_method', expected_class: Symbol, example: ':name')
|
73
|
+
validate_config_option(option: 'article_review_period', expected_class: ActiveSupport::Duration, example: '1.year')
|
74
|
+
validate_config_option(option: 'article_review_prompt_days', expected_class: Integer, example: '30')
|
55
75
|
end
|
56
76
|
|
57
|
-
def
|
58
|
-
return unless !
|
59
|
-
|
60
|
-
raise "#{config_error_prefix} tag_whitelist must be Enumerable"
|
61
|
-
end
|
62
|
-
|
63
|
-
def validate_attr_whitelist
|
64
|
-
return unless !attr_whitelist.is_a?(Enumerable)
|
65
|
-
|
66
|
-
raise "#{config_error_prefix} attr_whitelist must be Enumerable"
|
77
|
+
def validate_config_option(option:, expected_class:, example:)
|
78
|
+
return unless !send(option.to_sym).is_a? expected_class
|
79
|
+
raise Error::Config, "#{config_error_prefix} #{option} must be #{expected_class}, e.g. #{example}"
|
67
80
|
end
|
68
81
|
|
69
82
|
def config_error_prefix
|
data/lib/dokno/engine.rb
CHANGED
@@ -4,10 +4,6 @@ module Dokno
|
|
4
4
|
class Engine < ::Rails::Engine
|
5
5
|
isolate_namespace Dokno
|
6
6
|
|
7
|
-
initializer 'Dokno precompile', group: :all do |app|
|
8
|
-
app.config.assets.precompile << "dokno_manifest.js"
|
9
|
-
end
|
10
|
-
|
11
7
|
config.generators do |g|
|
12
8
|
g.test_framework :rspec
|
13
9
|
end
|
@@ -18,6 +14,10 @@ module Dokno
|
|
18
14
|
end
|
19
15
|
end
|
20
16
|
|
17
|
+
initializer 'Dokno precompile', group: :all do |app|
|
18
|
+
app.config.assets.precompile << "dokno_manifest.js"
|
19
|
+
end
|
20
|
+
|
21
21
|
initializer 'local_helper.action_controller' do
|
22
22
|
ActiveSupport.on_load :action_controller do
|
23
23
|
helper Dokno::ApplicationHelper
|
data/lib/dokno/version.rb
CHANGED
@@ -1,14 +1,27 @@
|
|
1
1
|
Dokno.configure do |config|
|
2
|
-
|
3
|
-
|
2
|
+
# To control the permitted HTML tags and attributes within articles,
|
3
|
+
# uncomment and change the defaults.
|
4
|
+
# (Enumerable) tag_whitelist
|
5
|
+
# (Enumerable) attr_whitelist
|
6
|
+
# config.tag_whitelist = %w[code img h1 h2 h3 h4 h5 h6 a em u i b strong ol ul li table thead tbody tfoot tr th td blockquote hr br p]
|
7
|
+
# config.attr_whitelist = %w[src alt title href target]
|
4
8
|
|
5
9
|
# To restrict Dokno data modification and include indentifying information
|
6
10
|
# in change log entries, provide the appropriate user values for your app below.
|
7
11
|
# (String) app_user_object
|
8
12
|
# (Symbol) app_user_auth_method
|
9
13
|
# (Symbol) app_user_name_method
|
14
|
+
# config.app_user_object = 'current_user'
|
15
|
+
# config.app_user_auth_method = :admin?
|
16
|
+
# config.app_user_name_method = :name
|
10
17
|
|
11
|
-
#
|
12
|
-
#
|
13
|
-
#
|
18
|
+
# To control the amount of time before a created/updated article is flagged
|
19
|
+
# for accuracy/relevance review, uncomment and change the default.
|
20
|
+
# (ActiveSupport::Duration) article_review_period
|
21
|
+
# config.article_review_period = 1.year
|
22
|
+
|
23
|
+
# To control the number of days prior to an article being up for review
|
24
|
+
# that users should be prompted to re-review, uncomment and change the default.
|
25
|
+
# (Integer) article_review_prompt_days
|
26
|
+
# config.article_review_prompt_days = 30
|
14
27
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dokno
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Courtney Payne
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-12-
|
11
|
+
date: 2020-12-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: diffy
|
@@ -38,6 +38,34 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '3.5'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bullet
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '6.1'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '6.1'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: capybara
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '3.34'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '3.34'
|
41
69
|
- !ruby/object:Gem::Dependency
|
42
70
|
name: database_cleaner-active_record
|
43
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -52,6 +80,20 @@ dependencies:
|
|
52
80
|
- - "~>"
|
53
81
|
- !ruby/object:Gem::Version
|
54
82
|
version: '1.8'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: faker
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '2.15'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '2.15'
|
55
97
|
- !ruby/object:Gem::Dependency
|
56
98
|
name: pg
|
57
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,6 +128,20 @@ dependencies:
|
|
86
128
|
- - "~>"
|
87
129
|
- !ruby/object:Gem::Version
|
88
130
|
version: '3.9'
|
131
|
+
- !ruby/object:Gem::Dependency
|
132
|
+
name: puma
|
133
|
+
requirement: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - "~>"
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '5.1'
|
138
|
+
type: :development
|
139
|
+
prerelease: false
|
140
|
+
version_requirements: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - "~>"
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '5.1'
|
89
145
|
- !ruby/object:Gem::Dependency
|
90
146
|
name: rails
|
91
147
|
requirement: !ruby/object:Gem::Requirement
|
@@ -127,50 +183,61 @@ dependencies:
|
|
127
183
|
- !ruby/object:Gem::Version
|
128
184
|
version: 4.0.1
|
129
185
|
- !ruby/object:Gem::Dependency
|
130
|
-
name:
|
186
|
+
name: selenium-webdriver
|
131
187
|
requirement: !ruby/object:Gem::Requirement
|
132
188
|
requirements:
|
133
189
|
- - "~>"
|
134
190
|
- !ruby/object:Gem::Version
|
135
|
-
version:
|
191
|
+
version: '3.142'
|
192
|
+
- - ">="
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: 3.142.7
|
136
195
|
type: :development
|
137
196
|
prerelease: false
|
138
197
|
version_requirements: !ruby/object:Gem::Requirement
|
139
198
|
requirements:
|
140
199
|
- - "~>"
|
141
200
|
- !ruby/object:Gem::Version
|
142
|
-
version:
|
201
|
+
version: '3.142'
|
202
|
+
- - ">="
|
203
|
+
- !ruby/object:Gem::Version
|
204
|
+
version: 3.142.7
|
143
205
|
- !ruby/object:Gem::Dependency
|
144
|
-
name:
|
206
|
+
name: simplecov
|
145
207
|
requirement: !ruby/object:Gem::Requirement
|
146
208
|
requirements:
|
147
209
|
- - "~>"
|
148
210
|
- !ruby/object:Gem::Version
|
149
|
-
version:
|
211
|
+
version: 0.19.1
|
150
212
|
type: :development
|
151
213
|
prerelease: false
|
152
214
|
version_requirements: !ruby/object:Gem::Requirement
|
153
215
|
requirements:
|
154
216
|
- - "~>"
|
155
217
|
- !ruby/object:Gem::Version
|
156
|
-
version:
|
218
|
+
version: 0.19.1
|
157
219
|
- !ruby/object:Gem::Dependency
|
158
|
-
name:
|
220
|
+
name: webdrivers
|
159
221
|
requirement: !ruby/object:Gem::Requirement
|
160
222
|
requirements:
|
161
223
|
- - "~>"
|
162
224
|
- !ruby/object:Gem::Version
|
163
|
-
version: '
|
225
|
+
version: '4.4'
|
226
|
+
- - ">="
|
227
|
+
- !ruby/object:Gem::Version
|
228
|
+
version: 4.4.1
|
164
229
|
type: :development
|
165
230
|
prerelease: false
|
166
231
|
version_requirements: !ruby/object:Gem::Requirement
|
167
232
|
requirements:
|
168
233
|
- - "~>"
|
169
234
|
- !ruby/object:Gem::Version
|
170
|
-
version: '
|
235
|
+
version: '4.4'
|
236
|
+
- - ">="
|
237
|
+
- !ruby/object:Gem::Version
|
238
|
+
version: 4.4.1
|
171
239
|
description: Dokno allows you to easily mount a self-contained knowledgebase / wiki
|
172
|
-
/ help system to your Rails app
|
173
|
-
to your app.
|
240
|
+
/ help system to your Rails app.
|
174
241
|
email:
|
175
242
|
- cpayne624@gmail.com
|
176
243
|
executables: []
|
@@ -211,11 +278,14 @@ files:
|
|
211
278
|
- app/views/dokno/categories/index.html.erb
|
212
279
|
- app/views/dokno/categories/new.html.erb
|
213
280
|
- app/views/layouts/dokno/application.html.erb
|
281
|
+
- app/views/partials/_category_header.html.erb
|
214
282
|
- app/views/partials/_form_errors.html.erb
|
215
283
|
- app/views/partials/_logs.html.erb
|
216
284
|
- app/views/partials/_pagination.html.erb
|
217
285
|
- config/routes.rb
|
218
286
|
- db/migrate/20201203190330_baseline.rb
|
287
|
+
- db/migrate/20201211192306_add_review_due_at_to_articles.rb
|
288
|
+
- db/migrate/20201213165700_add_starred_to_article.rb
|
219
289
|
- lib/dokno.rb
|
220
290
|
- lib/dokno/config/config.rb
|
221
291
|
- lib/dokno/engine.rb
|
@@ -230,7 +300,7 @@ licenses:
|
|
230
300
|
metadata:
|
231
301
|
bug_tracker_uri: https://github.com/cpayne624/dokno/issues
|
232
302
|
changelog_uri: https://github.com/cpayne624/dokno/blob/master/CHANGELOG.md
|
233
|
-
post_install_message:
|
303
|
+
post_install_message:
|
234
304
|
rdoc_options: []
|
235
305
|
require_paths:
|
236
306
|
- lib
|
@@ -245,8 +315,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
245
315
|
- !ruby/object:Gem::Version
|
246
316
|
version: '0'
|
247
317
|
requirements: []
|
248
|
-
rubygems_version: 3.1
|
249
|
-
signing_key:
|
318
|
+
rubygems_version: 3.2.0.rc.1
|
319
|
+
signing_key:
|
250
320
|
specification_version: 4
|
251
321
|
summary: Dokno (dough-no) is a lightweight mountable Rails Engine for storing and
|
252
322
|
managing your app's domain knowledge.
|