formol 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (226) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.md +147 -0
  3. data/Rakefile +29 -0
  4. data/app/assets/images/formol/read.png +0 -0
  5. data/app/assets/images/formol/unread.png +0 -0
  6. data/app/assets/javascripts/formol/admin/categories.js.coffee +55 -0
  7. data/app/assets/javascripts/formol/admin/forums.js +2 -0
  8. data/app/assets/javascripts/formol/application.js +9 -0
  9. data/app/assets/javascripts/formol/categories.js +2 -0
  10. data/app/assets/javascripts/formol/forums.js +2 -0
  11. data/app/assets/javascripts/formol/poll_votes.js +2 -0
  12. data/app/assets/javascripts/formol/posts.js.coffee +9 -0
  13. data/app/assets/javascripts/formol/preferences.js +2 -0
  14. data/app/assets/javascripts/formol/subscriptions.js.coffee +13 -0
  15. data/app/assets/javascripts/formol/topics.js.coffee +54 -0
  16. data/app/assets/javascripts/lib/jquery.prevent_double_submit.js.coffee +11 -0
  17. data/app/assets/javascripts/markitup/jquery.markitup.js +593 -0
  18. data/app/assets/javascripts/markitup/sets/markdown/set.js +53 -0
  19. data/app/assets/stylesheets/form_struct.css.scss +39 -0
  20. data/app/assets/stylesheets/formol/admin/categories.css.scss +30 -0
  21. data/app/assets/stylesheets/formol/admin/forums.css +4 -0
  22. data/app/assets/stylesheets/formol/categories.css.scss +3 -0
  23. data/app/assets/stylesheets/formol/development.css +4 -0
  24. data/app/assets/stylesheets/formol/forums.css.scss +3 -0
  25. data/app/assets/stylesheets/formol/mixins/after_clear.css.scss +7 -0
  26. data/app/assets/stylesheets/formol/partials/breadcrumb.css.scss +9 -0
  27. data/app/assets/stylesheets/formol/partials/categories/list.css.scss +101 -0
  28. data/app/assets/stylesheets/formol/partials/formol_lists.css.scss +6 -0
  29. data/app/assets/stylesheets/formol/partials/forums/list.css.scss +97 -0
  30. data/app/assets/stylesheets/formol/partials/polls/poll.css.scss +9 -0
  31. data/app/assets/stylesheets/formol/partials/posts/post.css.scss +116 -0
  32. data/app/assets/stylesheets/formol/posts.css.scss +8 -0
  33. data/app/assets/stylesheets/formol/topics.css.scss +42 -0
  34. data/app/assets/stylesheets/markitup/sets/markdown/images/block_code.png +0 -0
  35. data/app/assets/stylesheets/markitup/sets/markdown/images/bold.png +0 -0
  36. data/app/assets/stylesheets/markitup/sets/markdown/images/code.png +0 -0
  37. data/app/assets/stylesheets/markitup/sets/markdown/images/h1.png +0 -0
  38. data/app/assets/stylesheets/markitup/sets/markdown/images/h2.png +0 -0
  39. data/app/assets/stylesheets/markitup/sets/markdown/images/h3.png +0 -0
  40. data/app/assets/stylesheets/markitup/sets/markdown/images/h4.png +0 -0
  41. data/app/assets/stylesheets/markitup/sets/markdown/images/h5.png +0 -0
  42. data/app/assets/stylesheets/markitup/sets/markdown/images/h6.png +0 -0
  43. data/app/assets/stylesheets/markitup/sets/markdown/images/italic.png +0 -0
  44. data/app/assets/stylesheets/markitup/sets/markdown/images/link.png +0 -0
  45. data/app/assets/stylesheets/markitup/sets/markdown/images/list-bullet.png +0 -0
  46. data/app/assets/stylesheets/markitup/sets/markdown/images/list-numeric.png +0 -0
  47. data/app/assets/stylesheets/markitup/sets/markdown/images/picture.png +0 -0
  48. data/app/assets/stylesheets/markitup/sets/markdown/images/preview.png +0 -0
  49. data/app/assets/stylesheets/markitup/sets/markdown/images/quotes.png +0 -0
  50. data/app/assets/stylesheets/markitup/sets/markdown/style.css +57 -0
  51. data/app/assets/stylesheets/markitup/skins/markitup/images/bg-container.png +0 -0
  52. data/app/assets/stylesheets/markitup/skins/markitup/images/bg-editor-bbcode.png +0 -0
  53. data/app/assets/stylesheets/markitup/skins/markitup/images/bg-editor-dotclear.png +0 -0
  54. data/app/assets/stylesheets/markitup/skins/markitup/images/bg-editor-html.png +0 -0
  55. data/app/assets/stylesheets/markitup/skins/markitup/images/bg-editor-json.png +0 -0
  56. data/app/assets/stylesheets/markitup/skins/markitup/images/bg-editor-markdown.png +0 -0
  57. data/app/assets/stylesheets/markitup/skins/markitup/images/bg-editor-textile.png +0 -0
  58. data/app/assets/stylesheets/markitup/skins/markitup/images/bg-editor-wiki.png +0 -0
  59. data/app/assets/stylesheets/markitup/skins/markitup/images/bg-editor-xml.png +0 -0
  60. data/app/assets/stylesheets/markitup/skins/markitup/images/bg-editor.png +0 -0
  61. data/app/assets/stylesheets/markitup/skins/markitup/images/handle.png +0 -0
  62. data/app/assets/stylesheets/markitup/skins/markitup/images/menu.png +0 -0
  63. data/app/assets/stylesheets/markitup/skins/markitup/images/submenu.png +0 -0
  64. data/app/assets/stylesheets/markitup/skins/markitup/style.css +147 -0
  65. data/app/assets/stylesheets/markitup/skins/simple/images/handle.png +0 -0
  66. data/app/assets/stylesheets/markitup/skins/simple/images/menu.png +0 -0
  67. data/app/assets/stylesheets/markitup/skins/simple/images/submenu.png +0 -0
  68. data/app/assets/stylesheets/markitup/skins/simple/style.css +118 -0
  69. data/app/assets/stylesheets/pygments/autumn.css +58 -0
  70. data/app/assets/stylesheets/pygments/borland.css +46 -0
  71. data/app/assets/stylesheets/pygments/bw.css +34 -0
  72. data/app/assets/stylesheets/pygments/colorful.css +61 -0
  73. data/app/assets/stylesheets/pygments/default.css +62 -0
  74. data/app/assets/stylesheets/pygments/emacs.css +61 -0
  75. data/app/assets/stylesheets/pygments/friendly.css +61 -0
  76. data/app/assets/stylesheets/pygments/fruity.css +70 -0
  77. data/app/assets/stylesheets/pygments/manni.css +61 -0
  78. data/app/assets/stylesheets/pygments/murphy.css +61 -0
  79. data/app/assets/stylesheets/pygments/native.css +70 -0
  80. data/app/assets/stylesheets/pygments/pastie.css +60 -0
  81. data/app/assets/stylesheets/pygments/perldoc.css +58 -0
  82. data/app/assets/stylesheets/pygments/tango.css +69 -0
  83. data/app/assets/stylesheets/pygments/trac.css +59 -0
  84. data/app/assets/stylesheets/pygments/vim.css +70 -0
  85. data/app/assets/stylesheets/pygments/vs.css +33 -0
  86. data/app/controllers/formol/admin/admin_controller.rb +11 -0
  87. data/app/controllers/formol/admin/categories_controller.rb +60 -0
  88. data/app/controllers/formol/admin/forums_controller.rb +56 -0
  89. data/app/controllers/formol/application_controller.rb +47 -0
  90. data/app/controllers/formol/categories_controller.rb +21 -0
  91. data/app/controllers/formol/forums_controller.rb +19 -0
  92. data/app/controllers/formol/poll_votes_controller.rb +23 -0
  93. data/app/controllers/formol/posts_controller.rb +71 -0
  94. data/app/controllers/formol/preferences_controller.rb +32 -0
  95. data/app/controllers/formol/subscriptions_controller.rb +29 -0
  96. data/app/controllers/formol/topics_controller.rb +91 -0
  97. data/app/helpers/formol/admin/categories_helper.rb +4 -0
  98. data/app/helpers/formol/admin/forums_helper.rb +4 -0
  99. data/app/helpers/formol/application_helper.rb +35 -0
  100. data/app/helpers/formol/categories_helper.rb +15 -0
  101. data/app/helpers/formol/forums_helper.rb +19 -0
  102. data/app/helpers/formol/poll_votes_helper.rb +4 -0
  103. data/app/helpers/formol/posts_helper.rb +27 -0
  104. data/app/helpers/formol/preferences_helper.rb +4 -0
  105. data/app/helpers/formol/subscriptions_helper.rb +4 -0
  106. data/app/helpers/formol/topics_helper.rb +27 -0
  107. data/app/mailers/formol/subscription_mailer.rb +13 -0
  108. data/app/models/formol/category.rb +42 -0
  109. data/app/models/formol/forum.rb +77 -0
  110. data/app/models/formol/poll/option.rb +20 -0
  111. data/app/models/formol/poll/vote.rb +32 -0
  112. data/app/models/formol/poll.rb +107 -0
  113. data/app/models/formol/post.rb +162 -0
  114. data/app/models/formol/post_observer.rb +9 -0
  115. data/app/models/formol/topic/subscription.rb +16 -0
  116. data/app/models/formol/topic/track.rb +57 -0
  117. data/app/models/formol/topic.rb +185 -0
  118. data/app/models/formol/tracking.rb +45 -0
  119. data/app/models/formol/user_preference.rb +18 -0
  120. data/app/views/formol/admin/categories/_category.html.erb +9 -0
  121. data/app/views/formol/admin/categories/_form.html.erb +8 -0
  122. data/app/views/formol/admin/categories/edit.html.erb +3 -0
  123. data/app/views/formol/admin/categories/index.html.erb +3 -0
  124. data/app/views/formol/admin/categories/new.html.erb +3 -0
  125. data/app/views/formol/admin/forums/_form.html.erb +9 -0
  126. data/app/views/formol/admin/forums/_forum.html.erb +12 -0
  127. data/app/views/formol/admin/forums/edit.html.erb +3 -0
  128. data/app/views/formol/admin/forums/new.html.erb +3 -0
  129. data/app/views/formol/categories/_category.html.erb +5 -0
  130. data/app/views/formol/categories/index.html.erb +5 -0
  131. data/app/views/formol/categories/show.html.erb +3 -0
  132. data/app/views/formol/forums/_forum.html.erb +13 -0
  133. data/app/views/formol/forums/_list.html.erb +16 -0
  134. data/app/views/formol/forums/show.html.erb +18 -0
  135. data/app/views/formol/poll/options/_form.html.erb +1 -0
  136. data/app/views/formol/poll_votes/_form.html.erb +8 -0
  137. data/app/views/formol/polls/_form.html.erb +14 -0
  138. data/app/views/formol/polls/_poll.html.erb +24 -0
  139. data/app/views/formol/posts/_form.html.erb +7 -0
  140. data/app/views/formol/posts/_last_post.html.erb +9 -0
  141. data/app/views/formol/posts/_list.html.erb +3 -0
  142. data/app/views/formol/posts/_post.html.erb +47 -0
  143. data/app/views/formol/posts/edit.html.erb +10 -0
  144. data/app/views/formol/posts/new.html.erb +14 -0
  145. data/app/views/formol/preferences/show.html.erb +11 -0
  146. data/app/views/formol/subscription_mailer/topic_reply.en.html.erb +8 -0
  147. data/app/views/formol/subscription_mailer/topic_reply.fr.html.erb +8 -0
  148. data/app/views/formol/topics/_form.html.erb +20 -0
  149. data/app/views/formol/topics/_list.html.erb +16 -0
  150. data/app/views/formol/topics/_topic.html.erb +13 -0
  151. data/app/views/formol/topics/edit.html.erb +5 -0
  152. data/app/views/formol/topics/new.html.erb +5 -0
  153. data/app/views/formol/topics/show.html.erb +25 -0
  154. data/app/views/layouts/formol/mail.html.erb +9 -0
  155. data/config/locales/en.yml +3 -0
  156. data/config/locales/formol/views/forums/en.yml +13 -0
  157. data/config/locales/formol/views/forums/fr.yml +13 -0
  158. data/config/locales/formol/views/poll_votes/en.yml +5 -0
  159. data/config/locales/formol/views/polls/en.yml.yml +5 -0
  160. data/config/locales/formol/views/posts/en.yml +23 -0
  161. data/config/locales/formol/views/posts/fr.yml +20 -0
  162. data/config/locales/formol/views/topics/en.yml +23 -0
  163. data/config/locales/formol/views/topics/fr.yml +20 -0
  164. data/config/routes.rb +31 -0
  165. data/db/migrate/20111221101158_create_formol_categories.rb +7 -0
  166. data/db/migrate/20111221111417_create_formol_forums.rb +10 -0
  167. data/db/migrate/20111221121010_create_formol_topics.rb +9 -0
  168. data/db/migrate/20111221123515_create_formol_posts.rb +9 -0
  169. data/db/migrate/20111221151653_add_index_on_tables.rb +15 -0
  170. data/db/migrate/20120103163438_add_user_to_models.rb +13 -0
  171. data/db/migrate/20120104132631_add_counter_cache_to_models.rb +12 -0
  172. data/db/migrate/20120104163741_add_pinned_to_topics.rb +7 -0
  173. data/db/migrate/20120105133522_add_position_to_categories.rb +7 -0
  174. data/db/migrate/20120105190708_add_position_to_forums.rb +7 -0
  175. data/db/migrate/20120105212559_add_lock_to_topics.rb +7 -0
  176. data/db/migrate/20120106130944_add_first_post_and_last_post_to_topics.rb +8 -0
  177. data/db/migrate/20120106192951_change_forum_description_to_string.rb +9 -0
  178. data/db/migrate/20120107012517_add_last_post_to_forum.rb +7 -0
  179. data/db/migrate/20120107122921_add_missing_indexes.rb +12 -0
  180. data/db/migrate/20120107123654_add_default_on_forum_counters.rb +10 -0
  181. data/db/migrate/20120108114030_add_views_to_topics.rb +7 -0
  182. data/db/migrate/20120108131533_create_formol_topic_tracks.rb +13 -0
  183. data/db/migrate/20120109115141_create_formol_topic_subscriptions.rb +10 -0
  184. data/db/migrate/20120109220633_create_formol_user_preferences.rb +11 -0
  185. data/db/migrate/20120109223624_add_display_signature_to_posts.rb +7 -0
  186. data/db/migrate/20120109233054_add_display_signatures_and_avatars_to_user_preferences.rb +8 -0
  187. data/db/migrate/20120110152548_create_formol_polls.rb +14 -0
  188. data/db/migrate/20120110152618_create_formol_poll_options.rb +11 -0
  189. data/db/migrate/20120110152632_create_formol_poll_votes.rb +12 -0
  190. data/lib/formol/config.rb +12 -0
  191. data/lib/formol/controllers/auth.rb +9 -0
  192. data/lib/formol/controllers/nested/has_parent_category.rb +11 -0
  193. data/lib/formol/controllers/nested/has_parent_forum.rb +11 -0
  194. data/lib/formol/controllers/nested/has_parent_topic.rb +11 -0
  195. data/lib/formol/controllers.rb +5 -0
  196. data/lib/formol/engine.rb +18 -0
  197. data/lib/formol/formatters/redcarpet/formatter.rb +36 -0
  198. data/lib/formol/formatters/redcarpet/syntax_highlighter.rb +23 -0
  199. data/lib/formol/formatters.rb +2 -0
  200. data/lib/formol/generators/install/install_generator.rb +94 -0
  201. data/lib/formol/generators/install/templates/config/formol.yml +29 -0
  202. data/lib/formol/generators/install/templates/initializer/formol.rb.erb +21 -0
  203. data/lib/formol/generators/install/templates/lib/permissions/special_rights.rb +24 -0
  204. data/lib/formol/generators/install/templates/migrations/add_formol_profile_to_users.rb.erb +7 -0
  205. data/lib/formol/generators/install/templates/migrations/add_posts_count_to_user.rb.erb +7 -0
  206. data/lib/formol/generators.rb +1 -0
  207. data/lib/formol/integration/user.rb +76 -0
  208. data/lib/formol/integration.rb +1 -0
  209. data/lib/formol/permissions/controllers.rb +30 -0
  210. data/lib/formol/permissions/manager.rb +29 -0
  211. data/lib/formol/permissions/profile.rb +24 -0
  212. data/lib/formol/permissions/profiles.rb +44 -0
  213. data/lib/formol/permissions/user.rb +29 -0
  214. data/lib/formol/permissions.rb +5 -0
  215. data/lib/formol/rails/engine.rb +81 -0
  216. data/lib/formol/rails.rb +1 -0
  217. data/lib/formol/version.rb +10 -0
  218. data/lib/formol/view_helpers/assets_helper.rb +11 -0
  219. data/lib/formol/view_helpers/format_helper.rb +12 -0
  220. data/lib/formol/view_helpers.rb +2 -0
  221. data/lib/formol/will_paginate/list_link_renderer.rb +29 -0
  222. data/lib/formol/will_paginate.rb +1 -0
  223. data/lib/formol.rb +61 -0
  224. data/lib/formol_.rb +13 -0
  225. data/lib/tasks/formol_tasks.rake +0 -0
  226. metadata +348 -0
data/MIT-LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2011 Florian DUTEY
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.md ADDED
@@ -0,0 +1,147 @@
1
+ # Formol
2
+
3
+ Formol is a Rails 3.1 forum engine until Rails 3.2 is out for good.
4
+
5
+ ## Why an engine?
6
+
7
+ Because I needed it. And because a forum is rarely a standalone app in a professional context.
8
+
9
+ In a near future, formol engine will be packaged in an independent and standalone application for those who need it.
10
+
11
+ ## Why writing a forum in rails?
12
+
13
+ Customers often ask for a forum inside their app. They think about phpBB or vBulletin like forum but it doesn't exist in rails.
14
+ Developping one is really too expensive for a single project and:
15
+
16
+ * bridge users between a phpBB and a rails app is very tricky (I just don't wanna try it).
17
+ * phpBB / vBulletin is hard (or impossible) to embed into an application layout, especially a rails one.
18
+ * Rails app and php forum won't share their sessions
19
+
20
+ ## Why don't use an existing solution?
21
+
22
+ Existing solutions are:
23
+
24
+ * [Beast](https://github.com/courtenay/altered_beast)
25
+ * [Forem](https://github.com/radar/forem)
26
+ * [Rails3-forums](https://github.com/smholloway/Rails3-forum)
27
+
28
+ Beast has been inactive for 2 years. It's rails 2.2 and ruby 1.8. Don't need to say more.
29
+
30
+ Rails3-forums has been inactive for 8 months. It does less than formol after 1.5 weeks of development.
31
+
32
+ Forem is the most complete solution you can find in rails.
33
+ Unfortunatly, it doesn't suit my needs.
34
+
35
+ In addition, I had to "come back" to ruby (was programming Java for 1.5 year) and I've never written an engine, never used rails 3.1 for a real project.
36
+
37
+ I decided then to write my own, with the best test coverage I can get (actually 99.3%).
38
+
39
+ ## Scaling
40
+
41
+ I do my best to think about everything that could make this engine scale for devils:
42
+
43
+ * every non 'eager-loadable' association (like first and last on has_many) is heavily cached with belongs_to.
44
+ * there's counters cache everywhere
45
+ * I'll introduce caching (or try to in any case) for very high scaling when the app is stable.
46
+ * I use a lot of indexes
47
+
48
+ ## Compatibility
49
+
50
+ Actually, formol is only tested with following parameters:
51
+
52
+ * Ruby 1.9.2
53
+ * Rails 3.1.3
54
+ * Ubuntu
55
+ * Mysql
56
+
57
+ When I would have read travis documentation, I'll test it on more platforms / db / rails versions (rails 3.2, ruby 1.9.3 & jruby, postgreSQL)
58
+
59
+ ## Installation
60
+
61
+ As long as formol is in pre-alpha version, it won't be packaged as a gem.
62
+ It should be installable as a rails plugin but I didn't try it.
63
+
64
+ ## Features
65
+
66
+ * Administration
67
+ * categories
68
+ * forums
69
+ * Topics
70
+ * locking topics
71
+ * viewing all topics for a forum
72
+ * creating new topics
73
+ * pinning topics
74
+ * tracking (read / unread by user)
75
+ * subscriptions (with not scaling mailing)
76
+ * polls & votes
77
+ * Posts
78
+ * replying to topics
79
+ * deleting posts
80
+ * editing posts
81
+ * quoting
82
+ * display user's signature
83
+ * RTE
84
+ * Text formatting
85
+ * markdown
86
+ * syntax highlighting
87
+ * User preferences
88
+ * display signatures
89
+ * display avatars
90
+ * use signature by default
91
+ * signature
92
+ * User permissions
93
+ * Misc
94
+ * install generator
95
+ * gemspec
96
+ * basic styles
97
+
98
+ ## Preview
99
+
100
+ Find other screenshots in /previews
101
+
102
+ ![Topic content](https://github.com/mulasse/formol/raw/master/preview/topic_show.png)
103
+
104
+ ## Dependencies
105
+
106
+ At the moment, formol is independent from any auth system, but I still recommend [Devise](http://github.com/plataformatec/devise).
107
+ Formol is highly coupled with will_paginate, you can't use it without will_paginate.
108
+
109
+ Maybe I'll change this with something more flexible in the future.
110
+ It's not planned for the moment because I don't know other solutions than will_paginate.
111
+
112
+ Others:
113
+
114
+ * JavaScript
115
+ * [jQuery](http://jquery.com)
116
+ * Assets
117
+ * [Scss](http://sass-lang.com/)
118
+ * [CoffeeScript](http://coffeescript.org/)
119
+ * Rails
120
+ * [Will_paginate](https://github.com/mislav/will_paginate)
121
+ * [Formtastic](https://github.com/justinfrench/formtastic)
122
+ * [Attribute normalizer](https://github.com/mdeering/attribute_normalizer)
123
+ * [Pygment.rb](https://github.com/tmm1/pygments.rb)
124
+ * [Redcarpet](https://github.com/tanoku/redcarpet)
125
+ * [Ranked-model](https://github.com/harvesthq/ranked-model) #=> want to abandon it for something simpler like act_as_list but for rails 3
126
+ * [Default_value_for](https://github.com/FooBarWidget/default_value_for)
127
+
128
+ ## Coming next
129
+
130
+ * Mark all topics as read (actually have no scaling solution)
131
+ * Soft delete topics (i'm not sure now since all tests failed because soft deletion doesn't trigger destroy callbacks)
132
+ * Theme support
133
+ * Generator (devise views)
134
+ * Demo app
135
+ * Selenium tests
136
+ * More translations (french of course and more)
137
+ * Permissions management (by admin)
138
+ * Gravatars
139
+ * Avatar uploading
140
+
141
+ ## Boring legal stuff
142
+
143
+ Copyright 2011 Florian DUTEY
144
+
145
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
146
+
147
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/Rakefile ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env rake
2
+ begin
3
+ require 'bundler/setup'
4
+ rescue LoadError
5
+ puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
+ end
7
+
8
+ begin
9
+ require 'rdoc/task'
10
+ rescue LoadError
11
+ require 'rdoc/rdoc'
12
+ require 'rake/rdoctask'
13
+ RDoc::Task = Rake::RDocTask
14
+ end
15
+
16
+ RDoc::Task.new(:rdoc) do |rdoc|
17
+ rdoc.rdoc_dir = 'rdoc'
18
+ rdoc.title = 'Formol'
19
+ rdoc.options << '--line-numbers'
20
+ rdoc.rdoc_files.include('README.rdoc')
21
+ rdoc.rdoc_files.include('lib/**/*.rb')
22
+ end
23
+
24
+ APP_RAKEFILE = File.expand_path("../spec/dummy/Rakefile", __FILE__)
25
+ load 'rails/tasks/engine.rake'
26
+
27
+ Bundler::GemHelper.install_tasks
28
+
29
+ task :default => 'app:spec'
Binary file
Binary file
@@ -0,0 +1,55 @@
1
+ #= require jquery
2
+ #= require jquery-ui
3
+ #= require jquery_ujs
4
+
5
+ (($) ->
6
+ location = document.location.href.split('/admin')[0]
7
+
8
+ $ ->
9
+ $('.formol_categories').sortable({
10
+ axis: 'y',
11
+ stop: (event, ui) ->
12
+ nodes = $.map $('> li', $(this)), (li) ->
13
+ $(li).attr('id').match(/formol_category_(\d+)/)[1]
14
+
15
+ $.ajax {
16
+ url: location + '/admin/categories/sort',
17
+ type: 'POST',
18
+ data: {
19
+ _method: 'put',
20
+ categories: nodes
21
+ }
22
+ }
23
+ }).disableSelection()
24
+
25
+ $('.formol_category_forums').sortable({
26
+ connectWith: '.formol_category_forums'
27
+ items: '> li:not(.empty)',
28
+ axis: 'y',
29
+ receive: (event, ui) ->
30
+ self = $(this)
31
+
32
+ if (empty = $('li.empty', self)).length == 1
33
+ empty.remove()
34
+
35
+ if $('li', ui.sender).length == 0
36
+ $('<li></li>').addClass('empty').html('no forums').appendTo(ui.sender)
37
+ stop: (event, ui) ->
38
+ parent = $(ui.item).parent()
39
+ parentId = parent.attr('id').match(/formol_category_(\d+)_forums/)[1]
40
+
41
+ #collect li ids
42
+ nodes = $.map $('> li', parent), (li) ->
43
+ $(li).attr('id').match(/formol_forum_(\d+)/)[1]
44
+
45
+ #TODO: use url helpers with rails-routes.js
46
+ $.ajax({
47
+ url: location + '/admin/categories/' + parentId + '/forums/reorganize',
48
+ type: 'post',
49
+ data: {
50
+ _method: 'put',
51
+ forums: nodes
52
+ }
53
+ })
54
+ }).disableSelection()
55
+ )(jQuery)
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,9 @@
1
+ // This is a manifest file that'll be compiled into including all the files listed below.
2
+ // Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
3
+ // be included in the compiled file accessible from http://example.com/assets/application.js
4
+ // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
5
+ // the compiled file.
6
+ //
7
+ //= require jquery
8
+ //= require jquery-ui
9
+ //= require jquery_ujs
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,9 @@
1
+ #= require lib/jquery.prevent_double_submit
2
+ #= require markitup/jquery.markitup.js
3
+ #= require markitup/sets/markdown/set.js
4
+
5
+ (($) ->
6
+ $ ->
7
+ $('form').preventDoubleSubmit()
8
+ $('textarea').markItUp(mySettings)
9
+ )(jQuery)
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,13 @@
1
+ (($) ->
2
+ $ ->
3
+ $('.subscribe a').bind 'ajax:success', (event, XMLHttpRequest, ajaxOptions) ->
4
+ element = $(event.target)
5
+ method = element.data('method')
6
+ txt = element.data('switch-text')
7
+ switchTxt = element.text()
8
+ newMethod = if method == 'post' then 'delete' else 'post'
9
+
10
+ element.data('method', newMethod)
11
+ element.data('switch-text', switchTxt)
12
+ element.text(txt)
13
+ )(jQuery)
@@ -0,0 +1,54 @@
1
+ #= require lib/jquery.prevent_double_submit
2
+ #= require formol/subscriptions
3
+ #= require markitup/jquery.markitup.js
4
+ #= require markitup/sets/markdown/set.js
5
+
6
+ (($) ->
7
+ $ ->
8
+ $('form').preventDoubleSubmit()
9
+ $('textarea').markItUp(mySettings)
10
+
11
+ togglePollCheckbox = $('#topic_attach_poll')
12
+ pollContainer = $('fieldset.poll ol')
13
+
14
+ togglePoll = () ->
15
+ pollContainer.toggle togglePollCheckbox.is(':checked')
16
+
17
+ togglePoll()
18
+
19
+ $(togglePollCheckbox).click () ->
20
+ togglePoll()
21
+
22
+ poll_options = $('.answers li.input')
23
+ index = poll_options.length
24
+
25
+ if index > 0
26
+ $('a.add_poll_option').click ->
27
+ id_replacement = [/_(\d)_/, '_' + index + '_']
28
+ name_replacement = [/\[(\d)\]/, '[' + index + ']']
29
+ replacement_meth = String.prototype.replace
30
+
31
+ new_line = poll_options.eq(0).clone()
32
+ new_id = replacement_meth.apply(new_line.attr('id'), id_replacement)
33
+
34
+ new_line.attr('id', new_id)
35
+
36
+ new_line.appendTo(poll_options.parent())
37
+
38
+ new_input = new_line.find('input')
39
+
40
+ new_id = replacement_meth.apply(new_input.attr('id'), id_replacement)
41
+ new_name = replacement_meth.apply(new_input.attr('name'), name_replacement)
42
+
43
+ new_input.attr('id', new_id)
44
+ new_input.attr('name', new_name)
45
+ new_input.val('')
46
+
47
+ new_label = new_line.find('label')
48
+
49
+ new_label.attr('for', new_id)
50
+
51
+ index += 1
52
+
53
+ false
54
+ )(jQuery)
@@ -0,0 +1,11 @@
1
+ (($) ->
2
+ $.fn.preventDoubleSubmit = () ->
3
+ $(@).submit ->
4
+ self = $(@)
5
+
6
+ if @beenSubmitted
7
+ false
8
+ else
9
+ $('fieldset.buttons input', self).attr('disabled', true)
10
+ @beenSubmitted = true
11
+ )(jQuery)