c80_news_tz 0.1.1.24 → 0.1.1.25

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
  SHA1:
3
- metadata.gz: 99c3ec7555759f8106b24a68a7268a991f371f22
4
- data.tar.gz: 0c754f360cfb235f5c93fb862b8b13d1775f0e7f
3
+ metadata.gz: fdfca018b811d2190fc6420436a90d426d882cd5
4
+ data.tar.gz: 5a2b40535b355d269a916a3eda96804bd81bb770
5
5
  SHA512:
6
- metadata.gz: d539c98a390d1d0b3a6496ac8daacde71affae08308ca6d6584686870abb94daab0d76d90753238bad67bd086df494c847b0cd5f2ad934bc69fb8d841d393afd
7
- data.tar.gz: bbff23e19172c63569c4b084bf8565d3dadcc77a29b82de00ed386aa6feedc43eb8f740e73f55c66ea8b518de701c0a57370bcf1956d7363de69617a5966bf0f
6
+ metadata.gz: 47bbaf4ff2f8189eed4ac55ed419a5caaadcfbe32f58ef6c5d40e045d31ed9dec7fbb195afb31a0fa87d33cc0c328a592df0bd7a44b12a55652c0a002cc6aeba
7
+ data.tar.gz: afe2294ccbc9e0312f4e56d5404994fa26247ea518fd9370df5d1e33faa8d74cda3bba0c9c64afdd0650358674e0ff7957ec55ed7cb039b5e4fcc73e36ec0a7f
@@ -47,9 +47,10 @@ function comment_show_form() {
47
47
  $form.attr('action', '/comments.js');
48
48
  } else {
49
49
  var $social = $("#social_buttons");
50
- $social.attr('id','social_buttons_2');
51
- $social.find('p').text('Чтобы иметь возможность оставлять комментарии, пожалуйста, авторизуйтесь через:');
52
- $placeholder.append($social.clone());
50
+ var $social_cloned = $social.clone();
51
+ $social_cloned.attr('id','social_buttons_2');
52
+ $social_cloned.find('p').text('Чтобы иметь возможность оставлять комментарии, пожалуйста, авторизуйтесь через:');
53
+ $placeholder.append($social_cloned);
53
54
  }
54
55
  return false
55
56
  }
@@ -1,6 +1,8 @@
1
1
  module C80NewsTz
2
2
  class CommentsController < ApplicationController
3
3
 
4
+ before_action :check_comments_enabled
5
+
4
6
  def create
5
7
 
6
8
  mark_spam = false
@@ -35,16 +37,26 @@ module C80NewsTz
35
37
 
36
38
  end
37
39
 
40
+ private
41
+
38
42
  def comment_params
39
43
  params.require(:comment).permit(:message, :user_id, :fact_id, :r_blurb_id)
40
44
  end
41
45
 
42
- private
43
46
 
44
47
  def update_user_last_comment(user)
45
48
  user.last_comment_ts = Time.now.to_i
46
49
  user.save
47
50
  end
48
51
 
52
+ def check_comments_enabled
53
+ comments_enabled = CommentsProps.find(1).comments_enabled
54
+ unless comments_enabled
55
+ respond_to do |format|
56
+ format.js { render :action => 'comments_disabled' }
57
+ end
58
+ end
59
+ end
60
+
49
61
  end
50
62
  end
@@ -2,7 +2,7 @@ module C80NewsTz
2
2
  module CommentsHelper
3
3
 
4
4
  # рендер блока с комментариями к публикации
5
- def render_comments_block(blurb_or_fact, current_user = nil)
5
+ def render_comments_block(blurb_or_fact, current_user = nil, comments_enabled = true)
6
6
 
7
7
  n = blurb_or_fact.comments.count
8
8
  # list = [
@@ -61,7 +61,8 @@ module C80NewsTz
61
61
  :form_params => {
62
62
  :current_user => current_user,
63
63
  :r_blurb_id => r_blurb_id,
64
- :fact_id => fact_id
64
+ :fact_id => fact_id,
65
+ :comments_enabled => comments_enabled
65
66
  }
66
67
  }
67
68
  end
@@ -84,13 +85,15 @@ module C80NewsTz
84
85
 
85
86
  # рендер формы либо отправки комментария, либо ответа на комментарий
86
87
  def render_comment_form(options)
87
- unless options[:current_user].nil?
88
- render :partial => "c80_news_tz/comments/shared/reply_comment_form",
89
- :locals => {
90
- current_user_id: options[:current_user].id,
91
- r_blurb_id: options[:r_blurb_id],
92
- fact_id: options[:fact_id]
93
- }
88
+ if options[:comments_enabled]
89
+ unless options[:current_user].nil?
90
+ render :partial => "c80_news_tz/comments/shared/reply_comment_form",
91
+ :locals => {
92
+ current_user_id: options[:current_user].id,
93
+ r_blurb_id: options[:r_blurb_id],
94
+ fact_id: options[:fact_id]
95
+ }
96
+ end
94
97
  end
95
98
  end
96
99
 
File without changes
@@ -0,0 +1,5 @@
1
+ module C80NewsTz
2
+ class CommentsProps < ActiveRecord::Base
3
+
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ var $form = $('form#comment_form');
2
+ if ($form.length) {
3
+ var $error_text = $form.find("span#error_text");
4
+ var $message = $('<span>Возможность комментирования временно отключена, на сайте ведутся технические работы.</span>');
5
+ $error_text.text("");
6
+ $error_text.append($message);
7
+ }
@@ -9,9 +9,10 @@
9
9
  <%= link_to image_tag(comment.user.image_url, :alt => comment.user_name),
10
10
  comment.user.url,
11
11
  :title => comment.user_name,
12
- :class => 'avatar'
12
+ :class => 'avatar',
13
+ :target => '_blank'
13
14
  %>
14
- <%= link_to comment.user_name, comment.user.url, :class => 'username' %>
15
+ <%= link_to comment.user_name, comment.user.url, class:'username', title:comment.user_name, target:'_blank' %>
15
16
  </span>
16
17
 
17
18
  <%# время комментария %>
@@ -5,9 +5,11 @@
5
5
  <%= render_comments_list(comments_list) %>
6
6
  </ul>
7
7
 
8
- <h2 class="write_comment">
9
- <%= link_to "Написать комментарий", "#", onclick: 'return comment_show_form()' %>
10
- </h2>
8
+ <% if form_params[:comments_enabled] %>
9
+ <h2 class="write_comment">
10
+ <%= link_to "Написать комментарий", "#", onclick: 'return comment_show_form()' %>
11
+ </h2>
12
+ <% end %>
11
13
 
12
14
  <div id="comment_form_placeholder"></div>
13
15
 
@@ -8,7 +8,7 @@
8
8
  </div>
9
9
  </div>
10
10
  <div class="buttons">
11
- <%= f.submit :id => 'comment_submit', class: 'btn btn-default', disabled:'disabled' %>
11
+ <%= f.submit 'Отправить', id: 'comment_submit', class: 'btn btn-default', disabled:'disabled' %>
12
12
  <span id="error_text" class="error"></span>
13
13
  </div>
14
14
  <% end %>
@@ -0,0 +1,10 @@
1
+ class CreateCommentsProps < ActiveRecord::Migration
2
+ def change
3
+ create_table :c80_news_tz_comments_props, :options => 'COLLATE=utf8_unicode_ci' do |t|
4
+ t.integer :anitspam_delay
5
+ t.boolean :comments_enabled
6
+
7
+ t.timestamps null: false
8
+ end
9
+ end
10
+ end
@@ -1,3 +1,3 @@
1
1
  module C80NewsTz
2
- VERSION = "0.1.1.24"
2
+ VERSION = "0.1.1.25"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: c80_news_tz
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1.24
4
+ version: 0.1.1.25
5
5
  platform: ruby
6
6
  authors:
7
7
  - C80609A
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-03-30 00:00:00.000000000 Z
11
+ date: 2016-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -150,8 +150,9 @@ files:
150
150
  - app/models/c80_news_tz/banner02.rb
151
151
  - app/models/c80_news_tz/banner03.rb
152
152
  - app/models/c80_news_tz/banner_validator.rb
153
+ - app/models/c80_news_tz/comment.rb
153
154
  - app/models/c80_news_tz/comment_validator.rb
154
- - app/models/c80_news_tz/comments.rb
155
+ - app/models/c80_news_tz/comments_props.rb
155
156
  - app/models/c80_news_tz/company.rb
156
157
  - app/models/c80_news_tz/cphoto.rb
157
158
  - app/models/c80_news_tz/fact.rb
@@ -187,6 +188,7 @@ files:
187
188
  - app/views/c80_news_tz/application/guru.js.erb
188
189
  - app/views/c80_news_tz/banners/counter.html.erb
189
190
  - app/views/c80_news_tz/comments/antispam.js.erb
191
+ - app/views/c80_news_tz/comments/comments_disabled.js.erb
190
192
  - app/views/c80_news_tz/comments/created.js.erb
191
193
  - app/views/c80_news_tz/comments/shared/_comment_item.html.erb
192
194
  - app/views/c80_news_tz/comments/shared/_comments_block.html.erb
@@ -241,6 +243,7 @@ files:
241
243
  - db/migrate/20160314093946_add_users_indexes.rb
242
244
  - db/migrate/20160325122727_create_comments.rb
243
245
  - db/migrate/20160330152627_add_antispam_last_comment_ts_to_users.rb
246
+ - db/migrate/20160331103030_create_comments_props.rb
244
247
  - db/seeds/19_fill_news_props.rb.example
245
248
  - db/seeds/20_fill_rubrics.rb.example
246
249
  - db/seeds/21_fill_facts.rb.example