my_forum 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rdoc +12 -1
- data/Rakefile +4 -3
- data/{test/dummy/public/favicon.ico → 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 +6 -0
- data/app/assets/javascripts/my_forum/forums.js.coffee +0 -0
- data/app/assets/javascripts/my_forum/jquery.scrollTo.min.js +7 -0
- data/app/assets/javascripts/my_forum/jquery.selection.js +354 -0
- data/app/assets/javascripts/my_forum/my_forum.js.coffee +118 -0
- data/app/assets/javascripts/my_forum/posts.js.coffee +20 -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 +80 -0
- data/app/assets/stylesheets/my_forum/forums.css.scss +31 -0
- data/app/assets/stylesheets/my_forum/posts.css.scss +138 -0
- data/app/assets/stylesheets/my_forum/private_messages.css.scss +11 -0
- data/app/assets/stylesheets/my_forum/topics.css.scss +16 -0
- data/app/assets/stylesheets/my_forum/users.css.scss +3 -0
- data/app/assets/stylesheets/my_forum/welcome.css.scss +73 -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/emoticons_controller.rb +65 -0
- data/app/controllers/my_forum/admin/forums_controller.rb +35 -0
- data/app/controllers/my_forum/admin/mail_controller.rb +31 -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 +81 -0
- data/app/controllers/my_forum/attachments_controller.rb +30 -0
- data/app/controllers/my_forum/forums_controller.rb +39 -0
- data/app/controllers/my_forum/images_controller.rb +7 -0
- data/app/controllers/my_forum/posts_controller.rb +96 -0
- data/app/controllers/my_forum/private_messages_controller.rb +73 -0
- data/app/controllers/my_forum/topics_controller.rb +96 -0
- data/app/controllers/my_forum/users_controller.rb +145 -0
- data/app/controllers/my_forum/welcome_controller.rb +30 -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 +43 -0
- data/app/helpers/my_forum/emoticons_helper.rb +7 -0
- data/app/helpers/my_forum/forums_helper.rb +44 -0
- data/app/helpers/my_forum/posts_helper.rb +76 -0
- data/app/helpers/my_forum/private_messages_helper.rb +25 -0
- data/app/helpers/my_forum/topics_helper.rb +18 -0
- data/app/helpers/my_forum/users_helper.rb +33 -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 +31 -0
- data/app/models/my_forum/attachment.rb +12 -0
- data/app/models/my_forum/avatar.rb +11 -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/emoticon.rb +6 -0
- data/app/models/my_forum/forum.rb +50 -0
- data/app/models/my_forum/image.rb +5 -0
- data/app/models/my_forum/log_read_mark.rb +4 -0
- data/app/models/my_forum/post.rb +26 -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 +41 -0
- data/app/models/my_forum/user.rb +71 -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 +19 -0
- data/app/views/layouts/my_forum/admin_application.haml +29 -0
- data/app/views/layouts/my_forum/application.haml +23 -0
- data/app/views/my_forum/admin/categories/edit.haml +9 -0
- data/app/views/my_forum/admin/categories/new.haml +5 -0
- data/app/views/my_forum/admin/dashboard/index.haml +0 -0
- data/app/views/my_forum/admin/emoticons/edit.haml +4 -0
- data/app/views/my_forum/admin/emoticons/index.haml +15 -0
- data/app/views/my_forum/admin/emoticons/new.haml +5 -0
- data/app/views/my_forum/admin/forums/index.haml +47 -0
- data/app/views/my_forum/admin/forums/new.haml +6 -0
- data/app/views/my_forum/admin/mail/index.haml +9 -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 +16 -0
- data/app/views/my_forum/forums/show.haml +29 -0
- data/app/views/my_forum/posts/edit.html.haml +31 -0
- data/app/views/my_forum/private_messages/_sidebar.haml +10 -0
- data/app/views/my_forum/private_messages/inbox.haml +26 -0
- data/app/views/my_forum/private_messages/new.haml +21 -0
- data/app/views/my_forum/private_messages/show.haml +10 -0
- data/app/views/my_forum/shared/_post_preview.haml +15 -0
- data/app/views/my_forum/shared/_upload_photo.haml +45 -0
- data/app/views/my_forum/shared/post_preview.js.coffee +4 -0
- data/app/views/my_forum/topics/_post.haml +29 -0
- data/app/views/my_forum/topics/_profile_popover.haml +47 -0
- data/app/views/my_forum/topics/_quick_answer.haml +34 -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 +38 -0
- data/app/views/my_forum/topics/show.haml +60 -0
- data/app/views/my_forum/user_mailer/custom_email.text.erb +1 -0
- data/app/views/my_forum/user_mailer/ping_from_post.haml +8 -0
- data/app/views/my_forum/user_mailer/ping_from_post.text.erb +6 -0
- data/app/views/my_forum/user_mailer/pm_notification.text.erb +6 -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 +36 -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 +37 -0
- data/config/initializers/will_paginate.rb +24 -0
- data/config/locales/en.yml +68 -0
- data/config/locales/ru.yml +198 -0
- data/config/routes.rb +48 -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 +34 -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 +16 -0
- data/db/migrate/20151012095554_create_my_forum_images.rb +12 -0
- data/db/migrate/20151218135729_add_is_deleted.rb +6 -0
- data/db/migrate/20151220121140_create_my_forum_emoticons.rb +10 -0
- data/db/migrate/20151221203243_my_forum_rename_user_avatar.rb +5 -0
- data/db/migrate/20151221205045_my_forum_change_user_avatar.rb +5 -0
- data/db/migrate/20160122202142_add_latest_post_info_for_topic.rb +24 -0
- data/db/migrate/20160210130805_add_indexes_for_topics.rb +7 -0
- data/db/migrate/20160214085201_add_edited_by_for_post.rb +5 -0
- data/lib/my_forum/engine.rb +31 -0
- data/lib/my_forum/version.rb +1 -1
- data/lib/tasks/my_forum_tasks.rake +155 -4
- data/spec/controllers/my_forum/admin/emoticons_controller_spec.rb +7 -0
- data/spec/controllers/my_forum/admin/mail_controller_spec.rb +7 -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/{test → spec}/dummy/README.rdoc +0 -0
- data/{test → spec}/dummy/Rakefile +0 -0
- data/{test → spec}/dummy/app/assets/javascripts/application.js +1 -1
- data/{app/assets/stylesheets/my_forum → spec/dummy/app/assets/stylesheets}/application.css +1 -1
- data/{test → spec}/dummy/app/controllers/application_controller.rb +0 -0
- data/{test → spec}/dummy/app/helpers/application_helper.rb +0 -0
- data/{test → spec}/dummy/app/views/layouts/application.html.erb +0 -0
- data/{test → spec}/dummy/bin/bundle +0 -0
- data/{test → spec}/dummy/bin/rails +0 -0
- data/{test → spec}/dummy/bin/rake +0 -0
- data/{test → spec}/dummy/config/application.rb +0 -0
- data/{test → spec}/dummy/config/boot.rb +0 -0
- data/{test → spec}/dummy/config/database.yml +0 -0
- data/{test → spec}/dummy/config/environment.rb +0 -0
- data/{test → spec}/dummy/config/environments/development.rb +0 -0
- data/{test → spec}/dummy/config/environments/production.rb +1 -1
- data/{test → spec}/dummy/config/environments/test.rb +1 -1
- data/{test → spec}/dummy/config/initializers/assets.rb +0 -0
- data/{test → spec}/dummy/config/initializers/backtrace_silencers.rb +0 -0
- data/{test → spec}/dummy/config/initializers/cookies_serializer.rb +0 -0
- data/{test → spec}/dummy/config/initializers/filter_parameter_logging.rb +0 -0
- data/{test → spec}/dummy/config/initializers/inflections.rb +0 -0
- data/{test → spec}/dummy/config/initializers/mime_types.rb +0 -0
- data/{test → spec}/dummy/config/initializers/session_store.rb +0 -0
- data/{test → spec}/dummy/config/initializers/wrap_parameters.rb +0 -0
- data/{test → spec}/dummy/config/locales/en.yml +0 -0
- data/{test → spec}/dummy/config/routes.rb +0 -0
- data/{test → spec}/dummy/config/secrets.yml +0 -0
- data/{test → spec}/dummy/config.ru +0 -0
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/schema.rb +159 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/development.log +12 -0
- data/{test → spec}/dummy/public/404.html +0 -0
- data/{test → spec}/dummy/public/422.html +0 -0
- data/{test → spec}/dummy/public/500.html +0 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/helpers/my_forum/posts_helper_spec.rb +24 -0
- data/spec/helpers/my_forum/private_messages_helper_spec.rb +17 -0
- data/spec/models/my_forum/emoticon_spec.rb +7 -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 +356 -83
- data/app/views/layouts/my_forum/application.html.erb +0 -14
- data/test/dummy/app/assets/stylesheets/application.css +0 -15
- data/test/integration/navigation_test.rb +0 -10
- data/test/my_forum_test.rb +0 -7
- data/test/test_helper.rb +0 -15
@@ -0,0 +1,80 @@
|
|
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
|
+
@import "font-awesome-sprockets";
|
20
|
+
@import "font-awesome";
|
21
|
+
|
22
|
+
.popover {
|
23
|
+
min-width: 540px !important;
|
24
|
+
}
|
25
|
+
|
26
|
+
.popover-title {
|
27
|
+
font-weight: bold;
|
28
|
+
color: #000;
|
29
|
+
}
|
30
|
+
|
31
|
+
.modal-dialog {
|
32
|
+
.post_attachment {
|
33
|
+
max-width: 200px;
|
34
|
+
}
|
35
|
+
}
|
36
|
+
|
37
|
+
.buttons_for_new_topic {
|
38
|
+
margin-top: 10px;
|
39
|
+
}
|
40
|
+
|
41
|
+
.errors_for {
|
42
|
+
color: red;
|
43
|
+
padding: 10px;
|
44
|
+
border: 1px solid red;
|
45
|
+
margin-bottom: 14px;
|
46
|
+
}
|
47
|
+
|
48
|
+
#autocomplete_popup {
|
49
|
+
position: absolute;
|
50
|
+
border: 1px solid grey;
|
51
|
+
padding: 0;
|
52
|
+
background-color: #fff;
|
53
|
+
|
54
|
+
ul {
|
55
|
+
list-style-type: none;
|
56
|
+
padding-left: 0;
|
57
|
+
width: 200px;
|
58
|
+
|
59
|
+
li {
|
60
|
+
padding: 4px;
|
61
|
+
width: 100%;
|
62
|
+
cursor: pointer;
|
63
|
+
}
|
64
|
+
|
65
|
+
li:hover {
|
66
|
+
background-color: cornflowerblue;
|
67
|
+
}
|
68
|
+
}
|
69
|
+
|
70
|
+
}
|
71
|
+
.text-editor-buttons {
|
72
|
+
margin-bottom: -1px;
|
73
|
+
|
74
|
+
.btn-group.smiles {
|
75
|
+
img {
|
76
|
+
max-width: 16px;
|
77
|
+
height: 16px;
|
78
|
+
}
|
79
|
+
}
|
80
|
+
}
|
@@ -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,138 @@
|
|
1
|
+
.profile-popover {
|
2
|
+
font-size: 11px;
|
3
|
+
color: #000;
|
4
|
+
|
5
|
+
.second_row {
|
6
|
+
margin-left: 10px;
|
7
|
+
}
|
8
|
+
|
9
|
+
.pm {
|
10
|
+
margin: 16px 0;
|
11
|
+
}
|
12
|
+
}
|
13
|
+
|
14
|
+
.topic_posts_info {
|
15
|
+
background-color: #d3daed;
|
16
|
+
color: #fff;
|
17
|
+
font-size: 11px;
|
18
|
+
height: 38px;
|
19
|
+
line-height: 38px;
|
20
|
+
}
|
21
|
+
|
22
|
+
.post-list-container {
|
23
|
+
background-color: #f7f7f7;
|
24
|
+
|
25
|
+
.box {
|
26
|
+
margin: 12px;
|
27
|
+
border: 1px solid #DFDFDF;
|
28
|
+
background-color: #fff;
|
29
|
+
|
30
|
+
.user_profile_popover {
|
31
|
+
cursor: pointer;
|
32
|
+
}
|
33
|
+
|
34
|
+
.post_from_user_login {
|
35
|
+
.user_profile_popover {
|
36
|
+
position: relative;
|
37
|
+
z-index: 100;
|
38
|
+
padding: 5px;
|
39
|
+
}
|
40
|
+
|
41
|
+
font-weight: bold;
|
42
|
+
color: #c1ccf5;
|
43
|
+
}
|
44
|
+
|
45
|
+
.post_from_user_login .login:hover {
|
46
|
+
color: #fff;
|
47
|
+
}
|
48
|
+
|
49
|
+
.post-header {
|
50
|
+
height: 36px;
|
51
|
+
line-height: 36px;
|
52
|
+
margin: 0;
|
53
|
+
background-color: #4e61a8;
|
54
|
+
|
55
|
+
.post_number a {
|
56
|
+
color: #fff;
|
57
|
+
font-size: 9px;
|
58
|
+
}
|
59
|
+
}
|
60
|
+
|
61
|
+
.created_at {
|
62
|
+
margin-top: 10px;
|
63
|
+
font-size: 11px;
|
64
|
+
color: #a4a4a4;
|
65
|
+
}
|
66
|
+
|
67
|
+
.post_attachment {
|
68
|
+
max-width: 400px;
|
69
|
+
}
|
70
|
+
|
71
|
+
.quote {
|
72
|
+
border: 1px solid black;
|
73
|
+
}
|
74
|
+
|
75
|
+
.edited_by {
|
76
|
+
padding: 10px 40px;
|
77
|
+
font-size: 10px;
|
78
|
+
font-weight: bold;
|
79
|
+
font-style: italic;
|
80
|
+
}
|
81
|
+
|
82
|
+
.bbqoute {
|
83
|
+
|
84
|
+
.quote_info {
|
85
|
+
font-weight: bold;
|
86
|
+
font-size: 11px;
|
87
|
+
}
|
88
|
+
|
89
|
+
margin-right: 10px;
|
90
|
+
border: 1px solid gainsboro;
|
91
|
+
border-radius: 25px;
|
92
|
+
padding: 10px 20px 10px 20px;
|
93
|
+
}
|
94
|
+
|
95
|
+
.user-title {
|
96
|
+
margin-top: 10px;
|
97
|
+
font-size: 11px;
|
98
|
+
text-align: center;
|
99
|
+
}
|
100
|
+
|
101
|
+
img.user-avatar {
|
102
|
+
width: 100px;
|
103
|
+
}
|
104
|
+
|
105
|
+
.user-avatar {
|
106
|
+
text-align: center;
|
107
|
+
}
|
108
|
+
|
109
|
+
.user-posts-count {
|
110
|
+
font-size: 11px;
|
111
|
+
text-align: center;
|
112
|
+
margin-top: 8px;
|
113
|
+
}
|
114
|
+
|
115
|
+
.user-reg-date {
|
116
|
+
font-size: 11px;
|
117
|
+
text-align: center;
|
118
|
+
margin-top: 4px;
|
119
|
+
margin-bottom: 10px;
|
120
|
+
}
|
121
|
+
}
|
122
|
+
}
|
123
|
+
|
124
|
+
#new_topic {
|
125
|
+
.name, .description {
|
126
|
+
width: 50%;
|
127
|
+
}
|
128
|
+
}
|
129
|
+
|
130
|
+
#quick_answer {
|
131
|
+
margin: 26px 0;
|
132
|
+
}
|
133
|
+
|
134
|
+
#edit-post {
|
135
|
+
textarea {
|
136
|
+
width: 100%;
|
137
|
+
}
|
138
|
+
}
|
@@ -0,0 +1,73 @@
|
|
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
|
+
#recent_topics {
|
65
|
+
table {
|
66
|
+
font-size: 10px;
|
67
|
+
}
|
68
|
+
}
|
69
|
+
|
70
|
+
#online_users {
|
71
|
+
margin: 20px 0;
|
72
|
+
font-size: 10px
|
73
|
+
}
|
@@ -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,65 @@
|
|
1
|
+
require_dependency "my_forum/application_controller"
|
2
|
+
|
3
|
+
module MyForum
|
4
|
+
class Admin::EmoticonsController < ApplicationController
|
5
|
+
before_filter :verify_admin
|
6
|
+
|
7
|
+
layout 'layouts/my_forum/admin_application'
|
8
|
+
|
9
|
+
def index
|
10
|
+
@emoticons = Emoticon.all
|
11
|
+
end
|
12
|
+
|
13
|
+
def new
|
14
|
+
@emoticon = Emoticon.new
|
15
|
+
end
|
16
|
+
|
17
|
+
def create
|
18
|
+
#TODO validation add
|
19
|
+
|
20
|
+
# Create dir of not exists
|
21
|
+
FileUtils::mkdir_p Emoticon::UPLOAD_PATH
|
22
|
+
|
23
|
+
uploaded_io = params[:emoticon][:file_name]
|
24
|
+
File.open(File.join(Emoticon::UPLOAD_PATH, uploaded_io.original_filename), 'wb') do |file|
|
25
|
+
file.write(uploaded_io.read)
|
26
|
+
end
|
27
|
+
|
28
|
+
attachment = Emoticon.create(code: params[:emoticon][:code], file_name: uploaded_io.original_filename, is_active: true)
|
29
|
+
|
30
|
+
redirect_to admin_emoticons_path
|
31
|
+
end
|
32
|
+
|
33
|
+
def edit
|
34
|
+
@emoticon = Emoticon.find(params[:id])
|
35
|
+
end
|
36
|
+
|
37
|
+
def update
|
38
|
+
emoticon = Emoticon.find(params[:id])
|
39
|
+
emoticon.update(emoticon_params)
|
40
|
+
|
41
|
+
redirect_to admin_emoticons_path
|
42
|
+
end
|
43
|
+
|
44
|
+
def destroy
|
45
|
+
return unless emoticon = Emoticon.find(params[:id])
|
46
|
+
|
47
|
+
begin
|
48
|
+
FileUtils.rm File.join(Emoticon::UPLOAD_PATH, emoticon.file_name)
|
49
|
+
emoticon.destroy
|
50
|
+
rescue
|
51
|
+
Rails.logger.error 'can`t find and delete emoticon file'
|
52
|
+
ensure
|
53
|
+
emoticon.destroy
|
54
|
+
end
|
55
|
+
|
56
|
+
redirect_to admin_emoticons_path
|
57
|
+
end
|
58
|
+
|
59
|
+
private
|
60
|
+
|
61
|
+
def emoticon_params
|
62
|
+
params.require(:emoticon).permit(:code)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
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,31 @@
|
|
1
|
+
require_dependency "my_forum/application_controller"
|
2
|
+
|
3
|
+
module MyForum
|
4
|
+
class Admin::MailController < ApplicationController
|
5
|
+
before_filter :verify_admin
|
6
|
+
|
7
|
+
layout 'layouts/my_forum/admin_application'
|
8
|
+
|
9
|
+
def index
|
10
|
+
if request.post?
|
11
|
+
send_mails(params[:emails], params[:subject], params[:message]) unless params[:emails].blank?
|
12
|
+
redirect_to admin_mail_list_path
|
13
|
+
else
|
14
|
+
@users = User.all.map{ |u| [u.login, u.email]}
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
private
|
19
|
+
|
20
|
+
def send_mails(email_list, subject, message)
|
21
|
+
email_list.each do |mail|
|
22
|
+
begin
|
23
|
+
UserMailer.custom_email(email: mail, subject: subject, message: message).deliver_now
|
24
|
+
rescue => e
|
25
|
+
logger.error '============= send_mails Mailer ============='
|
26
|
+
logger.error e
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
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
|
@@ -1,4 +1,85 @@
|
|
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
|
3
84
|
end
|
4
85
|
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
require_dependency "my_forum/application_controller"
|
2
|
+
|
3
|
+
module MyForum
|
4
|
+
class AttachmentsController < ApplicationController
|
5
|
+
|
6
|
+
def create
|
7
|
+
upload_path = File.join(Attachment::UPLOAD_PATH, current_user.id.to_s)
|
8
|
+
|
9
|
+
# Create dir of not exists
|
10
|
+
FileUtils::mkdir_p upload_path
|
11
|
+
|
12
|
+
attachment_ids = []
|
13
|
+
|
14
|
+
params[:files].each do |uploaded_io|
|
15
|
+
next unless Attachment::ALLOWED_FILE_CONTENT_TYPE.include? uploaded_io.content_type
|
16
|
+
|
17
|
+
file_name = "#{Time.now.to_i}_#{uploaded_io.original_filename}"
|
18
|
+
File.open(File.join(upload_path, file_name), 'wb') do |file|
|
19
|
+
file.write(uploaded_io.read)
|
20
|
+
end
|
21
|
+
|
22
|
+
attachment = Attachment.create(user_id: current_user.id, file_name: file_name)
|
23
|
+
attachment_ids.push attachment.id
|
24
|
+
end
|
25
|
+
|
26
|
+
render json: { success: true, attachments: attachment_ids }.to_json
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|