ksk 0.4.7 → 0.4.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.editorconfig +13 -0
- data/Gemfile +1 -2
- data/README.md +0 -1
- data/app/assets/javascripts/ksk/application.js +8 -7
- data/app/assets/javascripts/ksk/classes/NaviAdmin.js +10 -4
- data/app/controllers/ksk/navigations_controller.rb +7 -4
- data/app/models/concerns/ksk/asset.rb +5 -5
- data/app/models/concerns/ksk/{paperclip_crop.rb → image_crop.rb} +6 -6
- data/app/models/concerns/ksk/navigation.rb +1 -2
- data/app/models/concerns/ksk/post.rb +0 -1
- data/app/models/concerns/ksk/static.rb +2 -2
- data/config/bhf/ksk.yml +4 -5
- data/ksk.gemspec +11 -14
- data/lib/{paperclip_processors → image_processors}/ksk_crop.rb +3 -3
- data/lib/ksk.rb +6 -5
- metadata +8 -23
- data/app/models/concerns/ksk/markdown.rb +0 -78
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 854dba2b8616df8ff94efcfb63205183583b860e18b7af07f3bf4bda39136fce
|
4
|
+
data.tar.gz: 8f52208f069053160c0bb8390211606973f91ecf1de2961a093d28f096992eeb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1900426cfe5512d4c00b4460950110af5c9ecceab997892ad21854ad2b6f5ad0885736af5e59d205623f271e57ef9f7a67ee9368eb86777166e18e86f00b542e
|
7
|
+
data.tar.gz: b626e2d8dc835497ee4a5e1f28553081be52503b3850818fbc782a882c5c5d427779f3497dce1ccb25f0b53472271636a5dd59d648b5b1a1de097122941a8fba
|
data/.editorconfig
ADDED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -8,7 +8,6 @@ Blog/Website management plugin for [bhf](http://antpaw.github.io/bhf/).
|
|
8
8
|
* The abstract [settings `.yml`](https://github.com/antpaw/ksk/tree/master/config/bhf/ksk.yml)
|
9
9
|
([learn how to use it in your own settings `.yml`](http://antpaw.github.io/bhf/#abstract_platform_settings))
|
10
10
|
* Include this [concerns](https://github.com/antpaw/ksk/tree/master/app/models/concerns/ksk) to your models.
|
11
|
-
* Use this [partials](https://github.com/antpaw/ksk/tree/master/app/views/bhf), for example to crop paperclip images.
|
12
11
|
|
13
12
|
|
14
13
|
## Contributing to ksk
|
@@ -1,7 +1,7 @@
|
|
1
1
|
//= require_tree ./classes
|
2
2
|
|
3
3
|
window.addEvent('bhfDomChunkReady', function(scope){
|
4
|
-
|
4
|
+
|
5
5
|
scope.getElements('.js_tree_holder').each(function(elem){
|
6
6
|
var naviA = new NaviAdmin({
|
7
7
|
elemTree: elem.getElement('.js_tree_list'),
|
@@ -31,17 +31,18 @@ window.addEvent('bhfDomChunkReady', function(scope){
|
|
31
31
|
new Request({
|
32
32
|
url: platform.getElement('.template_data').get('data-update-path'),
|
33
33
|
onSuccess: function(responseText){
|
34
|
+
var newId = JSON.parse(responseText).id;
|
34
35
|
new Element('li', {
|
35
|
-
'id': naviName+'_'+
|
36
|
-
'html': '<div> <span class="title">'+name+'</span> <span class="links">'+tmpl.get('html')+'</span></div>'.replace(/NAVIID/g,
|
36
|
+
'id': naviName+'_'+newId,
|
37
|
+
'html': '<div> <span class="title">'+name+'</span> <span class="links">'+tmpl.get('html')+'</span></div>'.replace(/NAVIID/g, newId)
|
37
38
|
})
|
38
39
|
.inject(platform.getElement('.js_tree_list li'), 'before');
|
39
40
|
naviA.reInit();
|
40
41
|
}
|
41
42
|
}).post(queryParams);
|
42
43
|
});
|
43
|
-
});
|
44
|
-
|
44
|
+
});
|
45
|
+
|
45
46
|
cropImages = scope.getElements('.js_crop_image');
|
46
47
|
if (cropImages.length) {
|
47
48
|
var cropInit = function(){
|
@@ -58,7 +59,7 @@ window.addEvent('bhfDomChunkReady', function(scope){
|
|
58
59
|
}
|
59
60
|
}
|
60
61
|
var hasSize = minWidth && minHeight;
|
61
|
-
|
62
|
+
|
62
63
|
$cropImg.Jcrop({
|
63
64
|
// minSize: (hasSize ? [minWidth, minHeight] : undefined),
|
64
65
|
aspectRatio: (hasSize ? (minWidth / minHeight) : undefined),
|
@@ -85,5 +86,5 @@ window.addEvent('bhfDomChunkReady', function(scope){
|
|
85
86
|
}
|
86
87
|
});
|
87
88
|
}
|
88
|
-
|
89
|
+
|
89
90
|
});
|
@@ -162,9 +162,15 @@ var NaviAdmin = new Class({
|
|
162
162
|
},
|
163
163
|
|
164
164
|
getNaviName: function(){
|
165
|
-
|
166
|
-
|
167
|
-
|
165
|
+
var navigationElements = this.elemTree.getElement('li.item');
|
166
|
+
if (navigationElements && navigationElements.length) {
|
167
|
+
return this.getId(
|
168
|
+
navigationElements.get('id')
|
169
|
+
).name;
|
170
|
+
}
|
171
|
+
else {
|
172
|
+
return 'navigation';
|
173
|
+
}
|
168
174
|
},
|
169
175
|
|
170
176
|
getIdPositions: function(){
|
@@ -181,4 +187,4 @@ var NaviAdmin = new Class({
|
|
181
187
|
reInit: function(){
|
182
188
|
this.initialize(this.options);
|
183
189
|
}
|
184
|
-
});
|
190
|
+
});
|
@@ -8,14 +8,17 @@ class Ksk::NavigationsController < Bhf::ApplicationController
|
|
8
8
|
|
9
9
|
def create
|
10
10
|
n = Navigation.new(params_navigation)
|
11
|
-
n.save
|
12
|
-
|
11
|
+
if n.save
|
12
|
+
render json: {id: n.id}
|
13
|
+
else
|
14
|
+
render status: 400, json: n.errors
|
15
|
+
end
|
13
16
|
end
|
14
17
|
|
15
18
|
private
|
16
19
|
def params_navigation
|
17
|
-
|
20
|
+
a = params.require(:navigation).permit(:title)
|
21
|
+
a
|
18
22
|
end
|
19
23
|
|
20
24
|
end
|
21
|
-
|
@@ -11,18 +11,18 @@ module Ksk::Asset
|
|
11
11
|
|
12
12
|
do_not_validate_attachment_file_type :file
|
13
13
|
before_file_post_process :is_image?
|
14
|
-
include Ksk::
|
14
|
+
include Ksk::ImageCrop
|
15
15
|
|
16
|
-
scope :only_images, -> {where(file_content_type: Bhf.configuration.
|
16
|
+
scope :only_images, -> {where(file_content_type: Bhf.configuration.image_types)}
|
17
17
|
scope :first_image, -> {only_images.limit(1)}
|
18
18
|
scope :other_images, -> {only_images.offset(1)}
|
19
19
|
|
20
|
-
scope :only_data_files, -> {where('file_content_type not in (?)', Bhf.configuration.
|
20
|
+
scope :only_data_files, -> {where('file_content_type not in (?)', Bhf.configuration.image_types)}
|
21
21
|
scope :first_data_files, -> {only_data_files.limit(1)}
|
22
22
|
end
|
23
23
|
|
24
24
|
def is_image?
|
25
|
-
Bhf.configuration.
|
25
|
+
Bhf.configuration.image_types.include?(file.content_type)
|
26
26
|
end
|
27
27
|
|
28
28
|
|
@@ -52,4 +52,4 @@ module Ksk::Asset
|
|
52
52
|
{ file: [] }
|
53
53
|
end
|
54
54
|
|
55
|
-
end
|
55
|
+
end
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module Ksk::
|
1
|
+
module Ksk::ImageCrop
|
2
2
|
extend ActiveSupport::Concern
|
3
3
|
|
4
4
|
included do
|
@@ -50,11 +50,11 @@ module Ksk::PaperclipCrop
|
|
50
50
|
def resize_banner(name, cords, resize)
|
51
51
|
ksk_images_for_crop.each_pair do |image_name, style_names|
|
52
52
|
image = send(image_name)
|
53
|
-
image.queued_for_write[name] = Paperclip.processor(:ksk_crop).make(image, cords, image)
|
54
|
-
style = Paperclip::Style.new(name, [resize, :jpg], image)
|
55
|
-
image.queued_for_write[name] = Paperclip.processor(:thumbnail).make(image.queued_for_write[name], style.processor_options, image.queued_for_write[name])
|
56
|
-
image.queued_for_write[name] = Paperclip.io_adapters.for(image.queued_for_write[name])
|
53
|
+
# image.queued_for_write[name] = Paperclip.processor(:ksk_crop).make(image, cords, image)
|
54
|
+
# style = Paperclip::Style.new(name, [resize, :jpg], image)
|
55
|
+
# image.queued_for_write[name] = Paperclip.processor(:thumbnail).make(image.queued_for_write[name], style.processor_options, image.queued_for_write[name])
|
56
|
+
# image.queued_for_write[name] = Paperclip.io_adapters.for(image.queued_for_write[name])
|
57
57
|
end
|
58
58
|
end
|
59
59
|
|
60
|
-
end
|
60
|
+
end
|
@@ -11,7 +11,7 @@ module Ksk::Navigation
|
|
11
11
|
|
12
12
|
belongs_to :static
|
13
13
|
belongs_to :navigation_type
|
14
|
-
belongs_to :parent, foreign_key: 'parent_id', class_name: 'Navigation'
|
14
|
+
belongs_to :parent, foreign_key: 'parent_id', class_name: 'Navigation', optional: true
|
15
15
|
has_many :children, foreign_key: 'parent_id', class_name: 'Navigation', dependent: :delete_all
|
16
16
|
|
17
17
|
scope :top_level, -> {where(parent_id: 0)}
|
@@ -21,7 +21,6 @@ module Ksk::Navigation
|
|
21
21
|
before_save :set_slug, :set_link
|
22
22
|
end
|
23
23
|
|
24
|
-
|
25
24
|
def set_slug
|
26
25
|
return if !slug.blank?
|
27
26
|
write_attribute(:slug, title.to_url)
|
@@ -2,13 +2,13 @@ module Ksk::Static
|
|
2
2
|
extend ActiveSupport::Concern
|
3
3
|
|
4
4
|
included do
|
5
|
-
include Ksk::Markdown
|
6
|
-
|
7
5
|
has_one :navigation
|
8
6
|
has_many :assets, as: :fileable
|
9
7
|
# TODO: needs on_delete hook to destroy navigation if Navigation is availible for this object
|
10
8
|
|
11
9
|
accepts_nested_attributes_for :assets, allow_destroy: true
|
10
|
+
|
11
|
+
has_rich_text :content
|
12
12
|
end
|
13
13
|
|
14
14
|
end
|
data/config/bhf/ksk.yml
CHANGED
@@ -11,8 +11,8 @@ pages:
|
|
11
11
|
multipart: true
|
12
12
|
types:
|
13
13
|
assets: assets
|
14
|
-
content:
|
15
|
-
|
14
|
+
content: rich_text
|
15
|
+
|
16
16
|
- category:
|
17
17
|
table:
|
18
18
|
columns: [id, title, updated_at, created_at]
|
@@ -22,11 +22,10 @@ pages:
|
|
22
22
|
columns: [id, title, content, updated_at, created_at]
|
23
23
|
per_page: 30
|
24
24
|
form:
|
25
|
-
display: [id, title, content
|
25
|
+
display: [id, title, content]
|
26
26
|
multipart: true
|
27
27
|
types:
|
28
|
-
|
29
|
-
content: markdown
|
28
|
+
content: rich_text
|
30
29
|
|
31
30
|
- navigation:
|
32
31
|
table:
|
data/ksk.gemspec
CHANGED
@@ -2,16 +2,16 @@
|
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
3
|
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: ksk 0.4.
|
5
|
+
# stub: ksk 0.4.8 ruby lib
|
6
6
|
|
7
7
|
Gem::Specification.new do |s|
|
8
8
|
s.name = "ksk".freeze
|
9
|
-
s.version = "0.4.
|
9
|
+
s.version = "0.4.8"
|
10
10
|
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
12
12
|
s.require_paths = ["lib".freeze]
|
13
13
|
s.authors = ["Anton Pawlik".freeze]
|
14
|
-
s.date = "
|
14
|
+
s.date = "2019-12-27"
|
15
15
|
s.description = "Blog/Website management plugin for bhf. Includes abstract settings .yml, model concerns and bhf view partials.".freeze
|
16
16
|
s.email = "anton.pawlik@gmail.com".freeze
|
17
17
|
s.extra_rdoc_files = [
|
@@ -19,6 +19,7 @@ Gem::Specification.new do |s|
|
|
19
19
|
"README.md"
|
20
20
|
]
|
21
21
|
s.files = [
|
22
|
+
".editorconfig",
|
22
23
|
"Gemfile",
|
23
24
|
"Gemfile.lock",
|
24
25
|
"LICENSE.txt",
|
@@ -32,10 +33,9 @@ Gem::Specification.new do |s|
|
|
32
33
|
"app/helpers/ksk/frontend_helper.rb",
|
33
34
|
"app/models/concerns/ksk/asset.rb",
|
34
35
|
"app/models/concerns/ksk/category.rb",
|
35
|
-
"app/models/concerns/ksk/
|
36
|
+
"app/models/concerns/ksk/image_crop.rb",
|
36
37
|
"app/models/concerns/ksk/navigation.rb",
|
37
38
|
"app/models/concerns/ksk/navigation_type.rb",
|
38
|
-
"app/models/concerns/ksk/paperclip_crop.rb",
|
39
39
|
"app/models/concerns/ksk/post.rb",
|
40
40
|
"app/models/concerns/ksk/preview.rb",
|
41
41
|
"app/models/concerns/ksk/static.rb",
|
@@ -53,30 +53,28 @@ Gem::Specification.new do |s|
|
|
53
53
|
"config/locales/en.yml",
|
54
54
|
"config/routes.rb",
|
55
55
|
"ksk.gemspec",
|
56
|
-
"lib/
|
57
|
-
"lib/
|
56
|
+
"lib/image_processors/ksk_crop.rb",
|
57
|
+
"lib/ksk.rb"
|
58
58
|
]
|
59
59
|
s.homepage = "http://github.com/antpaw/ksk".freeze
|
60
60
|
s.licenses = ["MIT".freeze]
|
61
|
-
s.rubygems_version = "
|
61
|
+
s.rubygems_version = "3.0.6".freeze
|
62
62
|
s.summary = "Blog/Website management plugin for bhf".freeze
|
63
63
|
|
64
64
|
if s.respond_to? :specification_version then
|
65
65
|
s.specification_version = 4
|
66
66
|
|
67
67
|
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
68
|
-
s.add_runtime_dependency(%q<bhf>.freeze, [">= 0"])
|
68
|
+
s.add_runtime_dependency(%q<bhf>.freeze, [">= 1.0.0.beta8"])
|
69
69
|
s.add_runtime_dependency(%q<stringex>.freeze, [">= 2"])
|
70
|
-
s.add_runtime_dependency(%q<paperclip>.freeze, [">= 4"])
|
71
70
|
s.add_development_dependency(%q<shoulda>.freeze, [">= 3"])
|
72
71
|
s.add_development_dependency(%q<rdoc>.freeze, [">= 3"])
|
73
72
|
s.add_development_dependency(%q<bundler>.freeze, [">= 1"])
|
74
73
|
s.add_development_dependency(%q<jeweler>.freeze, [">= 2"])
|
75
74
|
s.add_development_dependency(%q<simplecov>.freeze, [">= 0"])
|
76
75
|
else
|
77
|
-
s.add_dependency(%q<bhf>.freeze, [">= 0"])
|
76
|
+
s.add_dependency(%q<bhf>.freeze, [">= 1.0.0.beta8"])
|
78
77
|
s.add_dependency(%q<stringex>.freeze, [">= 2"])
|
79
|
-
s.add_dependency(%q<paperclip>.freeze, [">= 4"])
|
80
78
|
s.add_dependency(%q<shoulda>.freeze, [">= 3"])
|
81
79
|
s.add_dependency(%q<rdoc>.freeze, [">= 3"])
|
82
80
|
s.add_dependency(%q<bundler>.freeze, [">= 1"])
|
@@ -84,9 +82,8 @@ Gem::Specification.new do |s|
|
|
84
82
|
s.add_dependency(%q<simplecov>.freeze, [">= 0"])
|
85
83
|
end
|
86
84
|
else
|
87
|
-
s.add_dependency(%q<bhf>.freeze, [">= 0"])
|
85
|
+
s.add_dependency(%q<bhf>.freeze, [">= 1.0.0.beta8"])
|
88
86
|
s.add_dependency(%q<stringex>.freeze, [">= 2"])
|
89
|
-
s.add_dependency(%q<paperclip>.freeze, [">= 4"])
|
90
87
|
s.add_dependency(%q<shoulda>.freeze, [">= 3"])
|
91
88
|
s.add_dependency(%q<rdoc>.freeze, [">= 3"])
|
92
89
|
s.add_dependency(%q<bundler>.freeze, [">= 1"])
|
@@ -1,4 +1,4 @@
|
|
1
|
-
module
|
1
|
+
module ImageProcessors
|
2
2
|
|
3
3
|
class KskCrop < Processor
|
4
4
|
|
@@ -26,10 +26,10 @@ module Paperclip
|
|
26
26
|
else
|
27
27
|
File.expand_path(src.path)
|
28
28
|
end
|
29
|
-
success = Paperclip.run('convert', parameters, source: path, dest: File.expand_path(dst.path))
|
29
|
+
# success = Paperclip.run('convert', parameters, source: path, dest: File.expand_path(dst.path))
|
30
30
|
|
31
31
|
dst
|
32
32
|
end
|
33
33
|
|
34
34
|
end
|
35
|
-
end
|
35
|
+
end
|
data/lib/ksk.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
module Ksk
|
2
2
|
class Engine < Rails::Engine
|
3
|
-
|
3
|
+
|
4
4
|
isolate_namespace Ksk
|
5
5
|
|
6
6
|
Bhf.configure do |config|
|
@@ -8,16 +8,17 @@ module Ksk
|
|
8
8
|
config.js << 'ksk/application'
|
9
9
|
config.abstract_settings << "#{File.expand_path("../..", __FILE__)}/config/bhf/ksk"
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
initializer 'ksk.helper' do
|
13
13
|
ActiveSupport.on_load :action_controller do
|
14
14
|
helper Ksk::FrontendHelper
|
15
15
|
end
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
|
+
initializer 'ksk.assets.precompile' do |app|
|
19
|
+
app.config.assets.precompile += %w( ksk/application.css ksk/application.js )
|
20
|
+
end
|
18
21
|
end
|
19
22
|
end
|
20
23
|
|
21
24
|
require 'stringex'
|
22
|
-
require 'paperclip/processor'
|
23
|
-
require 'paperclip_processors/ksk_crop'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ksk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anton Pawlik
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2019-12-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bhf
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
19
|
+
version: 1.0.0.beta8
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
26
|
+
version: 1.0.0.beta8
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: stringex
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -38,20 +38,6 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '2'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: paperclip
|
43
|
-
requirement: !ruby/object:Gem::Requirement
|
44
|
-
requirements:
|
45
|
-
- - ">="
|
46
|
-
- !ruby/object:Gem::Version
|
47
|
-
version: '4'
|
48
|
-
type: :runtime
|
49
|
-
prerelease: false
|
50
|
-
version_requirements: !ruby/object:Gem::Requirement
|
51
|
-
requirements:
|
52
|
-
- - ">="
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version: '4'
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
42
|
name: shoulda
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -131,6 +117,7 @@ extra_rdoc_files:
|
|
131
117
|
- LICENSE.txt
|
132
118
|
- README.md
|
133
119
|
files:
|
120
|
+
- ".editorconfig"
|
134
121
|
- Gemfile
|
135
122
|
- Gemfile.lock
|
136
123
|
- LICENSE.txt
|
@@ -144,10 +131,9 @@ files:
|
|
144
131
|
- app/helpers/ksk/frontend_helper.rb
|
145
132
|
- app/models/concerns/ksk/asset.rb
|
146
133
|
- app/models/concerns/ksk/category.rb
|
147
|
-
- app/models/concerns/ksk/
|
134
|
+
- app/models/concerns/ksk/image_crop.rb
|
148
135
|
- app/models/concerns/ksk/navigation.rb
|
149
136
|
- app/models/concerns/ksk/navigation_type.rb
|
150
|
-
- app/models/concerns/ksk/paperclip_crop.rb
|
151
137
|
- app/models/concerns/ksk/post.rb
|
152
138
|
- app/models/concerns/ksk/preview.rb
|
153
139
|
- app/models/concerns/ksk/static.rb
|
@@ -165,8 +151,8 @@ files:
|
|
165
151
|
- config/locales/en.yml
|
166
152
|
- config/routes.rb
|
167
153
|
- ksk.gemspec
|
154
|
+
- lib/image_processors/ksk_crop.rb
|
168
155
|
- lib/ksk.rb
|
169
|
-
- lib/paperclip_processors/ksk_crop.rb
|
170
156
|
homepage: http://github.com/antpaw/ksk
|
171
157
|
licenses:
|
172
158
|
- MIT
|
@@ -186,8 +172,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
186
172
|
- !ruby/object:Gem::Version
|
187
173
|
version: '0'
|
188
174
|
requirements: []
|
189
|
-
|
190
|
-
rubygems_version: 2.6.13
|
175
|
+
rubygems_version: 3.0.6
|
191
176
|
signing_key:
|
192
177
|
specification_version: 4
|
193
178
|
summary: Blog/Website management plugin for bhf
|
@@ -1,78 +0,0 @@
|
|
1
|
-
module Ksk::Markdown
|
2
|
-
extend ActiveSupport::Concern
|
3
|
-
|
4
|
-
def text_used_content(type)
|
5
|
-
Ksk::Markdown.parse_text(markdown_text, type).each_with_object([]) do |match, used_numbers|
|
6
|
-
used_numbers << match[1].to_i
|
7
|
-
end
|
8
|
-
end
|
9
|
-
|
10
|
-
def text_unused_content(all_files, type, preselected = [])
|
11
|
-
all_numbers = []
|
12
|
-
all_files.each_with_index { |a, i| all_numbers << i+1 }
|
13
|
-
|
14
|
-
unused_numbers = all_numbers - (text_used_content(type)+preselected)
|
15
|
-
|
16
|
-
unused_files = []
|
17
|
-
all_files.each_with_index do |a, i|
|
18
|
-
unused_files << a if unused_numbers.include?(i+1)
|
19
|
-
end
|
20
|
-
|
21
|
-
unused_files
|
22
|
-
end
|
23
|
-
|
24
|
-
def text_used_images
|
25
|
-
text_used_content('img')
|
26
|
-
end
|
27
|
-
|
28
|
-
def text_unused_images
|
29
|
-
text_unused_content(assets.only_images, 'img', respond_to?(:markdown_preselect) && markdown_preselect || [])
|
30
|
-
end
|
31
|
-
|
32
|
-
def text_used_data_files
|
33
|
-
text_used_content('file')
|
34
|
-
end
|
35
|
-
|
36
|
-
def text_unused_data_files
|
37
|
-
text_unused_content(assets.only_data_files, 'file')
|
38
|
-
end
|
39
|
-
|
40
|
-
|
41
|
-
def markdown_text
|
42
|
-
content
|
43
|
-
end
|
44
|
-
|
45
|
-
def content_long
|
46
|
-
"#{intro} #{hidden_text}"
|
47
|
-
end
|
48
|
-
|
49
|
-
def content_short
|
50
|
-
intro
|
51
|
-
end
|
52
|
-
|
53
|
-
def intro
|
54
|
-
split_content[0]
|
55
|
-
end
|
56
|
-
|
57
|
-
def hidden_text
|
58
|
-
split_content[1]
|
59
|
-
end
|
60
|
-
|
61
|
-
def split_content
|
62
|
-
return [] if read_attribute(:content).blank?
|
63
|
-
read_attribute(:content).split('@@@')
|
64
|
-
end
|
65
|
-
|
66
|
-
def content_has_more?
|
67
|
-
!hidden_text.blank?
|
68
|
-
end
|
69
|
-
|
70
|
-
|
71
|
-
def self.parse_regex(type)
|
72
|
-
/(\{#{type}_(\d{1,2})_?(\w+)?\})/i
|
73
|
-
end
|
74
|
-
|
75
|
-
def self.parse_text(text, type)
|
76
|
-
text.to_s.scan(parse_regex(type))
|
77
|
-
end
|
78
|
-
end
|