bongo 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 64395bf51b4f938ef4e3b6d2524f705bffec951c75d371ef77812b8f610da3a9
4
- data.tar.gz: 8f64a0370bc61bb7484c6cba69264d1cfdd04e7096911873e7642aa7e63bf563
3
+ metadata.gz: 5e018498e675e3bb9291082e9041703e1b4b81f6a739502b03fca12080598c35
4
+ data.tar.gz: 89202916b3e43b153644fab00b360d9fb997999119b37c7c7f555df11a920ef1
5
5
  SHA512:
6
- metadata.gz: '089d77ebc1c1af9b93a701d297bfcaf5c99ce8400761a9e3a37deca72aadca1a1f5ab468992ed54a6b9f1489bbdfc9d8c1283dc1296e1e1e3c4fc7d83f113531'
7
- data.tar.gz: abc03456af1d38a13733f10a724297be93d10237076c9a8fe08c63e3edbe5ea2056346f3ee9d4a874e9715ce6b97de053ecc19a37fa68b24bf6227c73807198e
6
+ metadata.gz: 970c24e98878f15c05779524e6c0ec2b1f52b8589e8b6db4dfd987272b90f4109958f024225eaf777e28f6bba275993da66a33e3ce2e5c71618475614daa0ca9
7
+ data.tar.gz: 49b47ae00c0349700139d53a40a7a2e45800de748d898cc2d5a253fe74511054ca154dd8ffebe6dc137e4bb96ad58cd6a11c9bd83fc777d776bcdaaf15fb6aaa
data/README.md CHANGED
@@ -5,7 +5,7 @@ Rails engine for blogging using Trix and MongoDB.
5
5
  Add this line to your application's `Gemfile`:
6
6
 
7
7
  ```ruby
8
- gem 'bongo'
8
+ gem "bongo"
9
9
  ```
10
10
 
11
11
  And then execute:
@@ -7,7 +7,7 @@ module Bongo
7
7
  before_action :set_article, only: [:show, :edit, :update, :destroy]
8
8
 
9
9
  def index
10
- @articles = policy_scope(Article).order(publish_at: :desc)
10
+ @articles = policy_scope(Article).published.order(publish_at: :desc)
11
11
  respond_to do |format|
12
12
  format.html
13
13
  format.rss do
@@ -0,0 +1,7 @@
1
+ module Bongo
2
+ class DraftsController < ArticlesController
3
+ def index
4
+ @drafts = policy_scope(Article).not.published.order(updated_at: :desc)
5
+ end
6
+ end
7
+ end
@@ -1,11 +1,26 @@
1
1
  module Bongo
2
2
  class Article
3
3
  include Mongoid::Document
4
+ include Mongoid::Timestamps::Updated
5
+ include Mongoid::Slug
6
+
7
+ slug :title, history: true
4
8
 
5
9
  field :title, type: String
6
10
  field :text, type: String
7
11
  field :publish_at, type: Date
8
12
 
9
13
  scope :published, -> { where(:publish_at.lte => Date.today) }
14
+
15
+ # Mongoid (v7.0.8) doesn't have a cache_version method on its document.
16
+ # This causes https://jira.mongodb.org/browse/MONGOID-4680 when trying to
17
+ # use Rails collection caching.
18
+ def cache_version
19
+ if respond_to?(:updated_at)
20
+ updated_at.utc.to_s(:usec)
21
+ else
22
+ nil
23
+ end
24
+ end
10
25
  end
11
26
  end
@@ -0,0 +1,9 @@
1
+ <article>
2
+ <header>
3
+ <h2><%= link_to article.title, article %></h2>
4
+ <small><%= article.publish_at ? l(article.publish_at, format: :long) : "Unpublished draft"%></small>
5
+ </header>
6
+ <div class="trix-content">
7
+ <%= article.text.html_safe %>
8
+ </div>
9
+ </article>
@@ -0,0 +1 @@
1
+ <hr>
@@ -1,20 +1,9 @@
1
- <% @articles.each do |article| %>
2
- <article>
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>
10
- </article>
11
- <br>
12
- <% end %>
13
-
14
- <br>
15
-
16
- <% if policy(Bongo::Article).create? %>
17
- <%= link_to new_article_path do %>
18
- <b>New Article</b>
1
+ <header>
2
+ <% if policy(Bongo::Article).create? %>
3
+ <%= link_to drafts_url do %>
4
+ <i>Drafts</i>
5
+ <% end %>
19
6
  <% end %>
20
- <% end %>
7
+ </header>
8
+
9
+ <%= render(collection: @articles, partial: 'article', spacer_template: "hr", cached: true) || "There are no articles yet." %>
@@ -1,27 +1,19 @@
1
- <article>
2
- <header>
3
- <h2><%= @article.title %></h2>
4
- <small><%= @article.publish_at ? l(@article.publish_at, format: :long) : "Unpublished draft"%></small>
5
- </header>
1
+ <%= render @article %>
6
2
 
7
- <div class="trix-content">
8
- <%= @article.text.html_safe %>
9
- </div>
10
-
11
- <footer>
12
- <% if policy(@article).update? %>
13
- <%= link_to edit_article_path(@article) do %>
14
- <b>Edit</b>
15
- <% end %>
3
+ <footer>
4
+ <% if policy(@article).update? %>
5
+ <%= link_to edit_article_path(@article) do %>
6
+ <b>Edit</b>
16
7
  <% end %>
8
+ <% end %>
17
9
 
18
- <% if policy(@article).destroy? %>
19
- <%= link_to @article, method: :delete, data: {confirm: "Are you sure?"} do %>
20
- <em>Delete</em>
21
- <% end %>
10
+ <% if policy(@article).destroy? %>
11
+ <%= link_to @article, method: :delete, data: {confirm: "Are you sure?"} do %>
12
+ <em>Delete</em>
22
13
  <% end %>
14
+ <% end %>
23
15
 
24
- <br>
25
- <%= link_to 'Back', articles_path %>
26
- </footer>
27
- </article>
16
+ <%= link_to articles_path do %>
17
+ <i>Back</i>
18
+ <% end %>
19
+ </footer>
@@ -0,0 +1,16 @@
1
+ <header>
2
+ <% if policy(Bongo::Article).create? %>
3
+ <%= link_to new_article_path do %>
4
+ <b>New Article</b>
5
+ <% end %>
6
+ <% end %>
7
+ </header>
8
+
9
+ <ul>
10
+ <% @drafts.each do |draft| %>
11
+ <li>
12
+ <%= link_to draft.title, draft %><br>
13
+ <small>last modified <%= distance_of_time_in_words_to_now(draft.updated_at) %> ago</small>
14
+ </li>
15
+ <% end %>
16
+ </ul>
@@ -1,5 +1,6 @@
1
1
  Bongo::Engine.routes.draw do
2
2
  root to: "articles#index"
3
3
  resources :articles
4
+ resources :drafts
4
5
  resources :files, only: :create
5
6
  end
@@ -1,3 +1,4 @@
1
+ require "mongoid_slug"
1
2
  require "bongo/engine"
2
3
 
3
4
  module Bongo
@@ -1,3 +1,3 @@
1
1
  module Bongo
2
- VERSION = '0.1.1'
2
+ VERSION = "0.2.0"
3
3
  end
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.1.1
4
+ version: 0.2.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-30 00:00:00.000000000 Z
11
+ date: 2020-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: 7.0.5
41
+ - !ruby/object:Gem::Dependency
42
+ name: mongoid-slug
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '6'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '6'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: aws-sdk-s3
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -84,6 +98,7 @@ files:
84
98
  - app/assets/stylesheets/bongo/trix.css
85
99
  - app/controllers/bongo/application_controller.rb
86
100
  - app/controllers/bongo/articles_controller.rb
101
+ - app/controllers/bongo/drafts_controller.rb
87
102
  - app/controllers/bongo/files_controller.rb
88
103
  - app/helpers/bongo/application_helper.rb
89
104
  - app/helpers/bongo/articles_helper.rb
@@ -91,13 +106,16 @@ files:
91
106
  - app/mailers/bongo/application_mailer.rb
92
107
  - app/models/bongo/article.rb
93
108
  - app/policies/bongo/article_policy.rb
109
+ - app/views/bongo/articles/_article.html.erb
94
110
  - app/views/bongo/articles/_form.html.erb
111
+ - app/views/bongo/articles/_hr.html
95
112
  - app/views/bongo/articles/_notice.html.erb
96
113
  - app/views/bongo/articles/edit.html.erb
97
114
  - app/views/bongo/articles/index.html.erb
98
115
  - app/views/bongo/articles/index.rss.builder
99
116
  - app/views/bongo/articles/new.html.erb
100
117
  - app/views/bongo/articles/show.html.erb
118
+ - app/views/bongo/drafts/index.html.erb
101
119
  - app/views/layouts/bongo/application.html.erb
102
120
  - config/routes.rb
103
121
  - lib/bongo.rb