my_forum 0.0.1.beta56 → 0.0.1.beta57
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/stylesheets/my_forum/posts.css.scss +13 -0
- data/app/controllers/my_forum/posts_controller.rb +16 -0
- data/app/models/my_forum/forum.rb +2 -3
- data/app/views/my_forum/posts/edit.html.haml +31 -0
- data/app/views/my_forum/topics/_post.haml +8 -3
- data/app/views/my_forum/topics/_topic_header.haml +1 -1
- data/config/locales/ru.yml +7 -0
- data/db/migrate/20160214085201_add_edited_by_for_post.rb +5 -0
- data/lib/my_forum/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 27cb7d7f0bb08f12f2d2668c46bed635e33dcd83
|
4
|
+
data.tar.gz: d3692ef0a7cce204f15e70d42d9b11188dc7dfa1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1c95c056ade0b979bcb1c8bd3bfa15903d189a1809327d26702b3d21bd5f38c001971aa92f3f4b1afcbe1a53206b7f507cf29ef3953af2fcef268ad64f95b9c7
|
7
|
+
data.tar.gz: 34ac695ce54b8722794f1f8bd4f717e684318e45eab28a8e358554600fee60b3e0f9441edfdb3490bc2107601f22431fcc7f99057c82d3e967aab1cc330df65e
|
@@ -72,6 +72,13 @@
|
|
72
72
|
border: 1px solid black;
|
73
73
|
}
|
74
74
|
|
75
|
+
.edited_by {
|
76
|
+
padding: 10px 40px;
|
77
|
+
font-size: 10px;
|
78
|
+
font-weight: bold;
|
79
|
+
font-style: italic;
|
80
|
+
}
|
81
|
+
|
75
82
|
.bbqoute {
|
76
83
|
|
77
84
|
.quote_info {
|
@@ -123,3 +130,9 @@
|
|
123
130
|
#quick_answer {
|
124
131
|
margin: 26px 0;
|
125
132
|
}
|
133
|
+
|
134
|
+
#edit-post {
|
135
|
+
textarea {
|
136
|
+
width: 100%;
|
137
|
+
}
|
138
|
+
}
|
@@ -2,6 +2,7 @@ require_dependency "my_forum/application_controller"
|
|
2
2
|
|
3
3
|
module MyForum
|
4
4
|
class PostsController < ApplicationController
|
5
|
+
before_filter :verify_admin, only: [:edit, :update]
|
5
6
|
before_filter :find_topic, except: [:show, :preview]
|
6
7
|
before_filter :find_forum, except: [:show, :preview]
|
7
8
|
|
@@ -34,6 +35,21 @@ module MyForum
|
|
34
35
|
end
|
35
36
|
end
|
36
37
|
|
38
|
+
def edit
|
39
|
+
@forum = Forum.find(params[:forum_id])
|
40
|
+
@topic = Topic.find(params[:topic_id])
|
41
|
+
@post = Post.find(params[:id])
|
42
|
+
end
|
43
|
+
|
44
|
+
def update
|
45
|
+
post = Post.find(params[:id])
|
46
|
+
post.text = params[:post][:text]
|
47
|
+
post.edited_by = current_user.login
|
48
|
+
post.save
|
49
|
+
|
50
|
+
redirect_to forum_topic_path(post.topic.forum, post.topic, page: params[:page])
|
51
|
+
end
|
52
|
+
|
37
53
|
def preview
|
38
54
|
preview_html = ActionController::Base.helpers.sanitize format_bbcode(params[:text])
|
39
55
|
render '/my_forum/shared/post_preview.js.coffee', layout: false, locals: { preview_html: preview_html }
|
@@ -8,11 +8,10 @@ module MyForum
|
|
8
8
|
return false unless current_user
|
9
9
|
|
10
10
|
latest_post_ids = self.topics.where('latest_post_created_at >= ?', current_user.created_at).pluck(:latest_post_id)
|
11
|
-
read_log =
|
11
|
+
read_log = []
|
12
|
+
read_log = LogReadMark.where("user_id = ? AND post_id IN (?)", current_user.id, latest_post_ids).pluck(:post_id) unless latest_post_ids.blank?
|
12
13
|
|
13
14
|
!(latest_post_ids - read_log).empty?
|
14
|
-
#latest_post_ids.length != read_log
|
15
|
-
#read_log >= latest_post_ids.length
|
16
15
|
end
|
17
16
|
|
18
17
|
# Forum index page
|
@@ -0,0 +1,31 @@
|
|
1
|
+
%h2= t('.edit_post_in', topic_name: @topic.name)
|
2
|
+
|
3
|
+
#edit-post
|
4
|
+
= form_for @post, url: forum_topic_post_path(@forum, @topic, @post, page: params[:page]), role: 'form' do |form|
|
5
|
+
.row
|
6
|
+
.col-md-12
|
7
|
+
.text-editor-buttons{ data: { apply_to: 'post_text' } }
|
8
|
+
%div.btn-group
|
9
|
+
=link_to '#', class: 'btn btn-default btn-sm' do
|
10
|
+
%i{ class: 'fa fa-bold' }
|
11
|
+
=link_to '#', class: 'btn btn-default btn-sm' do
|
12
|
+
%i{ class: 'fa fa-italic' }
|
13
|
+
=link_to '#', class: 'btn btn-default btn-sm' do
|
14
|
+
%i{ class: 'fa fa-strikethrough' }
|
15
|
+
=link_to '#', class: 'btn btn-default btn-sm' do
|
16
|
+
%i{ class: 'fa fa-underline' }
|
17
|
+
|
18
|
+
%div.btn-group
|
19
|
+
=link_to '#', class: 'btn btn-default btn-sm', data: { toggle: 'modal' } do
|
20
|
+
%i{ class: 'fa fa-camera-retro' }
|
21
|
+
|
22
|
+
%div.btn-group.smiles
|
23
|
+
- emoticons_list.each do |code, path|
|
24
|
+
=link_to '#', class: 'btn btn-default btn-sm smile-past' do
|
25
|
+
%img{ src: path, class: 'smile', data: { code: code } }
|
26
|
+
|
27
|
+
.form-group= form.text_area :text, placeholder: t('.post_text'), class: 'form-control', rows: 10
|
28
|
+
|
29
|
+
= form.submit class: 'btn '
|
30
|
+
|
31
|
+
= render partial: 'my_forum/shared/upload_photo', locals: { textarea: 'post_text' }
|
@@ -1,15 +1,16 @@
|
|
1
1
|
- post_counter += 1
|
2
2
|
|
3
3
|
.row.post-header{ id: "post_number_#{post_counter}"}
|
4
|
-
.col-md-
|
4
|
+
.col-md-9
|
5
5
|
%span.post_from_user_login
|
6
6
|
- user_login = post.user.try(:login)
|
7
7
|
%span.user_profile_popover{ title: user_login, data: { toggle: 'popover', content: (render partial: 'profile_popover', locals: { user: post.user })}}
|
8
8
|
= online_user_marker(user_login)
|
9
9
|
%span.login= user_login
|
10
|
-
.col-md-
|
10
|
+
.col-md-3.post_number.text-right
|
11
11
|
- # TODO optimize condition!
|
12
12
|
- if current_user and current_user.is_admin? and post.topic.posts.first != post
|
13
|
+
=link_to t('.edit'), edit_forum_topic_post_path(@forum, post.topic, post, page: params[:page]), class: 'btn btn-xs btn-info', data: { confirm: "Are you sure?" }
|
13
14
|
=link_to t('.delete'), forum_topic_post_path(@forum, post.topic, post), class: 'btn btn-xs btn-danger', method: :delete, data: { confirm: "Are you sure?" }
|
14
15
|
%button.btn.btn-xs.btn-warning.quote-post{ data: { post_id: post.id } }
|
15
16
|
=t('.quote')
|
@@ -20,4 +21,8 @@
|
|
20
21
|
.col-md-10
|
21
22
|
.created_at= t('.sent', datetime: time(post.created_at))
|
22
23
|
#post_container{ id: post.id }
|
23
|
-
= sanitize format_post_text(post)
|
24
|
+
= sanitize format_post_text(post)
|
25
|
+
|
26
|
+
-if post.edited_by
|
27
|
+
.row
|
28
|
+
.edited_by.text-right= t('.edited_by', login: post.edited_by, date: time(post.updated_at))
|
data/config/locales/ru.yml
CHANGED
@@ -110,11 +110,18 @@ ru:
|
|
110
110
|
quick_answer_preview: 'Предварительный просмотр'
|
111
111
|
advanced_answer: 'Расширенный ответ'
|
112
112
|
post:
|
113
|
+
edited_by: "Было отредактированно %{login}, %{date}"
|
113
114
|
sent: "Отправленно: %{datetime}"
|
114
115
|
number: "Сообщение #%{post_number}"
|
115
116
|
quote: 'Цитировать'
|
117
|
+
edit: 'изменить'
|
116
118
|
delete: 'удалить'
|
117
119
|
|
120
|
+
posts:
|
121
|
+
edit:
|
122
|
+
post_text: 'Текст поста'
|
123
|
+
edit_post_in: "Редактировать пост в '%{topic_name}'"
|
124
|
+
|
118
125
|
users:
|
119
126
|
signin:
|
120
127
|
sign_in_head: 'Вход на форум'
|
data/lib/my_forum/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: my_forum
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.1.
|
4
|
+
version: 0.0.1.beta57
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Vitaly Omelchenko
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02-
|
11
|
+
date: 2016-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -238,6 +238,7 @@ files:
|
|
238
238
|
- app/views/my_forum/admin/users/index.haml
|
239
239
|
- app/views/my_forum/forums/_topic_subject.html.haml
|
240
240
|
- app/views/my_forum/forums/show.haml
|
241
|
+
- app/views/my_forum/posts/edit.html.haml
|
241
242
|
- app/views/my_forum/private_messages/_sidebar.haml
|
242
243
|
- app/views/my_forum/private_messages/inbox.haml
|
243
244
|
- app/views/my_forum/private_messages/new.haml
|
@@ -285,6 +286,7 @@ files:
|
|
285
286
|
- db/migrate/20151221205045_my_forum_change_user_avatar.rb
|
286
287
|
- db/migrate/20160122202142_add_latest_post_info_for_topic.rb
|
287
288
|
- db/migrate/20160210130805_add_indexes_for_topics.rb
|
289
|
+
- db/migrate/20160214085201_add_edited_by_for_post.rb
|
288
290
|
- lib/my_forum.rb
|
289
291
|
- lib/my_forum/engine.rb
|
290
292
|
- lib/my_forum/version.rb
|