notee 0.3.3 → 0.3.4

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.
@@ -3,13 +3,18 @@ require_dependency "notee/application_controller"
3
3
 
4
4
  module Notee
5
5
  class CategoriesController < ApplicationController
6
- before_action :set_category, only: [:update, :destroy]
6
+ before_action :set_category, only: [:show, :update, :destroy]
7
7
 
8
8
  def index
9
9
  @categories = Category.all
10
10
  render json: { status: 'success', categories: @categories}
11
11
  end
12
12
 
13
+ def show
14
+ p @category
15
+ render json: { status: 'success', category: @category}
16
+ end
17
+
13
18
  def create
14
19
  @category = Category.new(category_params)
15
20
  respond_to do |format|
@@ -44,7 +49,7 @@ module Notee
44
49
  private
45
50
 
46
51
  def category_params
47
- params.require(:category).permit(:name, :slug, :parent_id, :status)
52
+ params.require(:category).permit(:name, :slug, :parent_id, :is_private)
48
53
  end
49
54
 
50
55
  def set_category
@@ -4,6 +4,7 @@ module Notee
4
4
  class NoteesController < ApplicationController
5
5
 
6
6
  # callbacks
7
+ skip_before_action :restrict_access_json, only: [:index]
7
8
  before_action :restrict_access, only: [:index]
8
9
 
9
10
  def index
@@ -0,0 +1,19 @@
1
+
2
+ require_dependency "notee/application_controller"
3
+
4
+ module Notee
5
+ class StatusesController < ApplicationController
6
+
7
+ def index
8
+ @statuses = Notee::STATUS
9
+ render json: { status: 'success', statuses: @statuses}
10
+ end
11
+
12
+ def show
13
+ statuses = Notee::STATUS
14
+ @status = statuses.key(params[:status].to_i)
15
+ render json: { status: 'success', name: @status}
16
+ end
17
+
18
+ end
19
+ end
data/config/routes.rb CHANGED
@@ -13,5 +13,6 @@ Notee::Engine.routes.draw do
13
13
  resources :posts, only: [:index, :show, :create, :update, :destroy]
14
14
  resources :images, only: [:index, :show, :create, :destroy]
15
15
  resources :categories, only: [:index, :show, :create, :update, :destroy]
16
+ resources :statuses, only: [:index, :show]
16
17
  end
17
18
  end
@@ -7,7 +7,7 @@ class CreateNoteeCategories < ActiveRecord::Migration
7
7
  t.string :name, null: false, default: "category_name"
8
8
  t.string :slug, null: false, uniqueness: true
9
9
  t.integer :parent_id
10
- t.integer :status, null: false, default: 0
10
+ t.boolean :is_private, null: false, default: false
11
11
 
12
12
  t.timestamps null: false
13
13
  end
data/lib/notee.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'notee/engine'
2
2
  require 'notee/version'
3
+ require 'notee/status'
3
4
  require_relative 'notee/configuration'
4
5
 
5
6
  module Notee
data/lib/notee/helper.rb CHANGED
@@ -3,14 +3,14 @@ module Notee
3
3
  def notees(search_txt)
4
4
  if search_txt.nil?
5
5
  # all_notees
6
- @notees = Notee::Post.where(status: 1).order(published_at: :desc)
6
+ @notees = Notee::Post.where(status: Notee::STATUS[:published]).order(published_at: :desc)
7
7
  else
8
8
  # search_by_category_slug
9
9
  category_id = Notee::Category.find_by(slug: search_txt)
10
10
  category_id = Notee::Category.find_by(name: search_txt) unless category_id
11
11
  return false unless category_id
12
12
 
13
- @notees = Notee::Post.where(category_id: category_id, status: 1).order(published_at: :desc)
13
+ @notees = Notee::Post.where(category_id: category_id, status: Notee::STATUS[:published]).order(published_at: :desc)
14
14
  end
15
15
 
16
16
  @notees
@@ -18,14 +18,14 @@ module Notee
18
18
  end
19
19
 
20
20
  def secret_notees
21
- @notees = Notee::Post.where(status: 2).order(published_at: :desc)
21
+ @notees = Notee::Post.where(status: Notee::STATUS[:secret_published]).order(published_at: :desc)
22
22
  end
23
23
 
24
24
 
25
25
  def notee(search_txt)
26
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
27
+ @notee = Notee::Post.find_by(id: search_txt, status: Notee::STATUS[:published])
28
+ @notee = Notee::Post.find_by(slug: search_txt, status: Notee::STATUS[:published]) unless @notee
29
29
 
30
30
  @notee
31
31
  end
@@ -0,0 +1,11 @@
1
+ # coding: utf-8
2
+
3
+ module Notee
4
+ STATUS = {
5
+ :draft => 0,
6
+ :published => 1,
7
+ :secret_published => 2,
8
+ :privated => 3,
9
+ :deleted => 4
10
+ }
11
+ end
data/lib/notee/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Notee
2
- VERSION = "0.3.3"
2
+ VERSION = "0.3.4"
3
3
  end
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.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - takujifunao
@@ -145,6 +145,7 @@ files:
145
145
  - app/controllers/notee/images_controller.rb
146
146
  - app/controllers/notee/notees_controller.rb
147
147
  - app/controllers/notee/posts_controller.rb
148
+ - app/controllers/notee/statuses_controller.rb
148
149
  - app/controllers/notee/tokens_controller.rb
149
150
  - app/helpers/notee/application_helper.rb
150
151
  - app/helpers/notee/categories_helper.rb
@@ -166,6 +167,7 @@ files:
166
167
  - lib/notee/configuration.rb
167
168
  - lib/notee/engine.rb
168
169
  - lib/notee/helper.rb
170
+ - lib/notee/status.rb
169
171
  - lib/notee/version.rb
170
172
  - lib/notee/view_helper.rb
171
173
  - lib/tasks/images/default.png