ecrire 0.20.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (233) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +20 -0
  3. data/Gemfile +4 -0
  4. data/LICENCE +9 -0
  5. data/README.md +62 -0
  6. data/Rakefile +72 -0
  7. data/bin/ecrire +42 -0
  8. data/ecrire.gemspec +26 -0
  9. data/lib/ecrire/app/assets/javascripts/admin/editor/content.coffee +319 -0
  10. data/lib/ecrire/app/assets/javascripts/admin/editor/ext.coffee +94 -0
  11. data/lib/ecrire/app/assets/javascripts/admin/editor/extensions/clipboard.coffee +98 -0
  12. data/lib/ecrire/app/assets/javascripts/admin/editor/extensions/image.coffee +19 -0
  13. data/lib/ecrire/app/assets/javascripts/admin/editor/navigation/delete.js.coffee +11 -0
  14. data/lib/ecrire/app/assets/javascripts/admin/editor/navigation/draft.js.coffee +42 -0
  15. data/lib/ecrire/app/assets/javascripts/admin/editor/navigation/help.js.coffee +6 -0
  16. data/lib/ecrire/app/assets/javascripts/admin/editor/navigation/save.js.coffee +61 -0
  17. data/lib/ecrire/app/assets/javascripts/admin/editor/navigation/sticky.js.coffee +11 -0
  18. data/lib/ecrire/app/assets/javascripts/admin/editor/navigation/toggle.js.coffee +10 -0
  19. data/lib/ecrire/app/assets/javascripts/admin/editor/parsers/code.coffee +39 -0
  20. data/lib/ecrire/app/assets/javascripts/admin/editor/parsers/heading.coffee +19 -0
  21. data/lib/ecrire/app/assets/javascripts/admin/editor/parsers/image.coffee +129 -0
  22. data/lib/ecrire/app/assets/javascripts/admin/editor/parsers/link.coffee +44 -0
  23. data/lib/ecrire/app/assets/javascripts/admin/editor/parsers/lists.coffee +48 -0
  24. data/lib/ecrire/app/assets/javascripts/admin/editor/parsers/word.coffee +56 -0
  25. data/lib/ecrire/app/assets/javascripts/admin/posts/header.coffee +69 -0
  26. data/lib/ecrire/app/assets/javascripts/admin/posts/new.js.coffee +7 -0
  27. data/lib/ecrire/app/assets/javascripts/admin/posts/title.coffee +15 -0
  28. data/lib/ecrire/app/assets/javascripts/admin.js +5 -0
  29. data/lib/ecrire/app/assets/javascripts/application.js +21 -0
  30. data/lib/ecrire/app/assets/javascripts/shared/overlay.js.coffee +29 -0
  31. data/lib/ecrire/app/assets/javascripts/shared/popup.js.coffee +7 -0
  32. data/lib/ecrire/app/assets/javascripts/vendor/moment.js +3043 -0
  33. data/lib/ecrire/app/assets/javascripts/vendor/prism/prism.ruby.js +25 -0
  34. data/lib/ecrire/app/assets/javascripts/vendor/prism.js +578 -0
  35. data/lib/ecrire/app/assets/stylesheets/admin/base.css.scss +98 -0
  36. data/lib/ecrire/app/assets/stylesheets/admin/documentation.css.scss +28 -0
  37. data/lib/ecrire/app/assets/stylesheets/admin/editor/base.css.scss +41 -0
  38. data/lib/ecrire/app/assets/stylesheets/admin/editor/content.css.scss +57 -0
  39. data/lib/ecrire/app/assets/stylesheets/admin/editor/header.css.scss +62 -0
  40. data/lib/ecrire/app/assets/stylesheets/admin/editor/image.css.scss +58 -0
  41. data/lib/ecrire/app/assets/stylesheets/admin/editor/publish.css.scss +40 -0
  42. data/lib/ecrire/app/assets/stylesheets/admin/editor/save.css.scss +44 -0
  43. data/lib/ecrire/app/assets/stylesheets/admin/images.css.scss +64 -0
  44. data/lib/ecrire/app/assets/stylesheets/admin/loading.css.scss +48 -0
  45. data/lib/ecrire/app/assets/stylesheets/admin/mixins/animations.css.scss +30 -0
  46. data/lib/ecrire/app/assets/stylesheets/admin/mixins/form.css.scss +22 -0
  47. data/lib/ecrire/app/assets/stylesheets/admin/navigation.css.scss +96 -0
  48. data/lib/ecrire/app/assets/stylesheets/admin/posts.css.scss +46 -0
  49. data/lib/ecrire/app/assets/stylesheets/admin/variables.css.scss +7 -0
  50. data/lib/ecrire/app/assets/stylesheets/admin.css.scss +5 -0
  51. data/lib/ecrire/app/assets/stylesheets/application.css.scss +12 -0
  52. data/lib/ecrire/app/assets/stylesheets/sessions.css.scss +97 -0
  53. data/lib/ecrire/app/assets/stylesheets/shared/main.css.scss +5 -0
  54. data/lib/ecrire/app/assets/stylesheets/shared/popup.css.scss +76 -0
  55. data/lib/ecrire/app/assets/stylesheets/vendor/prism/ruby.scss +11 -0
  56. data/lib/ecrire/app/assets/stylesheets/vendor/prism.scss +149 -0
  57. data/lib/ecrire/app/controllers/admin/application_controller.rb +16 -0
  58. data/lib/ecrire/app/controllers/admin/configurations/images_controller.rb +28 -0
  59. data/lib/ecrire/app/controllers/admin/images_controller.rb +35 -0
  60. data/lib/ecrire/app/controllers/admin/labels_controller.rb +18 -0
  61. data/lib/ecrire/app/controllers/admin/partials_controller.rb +43 -0
  62. data/lib/ecrire/app/controllers/admin/posts_controller.rb +90 -0
  63. data/lib/ecrire/app/controllers/admin/properties_controller.rb +35 -0
  64. data/lib/ecrire/app/controllers/application_controller.rb +29 -0
  65. data/lib/ecrire/app/controllers/concerns/.keep +0 -0
  66. data/lib/ecrire/app/controllers/ecrire/posts_controller.rb +42 -0
  67. data/lib/ecrire/app/controllers/images_controller.rb +2 -0
  68. data/lib/ecrire/app/controllers/onboarding/databases_controller.rb +67 -0
  69. data/lib/ecrire/app/controllers/onboarding/users_controller.rb +32 -0
  70. data/lib/ecrire/app/controllers/onboarding_controller.rb +20 -0
  71. data/lib/ecrire/app/controllers/partials_controller.rb +8 -0
  72. data/lib/ecrire/app/controllers/sessions_controller.rb +23 -0
  73. data/lib/ecrire/app/controllers/static_controller.rb +5 -0
  74. data/lib/ecrire/app/forms/admin/image_builder.rb +24 -0
  75. data/lib/ecrire/app/forms/admin/partial_builder.rb +105 -0
  76. data/lib/ecrire/app/forms/admin/post_builder.rb +47 -0
  77. data/lib/ecrire/app/helpers/admin/images_helper.rb +60 -0
  78. data/lib/ecrire/app/helpers/admin/labels_helper.rb +26 -0
  79. data/lib/ecrire/app/helpers/admin/posts_helper.rb +26 -0
  80. data/lib/ecrire/app/helpers/application_helper.rb +64 -0
  81. data/lib/ecrire/app/helpers/content_tag_helper.rb +91 -0
  82. data/lib/ecrire/app/helpers/open_graph_helper.rb +45 -0
  83. data/lib/ecrire/app/helpers/posts_helper.rb +19 -0
  84. data/lib/ecrire/app/models/admin/image.rb +108 -0
  85. data/lib/ecrire/app/models/admin/partial.rb +4 -0
  86. data/lib/ecrire/app/models/admin/post.rb +56 -0
  87. data/lib/ecrire/app/models/concerns/.keep +0 -0
  88. data/lib/ecrire/app/models/image.rb +5 -0
  89. data/lib/ecrire/app/models/label.rb +3 -0
  90. data/lib/ecrire/app/models/partial.rb +3 -0
  91. data/lib/ecrire/app/models/post.rb +90 -0
  92. data/lib/ecrire/app/models/property/image.rb +30 -0
  93. data/lib/ecrire/app/models/property/label.rb +28 -0
  94. data/lib/ecrire/app/models/user.rb +31 -0
  95. data/lib/ecrire/app/strategies/password_strategy.rb +17 -0
  96. data/lib/ecrire/app/views/admin/configurations/images/complete.html.erb +6 -0
  97. data/lib/ecrire/app/views/admin/configurations/images/show.html.erb +14 -0
  98. data/lib/ecrire/app/views/admin/images/_errors.html.erb +14 -0
  99. data/lib/ecrire/app/views/admin/images/_form.html.erb +15 -0
  100. data/lib/ecrire/app/views/admin/images/destroy.js.erb +0 -0
  101. data/lib/ecrire/app/views/admin/images/errors.js.erb +1 -0
  102. data/lib/ecrire/app/views/admin/images/update.js.erb +1 -0
  103. data/lib/ecrire/app/views/admin/posts/_documentation.html.erb +61 -0
  104. data/lib/ecrire/app/views/admin/posts/_list.html.erb +18 -0
  105. data/lib/ecrire/app/views/admin/posts/_post.html.erb +3 -0
  106. data/lib/ecrire/app/views/admin/posts/edit.html.erb +73 -0
  107. data/lib/ecrire/app/views/admin/posts/help.js.erb +1 -0
  108. data/lib/ecrire/app/views/admin/posts/index.js.erb +1 -0
  109. data/lib/ecrire/app/views/admin/posts/title.html.erb +10 -0
  110. data/lib/ecrire/app/views/admin/posts/update/content.js.erb +1 -0
  111. data/lib/ecrire/app/views/admin/posts/update/title.js.erb +1 -0
  112. data/lib/ecrire/app/views/admin/properties/image/create.js.erb +14 -0
  113. data/lib/ecrire/app/views/admin/properties/image/destroy.js.erb +6 -0
  114. data/lib/ecrire/app/views/admin/properties/label/create.js.erb +8 -0
  115. data/lib/ecrire/app/views/admin/properties/label/destroy.js.erb +2 -0
  116. data/lib/ecrire/app/views/layouts/admin/application.html.erb +47 -0
  117. data/lib/ecrire/app/views/partials/show.html.erb +14 -0
  118. data/lib/ecrire/app/views/sessions/_form.html.erb +18 -0
  119. data/lib/ecrire/app/views/sessions/_navigation.html.erb +24 -0
  120. data/lib/ecrire/app/views/sessions/new.html.erb +1 -0
  121. data/lib/ecrire/application.rb +18 -0
  122. data/lib/ecrire/commands/base.rb +9 -0
  123. data/lib/ecrire/commands/console.rb +21 -0
  124. data/lib/ecrire/commands/new.rb +47 -0
  125. data/lib/ecrire/commands/server.rb +27 -0
  126. data/lib/ecrire/commands.rb +19 -0
  127. data/lib/ecrire/config/environment/development.rb +12 -0
  128. data/lib/ecrire/config/environment/production.rb +12 -0
  129. data/lib/ecrire/config/environment/test.rb +3 -0
  130. data/lib/ecrire/config/environment.rb +46 -0
  131. data/lib/ecrire/config/onboarding_routes.rb +11 -0
  132. data/lib/ecrire/config/routes.rb +32 -0
  133. data/lib/ecrire/db/migrate/20131111222709_create_posts.rb +16 -0
  134. data/lib/ecrire/db/migrate/20131113200949_create_users.rb +12 -0
  135. data/lib/ecrire/db/migrate/20131114205041_add_excerpt_to_post.rb +5 -0
  136. data/lib/ecrire/db/migrate/20131221181640_add_javascript_to_posts.rb +5 -0
  137. data/lib/ecrire/db/migrate/20131221195338_create_partials.rb +12 -0
  138. data/lib/ecrire/db/migrate/20140115215122_create_images.rb +12 -0
  139. data/lib/ecrire/db/migrate/20140209144412_add_favorite_flag_to_image.rb +5 -0
  140. data/lib/ecrire/db/migrate/20140617224837_create_labels.rb +12 -0
  141. data/lib/ecrire/db/migrate/20140618321984_add_properties_to_posts.rb +6 -0
  142. data/lib/ecrire/db/migrate/20150113839713_convert_markdown_in_post_content.rb +6 -0
  143. data/lib/ecrire/db/migrate/20150120093481_add_preview_to_posts.rb +8 -0
  144. data/lib/ecrire/db/schema.rb +76 -0
  145. data/lib/ecrire/locales/admin/configurations/images/en.yml +3 -0
  146. data/lib/ecrire/locales/admin/en.yml +26 -0
  147. data/lib/ecrire/locales/admin/images/en.yml +5 -0
  148. data/lib/ecrire/locales/admin/partials/en.yml +18 -0
  149. data/lib/ecrire/locales/admin/posts/en.yml +14 -0
  150. data/lib/ecrire/locales/en.yml +9 -0
  151. data/lib/ecrire/onboarding/assets/images/.keep +0 -0
  152. data/lib/ecrire/onboarding/assets/images/background.png +0 -0
  153. data/lib/ecrire/onboarding/assets/images/github-logo.png +0 -0
  154. data/lib/ecrire/onboarding/assets/images/profile.png +0 -0
  155. data/lib/ecrire/onboarding/assets/images/twitter-logo.png +0 -0
  156. data/lib/ecrire/onboarding/assets/javascripts/base.js +2 -0
  157. data/lib/ecrire/onboarding/assets/javascripts/databases/information.js.coffee +17 -0
  158. data/lib/ecrire/onboarding/assets/javascripts/message.js.coffee +5 -0
  159. data/lib/ecrire/onboarding/assets/stylesheets/base.css.scss +80 -0
  160. data/lib/ecrire/onboarding/assets/stylesheets/complete.css.scss +3 -0
  161. data/lib/ecrire/onboarding/assets/stylesheets/fonts.css.scss +17 -0
  162. data/lib/ecrire/onboarding/assets/stylesheets/form.css.scss +25 -0
  163. data/lib/ecrire/onboarding/assets/stylesheets/message.css.scss +11 -0
  164. data/lib/ecrire/onboarding/assets/stylesheets/terminal.css.scss +16 -0
  165. data/lib/ecrire/onboarding/assets/stylesheets/variables.css.scss +3 -0
  166. data/lib/ecrire/onboarding/assets/stylesheets/welcome.css.scss +62 -0
  167. data/lib/ecrire/onboarding/views/layouts/application.html.erb +16 -0
  168. data/lib/ecrire/onboarding/views/onboarding/complete.html.erb +6 -0
  169. data/lib/ecrire/onboarding/views/onboarding/databases/index.html.erb +34 -0
  170. data/lib/ecrire/onboarding/views/onboarding/users/index.html.erb +16 -0
  171. data/lib/ecrire/onboarding/views/onboarding/welcome.html.erb +12 -0
  172. data/lib/ecrire/railtie/onboarding.rb +63 -0
  173. data/lib/ecrire/railtie/theme.rb +69 -0
  174. data/lib/ecrire/railtie.rb +30 -0
  175. data/lib/ecrire/tasks/assets.rake +15 -0
  176. data/lib/ecrire/tasks/routes.rake +6 -0
  177. data/lib/ecrire/template/Gemfile +31 -0
  178. data/lib/ecrire/template/Rakefile +4 -0
  179. data/lib/ecrire/template/assets/images/.keep +0 -0
  180. data/lib/ecrire/template/assets/javascripts/base.js.coffee +0 -0
  181. data/lib/ecrire/template/assets/javascripts/post.js.coffee +0 -0
  182. data/lib/ecrire/template/assets/stylesheets/base.css.scss +86 -0
  183. data/lib/ecrire/template/assets/stylesheets/code.css.scss +24 -0
  184. data/lib/ecrire/template/assets/stylesheets/footer.css.scss +5 -0
  185. data/lib/ecrire/template/assets/stylesheets/header.css.scss +18 -0
  186. data/lib/ecrire/template/assets/stylesheets/home.css.scss +35 -0
  187. data/lib/ecrire/template/config.ru +4 -0
  188. data/lib/ecrire/template/controllers/posts_controller.rb +2 -0
  189. data/lib/ecrire/template/helpers/blog_helper.rb +2 -0
  190. data/lib/ecrire/template/views/layouts/application.html.erb +35 -0
  191. data/lib/ecrire/template/views/posts/_post.html.erb +9 -0
  192. data/lib/ecrire/template/views/posts/index.html.erb +13 -0
  193. data/lib/ecrire/template/views/posts/show.html.erb +7 -0
  194. data/lib/ecrire/template/views/static/about.html +0 -0
  195. data/lib/ecrire/template/views/static/customize/_helper.html +7 -0
  196. data/lib/ecrire/template/views/static/customize/_helper_used.html +6 -0
  197. data/lib/ecrire/template/views/static/customize/_image.html +1 -0
  198. data/lib/ecrire/template/views/static/customize/_index.html +1 -0
  199. data/lib/ecrire/template/views/static/customize/_javascript.html +1 -0
  200. data/lib/ecrire/template/views/static/customize/_layout.html.erb +15 -0
  201. data/lib/ecrire/template/views/static/customize/_post.html +3 -0
  202. data/lib/ecrire/template/views/static/customize.html +95 -0
  203. data/lib/ecrire/version.rb +3 -0
  204. data/lib/ecrire.rb +24 -0
  205. data/test/editor/controllers/admin/images_controller_test.rb +6 -0
  206. data/test/editor/controllers/admin/posts_controller_test.rb +90 -0
  207. data/test/editor/controllers/base_controller_test.rb +26 -0
  208. data/test/editor/controllers/images_controller_test.rb +2 -0
  209. data/test/editor/controllers/partials_controller_test.rb +2 -0
  210. data/test/editor/controllers/posts_controller_test.rb +21 -0
  211. data/test/editor/controllers/sessions_controller_test.rb +21 -0
  212. data/test/editor/helpers/base_helper_test.rb +19 -0
  213. data/test/editor/helpers/posts_helper_test.rb +3 -0
  214. data/test/editor/models/image_test.rb +33 -0
  215. data/test/editor/models/partial_test.rb +4 -0
  216. data/test/editor/models/post_test.rb +109 -0
  217. data/test/editor/models/user_test.rb +4 -0
  218. data/test/editor/test_helper.rb +28 -0
  219. data/test/fixtures/images.yml +11 -0
  220. data/test/fixtures/partials.yml +9 -0
  221. data/test/fixtures/posts.yml +16 -0
  222. data/test/fixtures/users.yml +9 -0
  223. data/test/initializations/railtie_test.rb +49 -0
  224. data/test/isolation.rb +16 -0
  225. data/test/themes/template/Gemfile +28 -0
  226. data/test/themes/template/assets/javascripts/blog.js.coffee +0 -0
  227. data/test/themes/template/assets/javascripts/post.js.coffee +0 -0
  228. data/test/themes/template/assets/stylesheets/blog.css.scss +0 -0
  229. data/test/themes/template/assets/stylesheets/post.css.scss +0 -0
  230. data/test/themes/template/config.ru +0 -0
  231. data/test/themes/template/views/layouts/application.html.erb +1 -0
  232. data/test/themes/template/views/posts/index.html.erb +0 -0
  233. metadata +275 -0
@@ -0,0 +1,47 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>Ecrire</title>
5
+ <link rel="shortcut icon" href="<%= url_for("/favicon.ico")%>" />
6
+ <%= stylesheet_link_tag "admin", media: "all" %>
7
+ <%= javascript_include_tag "admin" %>
8
+ <%= csrf_meta_tags %>
9
+ </head>
10
+ <%= body_tag class: %W(#{action_name} #{controller_name}) do %>
11
+
12
+ <main>
13
+ <%= content_tag :nav, id: 'Menu', class: ['admin', controller_name] do %>
14
+ <section>
15
+ <div class='back'>
16
+ <%= link_to 'Home', :root %>
17
+ </div>
18
+ <div class='posts'>
19
+ <h4>
20
+ <%= link_to 'New post', new_title_admin_posts_path, class: %w(new button) %>
21
+ </h4>
22
+ <%= link_to admin_posts_path(type: :draft), class: %w(drafts), remote: true, as: 'Posts.Popup' do %>
23
+ <span class='type'>Drafts</span>
24
+ <%= content_tag :span, posts.drafted.count, class: %w(count) %>
25
+ <% end %>
26
+
27
+ <%= link_to admin_posts_path(type: :published), class: %w(drafts), remote: true, as: 'Posts.Popup' do %>
28
+ <span class='type'>Published</span>
29
+ <%= content_tag :span, posts.published.count, class: %w(count) %>
30
+ <% end %>
31
+ </div>
32
+ </section>
33
+
34
+ <%= yield :menu %>
35
+
36
+ <%= button_to session_path, method: :delete, class: %w(logout), form_class: %w(form logout) do %>
37
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" class="logout" x="0px" y="0px" viewBox="0 0 20 20" enable-background="new 0 0 20 20" xml:space="preserve">
38
+ <path d="M19,10l-6-5v3H6v4h7v3L19,10z M3,3h8V1H3C1.9,1,1,1.9,1,3v14c0,1.1,0.9,2,2,2h8v-2H3V3z"/>
39
+ </svg>
40
+ <% end %>
41
+ <% end %>
42
+
43
+ <%= yield %>
44
+ </main>
45
+
46
+ <% end %>
47
+ </html>
@@ -0,0 +1,14 @@
1
+ <div class="partial">
2
+ <style scoped>
3
+ <%= @partial.stylesheet.html_safe %>
4
+ </style>
5
+
6
+ <script type="text/javascript">
7
+ <%= @partial.javascript.html_safe %>
8
+ </script>
9
+
10
+ <div class="content">
11
+ <%= @partial.content.html_safe %>
12
+ </div>
13
+ </div>
14
+
@@ -0,0 +1,18 @@
1
+ <%= form_for User.new, url: session_path, as: "session", html: { class: %w(session) } do |f| %>
2
+
3
+ <% unless warden.errors.empty? %>
4
+ <%= content_tag :p, warden.errors.full_messages.to_sentence, class: %w(errors) %>
5
+ <% end %>
6
+
7
+ <div class="fieldset">
8
+ <%= f.text_field :email, placeholder: t("sessions.email") %>
9
+ <%= f.password_field :password, placeholder: t("sessions.password") %>
10
+ </div>
11
+
12
+ <%= f.button do %>
13
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" x="0px" y="0px" viewBox="0 0 20 20" enable-background="new 0 0 20 20" xml:space="preserve">
14
+ <path d="M14,10L8,5v3H1v4h7v3L14,10z M17,17H9v2h8c1.1,0,2-0.9,2-2V3c0-1.1-0.9-2-2-2H9v2h8V17z"/>
15
+ </svg>
16
+ <% end %>
17
+
18
+ <% end %>
@@ -0,0 +1,24 @@
1
+ <nav id="Menu" class="admin">
2
+
3
+ <section>
4
+ <div class='posts'>
5
+ <%= link_to 'New post', new_title_admin_posts_path, class: %w(new button) %>
6
+ <%= link_to admin_posts_path(type: :draft), class: %w(drafts), remote: true, as: 'Posts.Popup' do %>
7
+ <span class='type'>Drafts</span>
8
+ <%= content_tag :span, Post.drafted.count, class: %w(count) %>
9
+ <% end %>
10
+
11
+ <%= link_to admin_posts_path(type: :published), class: %w(drafts), remote: true, as: 'Posts.Popup' do %>
12
+ <span class='type'>Published</span>
13
+ <%= content_tag :span, Post.published.count, class: %w(count) %>
14
+ <% end %>
15
+ </div>
16
+ </section>
17
+
18
+
19
+ <%= button_to session_path, method: :delete, class: %w(logout), form_class: %w(form logout) do %>
20
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" class="logout" x="0px" y="0px" viewBox="0 0 20 20" enable-background="new 0 0 20 20" xml:space="preserve">
21
+ <path d="M19,10l-6-5v3H6v4h7v3L19,10z M3,3h8V1H3C1.9,1,1,1.9,1,3v14c0,1.1,0.9,2,2,2h8v-2H3V3z"/>
22
+ </svg>
23
+ <% end %>
24
+ </nav>
@@ -0,0 +1 @@
1
+ <%= render 'form' %>
@@ -0,0 +1,18 @@
1
+ require 'warden'
2
+ require 'pg'
3
+ require 's3'
4
+ require 'kaminari'
5
+ require 'jointjs'
6
+
7
+ module Ecrire
8
+ class Application < Rails::Application
9
+ require 'ecrire/config/environment'
10
+ require 'ecrire/railtie'
11
+
12
+ # Let's not put anything in here. Because Rails instantiate the class as soon as it's defined,
13
+ # it's impossible to rely on any declaration made here.
14
+ #
15
+ # Instead, defined any configuration in config/environment.rb
16
+
17
+ end
18
+ end
@@ -0,0 +1,9 @@
1
+ module Ecrire
2
+ module Commands
3
+ class Base
4
+ def shift_argv!
5
+ ARGV.shift if ARGV.first && ARGV.first[0] != '-'
6
+ end
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,21 @@
1
+ require 'ecrire/commands/base'
2
+
3
+ module Ecrire
4
+ module Commands
5
+ class Console < ::Ecrire::Commands::Base
6
+ def initialize(options = {}, *args)
7
+ end
8
+
9
+ def run!
10
+ require 'ecrire'
11
+ require 'rails/commands/console'
12
+
13
+ shift_argv!
14
+ Ecrire::Application.require_environment!
15
+ Ecrire::Application.initialize!
16
+
17
+ Rails::Console.start(Ecrire::Application, *ARGV)
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,47 @@
1
+ require 'pathname'
2
+ require 'fileutils'
3
+ require 'yaml'
4
+ require 'securerandom'
5
+
6
+ require 'ecrire/commands/base'
7
+
8
+ module Ecrire
9
+ module Commands
10
+ class New < Ecrire::Commands::Base
11
+ attr_reader :path
12
+ def initialize(options = {}, *args)
13
+ if args[0].nil?
14
+ puts 'Please specify a blog name.'
15
+ puts 'Example: ecrire new blog.domain.com'
16
+ exit
17
+ end
18
+ @path = Pathname.new(Dir.pwd)
19
+ @path += args[0]
20
+ end
21
+
22
+ def run!
23
+ if Dir.exist?(@path)
24
+ ask_to_overwrite!
25
+ FileUtils.rm_rf(@path)
26
+ end
27
+ generate!
28
+ end
29
+
30
+ def generate!
31
+ Dir.mkdir @path
32
+ Dir.chdir @path
33
+ template = File.expand_path '../../template/*', __FILE__
34
+ FileUtils.cp_r(Dir[template], @path)
35
+ end
36
+
37
+ def ask_to_overwrite!
38
+ puts "You are about to overwrite #{@path} with a new theme."
39
+ puts "Are you sure? [y/n]"
40
+ confirm = STDIN.gets.chomp
41
+ if confirm != 'y'
42
+ exit
43
+ end
44
+ end
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,27 @@
1
+ require 'ecrire/commands/base'
2
+
3
+ module Ecrire
4
+ module Commands
5
+ class Server < Ecrire::Commands::Base
6
+
7
+ def initialize(options = {}, *args)
8
+
9
+ require 'ecrire'
10
+ require 'rails/commands/server'
11
+
12
+ shift_argv!
13
+
14
+ @server = Rails::Server.new
15
+ @server.options[:Port] = options[:Port]
16
+ end
17
+
18
+ def run!
19
+ @server.tap do |server|
20
+ Dir.chdir(Ecrire::Application.root)
21
+ server.start
22
+ end
23
+ end
24
+
25
+ end
26
+ end
27
+ end
@@ -0,0 +1,19 @@
1
+ require 'ecrire/commands/server'
2
+ require 'ecrire/commands/new'
3
+ require 'ecrire/commands/console'
4
+
5
+ module Ecrire
6
+ module Commands
7
+ def self.new
8
+ Ecrire::Commands::New
9
+ end
10
+
11
+ def self.server
12
+ Ecrire::Commands::Server
13
+ end
14
+
15
+ def self.console
16
+ Ecrire::Commands::Console
17
+ end
18
+ end
19
+ end
@@ -0,0 +1,12 @@
1
+ Ecrire::Application.configure do
2
+ config.cache_classes = false
3
+ config.eager_load = false
4
+ config.consider_all_requests_local = true
5
+ config.action_controller.perform_caching = false
6
+
7
+ config.active_support.deprecation = :log
8
+
9
+ config.active_record.migration_error = :page_load
10
+
11
+ config.assets.debug = true
12
+ end
@@ -0,0 +1,12 @@
1
+ Ecrire::Application.configure do
2
+ config.assets.js_compressor = :uglifier
3
+ config.assets.debug = false
4
+ config.assets.compile = true
5
+ config.assets.digest = true
6
+ config.assets.version = '1.0'
7
+
8
+ config.serve_static_files = false
9
+
10
+ config.log_level = :info
11
+
12
+ end
@@ -0,0 +1,3 @@
1
+ Ecrire::Application.configure do
2
+ config.action_controller.allow_forgery_protection = false
3
+ end
@@ -0,0 +1,46 @@
1
+ Rails.application.configure do
2
+ config = self.config
3
+ config.eager_load = true
4
+
5
+ config.paths.path = File.expand_path '../../', __FILE__
6
+ config.paths.add 'app/strategies', eager_load: true
7
+ config.paths.add 'app/forms', eager_load: true
8
+ config.paths.add 'lib/tasks', with: 'tasks', glob: '**/*.rake'
9
+
10
+ config.paths.add "config/locales", with: "locales", glob: "**/*.{rb,yml}"
11
+
12
+ config.paths.add 'Gemfile', with: 'config/Gemfile'
13
+
14
+ config.filter_parameters += [:password, :database]
15
+ config.session_store :cookie_store, key: '_ecrire_com_session'
16
+
17
+ config.assets.precompile = [
18
+ lambda do |filename, path|
19
+ path =~ /assets/ && !%w(.js .css).include?(File.extname(filename))
20
+ end,
21
+ /^(admin|application|base)\.(css|js)$/
22
+ ]
23
+
24
+ Warden::Manager.serialize_into_session do |user|
25
+ user.id
26
+ end
27
+
28
+ Warden::Manager.serialize_from_session do |id|
29
+ User.find_by_id(id)
30
+ end
31
+
32
+ config.to_prepare do
33
+ Warden::Strategies.add :password, PasswordStrategy
34
+ end
35
+
36
+ config.middleware.use Warden::Manager do |manager|
37
+ manager.default_strategies :password
38
+ manager.failure_app = SessionsController.action(:failed)
39
+ end
40
+
41
+ ActiveSupport.on_load(:action_controller) do
42
+ wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
43
+ end
44
+
45
+ require "ecrire/config/environment/#{Rails.env}"
46
+ end
@@ -0,0 +1,11 @@
1
+ Ecrire::Application.routes.draw do
2
+
3
+ root 'onboarding#index'
4
+
5
+ namespace :onboarding, only: :index do
6
+ resources :databases, only: [:index, :create]
7
+ resources :users, only: [:index, :create]
8
+ end
9
+ end
10
+
11
+
@@ -0,0 +1,32 @@
1
+ Ecrire::Application.routes.draw do
2
+ root 'posts#index'
3
+
4
+ get '/:year/:month/:id', controller: :posts, action: :show, constraints: { year: /\d+/, month: /\d+/ }, as: "post"
5
+ get '/feed', controller: :posts, action: :index, defaults: { format: :rss }
6
+
7
+ resources :posts, only: [:index]
8
+
9
+ resource :session, only: [:new, :create, :destroy]
10
+
11
+ resources :partials, only: [:show]
12
+
13
+ namespace :admin do
14
+ root 'posts#index'
15
+ resources :posts do
16
+ collection do
17
+ get 'new/title', controller: :posts, action: :new
18
+ get 'help', controller: :posts, action: :help
19
+ end
20
+ resource :image, shallow: true
21
+ resource :properties, only: [:create, :destroy]
22
+ end
23
+
24
+ namespace :configurations do
25
+ resource :images, only: [:show, :create]
26
+ end
27
+ end
28
+
29
+ get '/:view', to: 'static#show'
30
+
31
+ end
32
+
@@ -0,0 +1,16 @@
1
+ class CreatePosts < ActiveRecord::Migration
2
+ def change
3
+ create_table :posts do |t|
4
+
5
+ t.string :title, null: false
6
+ t.string :slug, null: false
7
+ t.text :content
8
+ t.text :stylesheet
9
+
10
+ t.datetime :published_at
11
+ t.timestamps
12
+
13
+ end
14
+ add_index :posts, :title, unique: true
15
+ end
16
+ end
@@ -0,0 +1,12 @@
1
+ class CreateUsers < ActiveRecord::Migration
2
+ def change
3
+ create_table :users do |t|
4
+
5
+ t.string :email, null: false
6
+ t.string :encrypted_password, null: false
7
+ t.timestamps
8
+ end
9
+
10
+ add_index :users, :email, unique: true
11
+ end
12
+ end
@@ -0,0 +1,5 @@
1
+ class AddExcerptToPost < ActiveRecord::Migration
2
+ def change
3
+ add_column :posts, :excerpt, :string
4
+ end
5
+ end
@@ -0,0 +1,5 @@
1
+ class AddJavascriptToPosts < ActiveRecord::Migration
2
+ def change
3
+ add_column :posts, :javascript, :text
4
+ end
5
+ end
@@ -0,0 +1,12 @@
1
+ class CreatePartials < ActiveRecord::Migration
2
+ def change
3
+ create_table :partials do |t|
4
+
5
+ t.timestamps
6
+ t.string :title, null: false
7
+ t.text :content
8
+ t.text :stylesheet
9
+ t.text :javascript
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,12 @@
1
+ class CreateImages < ActiveRecord::Migration
2
+ def change
3
+ create_table :images do |t|
4
+ t.string :url
5
+ t.string :key
6
+
7
+ t.references :post
8
+
9
+ t.timestamps
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,5 @@
1
+ class AddFavoriteFlagToImage < ActiveRecord::Migration
2
+ def change
3
+ add_column :images, :favorite, :boolean
4
+ end
5
+ end
@@ -0,0 +1,12 @@
1
+ class CreateLabels < ActiveRecord::Migration
2
+ def change
3
+ create_table :labels do |t|
4
+
5
+ t.string :name, null: false
6
+ t.timestamps
7
+
8
+ end
9
+ add_index :labels, :name, unique: false
10
+ end
11
+ end
12
+
@@ -0,0 +1,6 @@
1
+ class AddPropertiesToPosts < ActiveRecord::Migration
2
+ def change
3
+ execute 'CREATE EXTENSION hstore'
4
+ add_column :posts, :properties, :hstore
5
+ end
6
+ end
@@ -0,0 +1,6 @@
1
+ class ConvertMarkdownInPostContent < ActiveRecord::Migration
2
+ def change
3
+ add_column :posts, :compiled_content, :text
4
+ end
5
+ end
6
+
@@ -0,0 +1,8 @@
1
+ class AddPreviewToPosts < ActiveRecord::Migration
2
+ def change
3
+ add_column :posts, :compiled_preview_content, :text
4
+ remove_column :posts, :excerpt
5
+ rename_column :posts, :compiled_preview_content, :compiled_excerpt
6
+ end
7
+ end
8
+
@@ -0,0 +1,76 @@
1
+ # encoding: UTF-8
2
+ # This file is auto-generated from the current state of the database. Instead
3
+ # of editing this file, please use the migrations feature of Active Record to
4
+ # incrementally modify your database, and then regenerate this schema definition.
5
+ #
6
+ # Note that this schema.rb definition is the authoritative source for your
7
+ # database schema. If you need to create the application database on another
8
+ # system, you should be using db:schema:load, not running all the migrations
9
+ # from scratch. The latter is a flawed and unsustainable approach (the more migrations
10
+ # you'll amass, the slower it'll run and the greater likelihood for issues).
11
+ #
12
+ # It's strongly recommended that you check this file into your version control system.
13
+
14
+ ActiveRecord::Schema.define(version: 20150120093481) do
15
+
16
+ # These are extensions that must be enabled in order to support this database
17
+ enable_extension "plpgsql"
18
+ enable_extension "hstore"
19
+
20
+ create_table "abtests", force: :cascade do |t|
21
+ t.datetime "created_at"
22
+ t.datetime "updated_at"
23
+ end
24
+
25
+ create_table "images", force: :cascade do |t|
26
+ t.string "url", limit: 255
27
+ t.string "key", limit: 255
28
+ t.integer "post_id"
29
+ t.datetime "created_at"
30
+ t.datetime "updated_at"
31
+ t.boolean "favorite"
32
+ end
33
+
34
+ create_table "labels", force: :cascade do |t|
35
+ t.string "name", limit: 255, null: false
36
+ t.datetime "created_at"
37
+ t.datetime "updated_at"
38
+ end
39
+
40
+ add_index "labels", ["name"], name: "index_labels_on_name", using: :btree
41
+
42
+ create_table "partials", force: :cascade do |t|
43
+ t.datetime "created_at"
44
+ t.datetime "updated_at"
45
+ t.string "title", limit: 255, null: false
46
+ t.text "content"
47
+ t.text "stylesheet"
48
+ t.text "javascript"
49
+ end
50
+
51
+ create_table "posts", force: :cascade do |t|
52
+ t.string "title", limit: 255, null: false
53
+ t.string "slug", limit: 255, null: false
54
+ t.text "content"
55
+ t.text "stylesheet"
56
+ t.datetime "published_at"
57
+ t.datetime "created_at"
58
+ t.datetime "updated_at"
59
+ t.text "javascript"
60
+ t.hstore "properties"
61
+ t.text "compiled_content"
62
+ t.text "compiled_excerpt"
63
+ end
64
+
65
+ add_index "posts", ["title"], name: "index_posts_on_title", unique: true, using: :btree
66
+
67
+ create_table "users", force: :cascade do |t|
68
+ t.string "email", limit: 255, null: false
69
+ t.string "encrypted_password", limit: 255, null: false
70
+ t.datetime "created_at"
71
+ t.datetime "updated_at"
72
+ end
73
+
74
+ add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree
75
+
76
+ end
@@ -0,0 +1,3 @@
1
+ en:
2
+ admin:
3
+ configurations:
@@ -0,0 +1,26 @@
1
+ en:
2
+ admin:
3
+ navigation:
4
+ posts: "Posts"
5
+ partials: "Partials"
6
+ logout: ""
7
+
8
+ form:
9
+ image:
10
+ drop_pad: "Drop your image here."
11
+ post:
12
+ title: "Your title here"
13
+ content: "Write"
14
+ stylesheet: "Style"
15
+ javascript: "Script"
16
+ slug: "Create your own slug. It will be build with the title otherwise."
17
+ options:
18
+ fields:
19
+ text: 'Write'
20
+ CSS: 'Stylesheet'
21
+ JS: 'Javascript'
22
+ preview: "Preview"
23
+ partials: "Partials"
24
+ images:
25
+ link: "Images"
26
+ post_not_persisted: "Images unavailable. Save your post first."
@@ -0,0 +1,5 @@
1
+ en:
2
+ admin:
3
+ images:
4
+ helper:
5
+ title: "Configure s3 to upload images"
@@ -0,0 +1,18 @@
1
+ en:
2
+ admin:
3
+ partials:
4
+
5
+ index:
6
+ new_idea: "Build small HTML snippet you can reuse in your blog posts. It can be anything: Mailing list form, Christmas HTML snippet, etc."
7
+ start_writing: "Create a partial."
8
+
9
+ form:
10
+ title: "Partial's title"
11
+ content: "Write your HTML"
12
+ stylesheet: "Write your CSS"
13
+ javascript: "Write your JavaScript"
14
+ options:
15
+ fields:
16
+ text: 'Write'
17
+ CSS: 'Stylesheet'
18
+ JS: 'Javascript'
@@ -0,0 +1,14 @@
1
+ en:
2
+ admin:
3
+ posts:
4
+ new:
5
+ title: "Title for your new post"
6
+ editable: "Don't worry, you will be able to change the title afterwards."
7
+ index:
8
+ new_idea: "Every great post starts small."
9
+ start_writing: "Start writing."
10
+ update:
11
+ successful: "Saved"
12
+ permalink:
13
+ editable: "The permalink will change if you change the title of your post"
14
+ permanent: "Your post is published. For accessibility reasons, the permalink won't change if you change your title"
@@ -0,0 +1,9 @@
1
+ en:
2
+ posts:
3
+ edit: "Edit"
4
+ sessions:
5
+ email: "Email"
6
+ password: "Password"
7
+ home: "Go back"
8
+ submit: "Login"
9
+
File without changes