my_forum 0.0.1.beta8 → 0.0.1.beta9

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: 9cc43fd34c90373024f8b0db296d9aaa4578aa9e
4
- data.tar.gz: e6843ae240c19ed657d2b281be89be6a218ec90f
3
+ metadata.gz: 15f3d8458ba75bf60cea62853b7253c7dd1ad637
4
+ data.tar.gz: d9d3a429871206dc06b4d446a04401955df29070
5
5
  SHA512:
6
- metadata.gz: 423fd0a4e3dd7d74d7f111a4eb38a365134ab85db3b273128503146e68f749ca9dbd4b2f1e5a244d09eb0b09d8b271acd18fcbd532c96484165fc48698395089
7
- data.tar.gz: 54899113f69ee3cebcb701ff26471000d33a12ef17fa9a313a4cf95adbb927f852d9149379c245400ea361930202b9c639300d9cc15caed29d3c92a0e3041faf
6
+ metadata.gz: 05cbbc2f3e37f93f026de0e4945d9d68c5d60d4e0316783fff75ea8b647c58fe76c319459748c1a7407819fe59ec60e388a3d6b168f7f91dc4131f471f888b3b
7
+ data.tar.gz: 424d15c63e41e54fa179b18e8b6cfc1aaea8659e66a7fa3eb1282752a857fdba57594c625f32f7ea1a2bc6eb7f9d1647dfc75b070cace571c37e2357ab125b0f
@@ -61,6 +61,12 @@
61
61
  }
62
62
  }
63
63
 
64
+ #recent_topics {
65
+ table {
66
+ font-size: 10px;
67
+ }
68
+ }
69
+
64
70
  #online_users {
65
71
  margin: 20px 0;
66
72
  font-size: 10px
@@ -30,6 +30,19 @@ module MyForum
30
30
  end
31
31
  helper_method :new_pm_count
32
32
 
33
+ def forum_time(time)
34
+ local_time = time.localtime
35
+
36
+ if local_time.to_date == Time.now.to_date
37
+ return t('my_forum.today', hhmm: local_time.strftime('%H:%M'))
38
+ elsif local_time.to_date == (Time.now - 1.day).to_date
39
+ return t('my_forum.yerstaday ', hhmm: local_time.strftime('%H:%M'))
40
+ end
41
+
42
+ local_time.strftime('%Y-%m-%d %H:%M')
43
+ end
44
+ helper_method :forum_time
45
+
33
46
  private
34
47
 
35
48
  def user_activity
@@ -7,6 +7,17 @@ module MyForum
7
7
 
8
8
  @forum_categories = Category.includes(:forums, :user_groups).
9
9
  reject{|category| (category.user_groups.map(&:name) & (current_user_groups)).blank? }
10
+
11
+
12
+ # Don`r forget permissions
13
+ available_forum_ids = MyForum::Forum.where(category_id: @forum_categories.map(&:id)).pluck(:id)
14
+ @recent_topics = Topic.find_by_sql("
15
+ SELECT my_forum_topics.* FROM my_forum_topics
16
+ JOIN my_forum_forums ON my_forum_forums.id = my_forum_topics.forum_id
17
+ WHERE my_forum_forums.id IN (#{available_forum_ids.join(',')})
18
+ ORDER BY my_forum_topics.updated_at DESC limit 10
19
+ ")
20
+
10
21
  end
11
22
  end
12
23
  end
@@ -35,8 +35,9 @@ module MyForum
35
35
  content_tag :div, obj.errors.full_messages.to_sentence, class: 'errors_for'
36
36
  end
37
37
 
38
+ # TODO deprecate!
38
39
  def time(datetime)
39
- datetime.strftime('%T %F')
40
+ forum_time(datetime)
40
41
  end
41
42
 
42
43
  end
@@ -19,7 +19,7 @@ module MyForum
19
19
 
20
20
  def forum_stat(forum)
21
21
  html = content_tag(:div, t('.topics_count', topics_count: forum.topics_count))
22
- html += content_tag(:div, t('.messages_count', messages_count: forum.topics_count))
22
+ html += content_tag(:div, t('.messages_count', messages_count: forum.posts_count))
23
23
  html.html_safe
24
24
  end
25
25
 
@@ -27,8 +27,9 @@ module MyForum
27
27
  info = forum.latest_topic_info
28
28
 
29
29
  html = content_tag(:div, info ? (t('.last_answer_from') + info.user_login) : '-' )
30
- html += content_tag(:div, info ? (t('.in_forum') + info.topic_name) : '-' )
31
- html += content_tag(:div, info ? info.post_created_at : '-' )
30
+ html += content_tag(:div, info ? (link_to((t('.in_forum') + info.topic_name), forum_topic_path(info.forum_id, info.id))) : '-' )
31
+ html += content_tag(:div, info ? forum_time(info.post_created_at) : '-' )
32
+
32
33
  html.html_safe
33
34
  end
34
35
 
@@ -2,7 +2,7 @@ module MyForum
2
2
  module TopicsHelper
3
3
 
4
4
  def topic_last_post_info(topic)
5
- html = content_tag(:div, time(topic.last_post_time))
5
+ html = content_tag(:div, forum_time(topic.last_post_time))
6
6
  html += content_tag(:div, topic.last_post_user_login)
7
7
  html.html_safe
8
8
  end
@@ -6,7 +6,12 @@ module MyForum
6
6
 
7
7
  def latest_topic_info
8
8
  Topic.find_by_sql("
9
- SELECT my_forum_topics.name AS topic_name, my_forum_posts.created_at AS post_created_at, my_forum_users.login AS user_login
9
+ SELECT
10
+ my_forum_topics.name AS topic_name,
11
+ my_forum_topics.forum_id,
12
+ my_forum_topics.id,
13
+ my_forum_posts.created_at AS post_created_at,
14
+ my_forum_users.login AS user_login
10
15
  FROM my_forum_posts
11
16
  JOIN my_forum_topics ON my_forum_topics.id = my_forum_posts.topic_id
12
17
  JOIN my_forum_users ON my_forum_posts.user_id = my_forum_users.id
@@ -13,6 +13,21 @@
13
13
  .col-md-2.col-sm-2.forum-info= forum_stat(forum)
14
14
  .col-md-3.col-sm-3.forum-last-message-info= forum_last_message_info(forum)
15
15
 
16
+ #recent_topics
17
+ %table.table
18
+ %caption= t('.recent_topics')
19
+ %thead
20
+ %tr
21
+ %th= t('.topic_name')
22
+ %th= t('.last_message_from')
23
+ %th= t('.date')
24
+ %tbody
25
+ -@recent_topics.each do |topic|
26
+ %tr
27
+ %td= link_to topic.name, forum_topic_path(topic.forum, topic)
28
+ %td= topic.posts.last.user.login
29
+ %td= forum_time(topic.updated_at)
30
+
16
31
  #online_users.well
17
32
  = t('.users_online')
18
33
  = online_users
@@ -1,5 +1,8 @@
1
1
  en:
2
2
  my_forum:
3
+ today: "Today '%{hhmm}'"
4
+ yerstaday: "Yerstaday '%{hhmm}'"
5
+
3
6
  admin:
4
7
  forums:
5
8
  index:
@@ -1,5 +1,8 @@
1
1
  ru:
2
+ today: "Сегодня"
2
3
  my_forum:
4
+ today: "Сегодня в %{hhmm}"
5
+ yerstaday: "Вчера в %{hhmm}"
3
6
  create_new_pm: 'Написать личное сообщение'
4
7
  create_new_topic: 'Создать новую тему'
5
8
  bbquote:
@@ -36,6 +39,10 @@ ru:
36
39
  in_forum: 'в '
37
40
  users_online: 'Сейчас на форуме: '
38
41
  today_online: 'Сегодня на форуме были: '
42
+ recent_topics: 'Последние сообщения'
43
+ topic_name: 'Тема:'
44
+ last_message_from: 'Последнее сообщение от:'
45
+ date: 'Дата:'
39
46
 
40
47
  forums:
41
48
  show:
@@ -1,3 +1,3 @@
1
1
  module MyForum
2
- VERSION = "0.0.1.beta8"
2
+ VERSION = "0.0.1.beta9"
3
3
  end
@@ -1,4 +1,15 @@
1
1
  namespace :my_forum do
2
+ namespace :service do
3
+ desc 'Recalculate category posts count'
4
+ task recalculate_posts_count: :environment do
5
+ MyForum::Forum.all.each do |forum|
6
+ topic_ids = MyForum::Topic.where(forum_id: forum.id).pluck(:id)
7
+ count = MyForum::Post.where(topic_id: topic_ids).count
8
+ forum.update(posts_count: count)
9
+ end
10
+ end
11
+ end
12
+
2
13
  namespace :import do
3
14
  namespace :smf do
4
15
 
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.beta8
4
+ version: 0.0.1.beta9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vitaly Omelchenko
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-15 00:00:00.000000000 Z
11
+ date: 2015-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails