my_forum 0.0.1.beta60 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rdoc +1 -12
- data/Rakefile +3 -4
- data/app/assets/javascripts/my_forum/application.js +0 -6
- data/{spec/dummy/app/assets/stylesheets → app/assets/stylesheets/my_forum}/application.css +1 -1
- data/app/controllers/my_forum/application_controller.rb +0 -81
- data/app/helpers/my_forum/application_helper.rb +0 -43
- data/app/views/layouts/my_forum/application.html.erb +14 -0
- data/config/routes.rb +0 -48
- data/lib/my_forum/engine.rb +0 -31
- data/lib/my_forum/version.rb +1 -1
- data/lib/tasks/my_forum_tasks.rake +4 -155
- data/{spec → test}/dummy/README.rdoc +0 -0
- data/{spec → test}/dummy/Rakefile +0 -0
- data/{spec → test}/dummy/app/assets/javascripts/application.js +1 -1
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/{spec → test}/dummy/app/controllers/application_controller.rb +0 -0
- data/{spec → test}/dummy/app/helpers/application_helper.rb +0 -0
- data/{spec → test}/dummy/app/views/layouts/application.html.erb +0 -0
- data/{spec → test}/dummy/bin/bundle +0 -0
- data/{spec → test}/dummy/bin/rails +0 -0
- data/{spec → test}/dummy/bin/rake +0 -0
- data/{spec → test}/dummy/config/application.rb +0 -0
- data/{spec → test}/dummy/config/boot.rb +0 -0
- data/{spec → test}/dummy/config/database.yml +0 -0
- data/{spec → test}/dummy/config/environment.rb +0 -0
- data/{spec → test}/dummy/config/environments/development.rb +0 -0
- data/{spec → test}/dummy/config/environments/production.rb +1 -1
- data/{spec → test}/dummy/config/environments/test.rb +1 -1
- data/{spec → test}/dummy/config/initializers/assets.rb +0 -0
- data/{spec → test}/dummy/config/initializers/backtrace_silencers.rb +0 -0
- data/{spec → test}/dummy/config/initializers/cookies_serializer.rb +0 -0
- data/{spec → test}/dummy/config/initializers/filter_parameter_logging.rb +0 -0
- data/{spec → test}/dummy/config/initializers/inflections.rb +0 -0
- data/{spec → test}/dummy/config/initializers/mime_types.rb +0 -0
- data/{spec → test}/dummy/config/initializers/session_store.rb +0 -0
- data/{spec → test}/dummy/config/initializers/wrap_parameters.rb +0 -0
- data/{spec → test}/dummy/config/locales/en.yml +0 -0
- data/{spec → test}/dummy/config/routes.rb +0 -0
- data/{spec → test}/dummy/config/secrets.yml +0 -0
- data/{spec → test}/dummy/config.ru +0 -0
- data/{spec → test}/dummy/public/404.html +0 -0
- data/{spec → test}/dummy/public/422.html +0 -0
- data/{spec → test}/dummy/public/500.html +0 -0
- data/{spec → test}/dummy/public/favicon.ico +0 -0
- data/test/integration/navigation_test.rb +10 -0
- data/test/my_forum_test.rb +7 -0
- data/test/test_helper.rb +15 -0
- metadata +84 -355
- data/app/assets/javascripts/my_forum/admin/categories.js.coffee +0 -0
- data/app/assets/javascripts/my_forum/admin/dashboard.js.coffee +0 -0
- data/app/assets/javascripts/my_forum/admin/forums.js.coffee +0 -0
- data/app/assets/javascripts/my_forum/admin/roles.js +0 -2
- data/app/assets/javascripts/my_forum/admin/users.js +0 -2
- data/app/assets/javascripts/my_forum/forums.js.coffee +0 -0
- data/app/assets/javascripts/my_forum/jquery.scrollTo.min.js +0 -7
- data/app/assets/javascripts/my_forum/jquery.selection.js +0 -354
- data/app/assets/javascripts/my_forum/my_forum.js.coffee +0 -118
- data/app/assets/javascripts/my_forum/posts.js.coffee +0 -20
- data/app/assets/javascripts/my_forum/topics.js.coffee +0 -0
- data/app/assets/javascripts/my_forum/users.js.coffee +0 -0
- data/app/assets/javascripts/my_forum/welcome.js.coffee +0 -0
- data/app/assets/stylesheets/my_forum/admin/categories.css.scss +0 -0
- data/app/assets/stylesheets/my_forum/admin/dashboard.css.scss +0 -3
- data/app/assets/stylesheets/my_forum/admin/forums.css.scss +0 -7
- data/app/assets/stylesheets/my_forum/admin/roles.css +0 -4
- data/app/assets/stylesheets/my_forum/admin/users.css +0 -4
- data/app/assets/stylesheets/my_forum/application.css.scss +0 -80
- data/app/assets/stylesheets/my_forum/forums.css.scss +0 -31
- data/app/assets/stylesheets/my_forum/posts.css.scss +0 -138
- data/app/assets/stylesheets/my_forum/private_messages.css.scss +0 -11
- data/app/assets/stylesheets/my_forum/topics.css.scss +0 -16
- data/app/assets/stylesheets/my_forum/users.css.scss +0 -3
- data/app/assets/stylesheets/my_forum/welcome.css.scss +0 -73
- data/app/controllers/my_forum/admin/categories_controller.rb +0 -36
- data/app/controllers/my_forum/admin/dashboard_controller.rb +0 -13
- data/app/controllers/my_forum/admin/emoticons_controller.rb +0 -65
- data/app/controllers/my_forum/admin/forums_controller.rb +0 -35
- data/app/controllers/my_forum/admin/mail_controller.rb +0 -31
- data/app/controllers/my_forum/admin/roles_controller.rb +0 -38
- data/app/controllers/my_forum/admin/users_controller.rb +0 -14
- data/app/controllers/my_forum/attachments_controller.rb +0 -30
- data/app/controllers/my_forum/forums_controller.rb +0 -39
- data/app/controllers/my_forum/images_controller.rb +0 -7
- data/app/controllers/my_forum/posts_controller.rb +0 -81
- data/app/controllers/my_forum/private_messages_controller.rb +0 -73
- data/app/controllers/my_forum/topics_controller.rb +0 -96
- data/app/controllers/my_forum/users_controller.rb +0 -145
- data/app/controllers/my_forum/welcome_controller.rb +0 -30
- data/app/helpers/my_forum/admin/dashboard_helper.rb +0 -4
- data/app/helpers/my_forum/admin/forums_helper.rb +0 -4
- data/app/helpers/my_forum/admin/roles_helper.rb +0 -4
- data/app/helpers/my_forum/admin/users_helper.rb +0 -4
- data/app/helpers/my_forum/emoticons_helper.rb +0 -7
- data/app/helpers/my_forum/forums_helper.rb +0 -44
- data/app/helpers/my_forum/posts_helper.rb +0 -72
- data/app/helpers/my_forum/private_messages_helper.rb +0 -25
- data/app/helpers/my_forum/topics_helper.rb +0 -18
- data/app/helpers/my_forum/users_helper.rb +0 -33
- data/app/helpers/my_forum/welcome_helper.rb +0 -4
- data/app/mailers/application_mailer.rb +0 -4
- data/app/mailers/my_forum/user_mailer.rb +0 -24
- data/app/models/my_forum/attachment.rb +0 -12
- data/app/models/my_forum/avatar.rb +0 -11
- data/app/models/my_forum/category.rb +0 -7
- data/app/models/my_forum/category_permission.rb +0 -6
- data/app/models/my_forum/emoticon.rb +0 -6
- data/app/models/my_forum/forum.rb +0 -50
- data/app/models/my_forum/image.rb +0 -5
- data/app/models/my_forum/log_read_mark.rb +0 -4
- data/app/models/my_forum/post.rb +0 -26
- data/app/models/my_forum/private_message.rb +0 -8
- data/app/models/my_forum/role.rb +0 -6
- data/app/models/my_forum/topic.rb +0 -41
- data/app/models/my_forum/user.rb +0 -71
- data/app/models/my_forum/user_group.rb +0 -13
- data/app/models/my_forum/user_group_link.rb +0 -6
- data/app/models/my_forum/user_roles.rb +0 -6
- data/app/views/layouts/mailer.html.erb +0 -5
- data/app/views/layouts/mailer.text.erb +0 -1
- data/app/views/layouts/my_forum/_guest_navbar.html.haml +0 -4
- data/app/views/layouts/my_forum/_user_navbar.html.haml +0 -19
- data/app/views/layouts/my_forum/admin_application.haml +0 -29
- data/app/views/layouts/my_forum/application.haml +0 -23
- data/app/views/my_forum/admin/categories/edit.haml +0 -9
- data/app/views/my_forum/admin/categories/new.haml +0 -5
- data/app/views/my_forum/admin/dashboard/index.haml +0 -0
- data/app/views/my_forum/admin/emoticons/edit.haml +0 -4
- data/app/views/my_forum/admin/emoticons/index.haml +0 -15
- data/app/views/my_forum/admin/emoticons/new.haml +0 -5
- data/app/views/my_forum/admin/forums/index.haml +0 -47
- data/app/views/my_forum/admin/forums/new.haml +0 -6
- data/app/views/my_forum/admin/mail/index.haml +0 -9
- data/app/views/my_forum/admin/roles/index.haml +0 -12
- data/app/views/my_forum/admin/roles/new.haml +0 -22
- data/app/views/my_forum/admin/users/index.haml +0 -10
- data/app/views/my_forum/forums/_topic_subject.html.haml +0 -16
- data/app/views/my_forum/forums/show.haml +0 -29
- data/app/views/my_forum/posts/edit.html.haml +0 -31
- data/app/views/my_forum/private_messages/_sidebar.haml +0 -10
- data/app/views/my_forum/private_messages/inbox.haml +0 -26
- data/app/views/my_forum/private_messages/new.haml +0 -21
- data/app/views/my_forum/private_messages/show.haml +0 -10
- data/app/views/my_forum/shared/_post_preview.haml +0 -15
- data/app/views/my_forum/shared/_upload_photo.haml +0 -45
- data/app/views/my_forum/shared/post_preview.js.coffee +0 -4
- data/app/views/my_forum/topics/_post.haml +0 -29
- data/app/views/my_forum/topics/_profile_popover.haml +0 -47
- data/app/views/my_forum/topics/_quick_answer.haml +0 -34
- data/app/views/my_forum/topics/_topic_header.haml +0 -4
- data/app/views/my_forum/topics/_user_info.haml +0 -9
- data/app/views/my_forum/topics/new.haml +0 -38
- data/app/views/my_forum/topics/show.haml +0 -60
- data/app/views/my_forum/user_mailer/custom_email.text.erb +0 -1
- data/app/views/my_forum/user_mailer/pm_notification.text.erb +0 -6
- data/app/views/my_forum/user_mailer/reset_password_email.haml +0 -1
- data/app/views/my_forum/user_mailer/reset_password_email.text.erb +0 -1
- data/app/views/my_forum/users/edit.haml +0 -36
- data/app/views/my_forum/users/forgot_password.haml +0 -10
- data/app/views/my_forum/users/new.haml +0 -14
- data/app/views/my_forum/users/signin.haml +0 -14
- data/app/views/my_forum/users/signout.haml +0 -0
- data/app/views/my_forum/welcome/index.haml +0 -37
- data/config/initializers/will_paginate.rb +0 -24
- data/config/locales/en.yml +0 -68
- data/config/locales/ru.yml +0 -196
- data/db/migrate/20141117122725_create_my_forum_forums.rb +0 -12
- data/db/migrate/20141117122742_create_my_forum_topics.rb +0 -17
- data/db/migrate/20141117122751_create_my_forum_posts.rb +0 -11
- data/db/migrate/20141118081021_create_my_forum_categories.rb +0 -8
- data/db/migrate/20141118131215_create_my_forum_users.rb +0 -34
- data/db/migrate/20141222094522_create_my_forum_roles.rb +0 -10
- data/db/migrate/20141222094538_create_my_forum_user_roles.rb +0 -9
- data/db/migrate/20150202115250_create_my_forum_log_read_marks.rb +0 -10
- data/db/migrate/20150215200453_create_my_forum_user_groups.rb +0 -15
- data/db/migrate/20150215204852_create_my_forum_user_group_links.rb +0 -9
- data/db/migrate/20150215212443_create_my_forum_category_permissions.rb +0 -9
- data/db/migrate/20150227210814_create_my_forum_private_messages.rb +0 -16
- data/db/migrate/20151012095554_create_my_forum_images.rb +0 -12
- data/db/migrate/20151218135729_add_is_deleted.rb +0 -6
- data/db/migrate/20151220121140_create_my_forum_emoticons.rb +0 -10
- data/db/migrate/20151221203243_my_forum_rename_user_avatar.rb +0 -5
- data/db/migrate/20151221205045_my_forum_change_user_avatar.rb +0 -5
- data/db/migrate/20160122202142_add_latest_post_info_for_topic.rb +0 -24
- data/db/migrate/20160210130805_add_indexes_for_topics.rb +0 -7
- data/db/migrate/20160214085201_add_edited_by_for_post.rb +0 -5
- data/spec/controllers/my_forum/admin/emoticons_controller_spec.rb +0 -7
- data/spec/controllers/my_forum/admin/mail_controller_spec.rb +0 -7
- data/spec/controllers/my_forum/private_messages_controller_spec.rb +0 -7
- data/spec/controllers/my_forum/users_controller_spec.rb +0 -76
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/schema.rb +0 -159
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +0 -12
- data/spec/helpers/my_forum/posts_helper_spec.rb +0 -24
- data/spec/helpers/my_forum/private_messages_helper_spec.rb +0 -17
- data/spec/models/my_forum/emoticon_spec.rb +0 -7
- data/spec/models/my_forum/private_message_spec.rb +0 -7
- data/spec/models/my_forum/user_spec.rb +0 -13
- data/spec/rails_helper.rb +0 -52
- data/spec/spec_helper.rb +0 -87
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2ec79af48419743a46cb08ceacde067a36d5c658
|
4
|
+
data.tar.gz: 1b16082b7f8f5cd4ca953c80ecbfc7453a8bd642
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 69de62c7ab134078ab86b43becd29403e4df93687d1c5b474055b74c7d84dc998d671301ab98c448581593faeefb53e4c0e111024cd79442cbca458fca56e294
|
7
|
+
data.tar.gz: b9603bae08aceb948915a1bf2f00f60386447eb4beb11d2b42fce1fa2c82fb051948d391ab2524d5263f20fa09c10c20ad64de2b5613740c0f34e1c6b302aa82
|
data/README.rdoc
CHANGED
@@ -1,14 +1,3 @@
|
|
1
|
-
{<img src="https://travis-ci.org/vintyara/my_forum.svg?branch=master" alt="Build Status" />}[https://travis-ci.org/vintyara/my_forum]
|
2
|
-
|
3
1
|
= MyForum
|
4
2
|
|
5
|
-
This project rocks and uses MIT-LICENSE.
|
6
|
-
|
7
|
-
INSTALLATION
|
8
|
-
rake my_forum:install:migrations
|
9
|
-
|
10
|
-
For using existing User model, use somethink like this:
|
11
|
-
|
12
|
-
Create config/initializers/my_forum.rb with next content:
|
13
|
-
MyForum::Engine.use_custom_user_model = true
|
14
|
-
...
|
3
|
+
This project rocks and uses MIT-LICENSE.
|
data/Rakefile
CHANGED
@@ -14,20 +14,19 @@ RDoc::Task.new(:rdoc) do |rdoc|
|
|
14
14
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
15
|
end
|
16
16
|
|
17
|
-
APP_RAKEFILE = File.expand_path("../
|
17
|
+
APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
|
18
18
|
load 'rails/tasks/engine.rake'
|
19
19
|
|
20
20
|
|
21
21
|
|
22
22
|
Bundler::GemHelper.install_tasks
|
23
23
|
|
24
|
-
require '
|
25
|
-
require 'rspec/core/rake_task'
|
24
|
+
require 'rake/testtask'
|
26
25
|
|
27
26
|
Rake::TestTask.new(:test) do |t|
|
28
27
|
t.libs << 'lib'
|
29
28
|
t.libs << 'test'
|
30
|
-
t.pattern = '
|
29
|
+
t.pattern = 'test/**/*_test.rb'
|
31
30
|
t.verbose = false
|
32
31
|
end
|
33
32
|
|
@@ -10,10 +10,4 @@
|
|
10
10
|
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
|
11
11
|
// about supported directives.
|
12
12
|
//
|
13
|
-
//= require jquery
|
14
|
-
//= require jquery_ujs
|
15
|
-
//= require bootstrap-sprockets
|
16
|
-
//= require bootstrap
|
17
|
-
//= jquery.selection.js
|
18
|
-
//= jquery.scrollTo.min.js
|
19
13
|
//= require_tree .
|
@@ -1,85 +1,4 @@
|
|
1
1
|
module MyForum
|
2
2
|
class ApplicationController < ActionController::Base
|
3
|
-
|
4
|
-
before_filter :user_activity
|
5
|
-
|
6
|
-
helper_method :attachment_img_path, :emoticons_list, :is_admin?
|
7
|
-
|
8
|
-
def authenticate_user!
|
9
|
-
redirect_to admin_signin_path unless current_user
|
10
|
-
end
|
11
|
-
|
12
|
-
def current_user
|
13
|
-
return session[:user_id].blank? ? nil : User.where(id: session[:user_id]).first
|
14
|
-
end
|
15
|
-
helper_method :current_user
|
16
|
-
|
17
|
-
def current_user_id
|
18
|
-
session[:user_id]
|
19
|
-
end
|
20
|
-
helper_method :current_user_id
|
21
|
-
|
22
|
-
def is_admin?
|
23
|
-
return false unless current_user
|
24
|
-
current_user.is_admin?
|
25
|
-
end
|
26
|
-
|
27
|
-
def current_user_groups
|
28
|
-
return [].push UserGroup::GUEST_GROUP.name unless current_user
|
29
|
-
current_user.user_groups.map &:name
|
30
|
-
end
|
31
|
-
|
32
|
-
def new_pm_count
|
33
|
-
return unless current_user
|
34
|
-
PrivateMessage.unread_count_for(current_user)
|
35
|
-
end
|
36
|
-
helper_method :new_pm_count
|
37
|
-
|
38
|
-
def forum_time(time)
|
39
|
-
local_time = time
|
40
|
-
|
41
|
-
if local_time.to_date == Time.now.to_date
|
42
|
-
return t('my_forum.today', hhmm: local_time.strftime('%H:%M'))
|
43
|
-
elsif local_time.to_date == (Time.now - 1.day).to_date
|
44
|
-
return t('my_forum.yesterday', hhmm: local_time.strftime('%H:%M'))
|
45
|
-
end
|
46
|
-
|
47
|
-
local_time.strftime('%Y-%m-%d %H:%M')
|
48
|
-
end
|
49
|
-
helper_method :forum_time
|
50
|
-
|
51
|
-
private
|
52
|
-
|
53
|
-
def user_activity
|
54
|
-
current_user.touch if current_user
|
55
|
-
end
|
56
|
-
|
57
|
-
def verify_admin
|
58
|
-
redirect_to root_path unless current_user && current_user.is_admin
|
59
|
-
end
|
60
|
-
|
61
|
-
def check_access_permissions(obj)
|
62
|
-
return true if current_user && current_user.is_admin
|
63
|
-
|
64
|
-
category_user_groups = case obj.class.to_s
|
65
|
-
when 'MyForum::Forum'
|
66
|
-
obj.category.user_groups
|
67
|
-
when 'MyForum::Topic'
|
68
|
-
obj.forum.category.user_groups
|
69
|
-
else
|
70
|
-
[]
|
71
|
-
end
|
72
|
-
|
73
|
-
redirect_to root_path if (category_user_groups.map(&:name) & current_user_groups).blank?
|
74
|
-
end
|
75
|
-
|
76
|
-
def attachment_img_path(attachment_id)
|
77
|
-
attachment = Attachment.find_by_id(attachment_id.to_i)
|
78
|
-
File.join(Attachment::URL, attachment.user_id.to_s, attachment.file_name)
|
79
|
-
end
|
80
|
-
|
81
|
-
def emoticons_list
|
82
|
-
@emoticson ||= Emoticon.all.inject({}) {|hash, smile| hash.merge!(smile.code => File.join(Emoticon::URL, smile.file_name) ) }
|
83
|
-
end
|
84
3
|
end
|
85
4
|
end
|
@@ -1,47 +1,4 @@
|
|
1
1
|
module MyForum
|
2
2
|
module ApplicationHelper
|
3
|
-
|
4
|
-
def draw_navigation
|
5
|
-
html_li = content_tag :li, link_to('Forums', root_path)
|
6
|
-
|
7
|
-
if @forum
|
8
|
-
html_li += content_tag :li, '→'.html_safe
|
9
|
-
html_li += content_tag :li, link_to(@forum.name, forum_path(@forum))
|
10
|
-
end
|
11
|
-
|
12
|
-
if @forum && @topic && !@topic.new_record?
|
13
|
-
html_li += content_tag :li, '→'.html_safe
|
14
|
-
html_li += content_tag :li, link_to(@topic.name.html_safe, forum_topic_path(@forum, @topic))
|
15
|
-
end
|
16
|
-
|
17
|
-
html = content_tag :ul, class: 'draw-navigation' do
|
18
|
-
html_li
|
19
|
-
end
|
20
|
-
|
21
|
-
html.html_safe
|
22
|
-
end
|
23
|
-
|
24
|
-
def online_users
|
25
|
-
User.online.pluck(:login).join(', ')
|
26
|
-
end
|
27
|
-
|
28
|
-
def today_was_users
|
29
|
-
User.today_visited.pluck(:login).join(', ')
|
30
|
-
end
|
31
|
-
|
32
|
-
def errors_for(obj)
|
33
|
-
return if obj.errors.blank?
|
34
|
-
|
35
|
-
content_tag :div, obj.errors.full_messages.to_sentence, class: 'errors_for'
|
36
|
-
end
|
37
|
-
|
38
|
-
# TODO deprecate!
|
39
|
-
def time(datetime)
|
40
|
-
forum_time(datetime)
|
41
|
-
end
|
42
|
-
|
43
|
-
def upload_allowed_extensions
|
44
|
-
Attachment::ALLOWED_FILE_EXTENSIONS
|
45
|
-
end
|
46
3
|
end
|
47
4
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>MyForum</title>
|
5
|
+
<%= stylesheet_link_tag "my_forum/application", media: "all" %>
|
6
|
+
<%= javascript_include_tag "my_forum/application" %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
data/config/routes.rb
CHANGED
@@ -1,50 +1,2 @@
|
|
1
1
|
MyForum::Engine.routes.draw do
|
2
|
-
root 'welcome#index'
|
3
|
-
|
4
|
-
match 'signin', to: 'users#signin', via: [:get, :post]
|
5
|
-
match 'logout', to: 'users#logout', via: [:get]
|
6
|
-
match 'forgot_password', to: 'users#forgot_password', via: [:get, :post]
|
7
|
-
|
8
|
-
match 'unread_topics', to: 'forums#unread_topics', via: [:get], as: :unread_topics
|
9
|
-
match 'mark_all_as_read', to: 'forums#mark_all_as_read', via: [:get], as: :mark_all_as_read
|
10
|
-
|
11
|
-
match 'post/:id', to: 'posts#show', via: [:get], as: :post_content
|
12
|
-
match 'post/preview', to: 'posts#preview', via: [:post], as: :post_preview
|
13
|
-
|
14
|
-
resources :images
|
15
|
-
resources :avatars
|
16
|
-
resources :attachments
|
17
|
-
|
18
|
-
resources :users do
|
19
|
-
patch :avatar_update
|
20
|
-
|
21
|
-
collection do
|
22
|
-
get :autocomplete
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
resources :private_messages
|
27
|
-
|
28
|
-
resources :forums, only: [:index, :show] do
|
29
|
-
resources :topics do
|
30
|
-
patch :pin
|
31
|
-
patch :close
|
32
|
-
patch :delete
|
33
|
-
resources :posts
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
namespace :admin do
|
38
|
-
root 'dashboard#index'
|
39
|
-
|
40
|
-
match 'forums', to: 'forums#index', via: [:get]
|
41
|
-
match 'mail_list', to: 'mail#index', via: [:get, :post]
|
42
|
-
|
43
|
-
resources :emoticons
|
44
|
-
resources :users
|
45
|
-
resources :roles
|
46
|
-
resources :categories do
|
47
|
-
resources :forums
|
48
|
-
end
|
49
|
-
end
|
50
2
|
end
|
data/lib/my_forum/engine.rb
CHANGED
@@ -1,36 +1,5 @@
|
|
1
1
|
module MyForum
|
2
2
|
class Engine < ::Rails::Engine
|
3
3
|
isolate_namespace MyForum
|
4
|
-
|
5
|
-
require 'jquery-rails'
|
6
|
-
require 'bootstrap-sass'
|
7
|
-
|
8
|
-
config.after_initialize do
|
9
|
-
ActionView::Base.sanitized_allowed_tags = %w(strong em a img br p i pre div span iframe)
|
10
|
-
ActionView::Base.sanitized_allowed_attributes = %w(href title class src width height target)
|
11
|
-
end
|
12
|
-
|
13
|
-
config.generators do |g|
|
14
|
-
g.test_framework :rspec, :fixture => false
|
15
|
-
g.assets false
|
16
|
-
g.helper false
|
17
|
-
end
|
18
|
-
|
19
|
-
USE_CUSTOM_USER_MODEL = false
|
20
|
-
CUSTOM_USER_CLASS = 'User'
|
21
|
-
CUSTOM_USER_LOGIN_ATTR = 'login'
|
22
|
-
CUSTOM_USER_PASSWORD_ATTR = 'password'
|
23
|
-
CUSTOM_AUTHENTICATE_METHOD = 'users#authenticate'
|
24
|
-
|
25
|
-
attr_accessor :use_custom_user_model, :custom_user_class, :custom_user_login_attr, :custom_user_password_attr,
|
26
|
-
:custom_authenticate_method
|
27
|
-
|
28
|
-
def initialize
|
29
|
-
self.use_custom_user_model = USE_CUSTOM_USER_MODEL
|
30
|
-
self.custom_user_class = CUSTOM_USER_CLASS
|
31
|
-
self.custom_user_login_attr = CUSTOM_USER_LOGIN_ATTR
|
32
|
-
self.custom_user_password_attr = CUSTOM_USER_PASSWORD_ATTR
|
33
|
-
self.custom_authenticate_method = CUSTOM_AUTHENTICATE_METHOD
|
34
|
-
end
|
35
4
|
end
|
36
5
|
end
|
data/lib/my_forum/version.rb
CHANGED
@@ -1,155 +1,4 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
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
|
-
|
13
|
-
namespace :import do
|
14
|
-
namespace :smf do
|
15
|
-
|
16
|
-
if Rails.env.test?
|
17
|
-
require 'sqlite3'
|
18
|
-
$connection = SQLite3::Database.new('test.db')
|
19
|
-
else
|
20
|
-
$connection = Mysql2::Client.new(Rails.configuration.database_configuration['smf_import'])
|
21
|
-
end
|
22
|
-
|
23
|
-
desc "Import Boards"
|
24
|
-
task boards: :environment do
|
25
|
-
MyForum::Category.delete_all
|
26
|
-
MyForum::Forum.delete_all
|
27
|
-
|
28
|
-
sql = <<-SQL
|
29
|
-
SELECT
|
30
|
-
`smf_categories`.`name` AS category_name,
|
31
|
-
`smf_boards`.`name` AS board_name,
|
32
|
-
`smf_boards`.`description` AS board_description
|
33
|
-
FROM smf_boards
|
34
|
-
INNER JOIN `smf_categories` ON `smf_boards`.`id_cat` = `smf_categories`.`id_cat`
|
35
|
-
SQL
|
36
|
-
|
37
|
-
user_groups = MyForum::UserGroup.all
|
38
|
-
|
39
|
-
result = $connection.query sql
|
40
|
-
result.each do |row|
|
41
|
-
category = MyForum::Category.find_or_create_by(name: row['category_name'])
|
42
|
-
category.user_groups << user_groups if user_groups.any?
|
43
|
-
|
44
|
-
category.forums.create(name: row['board_name'], description: row['board_description'])
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
desc "Import Users"
|
49
|
-
task users: :environment do
|
50
|
-
MyForum::User.destroy_all
|
51
|
-
|
52
|
-
user_group = MyForum::UserGroup.where(name: 'Member').first
|
53
|
-
|
54
|
-
sql = "SELECT member_name, date_registered, real_name, email_address, personal_text, birthdate, website_title, website_url, signature, avatar, is_activated FROM smf_members;"
|
55
|
-
result = $connection.query sql
|
56
|
-
result.each do |row|
|
57
|
-
begin
|
58
|
-
date_registered = Time.at(row['date_registered'].to_i) rescue nil
|
59
|
-
user = MyForum::User.create!(
|
60
|
-
login: row['member_name'],
|
61
|
-
email: row['email_address'],
|
62
|
-
real_name: row['real_name'],
|
63
|
-
birthdate: row['birthdate'],
|
64
|
-
signature: row['signature'],
|
65
|
-
avatar: row['avatar'],
|
66
|
-
created_at: date_registered,
|
67
|
-
additional_info: {
|
68
|
-
personal_text: row['personal_text'],
|
69
|
-
website_title: row['website_title'],
|
70
|
-
website_url: row['website_url'],
|
71
|
-
is_activated: row['is_activated']
|
72
|
-
})
|
73
|
-
|
74
|
-
user.user_groups << user_group if user_group
|
75
|
-
rescue => e
|
76
|
-
print e
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
desc "Import Topics and Posts"
|
82
|
-
task topics: :environment do
|
83
|
-
MyForum::Topic.delete_all
|
84
|
-
MyForum::Post.delete_all
|
85
|
-
|
86
|
-
sql = <<-SQL
|
87
|
-
SELECT
|
88
|
-
`smf_boards`.`name` AS board_name, `smf_messages`.`poster_email`, `smf_messages`.`poster_name`, `smf_messages`.`body`,
|
89
|
-
`smf_messages`.`subject`, `smf_messages`.`poster_time`, `smf_messages`.`id_topic`
|
90
|
-
FROM `smf_messages`
|
91
|
-
INNER JOIN `smf_boards` ON `smf_messages`.`id_board` = `smf_boards`.`id_board`
|
92
|
-
ORDER BY `id_msg` ASC, `id_topic` ASC;
|
93
|
-
SQL
|
94
|
-
result = $connection.query sql
|
95
|
-
result.each do |row|
|
96
|
-
begin
|
97
|
-
user = MyForum::User.find_by_email(row['poster_email']) || MyForum::User.find_by_login(row['poster_name'])
|
98
|
-
user = MyForum::User.create!(login: row['poster_name'], email: row['poster_email'], is_deleted: true) unless user
|
99
|
-
|
100
|
-
forum = MyForum::Forum.find_or_create_by(name: row['board_name'])
|
101
|
-
|
102
|
-
# smf does not uses description field, so i use it temponary while import process
|
103
|
-
unless topic = MyForum::Topic.where(description: row['id_topic']).first
|
104
|
-
topic = forum.topics.create!(name: row['subject'], description: row['id_topic'])
|
105
|
-
end
|
106
|
-
|
107
|
-
post_time = Time.at(row['poster_time'].to_i)
|
108
|
-
topic.posts.create!(user: user, text: row['body'], forum_id: forum.id, created_at: post_time, updated_at: post_time)
|
109
|
-
rescue => e
|
110
|
-
print e
|
111
|
-
end
|
112
|
-
end
|
113
|
-
MyForum::Topic.update_all(description: nil)
|
114
|
-
|
115
|
-
end
|
116
|
-
|
117
|
-
desc "Import Private Messages"
|
118
|
-
task pms: :environment do
|
119
|
-
MyForum::PrivateMessage.delete_all
|
120
|
-
|
121
|
-
sql = <<-SQL
|
122
|
-
SELECT
|
123
|
-
smf_personal_messages.msgtime, smf_personal_messages.subject, smf_personal_messages.body, smf_personal_messages.from_name,
|
124
|
-
smf_pm_recipients.id_member as to_member, smf_members.member_name
|
125
|
-
FROM smf_personal_messages
|
126
|
-
LEFT JOIN smf_pm_recipients ON smf_personal_messages.id_pm = smf_pm_recipients.id_pm
|
127
|
-
LEFT JOIN smf_members ON smf_members.id_member = smf_pm_recipients.id_member
|
128
|
-
SQL
|
129
|
-
|
130
|
-
result = $connection.query sql
|
131
|
-
result.each do |row|
|
132
|
-
sender = MyForum::User.find_by_login(row['from_name'])
|
133
|
-
recipient = MyForum::User.find_by_login(row['member_name'])
|
134
|
-
next unless sender and recipient
|
135
|
-
|
136
|
-
pm_time = Time.at(row['msgtime'].to_i)
|
137
|
-
|
138
|
-
MyForum::PrivateMessage.create!(
|
139
|
-
sender_id: sender.id,
|
140
|
-
sender_login: sender.login,
|
141
|
-
recipient_id: recipient.id,
|
142
|
-
recipient_login: recipient.login,
|
143
|
-
sender_deleted: false,
|
144
|
-
recipient_deleted: false,
|
145
|
-
unread: false,
|
146
|
-
subject: row['subject'],
|
147
|
-
body: row['body'],
|
148
|
-
created_at: pm_time,
|
149
|
-
updated_at: pm_time)
|
150
|
-
end
|
151
|
-
|
152
|
-
end
|
153
|
-
end
|
154
|
-
end
|
155
|
-
end
|
1
|
+
# desc "Explaining what the task does"
|
2
|
+
# task :my_forum do
|
3
|
+
# # Task goes here
|
4
|
+
# end
|
File without changes
|
File without changes
|
@@ -0,0 +1,15 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any styles
|
10
|
+
* defined in the other CSS/SCSS files in this directory. It is generally better to create a new
|
11
|
+
* file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
@@ -20,7 +20,7 @@ Rails.application.configure do
|
|
20
20
|
# config.action_dispatch.rack_cache = true
|
21
21
|
|
22
22
|
# Disable Rails's static asset server (Apache or nginx will already do this).
|
23
|
-
config.
|
23
|
+
config.serve_static_assets = false
|
24
24
|
|
25
25
|
# Compress JavaScripts and CSS.
|
26
26
|
config.assets.js_compressor = :uglifier
|
@@ -13,7 +13,7 @@ Rails.application.configure do
|
|
13
13
|
config.eager_load = false
|
14
14
|
|
15
15
|
# Configure static asset server for tests with Cache-Control for performance.
|
16
|
-
config.
|
16
|
+
config.serve_static_assets = true
|
17
17
|
config.static_cache_control = 'public, max-age=3600'
|
18
18
|
|
19
19
|
# Show full error reports and disable caching.
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/test/test_helper.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
# Configure Rails Environment
|
2
|
+
ENV["RAILS_ENV"] = "test"
|
3
|
+
|
4
|
+
require File.expand_path("../dummy/config/environment.rb", __FILE__)
|
5
|
+
require "rails/test_help"
|
6
|
+
|
7
|
+
Rails.backtrace_cleaner.remove_silencers!
|
8
|
+
|
9
|
+
# Load support files
|
10
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
11
|
+
|
12
|
+
# Load fixtures from the engine
|
13
|
+
if ActiveSupport::TestCase.method_defined?(:fixture_path=)
|
14
|
+
ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
|
15
|
+
end
|