enki-engine 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (206) hide show
  1. data/.gitignore +13 -0
  2. data/.rspec +1 -0
  3. data/.travis.yml +3 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE +284 -0
  6. data/README.textile +112 -0
  7. data/Rakefile +13 -0
  8. data/TODO.textile +8 -0
  9. data/app/assets/images/admin/flash_bg.gif +0 -0
  10. data/app/assets/images/admin/future_bg.png +0 -0
  11. data/app/assets/images/admin/gray_bg.gif +0 -0
  12. data/app/assets/images/admin/new_button.png +0 -0
  13. data/app/assets/images/admin/silver_bg.gif +0 -0
  14. data/app/assets/images/admin/submit_bg.gif +0 -0
  15. data/app/assets/images/admin/subnav_bg.gif +0 -0
  16. data/app/assets/images/openid_icon.png +0 -0
  17. data/app/assets/images/rails.png +0 -0
  18. data/app/assets/images/silk/arrow_undo.png +0 -0
  19. data/app/assets/images/silk/delete.png +0 -0
  20. data/app/assets/images/silk/pencil.png +0 -0
  21. data/app/assets/javascripts/admin/actions.js +18 -0
  22. data/app/assets/javascripts/admin/comments.js +3 -0
  23. data/app/assets/javascripts/admin/common.js +109 -0
  24. data/app/assets/javascripts/admin/dashboard.js +33 -0
  25. data/app/assets/javascripts/admin/edit-preview.js +40 -0
  26. data/app/assets/javascripts/admin/pages.js +1 -0
  27. data/app/assets/javascripts/admin/posts.js +1 -0
  28. data/app/assets/javascripts/admin/shortcut.js +223 -0
  29. data/app/assets/javascripts/admin.js +17 -0
  30. data/app/assets/javascripts/application.js +15 -0
  31. data/app/assets/javascripts/common.js +22 -0
  32. data/app/assets/javascripts/enki.js +13 -0
  33. data/app/assets/javascripts/live-comment-preview.js +36 -0
  34. data/app/assets/stylesheets/admin.css +304 -0
  35. data/app/assets/stylesheets/application.css.scss +486 -0
  36. data/app/assets/stylesheets/humanmsg.css +112 -0
  37. data/app/assets/stylesheets/login.css +65 -0
  38. data/app/controllers/enki/admin/base_controller.rb +15 -0
  39. data/app/controllers/enki/admin/comments_controller.rb +52 -0
  40. data/app/controllers/enki/admin/dashboard_controller.rb +12 -0
  41. data/app/controllers/enki/admin/health_controller.rb +20 -0
  42. data/app/controllers/enki/admin/pages_controller.rb +97 -0
  43. data/app/controllers/enki/admin/posts_controller.rb +104 -0
  44. data/app/controllers/enki/admin/undo_items_controller.rb +43 -0
  45. data/app/controllers/enki/application_controller.rb +21 -0
  46. data/app/controllers/enki/archives_controller.rb +7 -0
  47. data/app/controllers/enki/base_controller.rb +5 -0
  48. data/app/controllers/enki/comments_controller.rb +43 -0
  49. data/app/controllers/enki/pages_controller.rb +7 -0
  50. data/app/controllers/enki/posts_controller.rb +27 -0
  51. data/app/helpers/enki/admin/navigation_helper.rb +10 -0
  52. data/app/helpers/enki/application_helper.rb +35 -0
  53. data/app/helpers/enki/date_helper.rb +15 -0
  54. data/app/helpers/enki/form_helper.rb +7 -0
  55. data/app/helpers/enki/host_helper.rb +19 -0
  56. data/app/helpers/enki/navigation_helper.rb +23 -0
  57. data/app/helpers/enki/page_title_helper.rb +33 -0
  58. data/app/helpers/enki/posts_helper.rb +9 -0
  59. data/app/helpers/enki/tag_helper.rb +7 -0
  60. data/app/helpers/enki/url_helper.rb +25 -0
  61. data/app/models/enki/base/post.rb +153 -0
  62. data/app/models/enki/comment.rb +75 -0
  63. data/app/models/enki/comment_activity.rb +33 -0
  64. data/app/models/enki/delete_comment_undo.rb +33 -0
  65. data/app/models/enki/delete_page_undo.rb +32 -0
  66. data/app/models/enki/delete_post_undo.rb +36 -0
  67. data/app/models/enki/page.rb +42 -0
  68. data/app/models/enki/post.rb +4 -0
  69. data/app/models/enki/stats.rb +19 -0
  70. data/app/models/enki/tag.rb +19 -0
  71. data/app/models/enki/tagging.rb +7 -0
  72. data/app/models/enki/undo_item.rb +10 -0
  73. data/app/views/enki/admin/comments/_comment.html.erb +12 -0
  74. data/app/views/enki/admin/comments/index.html.erb +30 -0
  75. data/app/views/enki/admin/comments/show.html.erb +9 -0
  76. data/app/views/enki/admin/dashboard/show.html.erb +61 -0
  77. data/app/views/enki/admin/health/index.html.erb +3 -0
  78. data/app/views/enki/admin/pages/_form.html.erb +3 -0
  79. data/app/views/enki/admin/pages/_page.html.erb +12 -0
  80. data/app/views/enki/admin/pages/index.html.erb +25 -0
  81. data/app/views/enki/admin/pages/new.html.erb +8 -0
  82. data/app/views/enki/admin/pages/show.html.erb +8 -0
  83. data/app/views/enki/admin/posts/_form.html.erb +11 -0
  84. data/app/views/enki/admin/posts/_post.html.erb +12 -0
  85. data/app/views/enki/admin/posts/_taggings_form.html.erb +4 -0
  86. data/app/views/enki/admin/posts/_upload_form.html.erb +0 -0
  87. data/app/views/enki/admin/posts/index.html.erb +25 -0
  88. data/app/views/enki/admin/posts/new.html.erb +8 -0
  89. data/app/views/enki/admin/posts/show.html.erb +8 -0
  90. data/app/views/enki/admin/undo_items/index.html.erb +24 -0
  91. data/app/views/enki/archives/index.html.erb +17 -0
  92. data/app/views/enki/comments/_comment.html.erb +4 -0
  93. data/app/views/enki/pages/_page.html.erb +3 -0
  94. data/app/views/enki/pages/show.html.erb +5 -0
  95. data/app/views/enki/posts/_post.html.erb +13 -0
  96. data/app/views/enki/posts/index.atom.builder +27 -0
  97. data/app/views/enki/posts/index.html.erb +15 -0
  98. data/app/views/enki/posts/show.html.erb +37 -0
  99. data/autotest/discover.rb +2 -0
  100. data/config/cucumber.yml +8 -0
  101. data/config/enki.yml.sample +16 -0
  102. data/config/initializers/enki_ext.rb +3 -0
  103. data/config/initializers/set_chronic_timezone.rb +1 -0
  104. data/config/initializers/verification.rb +135 -0
  105. data/config/routes.rb +34 -0
  106. data/db/migrate/20110709024316_initialize_db.rb +97 -0
  107. data/db/seeds.rb +8 -0
  108. data/enki-engine.gemspec +47 -0
  109. data/features/admin_dashboard.feature +10 -0
  110. data/features/admin_health.feature +10 -0
  111. data/features/admin_undo.feature +20 -0
  112. data/features/browsing.feature +16 -0
  113. data/features/step_definitions/admin.rb +27 -0
  114. data/features/step_definitions/browsing.rb +3 -0
  115. data/features/step_definitions/posts.rb +11 -0
  116. data/features/step_definitions/web_steps.rb +1 -0
  117. data/features/support/env.rb +59 -0
  118. data/features/support/paths.rb +35 -0
  119. data/features/support/selectors.rb +39 -0
  120. data/lib/core_extensions/object.rb +9 -0
  121. data/lib/core_extensions/string.rb +22 -0
  122. data/lib/enki/config.rb +44 -0
  123. data/lib/enki/engine.rb +19 -0
  124. data/lib/enki/html5_tags.rb +8 -0
  125. data/lib/enki/pagination_shim.rb +25 -0
  126. data/lib/enki/version.rb +3 -0
  127. data/lib/enki.rb +14 -0
  128. data/lib/enki_formatter.rb +11 -0
  129. data/lib/tag_list.rb +2 -0
  130. data/lib/tags_helper.rb +13 -0
  131. data/lib/tasks/cucumber.rake +65 -0
  132. data/lib/tasks/enki.rake +29 -0
  133. data/lib/undo_failed.rb +2 -0
  134. data/script/cucumber +10 -0
  135. data/spec/controllers/admin/comments_controller_spec.rb +140 -0
  136. data/spec/controllers/admin/dashboard_controller_spec.rb +47 -0
  137. data/spec/controllers/admin/health_controller_spec.rb +49 -0
  138. data/spec/controllers/admin/pages_controller_spec.rb +136 -0
  139. data/spec/controllers/admin/posts_controller_spec.rb +183 -0
  140. data/spec/controllers/admin/undo_items_controller_spec.rb +93 -0
  141. data/spec/controllers/archives_controller_spec.rb +37 -0
  142. data/spec/controllers/comments_controller_spec.rb +126 -0
  143. data/spec/controllers/pages_controller_spec.rb +46 -0
  144. data/spec/controllers/posts_controller_spec.rb +168 -0
  145. data/spec/dummy/Gemfile +5 -0
  146. data/spec/dummy/Rakefile +7 -0
  147. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  148. data/spec/dummy/config/application.rb +34 -0
  149. data/spec/dummy/config/boot.rb +10 -0
  150. data/spec/dummy/config/database.yml +6 -0
  151. data/spec/dummy/config/enki.yml +20 -0
  152. data/spec/dummy/config/environment.rb +5 -0
  153. data/spec/dummy/config/environments/development.rb +34 -0
  154. data/spec/dummy/config/environments/test.rb +32 -0
  155. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  156. data/spec/dummy/config/initializers/session_store.rb +8 -0
  157. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  158. data/spec/dummy/config/locales/en.yml +5 -0
  159. data/spec/dummy/config/routes.rb +14 -0
  160. data/spec/dummy/config.ru +6 -0
  161. data/spec/dummy/script/rails +6 -0
  162. data/spec/factories/factories.rb +36 -0
  163. data/spec/helpers/page_title_helper_spec.rb +54 -0
  164. data/spec/helpers/url_helper_spec.rb +23 -0
  165. data/spec/lib/slugorize_spec.rb +44 -0
  166. data/spec/models/comment_activity_spec.rb +60 -0
  167. data/spec/models/comment_spec.rb +125 -0
  168. data/spec/models/delete_comment_undo_spec.rb +52 -0
  169. data/spec/models/delete_post_undo_spec.rb +18 -0
  170. data/spec/models/page_spec.rb +75 -0
  171. data/spec/models/post_spec.rb +257 -0
  172. data/spec/models/stats_spec.rb +28 -0
  173. data/spec/models/tag_spec.rb +13 -0
  174. data/spec/models/tagging_spec.rb +30 -0
  175. data/spec/rcov.opts +2 -0
  176. data/spec/routing/admin/pages_routing_spec.rb +29 -0
  177. data/spec/routing/archives_routing_spec.rb +9 -0
  178. data/spec/routing/comments_routing_spec.rb +17 -0
  179. data/spec/routing/pages_routing_spec.rb +9 -0
  180. data/spec/routing/posts_routing_spec.rb +26 -0
  181. data/spec/spec.opts +4 -0
  182. data/spec/spec_helper.rb +60 -0
  183. data/spec/support/be_valid_html5.rb +150 -0
  184. data/spec/support/be_valid_xhtml.rb +148 -0
  185. data/spec/support/routes_override_helper.rb +12 -0
  186. data/spec/views/admin/comments/index.html_spec.rb +26 -0
  187. data/spec/views/admin/comments/show.html_spec.rb +28 -0
  188. data/spec/views/admin/dashboard/show.html_spec.rb +37 -0
  189. data/spec/views/admin/pages/index.html_spec.rb +23 -0
  190. data/spec/views/admin/pages/new.html_spec.rb +16 -0
  191. data/spec/views/admin/pages/show.html_spec.rb +16 -0
  192. data/spec/views/admin/posts/index.html_spec.rb +24 -0
  193. data/spec/views/admin/posts/new.html_spec.rb +16 -0
  194. data/spec/views/admin/posts/show.html_spec.rb +16 -0
  195. data/spec/views/admin/undo_items/index.html_spec.rb +19 -0
  196. data/spec/views/archives/index.html_spec.rb +34 -0
  197. data/spec/views/pages/show.html_spec.rb +23 -0
  198. data/spec/views/posts/index.atom.builder_spec.rb +36 -0
  199. data/spec/views/posts/index.html_spec.rb +39 -0
  200. data/spec/views/posts/show.html_spec.rb +49 -0
  201. data/vendor/assets/javascripts/humanmsg.js +86 -0
  202. data/vendor/assets/javascripts/jquery.easing.1.3.js +205 -0
  203. data/vendor/assets/javascripts/jquery.form.js +869 -0
  204. data/vendor/assets/javascripts/jquery.jfeed.js +143 -0
  205. data/vendor/assets/javascripts/jquery.livequery.js +250 -0
  206. metadata +464 -0
data/.gitignore ADDED
@@ -0,0 +1,13 @@
1
+ log/**/*
2
+ log
3
+ tmp/**/*
4
+ tmp
5
+ config/database.yml
6
+ schema.rb
7
+ .bundle
8
+ .rvmrc
9
+ *.sqlite3
10
+ *.log
11
+ *.gem
12
+ Gemfile.lock
13
+
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --colour
data/.travis.yml ADDED
@@ -0,0 +1,3 @@
1
+ before_script:
2
+ - "cp config/database.example.yml config/database.yml"
3
+ script: "bundle exec rake db:migrate --trace && bundle exec rake --trace"
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
4
+
data/LICENSE ADDED
@@ -0,0 +1,284 @@
1
+ THIS LICENSE MUST ACCOMPANY THIS APPLICATION AT ALL TIMES.
2
+
3
+ License follows:
4
+
5
+ GNU GENERAL PUBLIC LICENSE
6
+ Version 2, June 1991
7
+
8
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
9
+ 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
10
+ Everyone is permitted to copy and distribute verbatim copies
11
+ of this license document, but changing it is not allowed.
12
+
13
+ Preamble
14
+
15
+ The licenses for most software are designed to take away your
16
+ freedom to share and change it. By contrast, the GNU General Public
17
+ License is intended to guarantee your freedom to share and change free
18
+ software--to make sure the software is free for all its users. This
19
+ General Public License applies to most of the Free Software
20
+ Foundation's software and to any other program whose authors commit to
21
+ using it. (Some other Free Software Foundation software is covered by
22
+ the GNU Lesser General Public License instead.) You can apply it to
23
+ your programs, too.
24
+
25
+ When we speak of free software, we are referring to freedom, not
26
+ price. Our General Public Licenses are designed to make sure that you
27
+ have the freedom to distribute copies of free software (and charge for
28
+ this service if you wish), that you receive source code or can get it
29
+ if you want it, that you can change the software or use pieces of it
30
+ in new free programs; and that you know you can do these things.
31
+
32
+ To protect your rights, we need to make restrictions that forbid
33
+ anyone to deny you these rights or to ask you to surrender the rights.
34
+ These restrictions translate to certain responsibilities for you if you
35
+ distribute copies of the software, or if you modify it.
36
+
37
+ For example, if you distribute copies of such a program, whether
38
+ gratis or for a fee, you must give the recipients all the rights that
39
+ you have. You must make sure that they, too, receive or can get the
40
+ source code. And you must show them these terms so they know their
41
+ rights.
42
+
43
+ We protect your rights with two steps: (1) copyright the software, and
44
+ (2) offer you this license which gives you legal permission to copy,
45
+ distribute and/or modify the software.
46
+
47
+ Also, for each author's protection and ours, we want to make certain
48
+ that everyone understands that there is no warranty for this free
49
+ software. If the software is modified by someone else and passed on, we
50
+ want its recipients to know that what they have is not the original, so
51
+ that any problems introduced by others will not reflect on the original
52
+ authors' reputations.
53
+
54
+ Finally, any free program is threatened constantly by software
55
+ patents. We wish to avoid the danger that redistributors of a free
56
+ program will individually obtain patent licenses, in effect making the
57
+ program proprietary. To prevent this, we have made it clear that any
58
+ patent must be licensed for everyone's free use or not licensed at all.
59
+
60
+ The precise terms and conditions for copying, distribution and
61
+ modification follow.
62
+
63
+ GNU GENERAL PUBLIC LICENSE
64
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
65
+
66
+ 0. This License applies to any program or other work which contains
67
+ a notice placed by the copyright holder saying it may be distributed
68
+ under the terms of this General Public License. The "Program", below,
69
+ refers to any such program or work, and a "work based on the Program"
70
+ means either the Program or any derivative work under copyright law:
71
+ that is to say, a work containing the Program or a portion of it,
72
+ either verbatim or with modifications and/or translated into another
73
+ language. (Hereinafter, translation is included without limitation in
74
+ the term "modification".) Each licensee is addressed as "you".
75
+
76
+ Activities other than copying, distribution and modification are not
77
+ covered by this License; they are outside its scope. The act of
78
+ running the Program is not restricted, and the output from the Program
79
+ is covered only if its contents constitute a work based on the
80
+ Program (independent of having been made by running the Program).
81
+ Whether that is true depends on what the Program does.
82
+
83
+ 1. You may copy and distribute verbatim copies of the Program's
84
+ source code as you receive it, in any medium, provided that you
85
+ conspicuously and appropriately publish on each copy an appropriate
86
+ copyright notice and disclaimer of warranty; keep intact all the
87
+ notices that refer to this License and to the absence of any warranty;
88
+ and give any other recipients of the Program a copy of this License
89
+ along with the Program.
90
+
91
+ You may charge a fee for the physical act of transferring a copy, and
92
+ you may at your option offer warranty protection in exchange for a fee.
93
+
94
+ 2. You may modify your copy or copies of the Program or any portion
95
+ of it, thus forming a work based on the Program, and copy and
96
+ distribute such modifications or work under the terms of Section 1
97
+ above, provided that you also meet all of these conditions:
98
+
99
+ a) You must cause the modified files to carry prominent notices
100
+ stating that you changed the files and the date of any change.
101
+
102
+ b) You must cause any work that you distribute or publish, that in
103
+ whole or in part contains or is derived from the Program or any
104
+ part thereof, to be licensed as a whole at no charge to all third
105
+ parties under the terms of this License.
106
+
107
+ c) If the modified program normally reads commands interactively
108
+ when run, you must cause it, when started running for such
109
+ interactive use in the most ordinary way, to print or display an
110
+ announcement including an appropriate copyright notice and a
111
+ notice that there is no warranty (or else, saying that you provide
112
+ a warranty) and that users may redistribute the program under
113
+ these conditions, and telling the user how to view a copy of this
114
+ License. (Exception: if the Program itself is interactive but
115
+ does not normally print such an announcement, your work based on
116
+ the Program is not required to print an announcement.)
117
+
118
+ These requirements apply to the modified work as a whole. If
119
+ identifiable sections of that work are not derived from the Program,
120
+ and can be reasonably considered independent and separate works in
121
+ themselves, then this License, and its terms, do not apply to those
122
+ sections when you distribute them as separate works. But when you
123
+ distribute the same sections as part of a whole which is a work based
124
+ on the Program, the distribution of the whole must be on the terms of
125
+ this License, whose permissions for other licensees extend to the
126
+ entire whole, and thus to each and every part regardless of who wrote it.
127
+
128
+ Thus, it is not the intent of this section to claim rights or contest
129
+ your rights to work written entirely by you; rather, the intent is to
130
+ exercise the right to control the distribution of derivative or
131
+ collective works based on the Program.
132
+
133
+ In addition, mere aggregation of another work not based on the Program
134
+ with the Program (or with a work based on the Program) on a volume of
135
+ a storage or distribution medium does not bring the other work under
136
+ the scope of this License.
137
+
138
+ 3. You may copy and distribute the Program (or a work based on it,
139
+ under Section 2) in object code or executable form under the terms of
140
+ Sections 1 and 2 above provided that you also do one of the following:
141
+
142
+ a) Accompany it with the complete corresponding machine-readable
143
+ source code, which must be distributed under the terms of Sections
144
+ 1 and 2 above on a medium customarily used for software interchange; or,
145
+
146
+ b) Accompany it with a written offer, valid for at least three
147
+ years, to give any third party, for a charge no more than your
148
+ cost of physically performing source distribution, a complete
149
+ machine-readable copy of the corresponding source code, to be
150
+ distributed under the terms of Sections 1 and 2 above on a medium
151
+ customarily used for software interchange; or,
152
+
153
+ c) Accompany it with the information you received as to the offer
154
+ to distribute corresponding source code. (This alternative is
155
+ allowed only for noncommercial distribution and only if you
156
+ received the program in object code or executable form with such
157
+ an offer, in accord with Subsection b above.)
158
+
159
+ The source code for a work means the preferred form of the work for
160
+ making modifications to it. For an executable work, complete source
161
+ code means all the source code for all modules it contains, plus any
162
+ associated interface definition files, plus the scripts used to
163
+ control compilation and installation of the executable. However, as a
164
+ special exception, the source code distributed need not include
165
+ anything that is normally distributed (in either source or binary
166
+ form) with the major components (compiler, kernel, and so on) of the
167
+ operating system on which the executable runs, unless that component
168
+ itself accompanies the executable.
169
+
170
+ If distribution of executable or object code is made by offering
171
+ access to copy from a designated place, then offering equivalent
172
+ access to copy the source code from the same place counts as
173
+ distribution of the source code, even though third parties are not
174
+ compelled to copy the source along with the object code.
175
+
176
+ 4. You may not copy, modify, sublicense, or distribute the Program
177
+ except as expressly provided under this License. Any attempt
178
+ otherwise to copy, modify, sublicense or distribute the Program is
179
+ void, and will automatically terminate your rights under this License.
180
+ However, parties who have received copies, or rights, from you under
181
+ this License will not have their licenses terminated so long as such
182
+ parties remain in full compliance.
183
+
184
+ 5. You are not required to accept this License, since you have not
185
+ signed it. However, nothing else grants you permission to modify or
186
+ distribute the Program or its derivative works. These actions are
187
+ prohibited by law if you do not accept this License. Therefore, by
188
+ modifying or distributing the Program (or any work based on the
189
+ Program), you indicate your acceptance of this License to do so, and
190
+ all its terms and conditions for copying, distributing or modifying
191
+ the Program or works based on it.
192
+
193
+ 6. Each time you redistribute the Program (or any work based on the
194
+ Program), the recipient automatically receives a license from the
195
+ original licensor to copy, distribute or modify the Program subject to
196
+ these terms and conditions. You may not impose any further
197
+ restrictions on the recipients' exercise of the rights granted herein.
198
+ You are not responsible for enforcing compliance by third parties to
199
+ this License.
200
+
201
+ 7. If, as a consequence of a court judgment or allegation of patent
202
+ infringement or for any other reason (not limited to patent issues),
203
+ conditions are imposed on you (whether by court order, agreement or
204
+ otherwise) that contradict the conditions of this License, they do not
205
+ excuse you from the conditions of this License. If you cannot
206
+ distribute so as to satisfy simultaneously your obligations under this
207
+ License and any other pertinent obligations, then as a consequence you
208
+ may not distribute the Program at all. For example, if a patent
209
+ license would not permit royalty-free redistribution of the Program by
210
+ all those who receive copies directly or indirectly through you, then
211
+ the only way you could satisfy both it and this License would be to
212
+ refrain entirely from distribution of the Program.
213
+
214
+ If any portion of this section is held invalid or unenforceable under
215
+ any particular circumstance, the balance of the section is intended to
216
+ apply and the section as a whole is intended to apply in other
217
+ circumstances.
218
+
219
+ It is not the purpose of this section to induce you to infringe any
220
+ patents or other property right claims or to contest validity of any
221
+ such claims; this section has the sole purpose of protecting the
222
+ integrity of the free software distribution system, which is
223
+ implemented by public license practices. Many people have made
224
+ generous contributions to the wide range of software distributed
225
+ through that system in reliance on consistent application of that
226
+ system; it is up to the author/donor to decide if he or she is willing
227
+ to distribute software through any other system and a licensee cannot
228
+ impose that choice.
229
+
230
+ This section is intended to make thoroughly clear what is believed to
231
+ be a consequence of the rest of this License.
232
+
233
+ 8. If the distribution and/or use of the Program is restricted in
234
+ certain countries either by patents or by copyrighted interfaces, the
235
+ original copyright holder who places the Program under this License
236
+ may add an explicit geographical distribution limitation excluding
237
+ those countries, so that distribution is permitted only in or among
238
+ countries not thus excluded. In such case, this License incorporates
239
+ the limitation as if written in the body of this License.
240
+
241
+ 9. The Free Software Foundation may publish revised and/or new versions
242
+ of the General Public License from time to time. Such new versions will
243
+ be similar in spirit to the present version, but may differ in detail to
244
+ address new problems or concerns.
245
+
246
+ Each version is given a distinguishing version number. If the Program
247
+ specifies a version number of this License which applies to it and "any
248
+ later version", you have the option of following the terms and conditions
249
+ either of that version or of any later version published by the Free
250
+ Software Foundation. If the Program does not specify a version number of
251
+ this License, you may choose any version ever published by the Free Software
252
+ Foundation.
253
+
254
+ 10. If you wish to incorporate parts of the Program into other free
255
+ programs whose distribution conditions are different, write to the author
256
+ to ask for permission. For software which is copyrighted by the Free
257
+ Software Foundation, write to the Free Software Foundation; we sometimes
258
+ make exceptions for this. Our decision will be guided by the two goals
259
+ of preserving the free status of all derivatives of our free software and
260
+ of promoting the sharing and reuse of software generally.
261
+
262
+ NO WARRANTY
263
+
264
+ 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
265
+ FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
266
+ OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
267
+ PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
268
+ OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
269
+ MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
270
+ TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
271
+ PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
272
+ REPAIR OR CORRECTION.
273
+
274
+ 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
275
+ WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
276
+ REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
277
+ INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
278
+ OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
279
+ TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
280
+ YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
281
+ PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
282
+ POSSIBILITY OF SUCH DAMAGES.
283
+
284
+ END OF TERMS AND CONDITIONS
data/README.textile ADDED
@@ -0,0 +1,112 @@
1
+ h1. Enki Engine
2
+
3
+ A Ruby on Rails blogging engine extracted from Xavier Shay's Enki blogging app.
4
+
5
+ h2. Quick Start
6
+
7
+ * Add to your bundle:
8
+
9
+ gem 'enki_engine'
10
+
11
+ * Add the migrations
12
+
13
+ rake enki:install:migrations
14
+
15
+ * Create a config/enki.yml like the one below until I write a generator. Hint! Hint!
16
+
17
+ <pre><code># Configuration options for your blog - customise to taste
18
+ # This file contains no secret information, so can be stored in source control (unlike database.yml)
19
+ title: Articles
20
+ url: http://enkiblog.com/posts
21
+ author:
22
+ name: Don Alias # For copyright notice and ATOM feeds
23
+ email: don@enkiblog.com # Exception emails will go here, and it is used in ATOM feeds
24
+ open_id: # These are used to login to the admin area
25
+ - http://enkiblog.com
26
+ - http://secondaryopenid.com
27
+
28
+ engine:
29
+ mount_at: /content
30
+ pages_at: /
31
+
32
+ features:
33
+ comments: false
34
+ tags: true
35
+ form_helper: false</pre></code>
36
+
37
+ * A good place to start customizing is with Enki::Admin::BaseController, as you may want some authentication & authorization from the host app
38
+
39
+ <pre><code># app/models/enki/post.rb
40
+ module Enki
41
+ class Post < Base::Post
42
+
43
+ belongs_to :author, :class_name => 'User'
44
+
45
+ validates_presence_of :author_id
46
+
47
+ end
48
+ end
49
+
50
+ # app/controllers/enki/admin/base_controller.rb
51
+ module Enki
52
+ module Admin
53
+ class BaseController < Enki::ApplicationController
54
+
55
+ before_filter :require_account, :authorize
56
+
57
+ protected
58
+
59
+ # Post management is a proxy for all blog abilities.
60
+ def authorize
61
+ raise CanCan::AccessDenied unless can?(:manage, Enki::Post)
62
+ end
63
+
64
+ # requires a migration to put the author_id into posts and pages
65
+ def post_attributes
66
+ {:author => current_user}
67
+ end
68
+
69
+ end
70
+ end
71
+ end</pre></code>
72
+
73
+ * Read the code and improve it at will.
74
+
75
+ h2. More info
76
+
77
+ Enki is a compact, easily extendable base for your blog. It does this by being highly opinionated, for example:
78
+
79
+ * Public facing views should adhere to standards (XHTML(eXtensible Hypertext Markup Language), Atom)
80
+ * /yyyy/mm/dd/post-title is a good URL for your posts
81
+ * Live comment preview should be provided by default
82
+ * Google does search better than you or I
83
+ * You don't need a plugin system when you've got decent source control
84
+ * Hacking code is the easiest way to customize something
85
+
86
+ h2. Compatibility
87
+
88
+ Uses rails 3. Runs on MySQL or Postgres. Works on heroku.
89
+ Uses ActsAsTaggableOn but I'd like to make it agnostic of a tagging solution.
90
+ Uses SimpleForm whereas Enki uses Formtastic. I'd like this to be agnostic.
91
+ Supports WillPaginate and Kaminari or no pagination with a couple of untidy shims I threw in which could be implemented much better.
92
+
93
+ h2. Patches/Pull Request
94
+
95
+ * Fork the project.
96
+ * Make your improvement or bug fix.
97
+ * Add specs for it. This is important so I don’t break it in a future version unintentionally.
98
+ * Commit, do not mess with rakefile, version, or history. (if you want to have your own version, that is fine but bump version in a commit by itself I can ignore it when I pull)
99
+ * Send a pull request. Bonus points for topic branches.
100
+
101
+ h2. Contributors, these guys rock
102
+
103
+ <pre><code>git log | grep Author | sort | uniq</code></pre>
104
+
105
+ If you want to help out, try tackling something from the TODO or an "open issue":https://github.com/ThisIsHatch/enki_engine/issues. Please include specs for any fixes. Enki Engine is by design feature light. Unless you feel very strongly your feature should be in core, add a link to your fork in the wiki instead.
106
+
107
+ h2. License
108
+
109
+ GPL(General Public License) - See LICENSE
110
+
111
+ Admin design heavily inspired by "Habari":http://www.habariproject.org/en/ and broken by https://github.com/james2m
112
+
data/Rakefile ADDED
@@ -0,0 +1,13 @@
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ Bundler.setup :default, :development
4
+
5
+ desc 'Default: run specs'
6
+ task :default => :spec
7
+
8
+ require 'rspec/core/rake_task'
9
+ RSpec::Core::RakeTask.new do |t|
10
+ t.pattern = "spec/**/*_spec.rb"
11
+ end
12
+
13
+ Bundler::GemHelper.install_tasks
data/TODO.textile ADDED
@@ -0,0 +1,8 @@
1
+ * Change all author references to refer to an author_id and appropriate user model.
2
+ * Convert finders to scopes and AR3 sytax.
3
+ * Restore integration tests but probably not Cucumber.
4
+ * Properly rip out openid stuff.
5
+ * Generator to install config/enki.yml.
6
+ * Generator to create bare Enki::BaseController and Enki::Admin::BaseController in host app.
7
+ * Auto-slug generation broken?
8
+ * Do something with the CSS?
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -0,0 +1,18 @@
1
+ $(document).ready(function () {
2
+ $('form.undo-item').submit(function () {
3
+ asyncDeleteForm($(this), {
4
+ type: "POST",
5
+ success: function (msg) {
6
+ humanMsg.displayMsg( msg.message );
7
+ },
8
+ error: function (XMLHttpRequest, textStatus, errorThrown) {
9
+ humanMsg.displayMsg( 'Could not undo action' );
10
+ }
11
+ });
12
+
13
+ // Assume success and remove item
14
+ $(this).parent('td').parent('tr').remove();
15
+ restripe();
16
+ return false;
17
+ });
18
+ })
@@ -0,0 +1,3 @@
1
+ $(document).ready(function() {
2
+ destroyAndUndoBehaviour('comments')
3
+ }); // Defined in admin/common.js
@@ -0,0 +1,109 @@
1
+ jQuery.delegate = function(rules) {
2
+ return function(e) {
3
+ var target = $(e.target);
4
+ for (var selector in rules)
5
+ if (target.is(selector)) return rules[selector].apply(this, $.makeArray(arguments));
6
+ }
7
+ }
8
+
9
+ $(document).ajaxSend(function(e, xhr, options) {
10
+ var token = $("meta[name='csrf-token']").attr("content");
11
+ xhr.setRequestHeader("X-CSRF-Token", token);
12
+ });
13
+
14
+ function restripe() {
15
+ $('table tr:odd').removeClass('alt');
16
+ $('table tr:even').addClass('alt');
17
+ }
18
+
19
+ function asyncDeleteForm(obj, options) {
20
+ $.ajax($.extend({
21
+ type: "DELETE",
22
+ url: obj.attr('action'),
23
+ beforeSend: function(xhr) {
24
+ xhr.setRequestHeader("Accept", "application/json");
25
+ },
26
+ dataType: 'json',
27
+ success: function(msg){
28
+ display = msg.undo_message
29
+ if (msg.undo_path) {
30
+ display += '<span class="undo-link"> (<a class="undo-link" href="' + msg.undo_path + '">undo</a>)</span>';
31
+ undo_stack.push(msg.undo_path);
32
+ }
33
+ humanMsg.displayMsg(display);
34
+ },
35
+ error: function (XMLHttpRequest, textStatus, errorThrown) {
36
+ humanMsg.displayMsg( 'Could not delete item, or maybe it has already been deleted' );
37
+ }
38
+ }, options || {}));
39
+ }
40
+
41
+ function processUndo(path, options) {
42
+ $.ajax($.extend({
43
+ type: "POST",
44
+ url: path,
45
+ beforeSend: function(xhr) {
46
+ xhr.setRequestHeader("Accept", "application/json");
47
+ },
48
+ dataType: 'json',
49
+ success: function(msg){
50
+ humanMsg.displayMsg( msg.message );
51
+ },
52
+ error: function (XMLHttpRequest, textStatus, errorThrown) {
53
+ humanMsg.displayMsg( 'Could not undo' );
54
+ }
55
+ }, options || {}));
56
+
57
+ // Assume success and remove undo link
58
+ $('a.undo-link[href=' + path + ']').parent('span').hide();
59
+ undo_stack = jQuery.grep(undo_stack, function(e) { return e != path });
60
+ }
61
+
62
+ function asyncUndoBehaviour(options) {
63
+ $('#humanMsgLog').click($.delegate({
64
+ 'a.undo-link': function(e) {
65
+ processUndo(jQuery(e.target).attr('href'), options);
66
+ return false;
67
+ }
68
+ }));
69
+ jQuery.each(["Ctrl+Z", "Meta+Z"], function () {
70
+ shortcut.add(this, function() {
71
+ item = undo_stack.pop();
72
+ if (item)
73
+ processUndo(item, options)
74
+ else
75
+ humanMsg.displayMsg("Nothing to undo");
76
+ });
77
+ });
78
+ }
79
+
80
+ var undo_stack = new Array();
81
+
82
+ function onDeleteFormClick() {
83
+ asyncDeleteForm($(this));
84
+
85
+ // Assume success and remove item
86
+ $(this).parent('td').parent('tr').remove();
87
+ restripe();
88
+ return false;
89
+ }
90
+
91
+ function destroyAndUndoBehaviour(type) {
92
+ return function (){
93
+ asyncUndoBehaviour({
94
+ success: function(msg){
95
+ humanMsg.displayMsg( msg.message );
96
+ $.get('/admin/' + type + '/' + msg.obj.id, function(data) {
97
+ $('table tbody').append(data);
98
+
99
+ $('form.delete-item').unbind('submit', onDeleteFormClick);
100
+ $('form.delete-item').submit(onDeleteFormClick);
101
+ restripe();
102
+ });
103
+ },
104
+ });
105
+
106
+ $('form.delete-item').submit(onDeleteFormClick);
107
+ }
108
+ }
109
+
@@ -0,0 +1,33 @@
1
+ function extractId(obj) {
2
+ tokens = obj.attr('id').split('-');
3
+ return tokens[tokens.length-1];
4
+ }
5
+
6
+ $(document).ready(function (){
7
+ $('.comment-body').hide();
8
+
9
+ $('.comment-link').click (function() {
10
+ comment_body_id = '#comment-body-' + extractId($(this));
11
+
12
+ $('.comment-body').not(comment_body_id).hide();
13
+ $(comment_body_id).toggle();
14
+
15
+ return false;
16
+ })
17
+
18
+ $(document).click(function() {
19
+ $('.comment-body').hide();
20
+ });
21
+
22
+ asyncUndoBehaviour();
23
+
24
+ $('form.delete-item').submit(function () {
25
+ asyncDeleteForm($(this));
26
+
27
+ // Assume success and remove comment
28
+ comment_link_id = '#comment-link-' + extractId($(this));
29
+ $(comment_link_id).remove();
30
+ $(this).parent('div').parent('div').remove();
31
+ return false;
32
+ });
33
+ })