notee 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -8,7 +8,7 @@ module Notee
8
8
  has_many :children, class_name: Notee::Category, :foreign_key => 'parent_id', dependent: :destroy
9
9
 
10
10
  def set_slug
11
- self.slug = self.name.downcase if self.slug.nil?
11
+ self.slug = self.name.downcase unless self.slug.present?
12
12
  end
13
13
 
14
14
  end
@@ -1,31 +1,33 @@
1
1
  module Notee
2
2
  module Helper
3
- def get_all_notees
4
- @notees = Notee::Post.where(status: 1)
5
- end
6
-
7
- def get_secret_notees
8
- @notees = Notee::Post.where(status: 2)
9
- end
3
+ def notees(search_txt)
4
+ if search_txt.nil?
5
+ # all_notees
6
+ @notees = Notee::Post.where(status: 1)
7
+ else
8
+ # search_by_category_slug
9
+ category_id = Notee::Category.find_by(slug: search_txt)
10
+ category_id = Notee::Category.find_by(name: search_txt) unless category_id
11
+ return false unless category_id
10
12
 
11
- def get_notees_by_category_slug(category_slug)
13
+ @notees = Notee::Post.where(category_id: category_id, status: 1)
14
+ end
12
15
 
13
- return false unless category_slug
14
- category_id = Notee::Category.find_by(name: category_slug)
15
- return false unless category_id
16
+ @notees
16
17
 
17
- @notees = Notee::Post.where(category_id: category_id, status: 1)
18
18
  end
19
19
 
20
- def get_notee_by_id(id)
21
- return false unless id
22
- @notee = Notee::Post.find_by(id: id, status: 1)
20
+ def secret_notees
21
+ @notees = Notee::Post.where(status: 2)
23
22
  end
24
23
 
25
- def get_notee_by_slug(slug)
26
- return false unless slug
27
- @notee = Notee::Post.find_by(slug: slug, status: 1)
28
- end
29
24
 
25
+ def notee(search_txt)
26
+ return false unless search_txt
27
+ @notee = Notee::Post.find_by(id: search_txt, status: 1)
28
+ @notee = Notee::Post.find_by(slug: search_txt, status: 1) unless @notee
29
+
30
+ @notee
31
+ end
30
32
  end
31
33
  end
@@ -1,3 +1,3 @@
1
1
  module Notee
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
@@ -2,7 +2,7 @@ require 'redcarpet'
2
2
 
3
3
  module Notee
4
4
  module ViewHelper
5
- def notee_markdown(text)
5
+ def notee_content(text)
6
6
 
7
7
  unless @markdown
8
8
  renderer = Redcarpet::Render::HTML.new(filter_html: true, hard_wrap: true)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: notee
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - takujifunao