notee 0.2.8 → 0.2.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/notee/application.js +4673 -4669
- data/app/controllers/notee/application_controller.rb +2 -3
- data/app/controllers/notee/posts_controller.rb +4 -2
- data/app/models/notee/category.rb +5 -0
- data/app/models/notee/image.rb +5 -0
- data/app/models/notee/post.rb +6 -0
- data/app/models/notee/token.rb +2 -0
- data/db/migrate/20160605141510_create_notee_categories.rb +6 -1
- data/db/migrate/20160605141547_create_notee_images.rb +6 -0
- data/lib/notee/engine.rb +1 -1
- data/lib/notee/version.rb +1 -1
- data/lib/tasks/images/default.png +0 -0
- data/lib/tasks/notee_tasks.rake +20 -0
- metadata +3 -2
@@ -1,12 +1,11 @@
|
|
1
1
|
module Notee
|
2
2
|
class ApplicationController < ActionController::Base
|
3
3
|
|
4
|
-
|
5
|
-
|
4
|
+
before_action :set_access_token
|
5
|
+
before_action :restrict_access_json
|
6
6
|
|
7
7
|
private
|
8
8
|
def set_access_token
|
9
|
-
p "TODO: add access_token to http header"
|
10
9
|
# request['Authorization: Token token'] = session[:access_token] if session[:access_token].present?
|
11
10
|
end
|
12
11
|
|
@@ -3,9 +3,11 @@ require_dependency "notee/application_controller"
|
|
3
3
|
module Notee
|
4
4
|
class PostsController < ApplicationController
|
5
5
|
|
6
|
+
# callbacks
|
6
7
|
before_action :set_post, only: [:show, :update, :destroy]
|
7
|
-
|
8
|
-
|
8
|
+
skip_before_action :restrict_access_json, only: [:notee]
|
9
|
+
before_action :restrict_access, only: [:notee]
|
10
|
+
|
9
11
|
|
10
12
|
def notee
|
11
13
|
end
|
@@ -1,7 +1,12 @@
|
|
1
1
|
module Notee
|
2
2
|
class Category < ActiveRecord::Base
|
3
|
+
|
4
|
+
# callbacks
|
3
5
|
before_save :set_slug
|
4
6
|
|
7
|
+
# relations
|
8
|
+
has_many :children, class_name: Notee::Category, :foreign_key => 'parent_id', dependent: :destroy
|
9
|
+
|
5
10
|
def set_slug
|
6
11
|
self.slug = self.name.downcase if self.slug.nil?
|
7
12
|
end
|
data/app/models/notee/image.rb
CHANGED
data/app/models/notee/post.rb
CHANGED
@@ -1,8 +1,14 @@
|
|
1
1
|
module Notee
|
2
2
|
class Post < ActiveRecord::Base
|
3
|
+
|
4
|
+
# callbacks
|
3
5
|
before_create :set_title
|
4
6
|
before_create :set_slug
|
5
7
|
|
8
|
+
# relations
|
9
|
+
belongs_to :category
|
10
|
+
belongs_to :thumbnail, :class_name => Notee::Image, :foreign_key => 'thumbnail_id'
|
11
|
+
|
6
12
|
def set_title
|
7
13
|
self.title = "no_title#{Notee::Post.count}" unless self.title.present?
|
8
14
|
end
|
data/app/models/notee/token.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
1
|
class CreateNoteeCategories < ActiveRecord::Migration
|
2
|
+
class NoteeCategory < ActiveRecord::Base; end
|
3
|
+
|
2
4
|
def change
|
3
5
|
create_table :notee_categories do |t|
|
4
6
|
|
5
7
|
t.string :name, null: false, default: "category_name"
|
6
|
-
t.string :slug, null: false,
|
8
|
+
t.string :slug, null: false, uniqueness: true
|
7
9
|
t.integer :parent_id
|
8
10
|
t.integer :status, null: false, default: 0
|
9
11
|
|
@@ -11,5 +13,8 @@ class CreateNoteeCategories < ActiveRecord::Migration
|
|
11
13
|
end
|
12
14
|
|
13
15
|
add_index :notee_categories, [:slug], :unique => true
|
16
|
+
|
17
|
+
# create default category
|
18
|
+
Notee::Category.create :name => 'None'
|
14
19
|
end
|
15
20
|
end
|
@@ -1,4 +1,6 @@
|
|
1
1
|
class CreateNoteeImages < ActiveRecord::Migration
|
2
|
+
class NoteeImage < ActiveRecord::Base; end
|
3
|
+
|
2
4
|
def change
|
3
5
|
create_table :notee_images do |t|
|
4
6
|
|
@@ -9,6 +11,10 @@ class CreateNoteeImages < ActiveRecord::Migration
|
|
9
11
|
|
10
12
|
t.timestamps null: false
|
11
13
|
end
|
14
|
+
|
15
|
+
# create default image
|
16
|
+
default_image = Notee::Image.create :content => 'aa'
|
17
|
+
default_image.update_column("content", "default.png")
|
12
18
|
end
|
13
19
|
|
14
20
|
end
|
data/lib/notee/engine.rb
CHANGED
data/lib/notee/version.rb
CHANGED
Binary file
|
data/lib/tasks/notee_tasks.rake
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
desc 'setup notee'
|
2
2
|
namespace :notee do
|
3
|
+
|
3
4
|
task :start do
|
4
5
|
notee_mark
|
5
6
|
sh 'bundle exec rake notee:install:migrations'
|
6
7
|
add_engine_to_route
|
7
8
|
create_initializer_file
|
9
|
+
setup_default
|
8
10
|
end
|
9
11
|
|
10
12
|
def notee_mark
|
@@ -68,4 +70,22 @@ EOC
|
|
68
70
|
puts 'you should change notee_id & notee_password'
|
69
71
|
end
|
70
72
|
|
73
|
+
def setup_default
|
74
|
+
copy_default_image
|
75
|
+
end
|
76
|
+
|
77
|
+
private
|
78
|
+
|
79
|
+
def copy_default_image
|
80
|
+
image_dir = Rails.root.to_s + '/public/notee'
|
81
|
+
FileUtils.mkdir_p(image_dir) unless FileTest.exist?(image_dir)
|
82
|
+
|
83
|
+
image_url = image_dir + '/default.png'
|
84
|
+
unless FileTest.exist?(image_url)
|
85
|
+
open(image_url, 'wb') do |output|
|
86
|
+
output.write(File.open(File.expand_path('../images/default.png', __FILE__)).read)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
71
91
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: notee
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- takujifunao
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-07-
|
11
|
+
date: 2016-07-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -165,6 +165,7 @@ files:
|
|
165
165
|
- lib/notee/helper.rb
|
166
166
|
- lib/notee/version.rb
|
167
167
|
- lib/notee/view_helper.rb
|
168
|
+
- lib/tasks/images/default.png
|
168
169
|
- lib/tasks/notee_tasks.rake
|
169
170
|
- test/controllers/notee/categories_controller_test.rb
|
170
171
|
- test/controllers/notee/images_controller_test.rb
|