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 +4 -4
- data/app/assets/stylesheets/my_forum/welcome.css.scss +6 -0
- data/app/controllers/my_forum/application_controller.rb +13 -0
- data/app/controllers/my_forum/welcome_controller.rb +11 -0
- data/app/helpers/my_forum/application_helper.rb +2 -1
- data/app/helpers/my_forum/forums_helper.rb +4 -3
- data/app/helpers/my_forum/topics_helper.rb +1 -1
- data/app/models/my_forum/forum.rb +6 -1
- data/app/views/my_forum/welcome/index.haml +15 -0
- data/config/locales/en.yml +3 -0
- data/config/locales/ru.yml +7 -0
- data/lib/my_forum/version.rb +1 -1
- data/lib/tasks/my_forum_tasks.rake +11 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15f3d8458ba75bf60cea62853b7253c7dd1ad637
|
4
|
+
data.tar.gz: d9d3a429871206dc06b4d446a04401955df29070
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 05cbbc2f3e37f93f026de0e4945d9d68c5d60d4e0316783fff75ea8b647c58fe76c319459748c1a7407819fe59ec60e388a3d6b168f7f91dc4131f471f888b3b
|
7
|
+
data.tar.gz: 424d15c63e41e54fa179b18e8b6cfc1aaea8659e66a7fa3eb1282752a857fdba57594c625f32f7ea1a2bc6eb7f9d1647dfc75b070cace571c37e2357ab125b0f
|
@@ -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
|
@@ -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.
|
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
|
|
@@ -6,7 +6,12 @@ module MyForum
|
|
6
6
|
|
7
7
|
def latest_topic_info
|
8
8
|
Topic.find_by_sql("
|
9
|
-
SELECT
|
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
|
data/config/locales/en.yml
CHANGED
data/config/locales/ru.yml
CHANGED
@@ -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:
|
data/lib/my_forum/version.rb
CHANGED
@@ -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.
|
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-
|
11
|
+
date: 2015-12-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|