my_forum 0.0.1.beta1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +16 -0
- data/Rakefile +35 -0
- 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 +2 -0
- data/app/assets/javascripts/my_forum/admin/users.js +2 -0
- data/app/assets/javascripts/my_forum/application.js +16 -0
- data/app/assets/javascripts/my_forum/forums.js.coffee +0 -0
- data/app/assets/javascripts/my_forum/posts.js.coffee +0 -0
- 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 +3 -0
- data/app/assets/stylesheets/my_forum/admin/forums.css.scss +7 -0
- data/app/assets/stylesheets/my_forum/admin/roles.css +4 -0
- data/app/assets/stylesheets/my_forum/admin/users.css +4 -0
- data/app/assets/stylesheets/my_forum/application.css.scss +29 -0
- data/app/assets/stylesheets/my_forum/forums.css.scss +31 -0
- data/app/assets/stylesheets/my_forum/posts.css.scss +76 -0
- data/app/assets/stylesheets/my_forum/private_messages.css.scss +7 -0
- data/app/assets/stylesheets/my_forum/topics.css.scss +12 -0
- data/app/assets/stylesheets/my_forum/users.css.scss +0 -0
- data/app/assets/stylesheets/my_forum/welcome.css.scss +66 -0
- data/app/controllers/my_forum/admin/categories_controller.rb +36 -0
- data/app/controllers/my_forum/admin/dashboard_controller.rb +13 -0
- data/app/controllers/my_forum/admin/forums_controller.rb +35 -0
- data/app/controllers/my_forum/admin/roles_controller.rb +38 -0
- data/app/controllers/my_forum/admin/users_controller.rb +14 -0
- data/app/controllers/my_forum/application_controller.rb +56 -0
- data/app/controllers/my_forum/forums_controller.rb +39 -0
- data/app/controllers/my_forum/posts_controller.rb +29 -0
- data/app/controllers/my_forum/private_messages_controller.rb +67 -0
- data/app/controllers/my_forum/topics_controller.rb +47 -0
- data/app/controllers/my_forum/users_controller.rb +89 -0
- data/app/controllers/my_forum/welcome_controller.rb +12 -0
- data/app/helpers/my_forum/admin/dashboard_helper.rb +4 -0
- data/app/helpers/my_forum/admin/forums_helper.rb +4 -0
- data/app/helpers/my_forum/admin/roles_helper.rb +4 -0
- data/app/helpers/my_forum/admin/users_helper.rb +4 -0
- data/app/helpers/my_forum/application_helper.rb +39 -0
- data/app/helpers/my_forum/forums_helper.rb +42 -0
- data/app/helpers/my_forum/posts_helper.rb +29 -0
- data/app/helpers/my_forum/private_messages_helper.rb +18 -0
- data/app/helpers/my_forum/topics_helper.rb +11 -0
- data/app/helpers/my_forum/users_helper.rb +23 -0
- data/app/helpers/my_forum/welcome_helper.rb +4 -0
- data/app/mailers/application_mailer.rb +4 -0
- data/app/mailers/my_forum/user_mailer.rb +14 -0
- data/app/models/my_forum/category.rb +7 -0
- data/app/models/my_forum/category_permission.rb +6 -0
- data/app/models/my_forum/forum.rb +56 -0
- data/app/models/my_forum/log_read_mark.rb +4 -0
- data/app/models/my_forum/post.rb +14 -0
- data/app/models/my_forum/private_message.rb +8 -0
- data/app/models/my_forum/role.rb +6 -0
- data/app/models/my_forum/topic.rb +33 -0
- data/app/models/my_forum/user.rb +45 -0
- data/app/models/my_forum/user_group.rb +13 -0
- data/app/models/my_forum/user_group_link.rb +6 -0
- data/app/models/my_forum/user_roles.rb +6 -0
- data/app/views/layouts/mailer.html.erb +5 -0
- data/app/views/layouts/mailer.text.erb +1 -0
- data/app/views/layouts/my_forum/_guest_navbar.html.haml +4 -0
- data/app/views/layouts/my_forum/_user_navbar.html.haml +18 -0
- data/app/views/layouts/my_forum/admin_application.haml +27 -0
- data/app/views/layouts/my_forum/application.haml +21 -0
- data/app/views/my_forum/admin/categories/edit.haml +9 -0
- data/app/views/my_forum/admin/categories/new.haml +8 -0
- data/app/views/my_forum/admin/dashboard/index.haml +0 -0
- data/app/views/my_forum/admin/forums/index.haml +37 -0
- data/app/views/my_forum/admin/forums/new.haml +6 -0
- data/app/views/my_forum/admin/roles/index.haml +12 -0
- data/app/views/my_forum/admin/roles/new.haml +22 -0
- data/app/views/my_forum/admin/users/index.haml +10 -0
- data/app/views/my_forum/forums/_topic_subject.html.haml +15 -0
- data/app/views/my_forum/forums/show.haml +28 -0
- data/app/views/my_forum/private_messages/_sidebar.haml +10 -0
- data/app/views/my_forum/private_messages/inbox.haml +24 -0
- data/app/views/my_forum/private_messages/new.haml +16 -0
- data/app/views/my_forum/private_messages/show.haml +10 -0
- data/app/views/my_forum/topics/_post.haml +12 -0
- data/app/views/my_forum/topics/_quick_answer.haml +8 -0
- data/app/views/my_forum/topics/_topic_header.haml +4 -0
- data/app/views/my_forum/topics/_user_info.haml +9 -0
- data/app/views/my_forum/topics/new.haml +12 -0
- data/app/views/my_forum/topics/show.haml +21 -0
- data/app/views/my_forum/user_mailer/reset_password_email.haml +1 -0
- data/app/views/my_forum/user_mailer/reset_password_email.text.erb +1 -0
- data/app/views/my_forum/users/edit.haml +12 -0
- data/app/views/my_forum/users/forgot_password.haml +10 -0
- data/app/views/my_forum/users/new.haml +14 -0
- data/app/views/my_forum/users/signin.haml +14 -0
- data/app/views/my_forum/users/signout.haml +0 -0
- data/app/views/my_forum/welcome/index.haml +21 -0
- data/config/locales/en.yml +65 -0
- data/config/locales/ru.yml +121 -0
- data/config/routes.rb +31 -0
- data/db/migrate/20141117122725_create_my_forum_forums.rb +12 -0
- data/db/migrate/20141117122742_create_my_forum_topics.rb +17 -0
- data/db/migrate/20141117122751_create_my_forum_posts.rb +11 -0
- data/db/migrate/20141118081021_create_my_forum_categories.rb +8 -0
- data/db/migrate/20141118131215_create_my_forum_users.rb +25 -0
- data/db/migrate/20141222094522_create_my_forum_roles.rb +10 -0
- data/db/migrate/20141222094538_create_my_forum_user_roles.rb +9 -0
- data/db/migrate/20150202115250_create_my_forum_log_read_marks.rb +10 -0
- data/db/migrate/20150215200453_create_my_forum_user_groups.rb +15 -0
- data/db/migrate/20150215204852_create_my_forum_user_group_links.rb +9 -0
- data/db/migrate/20150215212443_create_my_forum_category_permissions.rb +9 -0
- data/db/migrate/20150227210814_create_my_forum_private_messages.rb +14 -0
- data/lib/my_forum/engine.rb +31 -0
- data/lib/my_forum/version.rb +3 -0
- data/lib/my_forum.rb +4 -0
- data/lib/tasks/my_forum_tasks.rake +4 -0
- data/spec/controllers/my_forum/private_messages_controller_spec.rb +7 -0
- data/spec/controllers/my_forum/users_controller_spec.rb +76 -0
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/config/application.rb +23 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +37 -0
- data/spec/dummy/config/environments/production.rb +78 -0
- data/spec/dummy/config/environments/test.rb +39 -0
- data/spec/dummy/config/initializers/assets.rb +8 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +4 -0
- data/spec/dummy/config/secrets.yml +22 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/schema.rb +128 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +97 -0
- data/spec/dummy/log/test.log +4926 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/helpers/my_forum/private_messages_helper_spec.rb +17 -0
- data/spec/models/my_forum/private_message_spec.rb +7 -0
- data/spec/models/my_forum/user_spec.rb +13 -0
- data/spec/rails_helper.rb +52 -0
- data/spec/spec_helper.rb +87 -0
- metadata +348 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA1:
|
|
3
|
+
metadata.gz: 75c4514607a2f4f93f603580bdfa73e2c313fbc2
|
|
4
|
+
data.tar.gz: 15603a327245be2871d7db6c93f9ba883a9fed8b
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 95409f57bd97a5e16fa8f2703557bbf71e9252b98272f19258f354afaa08268405fdfd2d7d83f1291296752aa2d3594f8bd1ef6efb010d431b7b0ce43cda8e4a
|
|
7
|
+
data.tar.gz: 3cdd4ae7ee965f3de93c0995017d193a5120c12ec464721bdcbd1dbc6afa38fa1e3ac0094abf0a2201e7df850e085381eb6c385d642f4fc0035b718d1ee32983
|
data/MIT-LICENSE
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
Copyright 2014 YOURNAME
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
4
|
+
a copy of this software and associated documentation files (the
|
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
9
|
+
the following conditions:
|
|
10
|
+
|
|
11
|
+
The above copyright notice and this permission notice shall be
|
|
12
|
+
included in all copies or substantial portions of the Software.
|
|
13
|
+
|
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
= MyForum
|
|
4
|
+
|
|
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
|
+
...
|
|
15
|
+
|
|
16
|
+
http://w3facility.org/question/ruby-regex-for-stripping-bbcode/
|
data/Rakefile
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
begin
|
|
2
|
+
require 'bundler/setup'
|
|
3
|
+
rescue LoadError
|
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
require 'rdoc/task'
|
|
8
|
+
|
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
|
11
|
+
rdoc.title = 'MyForum'
|
|
12
|
+
rdoc.options << '--line-numbers'
|
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
|
|
18
|
+
load 'rails/tasks/engine.rake'
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
Bundler::GemHelper.install_tasks
|
|
23
|
+
|
|
24
|
+
require 'rspec/core'
|
|
25
|
+
require 'rspec/core/rake_task'
|
|
26
|
+
|
|
27
|
+
Rake::TestTask.new(:test) do |t|
|
|
28
|
+
t.libs << 'lib'
|
|
29
|
+
t.libs << 'test'
|
|
30
|
+
t.pattern = 'spec/**/*_spec.rb'
|
|
31
|
+
t.verbose = false
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
task default: :test
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
|
2
|
+
// listed below.
|
|
3
|
+
//
|
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
|
6
|
+
//
|
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
|
8
|
+
// compiled file.
|
|
9
|
+
//
|
|
10
|
+
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
|
|
11
|
+
// about supported directives.
|
|
12
|
+
//
|
|
13
|
+
//= require jquery
|
|
14
|
+
//= require jquery_ujs
|
|
15
|
+
//= require bootstrap
|
|
16
|
+
//= require_tree .
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,29 @@
|
|
|
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
|
+
*/
|
|
16
|
+
|
|
17
|
+
@import "bootstrap-sprockets";
|
|
18
|
+
@import "bootstrap";
|
|
19
|
+
|
|
20
|
+
.buttons_for_new_topic {
|
|
21
|
+
margin-top: 10px;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.errors_for {
|
|
25
|
+
color: red;
|
|
26
|
+
padding: 10px;
|
|
27
|
+
border: 1px solid red;
|
|
28
|
+
margin-bottom: 14px;
|
|
29
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
.topic-list-container {
|
|
2
|
+
background-color: #f7f7f7;
|
|
3
|
+
padding: 6px;
|
|
4
|
+
|
|
5
|
+
a {
|
|
6
|
+
color: #000;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.box {
|
|
10
|
+
padding: 4px 6px;
|
|
11
|
+
border: 1px solid #DFDFDF;
|
|
12
|
+
background-color: #fff;
|
|
13
|
+
|
|
14
|
+
.topic-row {
|
|
15
|
+
margin-bottom: 10px;
|
|
16
|
+
|
|
17
|
+
.info {
|
|
18
|
+
font-size: 11px;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.topic_subject {
|
|
22
|
+
color: #4E6EE3;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.topic_description {
|
|
26
|
+
font-size: 11px;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
}
|
|
31
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
.topic_posts_info {
|
|
2
|
+
background-color: #d3daed;
|
|
3
|
+
color: #fff;
|
|
4
|
+
font-size: 11px;
|
|
5
|
+
height: 38px;
|
|
6
|
+
line-height: 38px;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.post-list-container {
|
|
10
|
+
background-color: #f7f7f7;
|
|
11
|
+
|
|
12
|
+
.box {
|
|
13
|
+
margin: 12px;
|
|
14
|
+
border: 1px solid #DFDFDF;
|
|
15
|
+
background-color: #fff;
|
|
16
|
+
|
|
17
|
+
.post_from_user_login {
|
|
18
|
+
font-weight: bold;
|
|
19
|
+
color: #c1ccf5;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.post-header {
|
|
23
|
+
height: 36px;
|
|
24
|
+
line-height: 36px;
|
|
25
|
+
margin: 0;
|
|
26
|
+
background-color: #4e61a8;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.created_at {
|
|
30
|
+
margin-top: 10px;
|
|
31
|
+
font-size: 11px;
|
|
32
|
+
color: #a4a4a4;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.quote {
|
|
36
|
+
border: 1px solid black;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.user-title {
|
|
40
|
+
margin-top: 10px;
|
|
41
|
+
font-size: 11px;
|
|
42
|
+
text-align: center;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
img.user-avatar {
|
|
46
|
+
width: 100px;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.user-avatar {
|
|
50
|
+
text-align: center;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.user-posts-count {
|
|
54
|
+
font-size: 11px;
|
|
55
|
+
text-align: center;
|
|
56
|
+
margin-top: 8px;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.user-reg-date {
|
|
60
|
+
font-size: 11px;
|
|
61
|
+
text-align: center;
|
|
62
|
+
margin-top: 4px;
|
|
63
|
+
margin-bottom: 10px;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
#new_topic {
|
|
69
|
+
.name, .description {
|
|
70
|
+
width: 50%;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
#quick_answer {
|
|
75
|
+
margin: 26px 0;
|
|
76
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
#forum_header {
|
|
2
|
+
overflow: hidden;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
#guest_navbar {
|
|
6
|
+
margin-top: 10px;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
#forum-navigation {
|
|
10
|
+
.draw-navigation {
|
|
11
|
+
list-style: none;
|
|
12
|
+
margin: 0;
|
|
13
|
+
padding: 0;
|
|
14
|
+
color: #777;
|
|
15
|
+
font-size: 10px;
|
|
16
|
+
|
|
17
|
+
a {
|
|
18
|
+
color: #777;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
li {
|
|
22
|
+
float: left;
|
|
23
|
+
margin: 0 10px 0 0;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.category-header,
|
|
30
|
+
.forum-header {
|
|
31
|
+
margin-top: 14px;
|
|
32
|
+
height: 34px;
|
|
33
|
+
line-height: 31px;
|
|
34
|
+
padding-left: 20px;
|
|
35
|
+
color: #fff;
|
|
36
|
+
font-weight: bold;
|
|
37
|
+
background-color: #4E6EE3;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.category-forums-container {
|
|
41
|
+
background-color: #f7f7f7;
|
|
42
|
+
padding: 6px;
|
|
43
|
+
|
|
44
|
+
.box {
|
|
45
|
+
padding: 4px 6px;
|
|
46
|
+
border: 1px solid #DFDFDF;
|
|
47
|
+
background-color: #fff;
|
|
48
|
+
|
|
49
|
+
.forum-row {
|
|
50
|
+
margin-top: 10px;
|
|
51
|
+
|
|
52
|
+
.forum-info {
|
|
53
|
+
font-size: 11px;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.forum-last-message-info {
|
|
57
|
+
font-size: 11px;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
#online_users {
|
|
65
|
+
margin: 20px 0;
|
|
66
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
require_dependency "my_forum/application_controller"
|
|
2
|
+
|
|
3
|
+
module MyForum
|
|
4
|
+
class Admin::CategoriesController < ApplicationController
|
|
5
|
+
|
|
6
|
+
before_filter :verify_admin
|
|
7
|
+
|
|
8
|
+
layout 'layouts/my_forum/admin_application'
|
|
9
|
+
|
|
10
|
+
def new
|
|
11
|
+
@category = Category.new
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def create
|
|
15
|
+
@category = Category.new(category_params)
|
|
16
|
+
@category.save ? redirect_to(admin_forums_path) : raise('category not created')
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def edit
|
|
20
|
+
@category = Category.find(params[:id])
|
|
21
|
+
@user_groups = UserGroup.all
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def update
|
|
25
|
+
@category = Category.find(params[:id])
|
|
26
|
+
@category.update_attributes(category_params)
|
|
27
|
+
redirect_to edit_admin_category_path(@category)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
protected
|
|
31
|
+
|
|
32
|
+
def category_params
|
|
33
|
+
params.require(:category).permit(:name, { :user_group_ids => [] })
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
require_dependency "my_forum/application_controller"
|
|
2
|
+
|
|
3
|
+
module MyForum
|
|
4
|
+
class Admin::ForumsController < ApplicationController
|
|
5
|
+
|
|
6
|
+
before_filter :verify_admin
|
|
7
|
+
|
|
8
|
+
layout 'layouts/my_forum/admin_application'
|
|
9
|
+
|
|
10
|
+
before_filter :find_category, only: [ :new, :create ]
|
|
11
|
+
|
|
12
|
+
def index
|
|
13
|
+
@categories = Category.all
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
def new
|
|
17
|
+
@forum = @forum_category.forums.build
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def create
|
|
21
|
+
@forum = @forum_category.forums.build(forum_params)
|
|
22
|
+
@forum.save ? redirect_to(admin_forums_path) : raise('forum not created')
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
protected
|
|
26
|
+
|
|
27
|
+
def find_category
|
|
28
|
+
@forum_category = Category.find(params[:category_id])
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def forum_params
|
|
32
|
+
params.require(:forum).permit(:name, :description)
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
require_dependency "my_forum/application_controller"
|
|
2
|
+
|
|
3
|
+
module MyForum
|
|
4
|
+
class Admin::RolesController < ApplicationController
|
|
5
|
+
|
|
6
|
+
before_filter :verify_admin
|
|
7
|
+
|
|
8
|
+
layout 'layouts/my_forum/admin_application'
|
|
9
|
+
|
|
10
|
+
def index
|
|
11
|
+
@roles = Role.all
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def new
|
|
15
|
+
@role = Role.new
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def create
|
|
19
|
+
@role = Role.new(role_params)
|
|
20
|
+
@role.save
|
|
21
|
+
redirect_to admin_roles_path
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def edit
|
|
25
|
+
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def update
|
|
29
|
+
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
private
|
|
33
|
+
|
|
34
|
+
def role_params
|
|
35
|
+
params.require(:role).permit(:name, :color)
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
require_dependency "my_forum/application_controller"
|
|
2
|
+
|
|
3
|
+
module MyForum
|
|
4
|
+
class Admin::UsersController < ApplicationController
|
|
5
|
+
before_filter :verify_admin
|
|
6
|
+
|
|
7
|
+
layout 'layouts/my_forum/admin_application'
|
|
8
|
+
|
|
9
|
+
def index
|
|
10
|
+
@users_count = User.count
|
|
11
|
+
@user_groups = UserGroup.all
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
module MyForum
|
|
2
|
+
class ApplicationController < ActionController::Base
|
|
3
|
+
|
|
4
|
+
before_filter :user_activity
|
|
5
|
+
|
|
6
|
+
def authenticate_user!
|
|
7
|
+
redirect_to admin_signin_path unless current_user
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def current_user
|
|
11
|
+
return session[:user_id].blank? ? nil : User.where(id: session[:user_id]).includes(:user_groups).first
|
|
12
|
+
end
|
|
13
|
+
helper_method :current_user
|
|
14
|
+
|
|
15
|
+
def current_user_id
|
|
16
|
+
session[:user_id]
|
|
17
|
+
end
|
|
18
|
+
helper_method :current_user_id
|
|
19
|
+
|
|
20
|
+
def current_user_groups
|
|
21
|
+
return [].push UserGroup::GUEST_GROUP.name unless current_user
|
|
22
|
+
current_user.user_groups.map &:name
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def new_pm_count
|
|
26
|
+
return unless current_user
|
|
27
|
+
PrivateMessage.unread_count_for(current_user)
|
|
28
|
+
end
|
|
29
|
+
helper_method :new_pm_count
|
|
30
|
+
|
|
31
|
+
private
|
|
32
|
+
|
|
33
|
+
def user_activity
|
|
34
|
+
current_user.touch if current_user
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
def verify_admin
|
|
38
|
+
redirect_to root_path unless current_user && current_user.is_admin
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def check_access_permissions(obj)
|
|
42
|
+
return true if current_user && current_user.is_admin
|
|
43
|
+
|
|
44
|
+
category_user_groups = case obj.class.to_s
|
|
45
|
+
when 'MyForum::Forum'
|
|
46
|
+
obj.category.user_groups
|
|
47
|
+
when 'MyForum::Topic'
|
|
48
|
+
obj.forum.category.user_groups
|
|
49
|
+
else
|
|
50
|
+
[]
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
redirect_to root_path if (category_user_groups.map(&:name) & current_user_groups).blank?
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
require_dependency "my_forum/application_controller"
|
|
2
|
+
|
|
3
|
+
module MyForum
|
|
4
|
+
class ForumsController < ApplicationController
|
|
5
|
+
before_filter :find_forum, only: [:show]
|
|
6
|
+
|
|
7
|
+
def show
|
|
8
|
+
check_access_permissions(@forum)
|
|
9
|
+
@forum_topics = @forum.topics_with_latest_post_info(page: params[:page], per_page: 30)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def unread_topics
|
|
13
|
+
redirect_to root_path and return unless current_user
|
|
14
|
+
@forum_topics = Forum.unread_topics_with_latest_post_info(user_id: current_user_id, page: params[:page], per_page: 30)
|
|
15
|
+
|
|
16
|
+
render action: :show
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def mark_all_as_read
|
|
20
|
+
redirect_to root_path and return unless current_user
|
|
21
|
+
|
|
22
|
+
Topic.find_in_batches(batch_size: 500) do |topic_group|
|
|
23
|
+
topic_group.each do |topic|
|
|
24
|
+
log = LogReadMark.find_or_create_by(user_id: current_user.id, topic_id: topic.id)
|
|
25
|
+
log.post_id = topic.latest_post_id
|
|
26
|
+
log.save
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
redirect_to root_path
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
private
|
|
34
|
+
|
|
35
|
+
def find_forum
|
|
36
|
+
@forum = Forum.find(params[:id])
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
require_dependency "my_forum/application_controller"
|
|
2
|
+
|
|
3
|
+
module MyForum
|
|
4
|
+
class PostsController < ApplicationController
|
|
5
|
+
before_filter :find_topic
|
|
6
|
+
before_filter :find_forum
|
|
7
|
+
|
|
8
|
+
def create
|
|
9
|
+
post = @topic.posts.build(post_params)
|
|
10
|
+
post.user = current_user
|
|
11
|
+
post.save
|
|
12
|
+
redirect_to forum_topic_path(@forum, @topic)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
private
|
|
16
|
+
|
|
17
|
+
def find_topic
|
|
18
|
+
@topic = Topic.find(params[:topic_id])
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def find_forum
|
|
22
|
+
@forum = Forum.find(params[:forum_id])
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def post_params
|
|
26
|
+
params.require(:post).permit(:text)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|