blog_boi 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +34 -22
- data/app/controllers/blog_boi/application_controller.rb +5 -3
- data/app/controllers/blog_boi/articles_controller.rb +1 -1
- data/app/controllers/blog_boi/comments_controller.rb +1 -1
- data/app/helpers/blog_boi/application_helper.rb +6 -5
- data/app/helpers/blog_boi/articles_helper.rb +3 -0
- data/app/views/blog_boi/articles/_article.html.erb +2 -2
- data/app/views/blog_boi/articles/_form.html.erb +2 -0
- data/app/views/blog_boi/articles/index.html.erb +1 -1
- data/app/views/blog_boi/articles/show.html.erb +8 -7
- data/app/views/layouts/blog_boi/application.html.erb +2 -0
- data/db/migrate/20190729022622_create_join_table_article_category.rb +2 -2
- data/lib/blog_boi.rb +1 -0
- data/lib/blog_boi/error_classes.rb +18 -0
- data/lib/blog_boi/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4a456021f5a432830adc986e89735e394c7b33173fcedce3e61a2816f0f0b53d
|
4
|
+
data.tar.gz: 8986ef7e0032f0a6c0441ffa4b1373fa0e58764e48d1f7544313610844ef0037
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea17c3c5344b1a36749734d75b797f6e187a8c8f59d4559b00ee81a9fe413fc2cd47f44f6c0bc1dcf159b5ca916ec362cc958c4b0076268305e9e761b3df0c02
|
7
|
+
data.tar.gz: 4f925f2a73151ce58c697763fdc3d1962541618c20433527be70718b8f814aefe971e40bcd45e3b4ec948844697b481b08209d737d1cab561ae17cf4a6ecd91e
|
data/README.md
CHANGED
@@ -2,9 +2,7 @@
|
|
2
2
|
|
3
3
|
BlogBoi is a rails gem / engine that provides out-of-the-box blogging functionality to your rails application
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
## A) Installation
|
5
|
+
## Installation
|
8
6
|
|
9
7
|
1. Add this line to your application's Gemfile:
|
10
8
|
|
@@ -65,20 +63,27 @@ BlogBoi.author_class = "User" # name of active record model containing authors w
|
|
65
63
|
|
66
64
|
See lib/blog_boi.rb for all customization options.
|
67
65
|
|
68
|
-
|
66
|
+
7. Finally, your parent application must define the method `admin_signed_in?`. If you are using Devise, this method may already exist. It should return true if the blog admin is signed in, and false if not. When it returns true, you may create, update, and destroy blog articles. It should be available in controllers and views; it should be defined in ApplicationController, and should be marked a helper method. E.g.
|
69
67
|
|
70
|
-
|
71
|
-
|
72
|
-
- Run all tests: `rake` or `rake test`
|
73
|
-
- In normal rails apps: running single test is possible, but not sure how (or if functionality included out of box for engine). Can also run a particular test method from the test case by providing the -n or --name flag. Can also run an entire directory of tests by providing the path to the directory. I don't think any of this works out of the box for engines. How can I get this to work?
|
68
|
+
```
|
69
|
+
class ApplicationController < ActionController::Base
|
74
70
|
|
75
|
-
|
71
|
+
helper_method :admin_signed_in?
|
76
72
|
|
77
|
-
|
73
|
+
def admin_signed_in?
|
74
|
+
...
|
75
|
+
end
|
78
76
|
|
79
|
-
|
77
|
+
end
|
78
|
+
```
|
79
|
+
|
80
|
+
## View partial hooks
|
81
|
+
|
82
|
+
List of view partial hooks that are rendered if they exist in parent application:
|
80
83
|
|
81
|
-
|
84
|
+
- `layouts/blog_boi/head_extension`: (for adding html to head of blog_boi application layout in `layouts/blog_boi/application`)
|
85
|
+
|
86
|
+
## Custom style / SCSS
|
82
87
|
|
83
88
|
To override SCSS bootstrap mixins / styles, add a file in parent application called blog_boi/bootstrap_overrides.scss.
|
84
89
|
- See test/dummy app for example
|
@@ -86,36 +91,43 @@ To override SCSS bootstrap mixins / styles, add a file in parent application cal
|
|
86
91
|
|
87
92
|
Override the header or footer by placing your own files at `views/layouts/_header` or `views/layouts/_footer`
|
88
93
|
|
89
|
-
##
|
94
|
+
## Running tests
|
95
|
+
|
96
|
+
- Run all tests other than system: `rake app:test`
|
97
|
+
- Run system tests: `rake app:test:system`
|
98
|
+
- Run all tests: `rake` or `rake test`
|
90
99
|
|
91
|
-
|
92
|
-
|
100
|
+
**Test coverage**
|
101
|
+
|
102
|
+
Exists in `coverage` folder in root directory.
|
103
|
+
|
104
|
+
To view in a browser, execute from root directory: `open coverage/index.html`
|
93
105
|
|
94
|
-
##
|
106
|
+
## License
|
95
107
|
|
96
108
|
The gem is currently available as open source software under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
97
109
|
|
98
|
-
##
|
110
|
+
## Contributing
|
99
111
|
|
100
112
|
This gem is currently not actively accepting contributions.
|
101
113
|
|
102
114
|
With that in mind, if you'd like to make a fix / change, please create a pull request (and when I have a moment - probably in a couple weeks time - I'll have a look)!
|
103
115
|
|
104
|
-
##
|
116
|
+
## Updating gem version (for maintainers)
|
105
117
|
|
106
|
-
**
|
118
|
+
**1. Update version**
|
107
119
|
|
108
120
|
In `lib/blog_boi/version.rb` update version.
|
109
121
|
|
110
|
-
**
|
122
|
+
**2. Build gem**
|
111
123
|
|
112
124
|
`gem build blog_boi.gemspec`
|
113
125
|
|
114
|
-
**
|
126
|
+
**3. Push gem**
|
115
127
|
|
116
128
|
`gem push blog_boi-X.X.X.gem` (replace X's with version)
|
117
129
|
|
118
|
-
**
|
130
|
+
**4. Tag GitHub**
|
119
131
|
|
120
132
|
`git tag -a vX.X.X -m "Msg"`
|
121
133
|
`git push --tags`
|
@@ -4,12 +4,14 @@ module BlogBoi
|
|
4
4
|
before_action :create_meta_tags_obj
|
5
5
|
|
6
6
|
# TBU
|
7
|
-
def
|
8
|
-
if
|
7
|
+
def authenticate_admin
|
8
|
+
if !defined?(admin_signed_in?)
|
9
|
+
raise BlogBoi::MethodNotImplementedByParentApplication, "admin_signed_in?"
|
10
|
+
elsif admin_signed_in?
|
9
11
|
true
|
10
12
|
else
|
11
13
|
redirect_to root_path
|
12
|
-
end
|
14
|
+
end
|
13
15
|
end
|
14
16
|
|
15
17
|
protected
|
@@ -4,7 +4,7 @@ module BlogBoi
|
|
4
4
|
class ArticlesController < ApplicationController
|
5
5
|
before_action :set_article, only: [:edit, :update, :destroy]
|
6
6
|
before_action :set_article_by_slug, only: [:show]
|
7
|
-
before_action :
|
7
|
+
before_action :authenticate_admin, only: [:new, :create, :edit, :update, :destroy]
|
8
8
|
before_action :set_categories
|
9
9
|
|
10
10
|
# GET /articles
|
@@ -2,7 +2,7 @@ require_dependency "blog_boi/application_controller"
|
|
2
2
|
|
3
3
|
module BlogBoi
|
4
4
|
class CommentsController < ApplicationController
|
5
|
-
before_action :set_categories, :
|
5
|
+
before_action :set_categories, :authenticate_admin
|
6
6
|
|
7
7
|
def create
|
8
8
|
@article = Article.find(params[:article_id])
|
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'byebug'
|
2
|
-
|
3
1
|
module BlogBoi
|
4
2
|
|
5
3
|
module ApplicationHelper
|
@@ -17,9 +15,12 @@ module BlogBoi
|
|
17
15
|
|
18
16
|
end
|
19
17
|
|
20
|
-
|
21
|
-
|
22
|
-
|
18
|
+
def is_admin?
|
19
|
+
if defined?(admin_signed_in?)
|
20
|
+
admin_signed_in?
|
21
|
+
else
|
22
|
+
raise BlogBoi::MethodNotImplementedByParentApplication, "admin_signed_in?"
|
23
|
+
end
|
23
24
|
end
|
24
25
|
|
25
26
|
def controller_action
|
@@ -28,10 +28,10 @@
|
|
28
28
|
</div>
|
29
29
|
|
30
30
|
|
31
|
-
<% if is_admin %>
|
31
|
+
<% if is_admin? %>
|
32
32
|
|
33
33
|
<div class="mt-2">
|
34
|
-
<%= link_to 'Show', article %> |
|
34
|
+
<%= link_to 'Show', article_path(article.slug) %> |
|
35
35
|
<%= link_to 'Edit', edit_article_path(article) %> |
|
36
36
|
<%= link_to 'Destroy', article, method: :delete, data: { confirm: 'Are you sure?' } %>
|
37
37
|
</div>
|
@@ -15,6 +15,8 @@
|
|
15
15
|
<div class="field mt-3">
|
16
16
|
<%= form.label :author_name %><br>
|
17
17
|
<%= form.text_field :author_name, placeholder: 'e.g. Charlie Reese', class: 'form-control' %>
|
18
|
+
<small class="d-block">Existing authors: <%= str_of_authors %></small>
|
19
|
+
<small class="d-block"><span class="text-danger">Warning</span>: entering a new name will create a new <%= BlogBoi.author_class || '' %> entry in DB with only name filled in.</small>
|
18
20
|
</div>
|
19
21
|
|
20
22
|
<div class="field mt-3">
|
@@ -43,16 +43,17 @@
|
|
43
43
|
|
44
44
|
<%= render 'article_body' %>
|
45
45
|
|
46
|
-
|
46
|
+
<div class="mt-5">
|
47
|
+
|
48
|
+
<% if is_admin? %>
|
47
49
|
|
48
|
-
<div class="mt-5">
|
49
|
-
|
50
50
|
<%= link_to 'Edit', edit_article_path(@article) %> |
|
51
|
-
<%= link_to 'Back', articles_path %>
|
52
51
|
|
53
|
-
|
54
|
-
|
55
|
-
|
52
|
+
<% end %>
|
53
|
+
|
54
|
+
<%= link_to 'Back', articles_path %>
|
55
|
+
|
56
|
+
</div>
|
56
57
|
|
57
58
|
</div>
|
58
59
|
|
@@ -10,6 +10,8 @@
|
|
10
10
|
<%= stylesheet_link_tag "blog_boi/application", media: "all" %>
|
11
11
|
<%= stylesheet_link_tag "bootstrap_customizer", media: "all" %>
|
12
12
|
<%= javascript_include_tag "blog_boi/application" %>
|
13
|
+
|
14
|
+
<%= render 'layouts/blog_boi/head_extension' if lookup_context.exists?('layouts/blog_boi/_head_extension') %>
|
13
15
|
</head>
|
14
16
|
<body>
|
15
17
|
|
@@ -1,8 +1,8 @@
|
|
1
1
|
class CreateJoinTableArticleCategory < ActiveRecord::Migration[5.2]
|
2
2
|
def change
|
3
3
|
create_join_table :blog_boi_articles, :blog_boi_categories do |t|
|
4
|
-
t.index [:
|
5
|
-
t.index [:
|
4
|
+
t.index [:blog_boi_article_id, :blog_boi_category_id], name: 'index_blog_boi_article_id_category_id'
|
5
|
+
t.index [:blog_boi_category_id, :blog_boi_article_id], name: 'index_blog_boi_category_id_article_id'
|
6
6
|
end
|
7
7
|
end
|
8
8
|
end
|
data/lib/blog_boi.rb
CHANGED
@@ -0,0 +1,18 @@
|
|
1
|
+
module BlogBoi
|
2
|
+
|
3
|
+
class MethodNotImplementedByParentApplication < ::StandardError
|
4
|
+
attr_reader :method_missing
|
5
|
+
|
6
|
+
def initialize(method)
|
7
|
+
@method_missing = method
|
8
|
+
|
9
|
+
super(
|
10
|
+
'Parent application must implement the method ' +
|
11
|
+
method_missing +
|
12
|
+
" - See BlogBoi README for requirement."
|
13
|
+
)
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
data/lib/blog_boi/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: blog_boi
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Charlie Reese
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-10-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: kramdown
|
@@ -172,6 +172,7 @@ files:
|
|
172
172
|
- db/seeds.rb
|
173
173
|
- lib/blog_boi.rb
|
174
174
|
- lib/blog_boi/engine.rb
|
175
|
+
- lib/blog_boi/error_classes.rb
|
175
176
|
- lib/blog_boi/version.rb
|
176
177
|
- lib/tasks/blog_boi_tasks.rake
|
177
178
|
homepage: https://github.com/charliereese/blog_boi
|