bongo 0.0.1 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +9 -10
- data/app/assets/config/bongo_manifest.js +1 -0
- data/app/assets/javascripts/bongo/application.js +1 -0
- data/app/assets/javascripts/bongo/attachments.js.erb +51 -0
- data/app/assets/javascripts/bongo/trix.js +21 -0
- data/app/assets/stylesheets/bongo/application.css +0 -11
- data/app/assets/stylesheets/bongo/trix.css +374 -0
- data/app/controllers/bongo/application_controller.rb +1 -2
- data/app/controllers/bongo/articles_controller.rb +15 -1
- data/app/controllers/bongo/files_controller.rb +22 -0
- 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 +3 -2
- data/app/views/bongo/articles/index.html.erb +11 -5
- data/app/views/bongo/articles/index.rss.builder +18 -0
- data/app/views/bongo/articles/show.html.erb +18 -12
- data/app/views/layouts/bongo/application.html.erb +4 -0
- data/config/routes.rb +1 -0
- data/lib/bongo/version.rb +1 -1
- metadata +41 -6
@@ -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
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require_dependency "bongo/application_controller"
|
2
|
+
|
3
|
+
require "aws-sdk-s3"
|
4
|
+
|
5
|
+
module Bongo
|
6
|
+
class FilesController < ApplicationController
|
7
|
+
before_action :authenticate_user!
|
8
|
+
|
9
|
+
skip_before_action :verify_authenticity_token
|
10
|
+
|
11
|
+
def create
|
12
|
+
extension = File.extname(params[:file].original_filename)
|
13
|
+
s3 = Aws::S3::Resource.new
|
14
|
+
obj = s3.bucket(ENV["AWS_S3_BUCKET"]).object(SecureRandom.uuid + extension)
|
15
|
+
obj.upload_file(params[:file])
|
16
|
+
|
17
|
+
respond_to do |format|
|
18
|
+
format.json { render json: obj.public_url }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
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
|
@@ -15,7 +15,8 @@
|
|
15
15
|
<%= form.text_field :title, required: true %>
|
16
16
|
|
17
17
|
<%= form.label :text %>
|
18
|
-
<%= form.
|
18
|
+
<%= form.hidden_field :text %>
|
19
|
+
<trix-editor input="article_text" class="trix-content" required></trix-editor>
|
19
20
|
|
20
21
|
<%= form.label :publish_at %>
|
21
22
|
<%= form.date_field :publish_at %>
|
@@ -23,6 +24,6 @@
|
|
23
24
|
<button type="submit">Save</button>
|
24
25
|
|
25
26
|
<%= link_to articles_path do %>
|
26
|
-
<em>
|
27
|
+
<em>Cancel</em>
|
27
28
|
<% end %>
|
28
29
|
<% end %>
|
@@ -1,14 +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">
|
8
|
+
<%= article.text.html_safe %>
|
9
|
+
</div>
|
6
10
|
</article>
|
7
11
|
<br>
|
8
12
|
<% end %>
|
9
13
|
|
10
14
|
<br>
|
11
15
|
|
12
|
-
|
13
|
-
|
16
|
+
<% if policy(Bongo::Article).create? %>
|
17
|
+
<%= link_to new_article_path do %>
|
18
|
+
<b>New Article</b>
|
19
|
+
<% end %>
|
14
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.description 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,19 +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><%= simple_format @article.text %></main>
|
7
|
-
</article>
|
8
6
|
|
9
|
-
<
|
7
|
+
<div class="trix-content">
|
8
|
+
<%= @article.text.html_safe %>
|
9
|
+
</div>
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
11
|
+
<footer>
|
12
|
+
<% if policy(@article).update? %>
|
13
|
+
<%= link_to edit_article_path(@article) do %>
|
14
|
+
<b>Edit</b>
|
15
|
+
<% end %>
|
16
|
+
<% end %>
|
14
17
|
|
15
|
-
|
16
|
-
|
17
|
-
|
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 %>
|
18
23
|
|
19
|
-
|
20
|
-
|
21
|
-
|
24
|
+
<br>
|
25
|
+
<%= link_to 'Back', articles_path %>
|
26
|
+
</footer>
|
27
|
+
</article>
|
data/config/routes.rb
CHANGED
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.
|
4
|
+
version: 0.1.1
|
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
|
@@ -38,7 +38,35 @@ dependencies:
|
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 7.0.5
|
41
|
-
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: aws-sdk-s3
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
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'
|
69
|
+
description: Rails engine for blogging using MongoDB.
|
42
70
|
email:
|
43
71
|
- tohu@tuta.io
|
44
72
|
executables: []
|
@@ -49,18 +77,25 @@ files:
|
|
49
77
|
- README.md
|
50
78
|
- Rakefile
|
51
79
|
- app/assets/config/bongo_manifest.js
|
80
|
+
- app/assets/javascripts/bongo/application.js
|
81
|
+
- app/assets/javascripts/bongo/attachments.js.erb
|
82
|
+
- app/assets/javascripts/bongo/trix.js
|
52
83
|
- app/assets/stylesheets/bongo/application.css
|
84
|
+
- app/assets/stylesheets/bongo/trix.css
|
53
85
|
- app/controllers/bongo/application_controller.rb
|
54
86
|
- app/controllers/bongo/articles_controller.rb
|
87
|
+
- app/controllers/bongo/files_controller.rb
|
55
88
|
- app/helpers/bongo/application_helper.rb
|
56
89
|
- app/helpers/bongo/articles_helper.rb
|
57
90
|
- app/jobs/bongo/application_job.rb
|
58
91
|
- app/mailers/bongo/application_mailer.rb
|
59
92
|
- app/models/bongo/article.rb
|
93
|
+
- app/policies/bongo/article_policy.rb
|
60
94
|
- app/views/bongo/articles/_form.html.erb
|
61
95
|
- app/views/bongo/articles/_notice.html.erb
|
62
96
|
- app/views/bongo/articles/edit.html.erb
|
63
97
|
- app/views/bongo/articles/index.html.erb
|
98
|
+
- app/views/bongo/articles/index.rss.builder
|
64
99
|
- app/views/bongo/articles/new.html.erb
|
65
100
|
- app/views/bongo/articles/show.html.erb
|
66
101
|
- app/views/layouts/bongo/application.html.erb
|
@@ -69,7 +104,7 @@ files:
|
|
69
104
|
- lib/bongo/engine.rb
|
70
105
|
- lib/bongo/version.rb
|
71
106
|
- lib/tasks/bongo_tasks.rake
|
72
|
-
homepage: https://
|
107
|
+
homepage: https://github.com/thutterer/bongo
|
73
108
|
licenses:
|
74
109
|
- MIT
|
75
110
|
metadata: {}
|
@@ -88,8 +123,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
88
123
|
- !ruby/object:Gem::Version
|
89
124
|
version: '0'
|
90
125
|
requirements: []
|
91
|
-
rubygems_version: 3.
|
126
|
+
rubygems_version: 3.0.3
|
92
127
|
signing_key:
|
93
128
|
specification_version: 4
|
94
|
-
summary: A blogging engine
|
129
|
+
summary: A blogging engine for Rails
|
95
130
|
test_files: []
|