bongo 0.0.4 → 0.1.0
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/stylesheets/bongo/application.css +0 -6
- data/app/controllers/bongo/application_controller.rb +1 -2
- data/app/controllers/bongo/articles_controller.rb +15 -1
- data/app/models/bongo/article.rb +2 -0
- data/app/policies/bongo/article_policy.rb +29 -0
- data/app/views/bongo/articles/_form.html.erb +1 -1
- data/app/views/bongo/articles/index.html.erb +10 -6
- data/app/views/bongo/articles/index.rss.builder +18 -0
- data/app/views/bongo/articles/show.html.erb +18 -14
- data/app/views/layouts/bongo/application.html.erb +4 -0
- data/lib/bongo/version.rb +1 -1
- metadata +18 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bfa27b0833100b7eec1515acbaa7a569e69a3887fa8af9c831c1418b68228a8b
|
4
|
+
data.tar.gz: 627fa8516da9575c5176b475359a80c5d05bd0fd95895fdc0b97e7ccc1a09609
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d13fe172bca2498ec4291e8b5159b78ad9cb815b0c18ba73c33e171c91a423c54f666b62cef885e3b7a1f99a09ec47e76d4f8a106fd5f5d2f63baba7859f49fd
|
7
|
+
data.tar.gz: ff322224d305491093e1aac80fdaf820e73d289217205f2111f31ed9ca9c90c8cd8be7ecaf2a686d1bda66a97cc77f89c9eb2c39a43171cdfaa61602000b36e7
|
@@ -7,21 +7,32 @@ module Bongo
|
|
7
7
|
before_action :set_article, only: [:show, :edit, :update, :destroy]
|
8
8
|
|
9
9
|
def index
|
10
|
-
@articles = Article.
|
10
|
+
@articles = policy_scope(Article).order(publish_at: :desc)
|
11
|
+
respond_to do |format|
|
12
|
+
format.html
|
13
|
+
format.rss do
|
14
|
+
@articles = @articles.published.order(publish_at: :desc)
|
15
|
+
render layout: false
|
16
|
+
end
|
17
|
+
end
|
11
18
|
end
|
12
19
|
|
13
20
|
def show
|
21
|
+
authorize @article
|
14
22
|
end
|
15
23
|
|
16
24
|
def new
|
17
25
|
@article = Article.new
|
26
|
+
authorize @article
|
18
27
|
end
|
19
28
|
|
20
29
|
def edit
|
30
|
+
authorize @article
|
21
31
|
end
|
22
32
|
|
23
33
|
def create
|
24
34
|
@article = Article.new(article_params)
|
35
|
+
authorize @article
|
25
36
|
|
26
37
|
if @article.save
|
27
38
|
redirect_to @article, notice: 'Article was successfully created.'
|
@@ -31,6 +42,8 @@ module Bongo
|
|
31
42
|
end
|
32
43
|
|
33
44
|
def update
|
45
|
+
authorize @article
|
46
|
+
|
34
47
|
if @article.update(article_params)
|
35
48
|
redirect_to @article, notice: 'Article was successfully updated.'
|
36
49
|
else
|
@@ -39,6 +52,7 @@ module Bongo
|
|
39
52
|
end
|
40
53
|
|
41
54
|
def destroy
|
55
|
+
authorize @article
|
42
56
|
@article.destroy
|
43
57
|
redirect_to articles_url, notice: 'Article was successfully destroyed.'
|
44
58
|
end
|
data/app/models/bongo/article.rb
CHANGED
@@ -0,0 +1,29 @@
|
|
1
|
+
module Bongo
|
2
|
+
class ArticlePolicy < ApplicationPolicy
|
3
|
+
class Scope < Scope
|
4
|
+
def resolve
|
5
|
+
if user&.admin?
|
6
|
+
scope.all
|
7
|
+
else
|
8
|
+
scope.published
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def show?
|
14
|
+
true
|
15
|
+
end
|
16
|
+
|
17
|
+
def create?
|
18
|
+
user&.admin?
|
19
|
+
end
|
20
|
+
|
21
|
+
def update?
|
22
|
+
user&.admin?
|
23
|
+
end
|
24
|
+
|
25
|
+
def destroy?
|
26
|
+
user&.admin?
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -1,16 +1,20 @@
|
|
1
1
|
<% @articles.each do |article| %>
|
2
2
|
<article>
|
3
|
-
<
|
4
|
-
|
5
|
-
|
3
|
+
<header>
|
4
|
+
<h2><%= link_to article.title, article %></h2>
|
5
|
+
<small><%= article.publish_at ? l(article.publish_at, format: :long) : "Unpublished draft"%></small>
|
6
|
+
</header>
|
7
|
+
<div class="trix-content">
|
6
8
|
<%= article.text.html_safe %>
|
7
|
-
</
|
9
|
+
</div>
|
8
10
|
</article>
|
9
11
|
<br>
|
10
12
|
<% end %>
|
11
13
|
|
12
14
|
<br>
|
13
15
|
|
14
|
-
|
15
|
-
|
16
|
+
<% if policy(Bongo::Article).create? %>
|
17
|
+
<%= link_to new_article_path do %>
|
18
|
+
<b>New Article</b>
|
19
|
+
<% end %>
|
16
20
|
<% end %>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
xml.instruct! :xml, version: "1.0"
|
2
|
+
xml.rss version: "2.0" do
|
3
|
+
xml.channel do
|
4
|
+
xml.title (Front.config.name rescue "My Blog")
|
5
|
+
xml.description (Front.config.name rescue "A bongo blog")
|
6
|
+
xml.link root_url
|
7
|
+
|
8
|
+
@articles.each do |article|
|
9
|
+
xml.item do
|
10
|
+
xml.title article.title
|
11
|
+
xml.description ActionView::Base.full_sanitizer.sanitize(article.text).truncate(180)
|
12
|
+
xml.pubDate article.publish_at.to_s(:rfc822)
|
13
|
+
xml.link article_url(article)
|
14
|
+
xml.guid article_url(article)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -3,21 +3,25 @@
|
|
3
3
|
<h2><%= @article.title %></h2>
|
4
4
|
<small><%= @article.publish_at ? l(@article.publish_at, format: :long) : "Unpublished draft"%></small>
|
5
5
|
</header>
|
6
|
-
<main class="trix-content">
|
7
|
-
<%= @article.text.html_safe %>
|
8
|
-
</main>
|
9
|
-
</article>
|
10
6
|
|
11
|
-
<
|
7
|
+
<div class="trix-content">
|
8
|
+
<%= @article.text.html_safe %>
|
9
|
+
</div>
|
12
10
|
|
13
|
-
|
14
|
-
|
15
|
-
|
11
|
+
<footer>
|
12
|
+
<% if policy(@article).update? %>
|
13
|
+
<%= link_to edit_article_path(@article) do %>
|
14
|
+
<b>Edit</b>
|
15
|
+
<% end %>
|
16
|
+
<% end %>
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
|
18
|
+
<% if policy(@article).destroy? %>
|
19
|
+
<%= link_to @article, method: :delete, data: {confirm: "Are you sure?"} do %>
|
20
|
+
<em>Delete</em>
|
21
|
+
<% end %>
|
22
|
+
<% end %>
|
20
23
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
+
<br>
|
25
|
+
<%= link_to 'Back', articles_path %>
|
26
|
+
</footer>
|
27
|
+
</article>
|
data/lib/bongo/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bongo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thomas Hutterer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-05-
|
11
|
+
date: 2020-05-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '1'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: pundit
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.1'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2.1'
|
55
69
|
description: Rails engine for blogging using MongoDB.
|
56
70
|
email:
|
57
71
|
- tohu@tuta.io
|
@@ -76,10 +90,12 @@ files:
|
|
76
90
|
- app/jobs/bongo/application_job.rb
|
77
91
|
- app/mailers/bongo/application_mailer.rb
|
78
92
|
- app/models/bongo/article.rb
|
93
|
+
- app/policies/bongo/article_policy.rb
|
79
94
|
- app/views/bongo/articles/_form.html.erb
|
80
95
|
- app/views/bongo/articles/_notice.html.erb
|
81
96
|
- app/views/bongo/articles/edit.html.erb
|
82
97
|
- app/views/bongo/articles/index.html.erb
|
98
|
+
- app/views/bongo/articles/index.rss.builder
|
83
99
|
- app/views/bongo/articles/new.html.erb
|
84
100
|
- app/views/bongo/articles/show.html.erb
|
85
101
|
- app/views/layouts/bongo/application.html.erb
|