ksk 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -21,11 +21,13 @@ module Ksk
21
21
  end
22
22
 
23
23
  def md(text)
24
+ return '' if text.blank?
24
25
  markdown = Redcarpet::Markdown.new(Redcarpet::Render::HTML.new(), fenced_code_blocks: true, autolink: true)
25
26
  markdown.render(text).html_safe
26
27
  end
27
28
 
28
29
  def mdap(text, images, data_files)
30
+ return '' if text.blank?
29
31
  t = place_images(text, images)
30
32
  t = place_data_files(t, data_files)
31
33
  md(t)
data/lib/actives/asset.rb CHANGED
@@ -7,7 +7,7 @@ module Ksk
7
7
 
8
8
  belongs_to :fileable, polymorphic: true
9
9
 
10
- default_scope order: 'position ASC, created_at DESC'
10
+ default_scope -> {order 'position ASC, created_at DESC'}
11
11
 
12
12
  has_one :preview
13
13
  before_create :set_last_position
@@ -16,12 +16,12 @@ module Ksk
16
16
  #validates_attachment :file, :content_type => { :content_type => IMGTYPE }
17
17
  IMGTYPE = ['image/jpeg', 'image/pjpeg', 'image/jpg', 'image/png', 'image/tif', 'image/gif']
18
18
 
19
- scope :only_images, where(file_content_type: IMGTYPE)
20
- scope :first_image, only_images.limit(1)
21
- scope :other_images, only_images.offset(1)
19
+ scope :only_images, -> {where(file_content_type: IMGTYPE)}
20
+ scope :first_image, -> {only_images.limit(1)}
21
+ scope :other_images, -> {only_images.offset(1)}
22
22
 
23
- scope :only_data_files, where(['file_content_type not in (?)', IMGTYPE])
24
- scope :first_data_files, only_data_files.limit(1)
23
+ scope :only_data_files, -> {where(['file_content_type not in (?)', IMGTYPE])}
24
+ scope :first_data_files, -> {only_data_files.limit(1)}
25
25
 
26
26
  before_file_post_process :allow_only_images
27
27
  end
@@ -10,16 +10,16 @@ module Ksk
10
10
 
11
11
  before_validation :static_setter
12
12
 
13
- default_scope :order => 'position ASC, created_at DESC'
13
+ default_scope -> {order 'position ASC, created_at DESC'}
14
14
 
15
15
  belongs_to :static
16
16
  belongs_to :navigation_type
17
17
  belongs_to :parent, :foreign_key => 'parent_id', :class_name => 'Navigation'
18
18
  has_many :children, :foreign_key => 'parent_id', :class_name => 'Navigation', :dependent => :delete_all
19
19
 
20
- scope :top_level, where(parent_id: 0)
20
+ scope :top_level, -> {where(parent_id: 0)}
21
21
 
22
- scope :not_hidden, where(hidden: false)
22
+ scope :not_hidden, -> {where(hidden: false)}
23
23
 
24
24
  before_save :set_slug, :set_link
25
25
  end
data/lib/actives/post.rb CHANGED
@@ -8,18 +8,14 @@ module Ksk
8
8
  include Apdown
9
9
 
10
10
  belongs_to :category
11
- belongs_to :event
12
11
  has_many :assets, as: :fileable
13
12
  accepts_nested_attributes_for :assets, allow_destroy: true
14
13
 
15
- default_scope order: 'created_at DESC'
16
- default_scope where(published: true)
14
+ default_scope -> {order 'created_at DESC'}
15
+ default_scope -> {where(published: true)}
17
16
 
18
- scope :all_posts, except(:where)
19
- scope :top, where(top_news: true)
20
-
21
- validates_length_of :headline, minimum: 3
22
- validates_length_of :content, minimum: 10, maximum: 5000
17
+ scope :all_posts, -> {except(:where)}
18
+ scope :top, -> {where(top_news: true)}
23
19
 
24
20
  end
25
21
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ksk
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.2
4
+ version: 0.1.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-07-03 00:00:00.000000000 Z
12
+ date: 2013-07-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bhf