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,24 @@
1
+ div.file.preview {
2
+ @include display(flex);
3
+ @include flex-direction(column);
4
+ background: #FEFEFE;
5
+ box-shadow: 0 0 2px 0 #AAA;
6
+ pre {
7
+ background: none;
8
+ box-shadow: none;
9
+ }
10
+
11
+ p {
12
+ margin: 0;
13
+ padding: 1em;
14
+ background: rgb(242, 239, 232);
15
+ border-bottom: 1px solid #CDCBC8;
16
+ text-align: center;
17
+ word-break: break-all;
18
+ }
19
+ }
20
+
21
+ pre {
22
+ background: #FEFEFE;
23
+ box-shadow: 0 0 2px 0 #AAA;
24
+ }
@@ -0,0 +1,5 @@
1
+ footer {
2
+ a {
3
+ text-decoration: none;
4
+ }
5
+ }
@@ -0,0 +1,18 @@
1
+ main > header {
2
+ @include display(flex);
3
+ @include align-items(center);
4
+ @include justify-content(space-between);
5
+
6
+ padding: 2em 1em;
7
+
8
+ h1 {
9
+ font-family: courier;
10
+ }
11
+
12
+ nav {
13
+ a {
14
+ margin: 0 1em;
15
+ font-size: 0.8em;
16
+ }
17
+ }
18
+ }
@@ -0,0 +1,35 @@
1
+ main > article {
2
+
3
+ time {
4
+ font-size: 0.8em;
5
+ text-transform: uppercase;
6
+ }
7
+
8
+ ol.posts {
9
+ @include display(flex);
10
+ @include flex-direction(column);
11
+
12
+ li {
13
+ @include display(flex);
14
+ @include flex-direction(column);
15
+ margin-bottom: 1em;
16
+
17
+ h2 {
18
+ margin-bottom: 0;
19
+ }
20
+ }
21
+
22
+ div.content {
23
+ margin: 1em 0;
24
+ font-size: 1.1em;
25
+ }
26
+
27
+ }
28
+
29
+ div.posts.empty {
30
+ @include display(flex);
31
+ @include flex-direction(column);
32
+ @include align-items(center);
33
+ @include justify-content(center);
34
+ }
35
+ }
@@ -0,0 +1,4 @@
1
+ # This file is used by Rack-based servers to start the application.
2
+
3
+ require 'ecrire'
4
+ run Ecrire::Application.initialize!
@@ -0,0 +1,2 @@
1
+ class PostsController < Ecrire::PostsController
2
+ end
@@ -0,0 +1,2 @@
1
+ module BlogHelper
2
+ end
@@ -0,0 +1,35 @@
1
+ <!doctype html>
2
+ <html>
3
+
4
+ <head>
5
+ <%= title_tag %>
6
+ <%= assets_tags %>
7
+ <%= meta_informations_tags %>
8
+ </head>
9
+
10
+ <%= body_tag do %>
11
+
12
+ <main>
13
+ <%= admin_navigation %>
14
+ <header>
15
+ <h1><%= link_to 'E', :root %></h1>
16
+ <nav>
17
+ <%= link_to 'Customize', '/customize' %>
18
+ <% if !signed_in? %>
19
+ <%= link_to 'Log in', new_session_path %>
20
+ <% end %>
21
+ </nav>
22
+ </header>
23
+
24
+ <article>
25
+ <%= yield %>
26
+ </article>
27
+
28
+ <footer>
29
+ </footer>
30
+ </main>
31
+
32
+ <% end %>
33
+ </html>
34
+
35
+
@@ -0,0 +1,9 @@
1
+ <li class="post">
2
+ <%= content_tag :h2, link_to(post.title, post_path(post)) %>
3
+ <%= content_tag :time, l(post.published_at.to_date, format: :long) %>
4
+ <div class='content'>
5
+ <%= post.excerpt %>
6
+ </div>
7
+
8
+ <%= link_to 'Read more', post_path(post), class: %w(read) %>
9
+ </li>
@@ -0,0 +1,13 @@
1
+ <% if posts.any? %>
2
+ <ol class='posts'>
3
+ <%= render posts %>
4
+ <%= paginate posts %>
5
+ </ol>
6
+ <% else %>
7
+ <div class='posts empty'>
8
+ <p>You haven't published yet.</p>
9
+ <% if signed_in? %>
10
+ <%= link_to 'Create a new post', new_title_admin_posts_path %>
11
+ <% end %>
12
+ </div>
13
+ <% end %>
@@ -0,0 +1,7 @@
1
+ <%= content_tag :h2, post.title %>
2
+ <%= content_tag :time, l(post.published_at.to_date, format: :long) %>
3
+
4
+ <div class="content">
5
+ <%= @post.content.html_safe %>
6
+ </div>
7
+
File without changes
@@ -0,0 +1,7 @@
1
+ module YourHelper
2
+ def tags_list
3
+ Post.all.pluck(&:tags).uniq!.map do |tag|
4
+ link_to posts_path(tag: tag)
5
+ end
6
+ end
7
+ end
@@ -0,0 +1,6 @@
1
+ <aside>
2
+ <h2>Tags</h2>
3
+ <p>
4
+ <%= '<'.html_safe %>%= tags_list %>
5
+ </p>
6
+ </aside>
@@ -0,0 +1 @@
1
+ <%= '<'.html_safe %>%= image_tag 'header.png' %>
@@ -0,0 +1 @@
1
+ <%= '<'.html_safe %>%= render posts %>
@@ -0,0 +1 @@
1
+ #= require 'file'
@@ -0,0 +1,15 @@
1
+ <!doctype html>
2
+ <html>
3
+
4
+ <head>
5
+ <%= '<'.html_safe %>%= title_tag %>
6
+ <%= '<'.html_safe %>%= assets_tags %>
7
+ <%= '<'.html_safe %>%= meta_informations_tags %>
8
+ </head>
9
+
10
+ <%= '<'.html_safe %>%= body_tag id: [controller_name, action_name].join('-') do %>
11
+ <%= '<'.html_safe %>%= admin_navigation %>
12
+ <%= '<'.html_safe %>%= yield %>
13
+ <%= '<'.html_safe %>% end %>
14
+
15
+ </html>
@@ -0,0 +1,3 @@
1
+ <%= '<'.html_safe %>%= posts.each do |post| %>
2
+ <%= '<'.html_safe %>%= link_to post.title, post_path(post) %>
3
+ <%= '<'.html_safe %>% end %>
@@ -0,0 +1,95 @@
1
+ <section>
2
+ <h2>Customize your blog</h2>
3
+
4
+ <p>Ecrire generated a vanilla template for your blog. Everything you see in the folder is for you to modify. As you'll see below, there's already a lot that Ecrire comes with to help you make your blog yours.</p>
5
+
6
+ <p>Many of the features that are displayed here come directly from <a href="http://rubyonrails.org/">Ruby on Rails</a>. This is because Ecrire is built on top of it. That means that if you are already a user of Rails, you know <em>almost</em> everything there is to know about customizing your blog.</p>
7
+
8
+ </section>
9
+
10
+ <section class='customize'>
11
+ <h2>Views</h2>
12
+ <p>Views are where the HTML is built. It is built arount the concept of layout, views and partials. The three elements are nested together to create the HTML that will be sent to the browser &mdash; like this page.</p>
13
+
14
+ <h3>The layout</h3>
15
+ <p>The layout is where you put everything that is reused on <strong>every</strong> page. The layout is where you set the document type, the &lt;head&gt; element and everything else that you want to have on every page.</p>
16
+
17
+ <div class='file preview'>
18
+ <p><%= Rails.root %>/views/layouts/application.html.erb</p>
19
+ <pre><code class='language-ruby'><%= render('static/customize/layout').to_str %></code></pre>
20
+ </div>
21
+
22
+ <p>One thing you <strong>must</strong> have in your layout is the <code class='language-ruby'>&lt;%= yield %&gt;</code> call. This call will inject the view into the layout. If you want to learn more about the layout, Ruby on rails has a <a href="http://guides.rubyonrails.org/layouts_and_rendering.html#understanding-yield">great guide that explains</a> the layout more thoroughly.</p>
23
+
24
+ <h3>Views</h3>
25
+ <p>The post views is where you can customize your HTML dependant of the URL access. Initially, there's two views configured: <code>posts/index.html.erb</code> and <code>posts/show.html.erb</code></p>
26
+
27
+ <p>This view is the home page of your blog. If you want to list your post entries, you can do it by adding this code snippet to your view:</p>
28
+
29
+ <div class='file preview'>
30
+ <p><%= Rails.root %>/views/posts/index.html.erb</p>
31
+ <pre><code class='language-ruby'><%= render('static/customize/index').to_str %></code></pre>
32
+ </div>
33
+
34
+ <p>And then add more HTML through a the partial.</p>
35
+
36
+ <div class='file preview'>
37
+ <p><%= Rails.root %>/views/posts/_post.html.erb</p>
38
+ <pre><code class='language-ruby'><%= render('static/customize/post').to_str %></code></pre>
39
+ </div>
40
+
41
+
42
+ </section>
43
+
44
+ <section class='customize'>
45
+ <h2>Helpers</h2>
46
+ <p>Helpers are modules you can create to define methods that can be used for different purposes.</p>
47
+ <div class='file preview'>
48
+ <p><%= Rails.root %>/helpers/your_helper.rb</p>
49
+ <pre><code class='language-ruby'><%= render('static/customize/helper').to_str %></code></pre>
50
+ </div>
51
+
52
+ <p>It is automatically available in your views.</p>
53
+
54
+ <div class='file preview'>
55
+ <p><%= Rails.root %>/helpers/your_helper.rb</p>
56
+ <pre><code class='language-html'><%= render('static/customize/helper_used').to_str %></code></pre>
57
+ </div>
58
+ </section>
59
+
60
+ <section class='customize'>
61
+ <h2>Assets</h2>
62
+ <p>The assets are the CSS, JS and any images you would like to show on your blog that aren't a part of a blog post. Ecrire &mdash; via Rails &mdash; provides a few mechanism to help you build customize your theme.</p>
63
+
64
+ <p>Everything that is described here can be found in use within your default theme. Just browse the code to see an example of what is documented here.</p>
65
+
66
+ <h3>Stylesheets</h3>
67
+ <p>Stylesheets can either be pure CSS or <a href='http://sass-lang.com/'>SASS</a>. Rails will use the SASS preprocessor if the file ends with .scss.</p>
68
+
69
+ <p>You will notice a file name base.css.scss with a few @import rules. These rules are necessary if you want to include other files besides the <em>required</em> base.css. Since it supports wildcard, you don't need to specify every file in your folder.</p>
70
+
71
+ <p>You can also add libraries that are available as gem. By default, Ecrire comes with <a href='http://bourbon.io/'>Bourbon</a>, which is imported by default. That means you can have access to all the bourbon mixins from <strong>any</strong> stylesheet.</p>
72
+
73
+ <h3>Javascripts</h3>
74
+ <p>Javascripts can either be pure Javascript or Coffeescript.</p>
75
+
76
+ <p>If you choose to use Coffeescript, you only need to append .coffee to your file to enable the pre-compiler. Similar to your stylesheets, javascript has an import rule. While the @import rule is specified within the <a href='https://developer.mozilla.org/en/docs/Web/CSS/@import'>CSS Standard</a>, ECMAScript doesn't have such a thing.</p>
77
+
78
+ <p>Sprockets uses a directive through commenting the top of the file. It uses a similar syntax it shouldn't be too hard to make modification. Also, there's an example from within this theme.</p>
79
+
80
+ <div class='file preview'>
81
+ <p><%= Rails.root %>/assets/javascripts/base.js.coffee</p>
82
+ <pre><code class='language-coffeescript'><%= render('static/customize/javascript').to_str %></code></pre>
83
+ </div>
84
+
85
+ <p>Note that if you want to use vanilla javascript, you will need to use the commenting syntax for javascript (//=).</p>
86
+
87
+ <h3>Images</h3>
88
+ <p>Images can be any format that are supported by the browser. However, you need to use a helper when you use images that you put in the assets/images folder.</p>
89
+
90
+ <div class='file preview'>
91
+ <p><%= Rails.root %>/assets/images/header.png</p>
92
+ <pre><code class='language-coffeescript'><%= render('static/customize/image').to_str %></code></pre>
93
+ </div>
94
+
95
+ </section>
@@ -0,0 +1,3 @@
1
+ module Ecrire
2
+ VERSION = '0.20.0'
3
+ end
data/lib/ecrire.rb ADDED
@@ -0,0 +1,24 @@
1
+ module Ecrire
2
+
3
+ autoload :Application, 'ecrire/application'
4
+
5
+ def self.bundle?
6
+ ENV['BUNDLE_GEMFILE'] ||= Dir.pwd + '/Gemfile'
7
+ File.exists?(ENV['BUNDLE_GEMFILE'])
8
+ end
9
+
10
+ if Ecrire.bundle?
11
+ require 'bundler/setup'
12
+ require 'rails/all'
13
+
14
+ require 'bourbon'
15
+ require 'sass-rails'
16
+ require 'sprockets'
17
+ require 'coffee-rails'
18
+ require 'turbolinks'
19
+
20
+ Bundler.require(:required, :server, Rails.env)
21
+ else
22
+ require 'rails/all'
23
+ end
24
+ end
@@ -0,0 +1,6 @@
1
+ require_relative '../base_controller_test'
2
+
3
+ module Admin
4
+ class ImagesControllerTest < BaseControllerTest
5
+ end
6
+ end
@@ -0,0 +1,90 @@
1
+ module Admin
2
+ class PostsControllerTest < BaseControllerTest
3
+
4
+ def setup
5
+ super
6
+ proxy.set_user users(:pothibo)
7
+ end
8
+
9
+ test 'Validations: Error should be shown when missing the title' do
10
+ end
11
+
12
+ test 'Create a post' do
13
+ data = {
14
+ title: 'A new published post',
15
+ content: 'Some Blah blah',
16
+ stylesheet: 'h1 {\n text-align: center;\n }'
17
+ }
18
+
19
+ put :create, post: data
20
+ @post = assigns(:post)
21
+
22
+ assert_equal data[:title], @post.title
23
+ assert_equal data[:content], @post.content
24
+ assert_equal data[:stylesheet], @post.stylesheet
25
+ assert_equal data[:title].parameterize, @post.slug
26
+ end
27
+
28
+ test 'Update a post' do
29
+ data = {
30
+ title: 'A new published post',
31
+ content: 'Some Blah blah',
32
+ stylesheet: 'h1 {\n text-align: center;\n }'
33
+ }
34
+
35
+ put :update, id: posts(:published).id, post: data
36
+ @post = assigns(:post)
37
+
38
+ assert_equal data[:title], @post.title
39
+ assert_equal data[:content], @post.content
40
+ assert_equal data[:stylesheet], @post.stylesheet
41
+ assert_equal posts(:published).slug, @post.slug
42
+
43
+
44
+ data[:slug] = ""
45
+
46
+ put :update, id: posts(:published).id, post: data
47
+ @post = assigns(:post)
48
+
49
+ assert_equal data[:title], @post.title
50
+ assert_equal data[:content], @post.content
51
+ assert_equal data[:stylesheet], @post.stylesheet
52
+ assert_equal @post.title.parameterize, @post.slug
53
+ end
54
+
55
+ test 'Saving a post should redirect to keep editing the post' do
56
+ post :create, post: {'title' => 'Just a test'}
57
+ record = assigns(:post)
58
+ assert_redirected_to edit_admin_post_path(record.id)
59
+
60
+ put :update, id: record.id, post: {'content' => 'Something to say'}
61
+ assert_redirected_to edit_admin_post_path(record.id)
62
+ end
63
+
64
+ test 'Saving a published article should redirect to the post edit' do
65
+ @post = posts(:published)
66
+ put :update, id: @post.id, post: {'content' => 'Oh em G'}
67
+
68
+ assert_redirected_to edit_admin_post_path(@post.id)
69
+ end
70
+
71
+ test 'Publishing redirects to the blog post' do
72
+ data = {
73
+ title: 'A new published post',
74
+ content: 'Some Blah blah',
75
+ stylesheet: 'h1 {\n text-align: center;\n }'
76
+ }
77
+ put :update, id: posts(:published).id, post: data, button: 'publish'
78
+ assert assigns(:post).published?
79
+ assert_redirected_to post_path(assigns(:post).published_at.year, assigns(:post).published_at.month, assigns(:post).slug)
80
+ end
81
+
82
+ test 'Show draft posts' do
83
+ xhr :get, :index
84
+ assigns(:posts).each do |post|
85
+ assert !post.published?
86
+ end
87
+ end
88
+
89
+ end
90
+ end
@@ -0,0 +1,26 @@
1
+ require 'editor/test_helper'
2
+
3
+ class BaseControllerTest < ActionController::TestCase
4
+ include Warden::Test::Helpers
5
+
6
+ def self.manager
7
+ @manager ||= Warden::Manager.new(self,
8
+ {
9
+ default_strategies: :password,
10
+ failure_app: SessionsController.action(:failed)
11
+ })
12
+ end
13
+
14
+ def setup
15
+ @controller.env['warden'] = @request.env['warden'] = Warden::Proxy.new(@request.env, self.class.manager)
16
+ end
17
+
18
+ def teardown
19
+ Warden.test_reset!
20
+ end
21
+
22
+ def proxy
23
+ @controller.env['warden']
24
+ end
25
+
26
+ end
@@ -0,0 +1,2 @@
1
+ class ImagesControllerTest < BaseControllerTest
2
+ end
@@ -0,0 +1,2 @@
1
+ class PartialsControllerTest < BaseControllerTest
2
+ end
@@ -0,0 +1,21 @@
1
+ class PostsControllerTest < BaseControllerTest
2
+
3
+ test "redirect if the post isn't published" do
4
+ @post = posts(:draft)
5
+ get :show, year: 2003, month: 1, id: @post.id
6
+ assert_redirected_to :root
7
+ end
8
+
9
+ test "redirect if the post doesn't exist" do
10
+ get :show, year: 2003, month: 1, id: -1
11
+ assert_redirected_to :root
12
+ end
13
+
14
+ test 'Only published posts should be listed in the index' do
15
+ get :index
16
+ posts.each do |post|
17
+ assert post.published?
18
+ end
19
+ end
20
+
21
+ end
@@ -0,0 +1,21 @@
1
+ class SessionsControllerTest < BaseControllerTest
2
+ test 'should be able to log in' do
3
+ post :create, session: {email: "pothibo@gmail.com", password: "123456789"}
4
+ assert !proxy.user.nil?, "#{users(:pothibo).email} should be logged in"
5
+ assert_redirected_to root_path
6
+ end
7
+
8
+
9
+ # From what I could read, functional tests do not play nice with middlewares.
10
+ # So, because I can't rely on Warden::Manager to catch the thrown error here, I
11
+ # have 2 options: Move to integration testing or work around the issue.
12
+ # I chose the later for now but I believe that it might be a good idea to move controller
13
+ # testing to actual integration tests. Most of the work is done on the UI anyway so it would
14
+ # cover every cases.
15
+ test 'show and error if your credentials do not satisfy' do
16
+ catch :warden do
17
+ post :create, session: {email: "pothibo@gmail.com", password: "ksjaslk"}
18
+ end
19
+ assert proxy.user.nil?, "#{users(:pothibo).email} should NOT be logged in"
20
+ end
21
+ end
@@ -0,0 +1,19 @@
1
+ class BaseHelperTest < ActionView::TestCase
2
+ include Rails.application.routes.url_helpers
3
+
4
+ def signed_in?
5
+ !@user.nil?
6
+ end
7
+
8
+ def current_user
9
+ @user
10
+ end
11
+
12
+ protected
13
+
14
+ def sign_user_in!
15
+ @user = User.allocate
16
+ end
17
+
18
+ end
19
+
@@ -0,0 +1,3 @@
1
+ class PostsHelperTest < BaseHelperTest
2
+ end
3
+
@@ -0,0 +1,33 @@
1
+ require 'editor/test_helper'
2
+
3
+ class ImageTest < ActiveSupport::TestCase
4
+
5
+ Struct.new('File', :original_filename)
6
+
7
+ test 'should only return favorited images' do
8
+ Image.favorites.each do |image|
9
+ assert image.favorite?, 'Image should be favorited'
10
+ end
11
+ end
12
+
13
+ test 'path should handle blank base_folder' do
14
+ Rails.application.secrets.s3['path'] = ""
15
+ file = Struct::File.new('some_image.jpg')
16
+
17
+ image = Admin::Image.new
18
+ image.post = Admin::Post.first
19
+
20
+ assert_equal image.send(:path, file), "#{image.post.id}/some_image.jpg"
21
+ end
22
+
23
+ test 'path should handle base_folder' do
24
+ Rails.application.secrets.s3['path'] = "my_blog"
25
+ file = Struct::File.new('some_image.jpg')
26
+
27
+ image = Admin::Image.new
28
+ image.post = Admin::Post.first
29
+
30
+ assert_equal image.send(:path, file), "my_blog/#{image.post.id}/some_image.jpg"
31
+ end
32
+
33
+ end
@@ -0,0 +1,4 @@
1
+ require 'editor/test_helper'
2
+
3
+ class PartialTest < ActiveSupport::TestCase
4
+ end