notee 1.0.7 → 1.0.8
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.
- checksums.yaml +4 -4
- data/app/assets/javascripts/notee/application.js +45 -76973
- data/app/controllers/notee/comments_controller.rb +1 -1
- data/app/controllers/notee/tokens_controller.rb +15 -0
- data/app/models/notee/post.rb +1 -1
- data/app/models/notee/user.rb +0 -6
- data/app/views/notee/partials/_comment_box.html.erb +109 -120
- data/app/views/notee/partials/_meta.html.erb +3 -1
- data/app/views/notee/tokens/new.html.erb +16 -4
- data/config/routes.rb +2 -16
- data/db/migrate/20160605141437_create_notee_posts.rb +56 -1
- data/db/migrate/20160809145754_create_notee_users.rb +5 -0
- data/lib/notee/helpers/notee_helper.rb +8 -4
- data/lib/notee/version.rb +1 -1
- data/lib/tasks/config/notee.rb +1 -1
- data/lib/tasks/controllers/errors_controller.rb +23 -0
- data/lib/tasks/controllers/notee_controller.rb +1 -0
- data/lib/tasks/notee_tasks.rake +86 -48
- data/lib/tasks/stylesheets/notee/social/social.css +1 -0
- data/lib/tasks/views/layouts/notee_application.html.erb +6 -0
- data/lib/tasks/views/notee/about.html.erb +36 -41
- data/lib/tasks/views/notee/archives.html.erb +9 -14
- data/lib/tasks/views/notee/categories.html.erb +9 -14
- data/lib/tasks/views/notee/errors/internal_server_error.html.erb +5 -0
- data/lib/tasks/views/notee/errors/not_found.html.erb +5 -0
- data/lib/tasks/views/notee/partials/_footer.html.erb +5 -3
- data/lib/tasks/views/notee/partials/_header.html.erb +11 -1
- data/lib/tasks/views/notee/posts.html.erb +41 -44
- data/lib/tasks/views/notee/show.html.erb +29 -34
- data/lib/tasks/views/notee/writers.html.erb +5 -10
- data/test/controllers/notee/categories_controller_test.rb +2 -2
- data/test/controllers/notee/comments_controller_test.rb +2 -2
- data/test/controllers/notee/images_controller_test.rb +2 -2
- data/test/controllers/notee/posts_controller_test.rb +2 -2
- metadata +6 -2
@@ -12,6 +12,11 @@ class CreateNoteeUsers < ActiveRecord::Migration
|
|
12
12
|
t.timestamps null: false
|
13
13
|
end
|
14
14
|
|
15
|
+
# create root User
|
16
|
+
Notee::User.skip_callback(:create, :before, :create_authority)
|
17
|
+
Notee::User.create(id: 0, name: Notee.notee_id, email: "root", password: SecureRandom.hex, role: 9999)
|
18
|
+
Notee::User.set_callback(:create, :before, :create_authority)
|
19
|
+
|
15
20
|
add_index :notee_users, [:name, :email], :unique => true
|
16
21
|
end
|
17
22
|
end
|
@@ -7,6 +7,8 @@ module Notee
|
|
7
7
|
post = Notee::Post.find_by(id: search_txt)
|
8
8
|
post = Notee::Post.find_by(slug: search_txt) unless post
|
9
9
|
|
10
|
+
raise ActiveRecord::RecordNotFound unless post
|
11
|
+
|
10
12
|
return if post.status == Notee::STATUS[:draft] ||
|
11
13
|
post.status == Notee::STATUS[:deleted] ||
|
12
14
|
post.status == Notee::STATUS[:privated] ||
|
@@ -25,8 +27,9 @@ module Notee
|
|
25
27
|
# search_by_category_slug
|
26
28
|
category = Notee::Category.find_by(slug: search_txt)
|
27
29
|
category = Notee::Category.find_by(name: search_txt) unless category
|
28
|
-
|
29
|
-
|
30
|
+
|
31
|
+
raise ActiveRecord::RecordNotFound unless category
|
32
|
+
raise ActiveRecord::RecordNotFound if category.is_deleted
|
30
33
|
|
31
34
|
@posts = Notee::Post.where(category_id: category.id, status: Notee::STATUS[:published], is_deleted: false).order(published_at: :desc)
|
32
35
|
@posts
|
@@ -53,8 +56,9 @@ module Notee
|
|
53
56
|
def writer_notees(name_or_id)
|
54
57
|
writer = Notee::User.find_by(name: name_or_id)
|
55
58
|
writer = Notee::User.find_by(name: name_or_id) unless writer
|
56
|
-
|
57
|
-
|
59
|
+
|
60
|
+
raise ActiveRecord::RecordNotFound unless writer
|
61
|
+
raise ActiveRecord::RecordNotFound if writer.is_deleted
|
58
62
|
|
59
63
|
@posts = writer.posts
|
60
64
|
end
|
data/lib/notee/version.rb
CHANGED
data/lib/tasks/config/notee.rb
CHANGED
@@ -0,0 +1,23 @@
|
|
1
|
+
class ErrorsController < ActionController::Base
|
2
|
+
layout 'notee_application'
|
3
|
+
|
4
|
+
rescue_from ActiveRecord::RecordNotFound, with: :resque404
|
5
|
+
rescue_from ActionController::RoutingError, with: :resque404
|
6
|
+
rescue_from StandardError, with: :resque500
|
7
|
+
|
8
|
+
def resque404(exception = nil)
|
9
|
+
if exception
|
10
|
+
logger.info "Rendering 404 with exception: #{exception.message}"
|
11
|
+
end
|
12
|
+
render template: "notee/errors/not_found", status: 404
|
13
|
+
end
|
14
|
+
|
15
|
+
def resque500(exception = nil)
|
16
|
+
if exception
|
17
|
+
logger.info "Rendering 500 with exception: #{exception.message}"
|
18
|
+
end
|
19
|
+
render template: "notee/errors/internal_server_error", status: 500
|
20
|
+
end
|
21
|
+
|
22
|
+
def show; raise env["action_dispatch.exception"]; end
|
23
|
+
end
|
data/lib/tasks/notee_tasks.rake
CHANGED
@@ -3,17 +3,9 @@ namespace :notee do
|
|
3
3
|
require 'fileutils'
|
4
4
|
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
<!-- default notee setting -->
|
10
|
-
|
11
|
-
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
|
12
|
-
|
13
|
-
<!-- notee setting end -->
|
14
|
-
|
15
|
-
EOC
|
16
|
-
|
6
|
+
# -----------------------------------------------
|
7
|
+
# Constants
|
8
|
+
# -----------------------------------------------
|
17
9
|
|
18
10
|
APPLICATION_JS_PATH = "/app/assets/javascripts/application.js"
|
19
11
|
ADD_HIGHLIGHT_TXT = <<-EOC
|
@@ -61,61 +53,108 @@ $(document).on('ready', function() {
|
|
61
53
|
get '/writers/:name_or_id' => 'notee#writer_posts', as: 'notee_public_writer_posts'
|
62
54
|
get '/:id_or_slug' => 'notee#show', as: 'notee_public_show'
|
63
55
|
|
56
|
+
get '*anything' => 'errors#resque404'
|
57
|
+
|
64
58
|
######## notee setting end
|
65
59
|
|
66
60
|
EOC
|
67
61
|
|
68
62
|
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
NOTEE_JS_ORIGIN_PATH = "../javascripts/notee"
|
75
|
-
NOTEE_SCHEJULE_PATH = "/config/schedule.rb"
|
76
|
-
NOTEE_SCHEJULE_ORIGIN_PATH = "../config/schedule.rb"
|
77
|
-
NOTEE_CONTROLLER_PATH = "/app/controllers/notee_controller.rb"
|
78
|
-
NOTEE_CONTROLLER_ORIGIN_PATH = "../controllers/notee_controller.rb"
|
63
|
+
ENV_PRODUCTION_FILE_PATH = "/config/environments/production.rb"
|
64
|
+
ADD_ENV_PRODUCTION_TXT = "config.exceptions_app = ->(env) { ErrorsController.action(:show).call(env) }"
|
65
|
+
|
66
|
+
|
67
|
+
# FILE PATH
|
79
68
|
NOTEE_INIT_FILE_PATH = "/config/initializers/notee.rb"
|
80
69
|
NOTEE_INIT_FILE_ORIGIN_PATH = "../config/notee.rb"
|
81
|
-
|
82
|
-
|
70
|
+
NOTEE_LAYOUTS_FILE_PATH = "/app/views/layouts/notee_application.html.erb"
|
71
|
+
NOTEE_LAYOUTS_FILE_ORIGIN_PATH = "../views/layouts/notee_application.html.erb"
|
72
|
+
NOTEE_SCHEJULE_FILE_PATH = "/config/schedule.rb"
|
73
|
+
NOTEE_SCHEJULE_FILE_ORIGIN_PATH = "../config/schedule.rb"
|
74
|
+
NOTEE_CONTROLLER_FILE_PATH = "/app/controllers/notee_controller.rb"
|
75
|
+
NOTEE_CONTROLLER_FILE_ORIGIN_PATH = "../controllers/notee_controller.rb"
|
76
|
+
NOTEE_ERROR_CONTROLLER_FILE_PATH = "/app/controllers/errors_controller.rb"
|
77
|
+
NOTEE_ERROR_CONTROLLER_FILE_ORIGIN_PATH = "../controllers/errors_controller.rb"
|
78
|
+
|
79
|
+
# Directory PATH
|
80
|
+
NOTEE_VIEW_DIR_PATH = "/app/views/notee/"
|
81
|
+
NOTEE_VIEW_DIR_ORIGIN_PATH = "../views/notee"
|
82
|
+
NOTEE_CSS_DIR_PATH = "/app/assets/stylesheets/notee/"
|
83
|
+
NOTEE_CSS_DIR_ORIGIN_PATH = "../stylesheets/notee"
|
84
|
+
NOTEE_JS_DIR_PATH = "/app/assets/javascripts/notee/"
|
85
|
+
NOTEE_JS_DIR_ORIGIN_PATH = "../javascripts/notee"
|
86
|
+
NOTEE_IMAGE_DIR_PATH = "/public/notee/"
|
87
|
+
NOTEE_IMAGE_DIR_ORIGIN_PATH = "../images/notee"
|
88
|
+
|
89
|
+
|
90
|
+
# -----------------------------------------------
|
91
|
+
# Tasks
|
92
|
+
# -----------------------------------------------
|
93
|
+
|
83
94
|
|
84
95
|
task :start do
|
85
96
|
notee_mark
|
86
97
|
sh 'bundle exec rake notee:install:migrations'
|
87
|
-
|
88
|
-
|
98
|
+
|
99
|
+
# Add Code
|
89
100
|
add_notee_code( APPLICATION_JS_PATH, ADD_HIGHLIGHT_TXT, "//= require_tree .", "hljs.initHighlightingOnLoad()" )
|
101
|
+
delete_line( APPLICATION_JS_PATH, "//= require turbolinks" )
|
90
102
|
add_notee_code( APPLICATION_CSS_PATH, ADD_CSS_TXT, "*= require_tree .", "*= require_directory ./notee" )
|
91
103
|
delete_line( APPLICATION_CSS_PATH, "*= require_tree ." )
|
92
104
|
add_notee_code( ROUTE_FILE_PATH, ADD_ROUTE_TXT, "Rails.application.routes.draw do", "Notee::Engine" )
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
copy_directory(
|
97
|
-
|
98
|
-
|
105
|
+
add_line( ENV_PRODUCTION_FILE_PATH, ADD_ENV_PRODUCTION_TXT, "Rails.application.configure do")
|
106
|
+
|
107
|
+
# Copy Directory
|
108
|
+
copy_directory( NOTEE_VIEW_DIR_PATH, NOTEE_VIEW_DIR_ORIGIN_PATH )
|
109
|
+
copy_directory( NOTEE_CSS_DIR_PATH, NOTEE_CSS_DIR_ORIGIN_PATH )
|
110
|
+
copy_directory( NOTEE_JS_DIR_PATH, NOTEE_JS_DIR_ORIGIN_PATH )
|
111
|
+
copy_directory( NOTEE_IMAGE_DIR_PATH, NOTEE_IMAGE_DIR_ORIGIN_PATH )
|
112
|
+
|
113
|
+
# Create File
|
99
114
|
create_file( NOTEE_INIT_FILE_PATH, NOTEE_INIT_FILE_ORIGIN_PATH)
|
115
|
+
create_file( NOTEE_LAYOUTS_FILE_PATH, NOTEE_LAYOUTS_FILE_ORIGIN_PATH)
|
116
|
+
create_file( NOTEE_SCHEJULE_FILE_PATH, NOTEE_SCHEJULE_FILE_ORIGIN_PATH)
|
117
|
+
create_file( NOTEE_CONTROLLER_FILE_PATH, NOTEE_CONTROLLER_FILE_ORIGIN_PATH)
|
118
|
+
create_file( NOTEE_ERROR_CONTROLLER_FILE_PATH, NOTEE_ERROR_CONTROLLER_FILE_ORIGIN_PATH)
|
119
|
+
|
120
|
+
# Set Cron Job
|
100
121
|
sh 'bundle exec whenever --update-crontab RAILS_ENV=production'
|
101
122
|
end
|
102
123
|
|
124
|
+
|
103
125
|
task :destroy do
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
delete_file(
|
109
|
-
delete_file(
|
126
|
+
|
127
|
+
# Delete File
|
128
|
+
delete_file(NOTEE_ERROR_CONTROLLER_FILE_PATH)
|
129
|
+
delete_file(NOTEE_CONTROLLER_FILE_PATH)
|
130
|
+
delete_file(NOTEE_SCHEJULE_FILE_PATH)
|
131
|
+
delete_file(NOTEE_LAYOUTS_FILE_PATH)
|
110
132
|
delete_file(NOTEE_INIT_FILE_PATH)
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
133
|
+
|
134
|
+
# Delete Directory
|
135
|
+
delete_directory(NOTEE_IMAGE_DIR_PATH)
|
136
|
+
delete_directory(NOTEE_JS_DIR_PATH)
|
137
|
+
delete_directory(NOTEE_CSS_DIR_PATH)
|
138
|
+
delete_directory(NOTEE_VIEW_DIR_PATH)
|
139
|
+
|
140
|
+
# Delete Code
|
141
|
+
delete_line( ENV_PRODUCTION_FILE_PATH, ADD_ENV_PRODUCTION_TXT)
|
116
142
|
delete_notee_code(ROUTE_FILE_PATH, "######## default notee path", "######## notee setting end")
|
143
|
+
add_line(APPLICATION_CSS_PATH, "*= require_tree .", "//////// notee setting end")
|
144
|
+
delete_notee_code(APPLICATION_CSS_PATH, "//////// default notee setting", "//////// notee setting end")
|
145
|
+
add_line( APPLICATION_JS_PATH, "//= require turbolinks", "//= require jquery_ujs")
|
146
|
+
delete_notee_code(APPLICATION_JS_PATH, "//////// default notee setting", "//////// notee setting end")
|
147
|
+
|
148
|
+
# Delte Cron Job
|
149
|
+
sh 'bundle exec whenever --clear-crontab'
|
117
150
|
end
|
118
151
|
|
152
|
+
|
153
|
+
# -----------------------------------------------
|
154
|
+
# Methods
|
155
|
+
# -----------------------------------------------
|
156
|
+
|
157
|
+
|
119
158
|
private
|
120
159
|
|
121
160
|
def notee_mark
|
@@ -152,7 +191,7 @@ ________________________________
|
|
152
191
|
f.write(new_file)
|
153
192
|
f.close()
|
154
193
|
|
155
|
-
puts 'Notee added code => ' + add_file_path
|
194
|
+
puts 'Notee added code => in ' + add_file_path
|
156
195
|
end
|
157
196
|
|
158
197
|
|
@@ -232,16 +271,16 @@ ________________________________
|
|
232
271
|
|
233
272
|
|
234
273
|
|
235
|
-
def add_line(file_path, add_line, beginning_path
|
274
|
+
def add_line(file_path, add_line, beginning_path)
|
236
275
|
add_file_path = Rails.root.to_s + file_path
|
237
276
|
|
238
277
|
txt = <<-EOC
|
239
278
|
|
240
|
-
#{add_line}
|
279
|
+
#{add_line}
|
241
280
|
EOC
|
242
281
|
|
243
|
-
return puts '
|
244
|
-
return if File.open(add_file_path,"r").read.include?(
|
282
|
+
return puts 'add failed => notee code '+ add_file_path + '\n' unless delete_file = File.open(add_file_path,"r")
|
283
|
+
return if File.open(add_file_path,"r").read.include?(add_line)
|
245
284
|
|
246
285
|
new_file_text = String.new
|
247
286
|
initial_txt = true
|
@@ -281,5 +320,4 @@ ________________________________
|
|
281
320
|
puts 'Notee deleted => ' + delete_line + ' in' + delete_file_path
|
282
321
|
end
|
283
322
|
|
284
|
-
|
285
323
|
end
|
@@ -1,43 +1,38 @@
|
|
1
|
-
|
2
|
-
<div class="
|
3
|
-
|
4
|
-
<
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
augue velit cursus nunc.
|
38
|
-
</p>
|
39
|
-
</div>
|
1
|
+
<div class="notee_main">
|
2
|
+
<div class="notee_main_content">
|
3
|
+
<h1>Hello World</h1>
|
4
|
+
<p>
|
5
|
+
Lorem ipsum dolor sit amet,
|
6
|
+
consectetuer adipiscing elit.
|
7
|
+
Aenean commodo ligula eget dolor.
|
8
|
+
Aenean massa.
|
9
|
+
Cum sociis natoque penatibus et magnis dis parturient montes,
|
10
|
+
nascetur ridiculus mus.
|
11
|
+
Donec quam felis, ultricies nec, pellentesque eu,
|
12
|
+
pretium quis, sem. Nulla consequat massa quis enim.
|
13
|
+
Donec pede justo, fringilla vel, aliquet nec,
|
14
|
+
vulputate eget, arcu. In enim justo, rhoncus ut,
|
15
|
+
imperdiet a, venenatis vitae, justo.
|
16
|
+
Nullam dictum felis eu pede mollis pretium. Integer tincidunt.
|
17
|
+
Cras dapibus. Vivamus elementum semper nisi.
|
18
|
+
Aenean vulputate eleifend tellus.
|
19
|
+
Aenean leo ligula, porttitor eu,
|
20
|
+
consequat vitae, eleifend ac, enim.
|
21
|
+
Aliquam lorem ante,
|
22
|
+
dapibus in, viverra quis, feugiat a, tellus.
|
23
|
+
Phasellus viverra nulla ut metus varius laoreet.
|
24
|
+
Quisque rutrum. Aenean imperdiet. Etiam ultricies nisi vel augue.
|
25
|
+
Curabitur ullamcorper ultricies nisi. Nam eget dui. Etiam rhoncus.
|
26
|
+
Maecenas tempus, tellus eget condimentum rhoncus,
|
27
|
+
sem quam semper libero, sit amet adipiscing sem neque sed ipsum.
|
28
|
+
Nam quam nunc, blandit vel, luctus pulvinar, hendrerit id, lorem.
|
29
|
+
Maecenas nec odio et ante tincidunt tempus.
|
30
|
+
Donec vitae sapien ut libero venenatis faucibus.
|
31
|
+
Nullam quis ante. Etiam sit amet orci eget eros faucibus tincidunt.
|
32
|
+
Duis leo. Sed fringilla mauris sit amet nibh.
|
33
|
+
Donec sodales sagittis magna. Sed consequat,
|
34
|
+
leo eget bibendum sodales,
|
35
|
+
augue velit cursus nunc.
|
36
|
+
</p>
|
40
37
|
</div>
|
41
|
-
<%= render :partial => "notee/partials/sidebar.html.erb" %>
|
42
38
|
</div>
|
43
|
-
<%= render :partial => "notee/partials/footer.html.erb" %>
|
@@ -1,15 +1,10 @@
|
|
1
|
-
|
2
|
-
<
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
</div>
|
11
|
-
<% end %>
|
12
|
-
</div>
|
13
|
-
<%= render :partial => "notee/partials/sidebar.html.erb" %>
|
1
|
+
<div class="notee_main">
|
2
|
+
<h2>Archive List</h2>
|
3
|
+
<% @archives.each do |key, count| %>
|
4
|
+
<div class="notee_list">
|
5
|
+
<a href="/archives/<%= key %>">
|
6
|
+
<h3><%= key %> (<%= count %>)</h3>
|
7
|
+
</a>
|
8
|
+
</div>
|
9
|
+
<% end %>
|
14
10
|
</div>
|
15
|
-
<%= render :partial => "notee/partials/footer.html.erb" %>
|
@@ -1,15 +1,10 @@
|
|
1
|
-
|
2
|
-
<
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
</div>
|
11
|
-
<% end %>
|
12
|
-
</div>
|
13
|
-
<%= render :partial => "notee/partials/sidebar.html.erb" %>
|
1
|
+
<div class="notee_main">
|
2
|
+
<h2>Category List</h2>
|
3
|
+
<% @categories.each do |key, category_array| %>
|
4
|
+
<div class="notee_list">
|
5
|
+
<a href="/categories/<%= category_array[1].slug %>">
|
6
|
+
<h3><%= category_array[1].name %> (<%= category_array[0] %>)</h3>
|
7
|
+
</a>
|
8
|
+
</div>
|
9
|
+
<% end %>
|
14
10
|
</div>
|
15
|
-
<%= render :partial => "notee/partials/footer.html.erb" %>
|