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.
Files changed (203) hide show
  1. checksums.yaml +4 -4
  2. data/README.rdoc +12 -1
  3. data/Rakefile +4 -3
  4. data/{test/dummy/public/favicon.ico → app/assets/javascripts/my_forum/admin/categories.js.coffee} +0 -0
  5. data/app/assets/javascripts/my_forum/admin/dashboard.js.coffee +0 -0
  6. data/app/assets/javascripts/my_forum/admin/forums.js.coffee +0 -0
  7. data/app/assets/javascripts/my_forum/admin/roles.js +2 -0
  8. data/app/assets/javascripts/my_forum/admin/users.js +2 -0
  9. data/app/assets/javascripts/my_forum/application.js +6 -0
  10. data/app/assets/javascripts/my_forum/forums.js.coffee +0 -0
  11. data/app/assets/javascripts/my_forum/jquery.scrollTo.min.js +7 -0
  12. data/app/assets/javascripts/my_forum/jquery.selection.js +354 -0
  13. data/app/assets/javascripts/my_forum/my_forum.js.coffee +118 -0
  14. data/app/assets/javascripts/my_forum/posts.js.coffee +20 -0
  15. data/app/assets/javascripts/my_forum/topics.js.coffee +0 -0
  16. data/app/assets/javascripts/my_forum/users.js.coffee +0 -0
  17. data/app/assets/javascripts/my_forum/welcome.js.coffee +0 -0
  18. data/app/assets/stylesheets/my_forum/admin/categories.css.scss +0 -0
  19. data/app/assets/stylesheets/my_forum/admin/dashboard.css.scss +3 -0
  20. data/app/assets/stylesheets/my_forum/admin/forums.css.scss +7 -0
  21. data/app/assets/stylesheets/my_forum/admin/roles.css +4 -0
  22. data/app/assets/stylesheets/my_forum/admin/users.css +4 -0
  23. data/app/assets/stylesheets/my_forum/application.css.scss +80 -0
  24. data/app/assets/stylesheets/my_forum/forums.css.scss +31 -0
  25. data/app/assets/stylesheets/my_forum/posts.css.scss +138 -0
  26. data/app/assets/stylesheets/my_forum/private_messages.css.scss +11 -0
  27. data/app/assets/stylesheets/my_forum/topics.css.scss +16 -0
  28. data/app/assets/stylesheets/my_forum/users.css.scss +3 -0
  29. data/app/assets/stylesheets/my_forum/welcome.css.scss +73 -0
  30. data/app/controllers/my_forum/admin/categories_controller.rb +36 -0
  31. data/app/controllers/my_forum/admin/dashboard_controller.rb +13 -0
  32. data/app/controllers/my_forum/admin/emoticons_controller.rb +65 -0
  33. data/app/controllers/my_forum/admin/forums_controller.rb +35 -0
  34. data/app/controllers/my_forum/admin/mail_controller.rb +31 -0
  35. data/app/controllers/my_forum/admin/roles_controller.rb +38 -0
  36. data/app/controllers/my_forum/admin/users_controller.rb +14 -0
  37. data/app/controllers/my_forum/application_controller.rb +81 -0
  38. data/app/controllers/my_forum/attachments_controller.rb +30 -0
  39. data/app/controllers/my_forum/forums_controller.rb +39 -0
  40. data/app/controllers/my_forum/images_controller.rb +7 -0
  41. data/app/controllers/my_forum/posts_controller.rb +96 -0
  42. data/app/controllers/my_forum/private_messages_controller.rb +73 -0
  43. data/app/controllers/my_forum/topics_controller.rb +96 -0
  44. data/app/controllers/my_forum/users_controller.rb +145 -0
  45. data/app/controllers/my_forum/welcome_controller.rb +30 -0
  46. data/app/helpers/my_forum/admin/dashboard_helper.rb +4 -0
  47. data/app/helpers/my_forum/admin/forums_helper.rb +4 -0
  48. data/app/helpers/my_forum/admin/roles_helper.rb +4 -0
  49. data/app/helpers/my_forum/admin/users_helper.rb +4 -0
  50. data/app/helpers/my_forum/application_helper.rb +43 -0
  51. data/app/helpers/my_forum/emoticons_helper.rb +7 -0
  52. data/app/helpers/my_forum/forums_helper.rb +44 -0
  53. data/app/helpers/my_forum/posts_helper.rb +76 -0
  54. data/app/helpers/my_forum/private_messages_helper.rb +25 -0
  55. data/app/helpers/my_forum/topics_helper.rb +18 -0
  56. data/app/helpers/my_forum/users_helper.rb +33 -0
  57. data/app/helpers/my_forum/welcome_helper.rb +4 -0
  58. data/app/mailers/application_mailer.rb +4 -0
  59. data/app/mailers/my_forum/user_mailer.rb +31 -0
  60. data/app/models/my_forum/attachment.rb +12 -0
  61. data/app/models/my_forum/avatar.rb +11 -0
  62. data/app/models/my_forum/category.rb +7 -0
  63. data/app/models/my_forum/category_permission.rb +6 -0
  64. data/app/models/my_forum/emoticon.rb +6 -0
  65. data/app/models/my_forum/forum.rb +50 -0
  66. data/app/models/my_forum/image.rb +5 -0
  67. data/app/models/my_forum/log_read_mark.rb +4 -0
  68. data/app/models/my_forum/post.rb +26 -0
  69. data/app/models/my_forum/private_message.rb +8 -0
  70. data/app/models/my_forum/role.rb +6 -0
  71. data/app/models/my_forum/topic.rb +41 -0
  72. data/app/models/my_forum/user.rb +71 -0
  73. data/app/models/my_forum/user_group.rb +13 -0
  74. data/app/models/my_forum/user_group_link.rb +6 -0
  75. data/app/models/my_forum/user_roles.rb +6 -0
  76. data/app/views/layouts/mailer.html.erb +5 -0
  77. data/app/views/layouts/mailer.text.erb +1 -0
  78. data/app/views/layouts/my_forum/_guest_navbar.html.haml +4 -0
  79. data/app/views/layouts/my_forum/_user_navbar.html.haml +19 -0
  80. data/app/views/layouts/my_forum/admin_application.haml +29 -0
  81. data/app/views/layouts/my_forum/application.haml +23 -0
  82. data/app/views/my_forum/admin/categories/edit.haml +9 -0
  83. data/app/views/my_forum/admin/categories/new.haml +5 -0
  84. data/app/views/my_forum/admin/dashboard/index.haml +0 -0
  85. data/app/views/my_forum/admin/emoticons/edit.haml +4 -0
  86. data/app/views/my_forum/admin/emoticons/index.haml +15 -0
  87. data/app/views/my_forum/admin/emoticons/new.haml +5 -0
  88. data/app/views/my_forum/admin/forums/index.haml +47 -0
  89. data/app/views/my_forum/admin/forums/new.haml +6 -0
  90. data/app/views/my_forum/admin/mail/index.haml +9 -0
  91. data/app/views/my_forum/admin/roles/index.haml +12 -0
  92. data/app/views/my_forum/admin/roles/new.haml +22 -0
  93. data/app/views/my_forum/admin/users/index.haml +10 -0
  94. data/app/views/my_forum/forums/_topic_subject.html.haml +16 -0
  95. data/app/views/my_forum/forums/show.haml +29 -0
  96. data/app/views/my_forum/posts/edit.html.haml +31 -0
  97. data/app/views/my_forum/private_messages/_sidebar.haml +10 -0
  98. data/app/views/my_forum/private_messages/inbox.haml +26 -0
  99. data/app/views/my_forum/private_messages/new.haml +21 -0
  100. data/app/views/my_forum/private_messages/show.haml +10 -0
  101. data/app/views/my_forum/shared/_post_preview.haml +15 -0
  102. data/app/views/my_forum/shared/_upload_photo.haml +45 -0
  103. data/app/views/my_forum/shared/post_preview.js.coffee +4 -0
  104. data/app/views/my_forum/topics/_post.haml +29 -0
  105. data/app/views/my_forum/topics/_profile_popover.haml +47 -0
  106. data/app/views/my_forum/topics/_quick_answer.haml +34 -0
  107. data/app/views/my_forum/topics/_topic_header.haml +4 -0
  108. data/app/views/my_forum/topics/_user_info.haml +9 -0
  109. data/app/views/my_forum/topics/new.haml +38 -0
  110. data/app/views/my_forum/topics/show.haml +60 -0
  111. data/app/views/my_forum/user_mailer/custom_email.text.erb +1 -0
  112. data/app/views/my_forum/user_mailer/ping_from_post.haml +8 -0
  113. data/app/views/my_forum/user_mailer/ping_from_post.text.erb +6 -0
  114. data/app/views/my_forum/user_mailer/pm_notification.text.erb +6 -0
  115. data/app/views/my_forum/user_mailer/reset_password_email.haml +1 -0
  116. data/app/views/my_forum/user_mailer/reset_password_email.text.erb +1 -0
  117. data/app/views/my_forum/users/edit.haml +36 -0
  118. data/app/views/my_forum/users/forgot_password.haml +10 -0
  119. data/app/views/my_forum/users/new.haml +14 -0
  120. data/app/views/my_forum/users/signin.haml +14 -0
  121. data/app/views/my_forum/users/signout.haml +0 -0
  122. data/app/views/my_forum/welcome/index.haml +37 -0
  123. data/config/initializers/will_paginate.rb +24 -0
  124. data/config/locales/en.yml +68 -0
  125. data/config/locales/ru.yml +198 -0
  126. data/config/routes.rb +48 -0
  127. data/db/migrate/20141117122725_create_my_forum_forums.rb +12 -0
  128. data/db/migrate/20141117122742_create_my_forum_topics.rb +17 -0
  129. data/db/migrate/20141117122751_create_my_forum_posts.rb +11 -0
  130. data/db/migrate/20141118081021_create_my_forum_categories.rb +8 -0
  131. data/db/migrate/20141118131215_create_my_forum_users.rb +34 -0
  132. data/db/migrate/20141222094522_create_my_forum_roles.rb +10 -0
  133. data/db/migrate/20141222094538_create_my_forum_user_roles.rb +9 -0
  134. data/db/migrate/20150202115250_create_my_forum_log_read_marks.rb +10 -0
  135. data/db/migrate/20150215200453_create_my_forum_user_groups.rb +15 -0
  136. data/db/migrate/20150215204852_create_my_forum_user_group_links.rb +9 -0
  137. data/db/migrate/20150215212443_create_my_forum_category_permissions.rb +9 -0
  138. data/db/migrate/20150227210814_create_my_forum_private_messages.rb +16 -0
  139. data/db/migrate/20151012095554_create_my_forum_images.rb +12 -0
  140. data/db/migrate/20151218135729_add_is_deleted.rb +6 -0
  141. data/db/migrate/20151220121140_create_my_forum_emoticons.rb +10 -0
  142. data/db/migrate/20151221203243_my_forum_rename_user_avatar.rb +5 -0
  143. data/db/migrate/20151221205045_my_forum_change_user_avatar.rb +5 -0
  144. data/db/migrate/20160122202142_add_latest_post_info_for_topic.rb +24 -0
  145. data/db/migrate/20160210130805_add_indexes_for_topics.rb +7 -0
  146. data/db/migrate/20160214085201_add_edited_by_for_post.rb +5 -0
  147. data/lib/my_forum/engine.rb +31 -0
  148. data/lib/my_forum/version.rb +1 -1
  149. data/lib/tasks/my_forum_tasks.rake +155 -4
  150. data/spec/controllers/my_forum/admin/emoticons_controller_spec.rb +7 -0
  151. data/spec/controllers/my_forum/admin/mail_controller_spec.rb +7 -0
  152. data/spec/controllers/my_forum/private_messages_controller_spec.rb +7 -0
  153. data/spec/controllers/my_forum/users_controller_spec.rb +76 -0
  154. data/{test → spec}/dummy/README.rdoc +0 -0
  155. data/{test → spec}/dummy/Rakefile +0 -0
  156. data/{test → spec}/dummy/app/assets/javascripts/application.js +1 -1
  157. data/{app/assets/stylesheets/my_forum → spec/dummy/app/assets/stylesheets}/application.css +1 -1
  158. data/{test → spec}/dummy/app/controllers/application_controller.rb +0 -0
  159. data/{test → spec}/dummy/app/helpers/application_helper.rb +0 -0
  160. data/{test → spec}/dummy/app/views/layouts/application.html.erb +0 -0
  161. data/{test → spec}/dummy/bin/bundle +0 -0
  162. data/{test → spec}/dummy/bin/rails +0 -0
  163. data/{test → spec}/dummy/bin/rake +0 -0
  164. data/{test → spec}/dummy/config/application.rb +0 -0
  165. data/{test → spec}/dummy/config/boot.rb +0 -0
  166. data/{test → spec}/dummy/config/database.yml +0 -0
  167. data/{test → spec}/dummy/config/environment.rb +0 -0
  168. data/{test → spec}/dummy/config/environments/development.rb +0 -0
  169. data/{test → spec}/dummy/config/environments/production.rb +1 -1
  170. data/{test → spec}/dummy/config/environments/test.rb +1 -1
  171. data/{test → spec}/dummy/config/initializers/assets.rb +0 -0
  172. data/{test → spec}/dummy/config/initializers/backtrace_silencers.rb +0 -0
  173. data/{test → spec}/dummy/config/initializers/cookies_serializer.rb +0 -0
  174. data/{test → spec}/dummy/config/initializers/filter_parameter_logging.rb +0 -0
  175. data/{test → spec}/dummy/config/initializers/inflections.rb +0 -0
  176. data/{test → spec}/dummy/config/initializers/mime_types.rb +0 -0
  177. data/{test → spec}/dummy/config/initializers/session_store.rb +0 -0
  178. data/{test → spec}/dummy/config/initializers/wrap_parameters.rb +0 -0
  179. data/{test → spec}/dummy/config/locales/en.yml +0 -0
  180. data/{test → spec}/dummy/config/routes.rb +0 -0
  181. data/{test → spec}/dummy/config/secrets.yml +0 -0
  182. data/{test → spec}/dummy/config.ru +0 -0
  183. data/spec/dummy/db/development.sqlite3 +0 -0
  184. data/spec/dummy/db/schema.rb +159 -0
  185. data/spec/dummy/db/test.sqlite3 +0 -0
  186. data/spec/dummy/log/development.log +12 -0
  187. data/{test → spec}/dummy/public/404.html +0 -0
  188. data/{test → spec}/dummy/public/422.html +0 -0
  189. data/{test → spec}/dummy/public/500.html +0 -0
  190. data/spec/dummy/public/favicon.ico +0 -0
  191. data/spec/helpers/my_forum/posts_helper_spec.rb +24 -0
  192. data/spec/helpers/my_forum/private_messages_helper_spec.rb +17 -0
  193. data/spec/models/my_forum/emoticon_spec.rb +7 -0
  194. data/spec/models/my_forum/private_message_spec.rb +7 -0
  195. data/spec/models/my_forum/user_spec.rb +13 -0
  196. data/spec/rails_helper.rb +52 -0
  197. data/spec/spec_helper.rb +87 -0
  198. metadata +356 -83
  199. data/app/views/layouts/my_forum/application.html.erb +0 -14
  200. data/test/dummy/app/assets/stylesheets/application.css +0 -15
  201. data/test/integration/navigation_test.rb +0 -10
  202. data/test/my_forum_test.rb +0 -7
  203. 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,11 @@
1
+ .new-pm.badge {
2
+ background-color: orange !important;
3
+ }
4
+
5
+ .new_pm_button {
6
+ margin-bottom: 14px;
7
+ }
8
+
9
+ .unread {
10
+ font-weight: bold;
11
+ }
@@ -0,0 +1,16 @@
1
+ .topic-header {
2
+ .info {
3
+ font-size: 12px;
4
+ color: #a4a4a4;
5
+ }
6
+ }
7
+
8
+ .topic-list {
9
+ .pin-sign {
10
+ margin-right: 8px;
11
+ }
12
+ }
13
+
14
+ textarea.quick-answer {
15
+ height: 100px !important;
16
+ }
@@ -0,0 +1,3 @@
1
+ .submit_update_avatar {
2
+ margin-top: 10px;
3
+ }
@@ -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,13 @@
1
+ require_dependency "my_forum/application_controller"
2
+
3
+ module MyForum
4
+ class Admin::DashboardController < ApplicationController
5
+
6
+ before_filter :verify_admin
7
+
8
+ layout 'layouts/my_forum/admin_application'
9
+
10
+ def index
11
+ end
12
+ end
13
+ 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