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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6b99919419adc515dae69ac72fed68472de713b5
4
- data.tar.gz: fe552695d52f7bfd995b1c683dfa7a2721e9c338
3
+ metadata.gz: 27cb7d7f0bb08f12f2d2668c46bed635e33dcd83
4
+ data.tar.gz: d3692ef0a7cce204f15e70d42d9b11188dc7dfa1
5
5
  SHA512:
6
- metadata.gz: 793c9a79c2b11bb7790ca38b50e0b4f5de3baf9e91612e0e9dbdd377f8ff96361eaabb9b3c3a35753fb1fc89c7b11395e606ac314181db448a960f6d35791101
7
- data.tar.gz: e04820058000d9cc9e6b65049c7a97c04a8f049a6da625c2895a4f2c0f2d916e90d522473c68f77185a97a28dfa97825a530353e03e906c2da84a8e375d0dbb1
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 = LogReadMark.where("user_id = ? AND post_id IN (?)", current_user.id, latest_post_ids).pluck(:post_id)
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-10
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-2.post_number.text-right
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))
@@ -1,4 +1,4 @@
1
1
  .row.topic-header
2
2
  .col-md-12
3
3
  %h2= topic.name.html_safe
4
- .info= "#{topic.info[:author]}, #{topic.info[:created]}"
4
+ .info= "#{topic.info[:author]}, #{time(topic.info[:created])}"
@@ -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: 'Вход на форум'
@@ -0,0 +1,5 @@
1
+ class AddEditedByForPost < ActiveRecord::Migration
2
+ def change
3
+ add_column :my_forum_posts, :edited_by, :string, default: nil
4
+ end
5
+ end
@@ -1,3 +1,3 @@
1
1
  module MyForum
2
- VERSION = "0.0.1.beta56"
2
+ VERSION = "0.0.1.beta57"
3
3
  end
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.beta56
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-10 00:00:00.000000000 Z
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