go_blog 0.1.0 → 0.1.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 66386a0030665aeafe236665935310fec35c7e3a
4
- data.tar.gz: 7780815768e5d48000941acec49390170c155488
3
+ metadata.gz: ef2ff35a8933badcd77abd352e849f3b27fa8056
4
+ data.tar.gz: 33c3207fe3fb8b8eb6e53bce313c9842c4c59ac9
5
5
  SHA512:
6
- metadata.gz: 0c8a3dc36c7356c1692dae49703001364e7e5061c1fadbd17158c36ca3bfccfcbab4ee25aef850c664407375eb20ab5b3202f498ce34576268b5407a216d6bce
7
- data.tar.gz: f6ec866827416f3a4060d561b749d4cd0ca138bf59365736c8999ed5b9c264a5db9122b851a3946190a220991614d7565a48c7a69fddc460bdc8c539c4c2de87
6
+ metadata.gz: 9e1321c3f1a5f6d7e29f6f9ac382f667f32748e15307a160ab10a246810477380e043147e88b6b4d70ad6e3560e9125f94d4fe066044294612e9ee0fbc5b30dc
7
+ data.tar.gz: 4c5122d2924e3cf1ebc9a110a8b3bcaa08b0221c967e18a39fdb00af544008cf9110e6fbbd47c9bad4ee248d9cb976f58da5364dcb07a35273faa8714d8c9055
@@ -1,15 +1,22 @@
1
1
  module Blog
2
2
  class PostsController < ApplicationController
3
- before_action :set_blog_post, only: [:show, :edit, :update, :destroy]
4
-
3
+ before_action :set_blog_post, only: [:show, :edit, :update, :destroy,:show_list]
4
+ before_action :authenticate_user!, except: [:list, :show_list]
5
+ load_and_authorize_resource except: [:list, :show_list,:create]
5
6
  # GET /blog/posts
6
7
  def index
7
8
  @blog_posts = Post.all
8
9
  end
9
10
 
11
+ def list
12
+ @blog_posts = Post.all
13
+ end
14
+
10
15
  # GET /blog/posts/1
11
16
  def show
12
17
  end
18
+ def show_list
19
+ end
13
20
 
14
21
  # GET /blog/posts/new
15
22
  def new
@@ -22,6 +29,7 @@ module Blog
22
29
 
23
30
  # POST /blog/posts
24
31
  def create
32
+ authorize! :create, @blog_post
25
33
  @blog_post = Post.new(blog_post_params)
26
34
 
27
35
  if @blog_post.save
@@ -4,7 +4,7 @@ module Blog
4
4
 
5
5
  def link_to_show
6
6
  h.link_to h.blog_post_path(id: self.id),
7
- class: 'tn btn-info btn-sm',
7
+ class: 'btn btn-info btn-sm',
8
8
  title: 'Visualizar',
9
9
  style: 'color: #FFF; float: none;' do
10
10
  h.content_tag :span, class: 'fa fa-search' do
@@ -12,9 +12,31 @@ module Blog
12
12
  end
13
13
  end
14
14
 
15
+ def link_to_read_more
16
+ h.link_to h.show_list_blog_posts_path(id: self.id),
17
+ class: 'btn btn-info btn-sm',
18
+ title: 'Visualizar',
19
+ style: 'color: #FFF; float: none;' do
20
+ h.content_tag :span do
21
+ 'Continue Lendo...'
22
+ end
23
+ end
24
+ end
25
+
26
+ def link_to_title
27
+ h.link_to h.show_list_blog_posts_path(id: self.id),
28
+ class: 'text-primary-dark',
29
+ title: self.title do
30
+ h.content_tag :span do
31
+ self.title
32
+ end
33
+ end
34
+ end
35
+
36
+
15
37
  def link_to_edit
16
38
  h.link_to h.edit_blog_post_path(id: self.id),
17
- class: 'tn btn-warning btn-sm',
39
+ class: 'btn btn-warning btn-sm',
18
40
  title: 'Alterar',
19
41
  style: 'color: #FFF; float: none;' do
20
42
  h.content_tag :span, class: 'fa fa-pencil' do
@@ -25,7 +47,7 @@ module Blog
25
47
  def link_to_delete
26
48
  h.link_to h.blog_post_path(id: self.id),
27
49
  method: 'delete',
28
- class: 'tn btn-danger btn-sm',
50
+ class: 'btn btn-danger btn-sm',
29
51
  title: 'Excluir',
30
52
  confirm: 'Deseja realmente excluir o registro?',
31
53
  style: 'color: #FFF; float: none;' do
@@ -1,5 +1,5 @@
1
1
  module Blog
2
2
  class Post < ApplicationRecord
3
- validates_presence_of :title, :user_id, :body
3
+ belongs_to :user
4
4
  end
5
5
  end
@@ -1,8 +1,8 @@
1
1
  <% collection.each do |resource| %>
2
2
  <tr id="<%= dom_id(resource) %>">
3
3
  <td><%= resource.title %></td>
4
- <td><%= resource.teaser %></td>
5
- <td><%= resource.body %></td>
4
+ <td><%= truncate_with_hover(resource.teaser.html_safe,30) %></td>
5
+ <td><%= truncate_with_hover(resource.body.html_safe,30) %></td>
6
6
  <td><%= resource.draft %></td>
7
7
  <td><%= resource.published_at %></td>
8
8
  <td><%= resource.user_id %></td>
@@ -0,0 +1,26 @@
1
+ <% collection.each do |resource| %>
2
+ <div class="block" id="<%= dom_id(resource) %>">
3
+ <div class="block-content">
4
+ <div class="row items-push">
5
+ <div class="col-md-4">
6
+ <a href="frontend_blog_story.php">
7
+ <img class="img-responsive" src="assets/img/photos/photo21.jpg" alt="">
8
+ </a>
9
+ </div>
10
+ <div class="col-md-12">
11
+ <div class="font-s12 push-10">
12
+ <em class="pull-right"><!--10 min--></em>
13
+ <a href="base_pages_profile.php"><%= resource.user.decorate.name %></a> <%= converte_date(resource.published_at) %>
14
+ </div>
15
+ <h4 class="text-uppercase push-10">
16
+ <%= resource.decorate.link_to_title %></h4>
17
+ <p class="push-20"><%= resource.teaser.html_safe %></p>
18
+ <div class="btn-group btn-group-sm">
19
+ <!--<a class="btn btn-default" href="javascript:void(0)"><i class="fa fa-share-alt push-5-r"></i> Compartilhar</a>-->
20
+ <%= resource.decorate.link_to_read_more %>
21
+ </div>
22
+ </div>
23
+ </div>
24
+ </div>
25
+ </div>
26
+ <% end %>
@@ -1,33 +1,32 @@
1
- <%= simple_form_for(@blog_post) do |f| %>
1
+ <%= simple_form_for @blog_post, class: "form-horizontal" do |f| %>
2
2
  <%= f.error_notification %>
3
3
 
4
- <%= f.hidden_field :user_id, id: :blog_post_user_id %>
4
+ <%= f.hidden_field :user_id, id: :blog_post_user_id, value: current_user.id %>
5
5
 
6
6
  <%= f.input :title, id: :blog_post_title %>
7
7
 
8
- <%= f.input :teaser, id: :blog_post_teaser, class: 'summernote_description', :id => 'description' %>
9
-
10
- <%= f.input :body, id: :blog_post_body, class: 'summernote_description', :id => 'description' %>
11
-
8
+ <%= f.input :teaser, as: :summernote %>
9
+ <%= f.input :body, as: :summernote %>
10
+ <%#= f.input :teaser, class: 'summernote', :id => 'blog_post_teaser' , label: false%>
11
+ <%#= f.input :body, class: 'summernote', :id => 'blog_post_body', label: false %>
12
12
  <%= f.input :draft, id: :blog_post_draft %>
13
13
 
14
14
  <%= f.input :published_at, id: :blog_post_published_at %>
15
15
 
16
-
17
16
  <%= f.input :custom_url, id: :blog_post_custom_url %>
18
17
 
19
18
 
20
19
 
21
20
  <div class="form-group form-actions">
22
- <%= link_to I18n.t('misc.action.back'), links_path, class: 'btn btn-sm btn-square btn-default' %>
21
+ <%= link_to I18n.t('misc.action.back'), blog_posts_path, class: 'btn btn-sm btn-square btn-default' %>
23
22
  <%= f.button :submit, class: 'btn btn-sm btn-square btn-primary' %>
24
23
  </div>
25
24
  <% end %>
26
25
 
27
- <script>
28
- $(document).ready(function () {
29
- $('.blog_post_teaser').summernote();
30
- $('.blog_post_body').summernote();
26
+ <script type="text/javascript">
27
+ $(document).ready(function() {
28
+ $('#blog_post_teaser').summernote();
29
+ $('#blog_post_body').summernote();
31
30
  });
32
31
  </script>
33
32
 
@@ -0,0 +1,157 @@
1
+ <main id="main-container" style="min-height: 190px;"><div class="bg-primary-dark">
2
+ <section class="content content-full content-boxed overflow-hidden">
3
+ <div class="push-100-t push-50 text-center">
4
+ <h1 class="h2 text-white push-10 animated fadeInDown" data-toggle="appear" data-class="animated fadeInDown">As Últimas Notícias Para você .</h1>
5
+ <h2 class="h5 text-white-op animated fadeInDown" data-toggle="appear" data-class="animated fadeInDown">Explore.</h2>
6
+ </div>
7
+ </section>
8
+ </div>
9
+ <section class="content content-boxed">
10
+ <div class="push-50-t push-50">
11
+ <div class="row">
12
+ <div class="col-md-12">
13
+
14
+
15
+
16
+
17
+ <%= render 'collection_list', collection: @blog_posts %>
18
+
19
+
20
+
21
+
22
+ <!--<nav>-->
23
+ <!--<ul class="pagination">-->
24
+ <!--<li class="active">-->
25
+ <!--<a href="javascript:void(0)">1</a>-->
26
+ <!--</li>-->
27
+ <!--<li>-->
28
+ <!--<a href="javascript:void(0)">2</a>-->
29
+ <!--</li>-->
30
+ <!--<li>-->
31
+ <!--<a href="javascript:void(0)">3</a>-->
32
+ <!--</li>-->
33
+ <!--<li>-->
34
+ <!--<a href="javascript:void(0)">4</a>-->
35
+ <!--</li>-->
36
+ <!--<li>-->
37
+ <!--<a href="javascript:void(0)">5</a>-->
38
+ <!--</li>-->
39
+ <!--<li>-->
40
+ <!--<a href="javascript:void(0)"><i class="fa fa-angle-right"></i></a>-->
41
+ <!--</li>-->
42
+ <!--</ul>-->
43
+ <!--</nav>-->
44
+ </div>
45
+ <!--<div class="col-md-4">-->
46
+ <!--<div class="block">-->
47
+ <!--<div class="block-header bg-gray-lighter">-->
48
+ <!--<h3 class="block-title">Search</h3>-->
49
+ <!--</div>-->
50
+ <!--<div class="block-content block-content-full">-->
51
+ <!--<form action="frontend_search.php" method="post">-->
52
+ <!--<div class="input-group input-group-lg">-->
53
+ <!--<input class="form-control" type="text" placeholder="Type and hit enter..">-->
54
+ <!--<div class="input-group-btn">-->
55
+ <!--<button class="btn btn-default"><i class="fa fa-search"></i></button>-->
56
+ <!--</div>-->
57
+ <!--</div>-->
58
+ <!--</form>-->
59
+ <!--</div>-->
60
+ <!--</div>-->
61
+ <!--<a class="block block-link-hover3" href="base_pages_profile.php">-->
62
+ <!--<div class="block-header bg-gray-lighter">-->
63
+ <!--<h3 class="block-title">About</h3>-->
64
+ <!--</div>-->
65
+ <!--<div class="block-content block-content-full text-center">-->
66
+ <!--<div>-->
67
+ <!--<img class="img-avatar img-avatar96" src="assets/img/avatars/avatar1.jpg" alt="">-->
68
+ <!--</div>-->
69
+ <!--<div class="h5 push-15-t push-5">Ann Parker</div>-->
70
+ <!--<div class="font-s13 text-muted">Publisher</div>-->
71
+ <!--</div>-->
72
+ <!--<div class="block-content border-t">-->
73
+ <!--<div class="row items-push text-center">-->
74
+ <!--<div class="col-xs-6">-->
75
+ <!--<div class="push-5"><i class="si si-pencil fa-2x"></i></div>-->
76
+ <!--<div class="h5 font-w300 text-muted">350 Stories</div>-->
77
+ <!--</div>-->
78
+ <!--<div class="col-xs-6">-->
79
+ <!--<div class="push-5"><i class="si si-users fa-2x"></i></div>-->
80
+ <!--<div class="h5 font-w300 text-muted">1.5k Followers</div>-->
81
+ <!--</div>-->
82
+ <!--</div>-->
83
+ <!--</div>-->
84
+ <!--</a>-->
85
+ <!--<div class="block">-->
86
+ <!--<div class="block-header bg-gray-lighter">-->
87
+ <!--<ul class="block-options">-->
88
+ <!--<li>-->
89
+ <!--<button type="button" data-toggle="block-option" data-action="refresh_toggle" data-action-mode="demo"><i class="si si-refresh"></i></button>-->
90
+ <!--</li>-->
91
+ <!--</ul>-->
92
+ <!--<h3 class="block-title">Recent Comments</h3>-->
93
+ <!--</div>-->
94
+ <!--<div class="block-content">-->
95
+ <!--<ul class="list list-simple">-->
96
+ <!--<li>-->
97
+ <!--<div class="push-5 clearfix">-->
98
+ <!--<span class="font-s13 text-muted push-10-l pull-right">25 min ago</span>-->
99
+ <!--<a class="font-w600" href="base_pages_profile.php">Sara Holland</a> on <a href="frontend_blog_story.php">Exploring the Alps</a>-->
100
+ <!--</div>-->
101
+ <!--<div class="font-s13">Awesome trip! Looking forward going there, I'm sure it will be a great experience!</div>-->
102
+ <!--</li>-->
103
+ <!--<li>-->
104
+ <!--<div class="push-5 clearfix">-->
105
+ <!--<span class="font-s13 text-muted push-10-l pull-right">42 min ago</span>-->
106
+ <!--<a class="font-w600" href="base_pages_profile.php">Joshua Munoz</a> on <a href="frontend_blog_story.php">Travel &amp; Work</a>-->
107
+ <!--</div>-->
108
+ <!--<div class="font-s13">Thank you for sharing your story with us! I really appreciate the info, it will come in handy for sure!</div>-->
109
+ <!--</li>-->
110
+ <!--<li>-->
111
+ <!--<div class="push-5 clearfix">-->
112
+ <!--<span class="font-s13 text-muted push-10-l pull-right">53 min ago</span>-->
113
+ <!--<a class="font-w600" href="base_pages_profile.php">Lisa Gordon</a> on <a href="frontend_blog_story.php">Black &amp; White</a>-->
114
+ <!--</div>-->
115
+ <!--<div class="font-s13">Really touching story.. I'm so happy everything went well at the end!</div>-->
116
+ <!--</li>-->
117
+ <!--<li>-->
118
+ <!--<div class="push-5 clearfix">-->
119
+ <!--<span class="font-s13 text-muted push-10-l pull-right">2 days ago</span>-->
120
+ <!--<a class="font-w600" href="base_pages_profile.php">George Stone</a> on <a href="frontend_blog_story.php">Sleep Better</a>-->
121
+ <!--</div>-->
122
+ <!--<div class="font-s13">Great advice! Thanks for sharing, I'm sure it will help many people sleep better and improve their lifes.</div>-->
123
+ <!--</li>-->
124
+ <!--</ul>-->
125
+ <!--<div class="text-center push">-->
126
+ <!--<small><a href="javascript:void(0)">Read More..</a></small>-->
127
+ <!--</div>-->
128
+ <!--</div>-->
129
+ <!--</div>-->
130
+ <!--<div class="block">-->
131
+ <!--<div class="block-header bg-gray-lighter">-->
132
+ <!--<h3 class="block-title">Social</h3>-->
133
+ <!--</div>-->
134
+ <!--<div class="block-content block-content-full">-->
135
+ <!--<div class="btn-group">-->
136
+ <!--<a class="btn btn-default" href="javascript:void(0)" data-toggle="tooltip" title="" data-original-title="Follow us on Twitter"><i class="fa fa-fw fa-twitter"></i></a>-->
137
+ <!--<a class="btn btn-default" href="javascript:void(0)" data-toggle="tooltip" title="" data-original-title="Like our Facebook page"><i class="fa fa-fw fa-facebook"></i></a>-->
138
+ <!--<a class="btn btn-default" href="javascript:void(0)" data-toggle="tooltip" title="" data-original-title="Follow us on Google Plus"><i class="fa fa-fw fa-google-plus"></i></a>-->
139
+ <!--<a class="btn btn-default" href="javascript:void(0)" data-toggle="tooltip" title="" data-original-title="Follow us on Dribbble"><i class="fa fa-fw fa-dribbble"></i></a>-->
140
+ <!--<a class="btn btn-default" href="javascript:void(0)" data-toggle="tooltip" title="" data-original-title="Subscribe on Youtube"><i class="fa fa-fw fa-youtube"></i></a>-->
141
+ <!--</div>-->
142
+ <!--</div>-->
143
+ <!--</div>-->
144
+ <!--</div>-->
145
+ </div>
146
+ </div>
147
+ </section>
148
+ <div class="bg-primary-dark">
149
+ <section class="content content-full content-boxed">
150
+ <div class="push-20-t push-20 text-center">
151
+ <h3 class="h4 text-white-op push-20 visibility-hidden" data-toggle="appear"> <strong></strong> </h3>
152
+ <!--<a class="btn btn-rounded btn-noborder btn-lg btn-success visibility-hidden" data-toggle="appear" data-class="animated bounceIn" href="frontend_pricing.php">Get Started Today</a>-->
153
+ </div>
154
+ </section>
155
+ </div>
156
+ </main>
157
+
@@ -39,12 +39,12 @@
39
39
 
40
40
  <tr>
41
41
  <td><strong><%= t 'activerecord.attributes.blog_post.teaser' %>:</strong></td>
42
- <td><%= @blog_post.teaser %></td>
42
+ <td><%= @blog_post.teaser.html_safe %></td>
43
43
  </tr>
44
44
 
45
45
  <tr>
46
46
  <td><strong><%= t 'activerecord.attributes.blog_post.body' %>:</strong></td>
47
- <td><%= @blog_post.body %></td>
47
+ <td><%= @blog_post.body.html_safe %></td>
48
48
  </tr>
49
49
 
50
50
  <tr>
@@ -0,0 +1,28 @@
1
+
2
+ <main id="main-container" style="min-height: 190px;"><div class="bg-image" style="background-image: url('<%=asset_path "railswall.jpg"%>');">
3
+ <div class="bg-primary-op">
4
+ <section class="content content-full content-boxed overflow-hidden">
5
+ <div class="push-150-t push-150 text-center">
6
+ <h1 class="text-white push-10 animated fadeInDown" data-toggle="appear" data-class="animated fadeInDown"><%= @blog_post.title %></h1>
7
+ </div>
8
+ </section>
9
+ </div>
10
+ </div>
11
+ <div class="bg-white">
12
+ <section class="content content-boxed">
13
+ <div class="text-center">
14
+ <a class="link-effect font-s13 font-w600" href="javascript:void(0)"><%= @blog_post.user.decorate.name %></a> <%= converte_date(@blog_post.published_at) %> <em></em>
15
+ </div>
16
+ <div class="row push-50-t push-50 nice-copy-story">
17
+ <div class="col-sm-8 col-sm-offset-2">
18
+ <p><%= @blog_post.body.html_safe %></p>
19
+
20
+
21
+ </div>
22
+ </div>
23
+ </section>
24
+ </div>
25
+
26
+ </main>
27
+
28
+
data/config/routes.rb CHANGED
@@ -1,5 +1,10 @@
1
1
  Rails.application.routes.draw do
2
2
  namespace :blog do
3
- resources :posts
3
+ resources :posts do
4
+ collection do
5
+ get 'list'
6
+ get 'show_list'
7
+ end
8
+ end
4
9
  end
5
10
  end
@@ -1,3 +1,3 @@
1
1
  module GoBlog
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: go_blog
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - João Carlos Ottobboni
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-08 00:00:00.000000000 Z
11
+ date: 2017-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: draper
@@ -87,11 +87,14 @@ files:
87
87
  - app/models/blog.rb
88
88
  - app/models/blog/post.rb
89
89
  - app/views/blog/posts/_collection.html.erb
90
+ - app/views/blog/posts/_collection_list.html.erb
90
91
  - app/views/blog/posts/_form.html.erb
91
92
  - app/views/blog/posts/edit.html.erb
92
93
  - app/views/blog/posts/index.html.erb
94
+ - app/views/blog/posts/list.html.erb
93
95
  - app/views/blog/posts/new.html.erb
94
96
  - app/views/blog/posts/show.html.erb
97
+ - app/views/blog/posts/show_list.html.erb
95
98
  - config/routes.rb
96
99
  - db/migrate/20171008203759_create_blog_posts.rb
97
100
  - lib/go_blog.rb