notee 0.3.6 → 0.3.7
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 +1308 -212
- data/app/controllers/notee/application_controller.rb +0 -9
- data/app/controllers/notee/tokens_controller.rb +7 -0
- data/app/controllers/notee/users_controller.rb +60 -0
- data/app/models/notee/user.rb +27 -0
- data/app/views/notee/partials/_comment_box.html.erb +10 -2
- data/config/routes.rb +4 -0
- data/db/migrate/20160605141437_create_notee_posts.rb +1 -3
- data/db/migrate/20160605141510_create_notee_categories.rb +1 -1
- data/db/migrate/20160608102012_create_notee_tokens.rb +2 -1
- data/db/migrate/20160803154954_create_notee_comments.rb +1 -1
- data/db/migrate/20160809145754_create_notee_users.rb +17 -0
- data/lib/notee/configuration.rb +7 -1
- data/lib/notee/helpers/notee_helper.rb +6 -0
- data/lib/notee/helpers/view_helper.rb +2 -4
- data/lib/notee/version.rb +1 -1
- data/lib/tasks/notee_tasks.rake +2 -0
- data/test/dummy/log/development.log +2 -0
- data/test/fixtures/notee/users.yml +19 -0
- data/test/models/notee/user_test.rb +9 -0
- metadata +9 -2
@@ -1,19 +1,10 @@
|
|
1
1
|
module Notee
|
2
2
|
class ApplicationController < ActionController::Base
|
3
|
-
|
4
|
-
before_action :set_access_token
|
5
3
|
before_action :restrict_access_json
|
6
4
|
|
7
5
|
private
|
8
|
-
def set_access_token
|
9
|
-
# request['Authorization: Token token'] = session[:access_token] if session[:access_token].present?
|
10
|
-
end
|
11
6
|
|
12
7
|
def restrict_access_json
|
13
|
-
# authenticate_or_request_with_http_token do |token, options|
|
14
|
-
# Token.exists?(access_token: token)
|
15
|
-
# end
|
16
|
-
|
17
8
|
unless Token.exists?(access_token: session[:access_token])
|
18
9
|
raise
|
19
10
|
end
|
@@ -14,6 +14,13 @@ module Notee
|
|
14
14
|
if Notee.notee_id == params[:id] && Notee.notee_password == params[:password]
|
15
15
|
if token = Token.create!
|
16
16
|
session[:access_token] = token.access_token
|
17
|
+
return redirect_to root_path
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
if now_user = User.sign_in(params[:id], params[:password])
|
22
|
+
if token = Token.create!(user_id: now_user.id)
|
23
|
+
session[:access_token] = token.access_token
|
17
24
|
end
|
18
25
|
end
|
19
26
|
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require_dependency "notee/application_controller"
|
2
|
+
|
3
|
+
module Notee
|
4
|
+
class UsersController < ApplicationController
|
5
|
+
|
6
|
+
# callbacks
|
7
|
+
before_action :set_user, only: [:show, :update, :destroy]
|
8
|
+
|
9
|
+
# GET /users
|
10
|
+
def index
|
11
|
+
@users = User.all.order(updated_at: :desc)
|
12
|
+
render json: { status: 'success', users: @users}
|
13
|
+
end
|
14
|
+
|
15
|
+
# GET /posts/1
|
16
|
+
def show
|
17
|
+
render json: { status: 'success', user: @user}
|
18
|
+
end
|
19
|
+
|
20
|
+
# POST /posts
|
21
|
+
def create
|
22
|
+
@user = User.new(user_params)
|
23
|
+
respond_to do |format|
|
24
|
+
if @user.save
|
25
|
+
format.json { render json: @user, status: 200 }
|
26
|
+
else
|
27
|
+
format.json { render json: @user.errors, status: :unprocessable_entity }
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# PATCH/PUT /posts/1
|
33
|
+
def update
|
34
|
+
respond_to do |format|
|
35
|
+
if @user.update(user_params)
|
36
|
+
format.json { render json: @user, status: 200 }
|
37
|
+
else
|
38
|
+
format.json { render json: @user.errors, status: :unprocessable_entity }
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
# DELETE /posts/1
|
44
|
+
def destroy
|
45
|
+
@user.destroy
|
46
|
+
render json: { status: 'success'}
|
47
|
+
end
|
48
|
+
|
49
|
+
private
|
50
|
+
|
51
|
+
def set_user
|
52
|
+
@user = User.find_by(id: params[:id])
|
53
|
+
end
|
54
|
+
|
55
|
+
# Only allow a trusted parameter "white list" through.
|
56
|
+
def post_params
|
57
|
+
params.require(:user).permit(:title, :content, :slug, :status, :category_id, :thumbnail_id, :published_at, :seo_keyword, :seo_description, :secret_published_password)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Notee
|
2
|
+
class User < ApplicationRecord
|
3
|
+
|
4
|
+
# accessors
|
5
|
+
attr_accessor :password
|
6
|
+
|
7
|
+
# callback
|
8
|
+
before_save :encrypt_password
|
9
|
+
|
10
|
+
def sign_in(name_or_email password)
|
11
|
+
user = self.find_by(name: name_or_email)
|
12
|
+
user = self.find_by(email: name_or_email) unless user
|
13
|
+
return false unless user
|
14
|
+
return false unless user.encrypted_password == encrypt(password)
|
15
|
+
|
16
|
+
return user
|
17
|
+
end
|
18
|
+
|
19
|
+
def encrypt(password)
|
20
|
+
return OpenSSL::Digest::MD5.hexdigest(password)
|
21
|
+
end
|
22
|
+
|
23
|
+
def encrypt_password
|
24
|
+
self.encrypted_password = encrypt(self.password)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -3,7 +3,6 @@
|
|
3
3
|
<comment_form post_id='<%= post_id %>'></comment_form>
|
4
4
|
</div>
|
5
5
|
|
6
|
-
|
7
6
|
<!-- <comment> tag -->
|
8
7
|
|
9
8
|
<script type="riot/tag">
|
@@ -15,6 +14,8 @@
|
|
15
14
|
/////////////////////////////////////////
|
16
15
|
|
17
16
|
<comment_form class="notee_comment_form" id="notee_form">
|
17
|
+
<form method="POST">
|
18
|
+
|
18
19
|
|
19
20
|
<label class="notee_label" for="comment_name">Name</label>
|
20
21
|
<input class="notee_text_field" type="text" name="comment[name]" id="comment_name" />
|
@@ -24,6 +25,8 @@
|
|
24
25
|
|
25
26
|
<label class="notee_label" for="comment_content">Content</label>
|
26
27
|
<textarea class="notee_text_area" name="comment[content]" id="comment_content"></textarea>
|
28
|
+
|
29
|
+
<div class="g-recaptcha" data-sitekey="<%= recaptcha %>"></div>
|
27
30
|
|
28
31
|
<input
|
29
32
|
type="submit"
|
@@ -32,6 +35,8 @@
|
|
32
35
|
data-disable-with="Create Comment"
|
33
36
|
onClick={notee_submit} />
|
34
37
|
|
38
|
+
</form>
|
39
|
+
|
35
40
|
this.notee_submit = function(e){
|
36
41
|
e.preventDefault();
|
37
42
|
var comment = {
|
@@ -41,7 +46,7 @@
|
|
41
46
|
content: document.getElementById("comment_content").value
|
42
47
|
};
|
43
48
|
|
44
|
-
if(comment.content != null){
|
49
|
+
if(comment.content != null || comment.content != ""){
|
45
50
|
var request = window.superagent;
|
46
51
|
var url = "/notee/api/comments";
|
47
52
|
var self = this;
|
@@ -119,10 +124,13 @@
|
|
119
124
|
</script>
|
120
125
|
|
121
126
|
|
127
|
+
|
128
|
+
|
122
129
|
<!-- Riot.js Settings -->
|
123
130
|
|
124
131
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/riot/2.3.18/riot+compiler.js"></script>
|
125
132
|
<script src="https://cdnjs.cloudflare.com/ajax/libs/superagent/2.1.0/superagent.min.js"></script>
|
133
|
+
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
|
126
134
|
<script>
|
127
135
|
window.onload = function() {
|
128
136
|
riot.mount('*');
|
data/config/routes.rb
CHANGED
@@ -6,12 +6,16 @@ Notee::Engine.routes.draw do
|
|
6
6
|
get 'edit/:id' => 'notees#index'
|
7
7
|
get 'category' => 'notees#index'
|
8
8
|
get 'image' => 'notees#index'
|
9
|
+
get 'user' => 'notees#index'
|
10
|
+
get 'user/new' => 'notees#index'
|
11
|
+
get 'user/edit/:id' => 'notees#index'
|
9
12
|
|
10
13
|
post 'secret_published' => 'notees#secret_published'
|
11
14
|
resources :tokens, only: [:new, :create, :destroy]
|
12
15
|
|
13
16
|
scope :api, { format: 'json' } do
|
14
17
|
resources :posts, only: [:index, :show, :create, :update, :destroy]
|
18
|
+
resources :users, only: [:index, :show, :create, :update, :destroy]
|
15
19
|
resources :images, only: [:index, :show, :create, :destroy]
|
16
20
|
resources :categories, only: [:index, :show, :create, :update, :destroy]
|
17
21
|
resources :statuses, only: [:index, :show]
|
@@ -4,7 +4,6 @@ class CreateNoteePosts < ActiveRecord::Migration
|
|
4
4
|
create_table :notee_posts do |t|
|
5
5
|
|
6
6
|
# notee's base
|
7
|
-
|
8
7
|
t.string :title
|
9
8
|
t.text :content
|
10
9
|
t.string :slug
|
@@ -12,6 +11,7 @@ class CreateNoteePosts < ActiveRecord::Migration
|
|
12
11
|
t.integer :category_id, default: 0
|
13
12
|
t.integer :thumbnail_id, default: 0
|
14
13
|
t.datetime :published_at
|
14
|
+
t.integer :user_id
|
15
15
|
|
16
16
|
# seo
|
17
17
|
t.string :seo_keyword, default: ""
|
@@ -20,8 +20,6 @@ class CreateNoteePosts < ActiveRecord::Migration
|
|
20
20
|
# secret_published
|
21
21
|
t.string :secret_published_password
|
22
22
|
|
23
|
-
# if you have user_id
|
24
|
-
# t.integer :user_id
|
25
23
|
|
26
24
|
t.timestamps null: false
|
27
25
|
|
@@ -12,7 +12,7 @@ class CreateNoteeCategories < ActiveRecord::Migration
|
|
12
12
|
t.timestamps null: false
|
13
13
|
end
|
14
14
|
|
15
|
-
add_index :notee_categories,
|
15
|
+
add_index :notee_categories, :slug, :unique => true
|
16
16
|
|
17
17
|
# create default category
|
18
18
|
Notee::Category.create :name => 'No_Category'
|
@@ -2,11 +2,12 @@ class CreateNoteeTokens < ActiveRecord::Migration
|
|
2
2
|
def change
|
3
3
|
create_table :notee_tokens do |t|
|
4
4
|
t.string :access_token, null: false
|
5
|
+
t.integer :user_id
|
5
6
|
t.datetime :expires_at, null: false
|
6
7
|
|
7
8
|
t.timestamps null: false
|
8
9
|
end
|
9
10
|
|
10
|
-
add_index :notee_tokens,
|
11
|
+
add_index :notee_tokens, :access_token, :unique => true
|
11
12
|
end
|
12
13
|
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class CreateNoteeUsers < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :notee_users do |t|
|
4
|
+
t.string :name, null: false
|
5
|
+
t.string :email, null: false
|
6
|
+
t.string :encrypted_password, null: false
|
7
|
+
t.text :profile
|
8
|
+
t.string :profile_img
|
9
|
+
t.text :sns
|
10
|
+
t.integer :role, null: false
|
11
|
+
|
12
|
+
t.timestamps null: false
|
13
|
+
end
|
14
|
+
|
15
|
+
add_index :notee_users, [:name, :email], :unique => true
|
16
|
+
end
|
17
|
+
end
|
data/lib/notee/configuration.rb
CHANGED
@@ -3,11 +3,15 @@ module Notee
|
|
3
3
|
|
4
4
|
VALID_OPTIONS_KEY = [
|
5
5
|
:notee_id,
|
6
|
-
:notee_password
|
6
|
+
:notee_password,
|
7
|
+
:recaptcha_key,
|
8
|
+
:recaptcha_secret_key
|
7
9
|
].freeze
|
8
10
|
|
9
11
|
DEFAULT_NOTEE_ID = nil
|
10
12
|
DEFAULT_NOTEE_PASSWORD = nil
|
13
|
+
DEFAULT_RECAPTCHA_KEY = nil
|
14
|
+
DEFAULT_RECAPTCHA_SECRET_KEY = nil
|
11
15
|
|
12
16
|
attr_accessor *VALID_OPTIONS_KEY
|
13
17
|
|
@@ -22,6 +26,8 @@ module Notee
|
|
22
26
|
def reset
|
23
27
|
self.notee_id = DEFAULT_NOTEE_ID
|
24
28
|
self.notee_password = DEFAULT_NOTEE_PASSWORD
|
29
|
+
self.recaptcha_key = DEFAULT_RECAPTCHA_KEY
|
30
|
+
self.recaptcha_secret_key = DEFAULT_RECAPTCHA_SECRET_KEY
|
25
31
|
end
|
26
32
|
|
27
33
|
end
|
@@ -67,6 +67,12 @@ module Notee
|
|
67
67
|
return Notee::Post.where(status: Notee::STATUS[:published]).group('year(published_at)').group('month(published_at)').count
|
68
68
|
end
|
69
69
|
end
|
70
|
+
|
71
|
+
def notee_comments(id)
|
72
|
+
return if id.nil?
|
73
|
+
@notee_comments = Notee::Post.where(post_id: id)
|
74
|
+
@notee_comments
|
75
|
+
end
|
70
76
|
end
|
71
77
|
end
|
72
78
|
end
|
@@ -3,7 +3,7 @@ require 'redcarpet'
|
|
3
3
|
module Notee
|
4
4
|
module Helpers
|
5
5
|
module ViewHelper
|
6
|
-
def notee_content
|
6
|
+
def notee_content(notee)
|
7
7
|
|
8
8
|
return if notee.nil?
|
9
9
|
|
@@ -21,9 +21,7 @@ module Notee
|
|
21
21
|
end
|
22
22
|
|
23
23
|
def notee_comment_box(id)
|
24
|
-
|
25
|
-
@comment = Notee::Comment.new
|
26
|
-
return render :partial => "notee/partials/comment_box.html.erb", :locals => { :post_id => id}
|
24
|
+
return render :partial => "notee/partials/comment_box.html.erb", :locals => { :post_id => id, :recaptcha => Notee.recaptcha_key}
|
27
25
|
end
|
28
26
|
end
|
29
27
|
end
|
data/lib/notee/version.rb
CHANGED
data/lib/tasks/notee_tasks.rake
CHANGED
@@ -3020,3 +3020,5 @@ rack (2.0.1) lib/rack/handler/webrick.rb:86:in `service'
|
|
3020
3020
|
Rendered /Users/takujifunao/Hack/01_mine/02_lib/notee/vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.0/lib/action_dispatch/middleware/templates/rescues/routing_error.html.erb within rescues/layout (213.0ms)
|
3021
3021
|
Rendered /Users/takujifunao/Hack/01_mine/02_lib/notee/vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.0/lib/action_dispatch/middleware/templates/rescues/_request_and_response.html.erb (1.2ms)
|
3022
3022
|
Rendered /Users/takujifunao/Hack/01_mine/02_lib/notee/vendor/bundle/ruby/2.3.0/gems/actionpack-5.0.0/lib/action_dispatch/middleware/templates/rescues/routing_error.html.erb within rescues/layout (198.4ms)
|
3023
|
+
DEPRECATION WARNING: ActiveRecord::Base.raise_in_transactional_callbacks= is deprecated, has no effect and will be removed without replacement. (called from load at /Users/takujifunao/Hack/01_mine/02_lib/notee/vendor/bundle/ruby/2.3.0/bin/rake:23)
|
3024
|
+
DEPRECATION WARNING: ActiveRecord::Base.raise_in_transactional_callbacks= is deprecated, has no effect and will be removed without replacement. (called from load at /Users/takujifunao/Hack/01_mine/02_lib/notee/vendor/bundle/ruby/2.3.0/bin/rake:23)
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
2
|
+
|
3
|
+
one:
|
4
|
+
name: MyString
|
5
|
+
email: MyString
|
6
|
+
encrypt_password: MyString
|
7
|
+
profile: MyText
|
8
|
+
profile_img: MyString
|
9
|
+
sns: MyText
|
10
|
+
role: 1
|
11
|
+
|
12
|
+
two:
|
13
|
+
name: MyString
|
14
|
+
email: MyString
|
15
|
+
encrypt_password: MyString
|
16
|
+
profile: MyText
|
17
|
+
profile_img: MyString
|
18
|
+
sns: MyText
|
19
|
+
role: 1
|
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.3.
|
4
|
+
version: 0.3.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- takujifunao
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-08-
|
11
|
+
date: 2016-08-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -148,6 +148,7 @@ files:
|
|
148
148
|
- app/controllers/notee/posts_controller.rb
|
149
149
|
- app/controllers/notee/statuses_controller.rb
|
150
150
|
- app/controllers/notee/tokens_controller.rb
|
151
|
+
- app/controllers/notee/users_controller.rb
|
151
152
|
- app/helpers/notee/application_helper.rb
|
152
153
|
- app/helpers/notee/categories_helper.rb
|
153
154
|
- app/helpers/notee/comments_helper.rb
|
@@ -158,6 +159,7 @@ files:
|
|
158
159
|
- app/models/notee/image.rb
|
159
160
|
- app/models/notee/post.rb
|
160
161
|
- app/models/notee/token.rb
|
162
|
+
- app/models/notee/user.rb
|
161
163
|
- app/views/layouts/notee/application.html.erb
|
162
164
|
- app/views/notee/notees/index.html.erb
|
163
165
|
- app/views/notee/partials/_comment_box.html.erb
|
@@ -169,6 +171,7 @@ files:
|
|
169
171
|
- db/migrate/20160605141547_create_notee_images.rb
|
170
172
|
- db/migrate/20160608102012_create_notee_tokens.rb
|
171
173
|
- db/migrate/20160803154954_create_notee_comments.rb
|
174
|
+
- db/migrate/20160809145754_create_notee_users.rb
|
172
175
|
- lib/notee.rb
|
173
176
|
- lib/notee/configuration.rb
|
174
177
|
- lib/notee/engine.rb
|
@@ -353,12 +356,14 @@ files:
|
|
353
356
|
- test/fixtures/notee/images.yml
|
354
357
|
- test/fixtures/notee/posts.yml
|
355
358
|
- test/fixtures/notee/tokens.yml
|
359
|
+
- test/fixtures/notee/users.yml
|
356
360
|
- test/integration/navigation_test.rb
|
357
361
|
- test/models/notee/category_test.rb
|
358
362
|
- test/models/notee/comment_test.rb
|
359
363
|
- test/models/notee/image_test.rb
|
360
364
|
- test/models/notee/post_test.rb
|
361
365
|
- test/models/notee/token_test.rb
|
366
|
+
- test/models/notee/user_test.rb
|
362
367
|
- test/notee_test.rb
|
363
368
|
- test/test_helper.rb
|
364
369
|
homepage: https://github.com/maru-3/notee.git
|
@@ -560,12 +565,14 @@ test_files:
|
|
560
565
|
- test/fixtures/notee/images.yml
|
561
566
|
- test/fixtures/notee/posts.yml
|
562
567
|
- test/fixtures/notee/tokens.yml
|
568
|
+
- test/fixtures/notee/users.yml
|
563
569
|
- test/integration/navigation_test.rb
|
564
570
|
- test/models/notee/category_test.rb
|
565
571
|
- test/models/notee/comment_test.rb
|
566
572
|
- test/models/notee/image_test.rb
|
567
573
|
- test/models/notee/post_test.rb
|
568
574
|
- test/models/notee/token_test.rb
|
575
|
+
- test/models/notee/user_test.rb
|
569
576
|
- test/notee_test.rb
|
570
577
|
- test/test_helper.rb
|
571
578
|
has_rdoc:
|