notee 0.3.5 → 0.3.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -6,6 +6,7 @@ namespace :notee do
6
6
  sh 'bundle exec rake notee:install:migrations'
7
7
  add_engine_to_route
8
8
  create_initializer_file
9
+ create_css_file
9
10
  setup_default
10
11
  end
11
12
 
@@ -27,24 +28,25 @@ ________________________________
27
28
 
28
29
  def add_engine_to_route
29
30
  puts ""
30
- return puts 'setup Notee Engine in config/route.rb\n' unless route_file = File.open("#{Rails.root}/config/routes.rb","r")
31
+ return puts 'setup Notee Engine in config/route.rb\n' unless route = File.open("#{Rails.root}/config/routes.rb","r")
32
+ return if File.open("#{Rails.root}/config/routes.rb","r").read.include?("Notee::Engine")
31
33
 
32
- notee_routes_str = String.new
33
34
  text = <<-EOC
34
35
 
35
36
  mount Notee::Engine => "/notee"
36
37
  EOC
37
38
 
38
- route_file.each_line do |line|
39
+ new_route = String.new
40
+ route.each_line do |line|
39
41
  line += text if line.include?("Rails.application.routes.draw do")
40
- notee_routes_str += line
42
+ new_route += line
41
43
  end
42
44
 
43
45
  f = File.open("#{Rails.root}/config/routes.rb","w")
44
- f.write(notee_routes_str)
46
+ f.write(new_route)
45
47
  f.close()
46
48
 
47
- puts 'add "mount Notee::Engine => "/notee" to config/route.rb'
49
+ puts 'Notee added "mount Notee::Engine => "/notee" to config/route.rb'
48
50
  puts ""
49
51
  end
50
52
 
@@ -70,6 +72,26 @@ EOC
70
72
  puts 'you should change notee_id & notee_password'
71
73
  end
72
74
 
75
+ def create_css_file
76
+ image_dir = Rails.root.to_s + '/app/assets/stylesheets/notee/'
77
+ FileUtils.mkdir_p(image_dir) unless FileTest.exist?(image_dir)
78
+
79
+ file_path = image_dir + 'notee_default.css'
80
+ return if File.exist?(file_path)
81
+
82
+ css = File.open(File.expand_path('../css/notee_default.css', __FILE__))
83
+ new_css = String.new
84
+ css.each_line do |line|
85
+ new_css += line
86
+ end
87
+
88
+
89
+ File.open(file_path,"w") do |file|
90
+ file.puts new_css
91
+ end
92
+ puts 'create file in "/app/assets/stylesheets/notee/notee_default.css"'
93
+ end
94
+
73
95
  def setup_default
74
96
  copy_default_image
75
97
  end
@@ -0,0 +1,52 @@
1
+ require 'test_helper'
2
+
3
+ module Notee
4
+ class CommentsControllerTest < ActionDispatch::IntegrationTest
5
+ include Engine.routes.url_helpers
6
+
7
+ setup do
8
+ @comment = notee_comments(:one)
9
+ end
10
+
11
+ test "should get index" do
12
+ get comments_url
13
+ assert_response :success
14
+ end
15
+
16
+ test "should get new" do
17
+ get new_comment_url
18
+ assert_response :success
19
+ end
20
+
21
+ test "should create comment" do
22
+ assert_difference('Comment.count') do
23
+ post comments_url, params: { comment: { content: @comment.content, email: @comment.email, name: @comment.name, post_id: @comment.post_id } }
24
+ end
25
+
26
+ assert_redirected_to comment_url(Comment.last)
27
+ end
28
+
29
+ test "should show comment" do
30
+ get comment_url(@comment)
31
+ assert_response :success
32
+ end
33
+
34
+ test "should get edit" do
35
+ get edit_comment_url(@comment)
36
+ assert_response :success
37
+ end
38
+
39
+ test "should update comment" do
40
+ patch comment_url(@comment), params: { comment: { content: @comment.content, email: @comment.email, name: @comment.name, post_id: @comment.post_id } }
41
+ assert_redirected_to comment_url(@comment)
42
+ end
43
+
44
+ test "should destroy comment" do
45
+ assert_difference('Comment.count', -1) do
46
+ delete comment_url(@comment)
47
+ end
48
+
49
+ assert_redirected_to comments_url
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,13 @@
1
+ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
2
+
3
+ one:
4
+ post_id: 1
5
+ content: MyText
6
+ name: MyString
7
+ email: MyString
8
+
9
+ two:
10
+ post_id: 1
11
+ content: MyText
12
+ name: MyString
13
+ email: MyString
@@ -0,0 +1,9 @@
1
+ require 'test_helper'
2
+
3
+ module Notee
4
+ class CommentTest < ActiveSupport::TestCase
5
+ # test "the truth" do
6
+ # assert true
7
+ # end
8
+ end
9
+ 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.3.5
4
+ version: 0.3.6
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-19 00:00:00.000000000 Z
11
+ date: 2016-08-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -142,6 +142,7 @@ files:
142
142
  - app/assets/stylesheets/notee/preview.scss
143
143
  - app/controllers/notee/application_controller.rb
144
144
  - app/controllers/notee/categories_controller.rb
145
+ - app/controllers/notee/comments_controller.rb
145
146
  - app/controllers/notee/images_controller.rb
146
147
  - app/controllers/notee/notees_controller.rb
147
148
  - app/controllers/notee/posts_controller.rb
@@ -149,30 +150,37 @@ files:
149
150
  - app/controllers/notee/tokens_controller.rb
150
151
  - app/helpers/notee/application_helper.rb
151
152
  - app/helpers/notee/categories_helper.rb
153
+ - app/helpers/notee/comments_helper.rb
152
154
  - app/helpers/notee/images_helper.rb
153
155
  - app/helpers/notee/posts_helper.rb
154
156
  - app/models/notee/category.rb
157
+ - app/models/notee/comment.rb
155
158
  - app/models/notee/image.rb
156
159
  - app/models/notee/post.rb
157
160
  - app/models/notee/token.rb
158
161
  - app/views/layouts/notee/application.html.erb
159
162
  - app/views/notee/notees/index.html.erb
163
+ - app/views/notee/partials/_comment_box.html.erb
164
+ - app/views/notee/partials/_secret_published.html.erb
160
165
  - app/views/notee/tokens/new.html.erb
161
166
  - config/routes.rb
162
167
  - db/migrate/20160605141437_create_notee_posts.rb
163
168
  - db/migrate/20160605141510_create_notee_categories.rb
164
169
  - db/migrate/20160605141547_create_notee_images.rb
165
170
  - db/migrate/20160608102012_create_notee_tokens.rb
171
+ - db/migrate/20160803154954_create_notee_comments.rb
166
172
  - lib/notee.rb
167
173
  - lib/notee/configuration.rb
168
174
  - lib/notee/engine.rb
169
- - lib/notee/helper.rb
175
+ - lib/notee/helpers/notee_helper.rb
176
+ - lib/notee/helpers/view_helper.rb
170
177
  - lib/notee/status.rb
171
178
  - lib/notee/version.rb
172
- - lib/notee/view_helper.rb
179
+ - lib/tasks/css/notee_default.css
173
180
  - lib/tasks/images/default.png
174
181
  - lib/tasks/notee_tasks.rake
175
182
  - test/controllers/notee/categories_controller_test.rb
183
+ - test/controllers/notee/comments_controller_test.rb
176
184
  - test/controllers/notee/images_controller_test.rb
177
185
  - test/controllers/notee/posts_controller_test.rb
178
186
  - test/dummy/README.rdoc
@@ -341,11 +349,13 @@ files:
341
349
  - test/dummy/tmp/cache/assets/sprockets/v3.0/z4/z4i9WzpZRzFXynWsqewNMikNdcZ9f9mGFdlrIP5N6Gs.cache
342
350
  - test/dummy/tmp/cache/assets/sprockets/v3.0/zN/zNfQXfFXMTyOoz3HbVM-_4m-46rWO7XrZPvGs4aJCQc.cache
343
351
  - test/fixtures/notee/categories.yml
352
+ - test/fixtures/notee/comments.yml
344
353
  - test/fixtures/notee/images.yml
345
354
  - test/fixtures/notee/posts.yml
346
355
  - test/fixtures/notee/tokens.yml
347
356
  - test/integration/navigation_test.rb
348
357
  - test/models/notee/category_test.rb
358
+ - test/models/notee/comment_test.rb
349
359
  - test/models/notee/image_test.rb
350
360
  - test/models/notee/post_test.rb
351
361
  - test/models/notee/token_test.rb
@@ -377,6 +387,7 @@ specification_version: 4
377
387
  summary: notee is very simple blogging gem.
378
388
  test_files:
379
389
  - test/controllers/notee/categories_controller_test.rb
390
+ - test/controllers/notee/comments_controller_test.rb
380
391
  - test/controllers/notee/images_controller_test.rb
381
392
  - test/controllers/notee/posts_controller_test.rb
382
393
  - test/dummy/app/assets/javascripts/application.js
@@ -545,11 +556,13 @@ test_files:
545
556
  - test/dummy/tmp/cache/assets/sprockets/v3.0/ZT/ZT-4a7lIKMm0Swxyt7MdXMz5v6r5MaVvtHvqAT6T8Ts.cache
546
557
  - test/dummy/tmp/cache/assets/sprockets/v3.0/Zu/ZuAoFB2A_kFOIb19dNUzEU5jP-SzQLmauPCURINz2Fo.cache
547
558
  - test/fixtures/notee/categories.yml
559
+ - test/fixtures/notee/comments.yml
548
560
  - test/fixtures/notee/images.yml
549
561
  - test/fixtures/notee/posts.yml
550
562
  - test/fixtures/notee/tokens.yml
551
563
  - test/integration/navigation_test.rb
552
564
  - test/models/notee/category_test.rb
565
+ - test/models/notee/comment_test.rb
553
566
  - test/models/notee/image_test.rb
554
567
  - test/models/notee/post_test.rb
555
568
  - test/models/notee/token_test.rb
data/lib/notee/helper.rb DELETED
@@ -1,36 +0,0 @@
1
- module Notee
2
- module Helper
3
- def notees(search_txt)
4
-
5
- @notees = []
6
-
7
- if search_txt.nil?
8
- # all_notees
9
- @notees = Notee::Post.where(status: Notee::STATUS[:published]).order(published_at: :desc)
10
- else
11
- # search_by_category_slug
12
- category_id = Notee::Category.find_by(slug: search_txt)
13
- category_id = Notee::Category.find_by(name: search_txt) unless category_id
14
- return false unless category_id
15
-
16
- @notees = Notee::Post.where(category_id: category_id, status: Notee::STATUS[:published]).order(published_at: :desc)
17
- end
18
-
19
- @notees
20
-
21
- end
22
-
23
- def secret_notees
24
- @notees = Notee::Post.where(status: Notee::STATUS[:secret_published]).order(published_at: :desc)
25
- end
26
-
27
-
28
- def notee(search_txt)
29
- return false unless search_txt
30
- @notee = Notee::Post.find_by(id: search_txt, status: Notee::STATUS[:published])
31
- @notee = Notee::Post.find_by(slug: search_txt, status: Notee::STATUS[:published]) unless @notee
32
-
33
- @notee
34
- end
35
- end
36
- end
@@ -1,16 +0,0 @@
1
- require 'redcarpet'
2
-
3
- module Notee
4
- module ViewHelper
5
- def notee_content(text)
6
-
7
- unless @markdown
8
- renderer = Redcarpet::Render::HTML.new(filter_html: true, hard_wrap: true)
9
- @markdown = Redcarpet::Markdown.new(renderer, :fenced_code_blocks => true, :highlight => true)
10
- end
11
-
12
- @markdown.render(text).html_safe
13
- end
14
-
15
- end
16
- end