ecrire 0.31.1 → 0.31.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/Gemfile +2 -1
- data/Rakefile +1 -45
- data/lib/ecrire.rb +12 -0
- data/lib/ecrire/app/assets/javascripts/admin/posts/content.coffee +7 -7
- data/lib/ecrire/app/assets/javascripts/admin/posts/header.coffee +1 -1
- data/lib/ecrire/app/assets/stylesheets/admin/base.scss +12 -3
- data/lib/ecrire/app/assets/stylesheets/admin/navigation.scss +0 -31
- data/lib/ecrire/app/assets/stylesheets/admin/navigation/base.scss +30 -0
- data/lib/ecrire/app/assets/stylesheets/admin/navigation/home.scss +22 -0
- data/lib/ecrire/app/assets/stylesheets/admin/posts.scss +0 -50
- data/lib/ecrire/app/assets/stylesheets/admin/posts/aside.scss +36 -0
- data/lib/ecrire/app/assets/stylesheets/admin/posts/editor.scss +4 -0
- data/lib/ecrire/app/assets/stylesheets/admin/posts/header.scss +2 -1
- data/lib/ecrire/app/assets/stylesheets/admin/posts/list.scss +61 -0
- data/lib/ecrire/app/assets/stylesheets/admin/{preview.scss → posts/preview.scss} +6 -3
- data/lib/ecrire/app/assets/stylesheets/editor/blockquote.scss +4 -0
- data/lib/ecrire/app/assets/stylesheets/editor/code.scss +1 -0
- data/lib/ecrire/app/assets/stylesheets/editor/content.scss +1 -1
- data/lib/ecrire/app/assets/stylesheets/editor/html.scss +20 -0
- data/lib/ecrire/app/assets/stylesheets/variables.scss +3 -0
- data/lib/ecrire/app/controllers/admin/posts_controller.rb +4 -4
- data/lib/ecrire/app/helpers/admin/images_helper.rb +4 -4
- data/lib/ecrire/app/helpers/admin/posts_helper.rb +4 -4
- data/lib/ecrire/app/helpers/application_helper.rb +1 -1
- data/lib/ecrire/app/models/admin/image.rb +4 -4
- data/lib/ecrire/app/models/post.rb +1 -1
- data/lib/ecrire/app/models/user.rb +4 -0
- data/lib/ecrire/app/views/admin/posts/_search.html.erb +1 -8
- data/lib/ecrire/app/views/admin/posts/help.js.erb +1 -1
- data/lib/ecrire/app/views/admin/posts/index.html.erb +43 -20
- data/lib/ecrire/app/views/admin/posts/index.js.erb +1 -1
- data/lib/ecrire/app/views/admin/posts/show.html.erb +2 -2
- data/lib/ecrire/app/views/admin/posts/tags/create.js.erb +2 -2
- data/lib/ecrire/app/views/admin/posts/tags/index.js.erb +1 -1
- data/lib/ecrire/app/views/admin/posts/tags/toggle.js.erb +2 -2
- data/lib/ecrire/app/views/admin/posts/titles/create.js.erb +2 -2
- data/lib/ecrire/app/views/admin/posts/titles/index.js.erb +1 -1
- data/lib/ecrire/app/views/admin/posts/titles/update.js.erb +1 -1
- data/lib/ecrire/app/views/admin/profiles/show.js.erb +1 -1
- data/lib/ecrire/app/views/admin/tags/create.js.erb +1 -1
- data/lib/ecrire/app/views/admin/tags/index.js.erb +1 -1
- data/lib/ecrire/app/views/admin/tags/update.js.erb +1 -1
- data/lib/ecrire/app/views/admin/titles/edit.js.erb +1 -1
- data/lib/ecrire/app/views/admin/titles/errors.js.erb +1 -1
- data/lib/ecrire/app/views/admin/titles/index.js.erb +1 -1
- data/lib/ecrire/app/views/layouts/admin/application.html.erb +20 -2
- data/lib/ecrire/application.rb +53 -29
- data/lib/ecrire/commands/server.rb +12 -2
- data/lib/ecrire/configuration.rb +39 -0
- data/lib/ecrire/onboarding/controllers/onboarding_controller.rb +2 -0
- data/lib/ecrire/onboarding/engine.rb +0 -4
- data/lib/ecrire/theme/engine.rb +4 -4
- data/lib/ecrire/theme/template/Gemfile +16 -16
- data/lib/ecrire/version.rb +1 -1
- data/test/configuration/postgresql.rb +60 -11
- data/test/editor/initializers.rb +20 -13
- data/test/editor/models/image_test.rb +2 -2
- data/test/editor/theme/secrets.yml +9 -0
- data/test/onboarding/initializers.rb +0 -2
- data/test/onboarding/theme/config.ru +0 -0
- data/test/task.rb +32 -24
- data/test/theme/initializers.rb +17 -12
- data/test/{secrets.yml → theme/theme/secrets.yml} +2 -0
- metadata +14 -4
@@ -1,10 +1,10 @@
|
|
1
|
-
#
|
1
|
+
#PostPreview > article {
|
2
2
|
@include justify-content(flex-start);
|
3
3
|
|
4
4
|
max-width: 900px;
|
5
5
|
margin: 0 auto;
|
6
6
|
padding: 0 1em 6em 1em;
|
7
|
-
width:
|
7
|
+
width: 100vw;
|
8
8
|
|
9
9
|
font-size: 1.3em;
|
10
10
|
line-height: 1.6em;
|
@@ -14,6 +14,7 @@
|
|
14
14
|
}
|
15
15
|
|
16
16
|
ul, ol {
|
17
|
+
margin: 1.5em 0;
|
17
18
|
padding-left: 1em;
|
18
19
|
}
|
19
20
|
|
@@ -27,6 +28,7 @@
|
|
27
28
|
|
28
29
|
li {
|
29
30
|
margin: 0.3em 0;
|
31
|
+
padding: 0;
|
30
32
|
}
|
31
33
|
|
32
34
|
p {
|
@@ -53,7 +55,7 @@
|
|
53
55
|
}
|
54
56
|
|
55
57
|
|
56
|
-
#
|
58
|
+
#PostPreview pre {
|
57
59
|
background-color: $light-blue;
|
58
60
|
font-size: 0.7em;
|
59
61
|
border-radius: 2px;
|
@@ -72,3 +74,4 @@
|
|
72
74
|
display: inline-block;
|
73
75
|
}
|
74
76
|
}
|
77
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
article.content div {
|
2
|
+
padding: 0.2rem 0.8rem;
|
3
|
+
border-left: solid 3px $light-blue;
|
4
|
+
font-size: 0.8rem;
|
5
|
+
position: relative;
|
6
|
+
}
|
7
|
+
|
8
|
+
article.content div:before {
|
9
|
+
content: 'HTML';
|
10
|
+
position: absolute;
|
11
|
+
left: -1.3rem;
|
12
|
+
top: 0;
|
13
|
+
bottom: 0;
|
14
|
+
width: 1rem;
|
15
|
+
font-size: 1.2rem;
|
16
|
+
font-weight: bold;
|
17
|
+
break-word: break-all;
|
18
|
+
color: $light-blue;
|
19
|
+
overflow-y: hidden;
|
20
|
+
}
|
@@ -20,19 +20,19 @@ module Admin
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def drafts
|
23
|
-
posts = Admin::Post
|
23
|
+
posts = Admin::Post
|
24
24
|
|
25
25
|
posts = posts.search search_posts_params
|
26
|
-
@posts = posts.order('posts.created_at DESC').includes(:titles)
|
26
|
+
@posts = posts.drafted.order('posts.created_at DESC').includes(:titles)
|
27
27
|
|
28
28
|
render 'index'
|
29
29
|
end
|
30
30
|
|
31
31
|
def published
|
32
|
-
posts = Admin::Post
|
32
|
+
posts = Admin::Post
|
33
33
|
|
34
34
|
posts = posts.search search_posts_params
|
35
|
-
@posts = posts.order('posts.published_at DESC').includes(:titles)
|
35
|
+
@posts = posts.published.order('posts.published_at DESC').includes(:titles)
|
36
36
|
render 'index'
|
37
37
|
end
|
38
38
|
|
@@ -3,7 +3,7 @@ module Admin
|
|
3
3
|
|
4
4
|
def image_form_signature(policy)
|
5
5
|
@signature ||= begin
|
6
|
-
key = Rails.application.secrets.s3[
|
6
|
+
key = Rails.application.secrets.s3[:secret_key]
|
7
7
|
sha = OpenSSL::Digest.new('sha1')
|
8
8
|
digest = OpenSSL::HMAC.digest sha, key, policy
|
9
9
|
Base64.encode64(digest).gsub("\n", "")
|
@@ -13,14 +13,14 @@ module Admin
|
|
13
13
|
def image_form_policy(post)
|
14
14
|
@policy ||= begin
|
15
15
|
namespace = [post.id]
|
16
|
-
if Rails.application.secrets.s3.has_key?(
|
17
|
-
namespace.insert 0, Rails.application.secrets.s3[
|
16
|
+
if Rails.application.secrets.s3.has_key?(:namespace)
|
17
|
+
namespace.insert 0, Rails.application.secrets.s3[:namespace]
|
18
18
|
end
|
19
19
|
|
20
20
|
policy = {
|
21
21
|
"expiration" => (Time.now + 10.years).utc.to_s(:iso8601),
|
22
22
|
"conditions" => [
|
23
|
-
{"bucket" => Rails.application.secrets.s3[
|
23
|
+
{"bucket" => Rails.application.secrets.s3[:bucket]},
|
24
24
|
["starts-with", "$key", "#{namespace.join('/')}/"],
|
25
25
|
["starts-with", "$Content-Type", ""],
|
26
26
|
{"acl" => "private"}
|
@@ -19,12 +19,12 @@ module Admin
|
|
19
19
|
contenteditable: true,
|
20
20
|
href: admin_post_path(@post.id) do |div|
|
21
21
|
|
22
|
-
namespace = Pathname.new(Rails.application.secrets.s3['namespace'] || '')
|
22
|
+
namespace = Pathname.new(Rails.application.secrets.fetch(:s3, {})['namespace'] || '')
|
23
23
|
|
24
24
|
if Rails.application.secrets.has_key?(:s3)
|
25
|
-
div['data-bucket'] = Rails.application.secrets.s3[
|
26
|
-
div['data-url'] = Rails.application.secrets.s3[
|
27
|
-
div['data-access-key'] = Rails.application.secrets.s3[
|
25
|
+
div['data-bucket'] = Rails.application.secrets.s3[:bucket]
|
26
|
+
div['data-url'] = Rails.application.secrets.s3[:url]
|
27
|
+
div['data-access-key'] = Rails.application.secrets.s3[:access_key]
|
28
28
|
div['data-signature'] = image_form_signature(image_form_policy(@post))
|
29
29
|
div['data-policy'] = image_form_policy(@post)
|
30
30
|
div['data-namespace'] = namespace + @post.id.to_s
|
@@ -43,7 +43,7 @@ module ApplicationHelper
|
|
43
43
|
# Will generate the asset url given with the +name+ of your favicon.
|
44
44
|
#
|
45
45
|
def favicon_tag(name = 'favicon.ico')
|
46
|
-
content_tag :link, nil, rel: %w(shortcut icon), href:
|
46
|
+
content_tag :link, nil, rel: %w(shortcut icon), href: image_path(name)
|
47
47
|
end
|
48
48
|
|
49
49
|
##
|
@@ -56,11 +56,11 @@ module Admin
|
|
56
56
|
|
57
57
|
def initialize(options={})
|
58
58
|
@errors = ActiveModel::Errors.new(self)
|
59
|
-
@access_key = options.fetch(
|
60
|
-
@secret_key = options.fetch(
|
61
|
-
@path = options.fetch(
|
59
|
+
@access_key = options.fetch(:access_key, "")
|
60
|
+
@secret_key = options.fetch(:secret_key, "")
|
61
|
+
@path = options.fetch(:path, "")
|
62
62
|
|
63
|
-
@bucket = service.bucket(options.fetch(
|
63
|
+
@bucket = service.bucket(options.fetch(:bucket, 'ecrire'))
|
64
64
|
end
|
65
65
|
|
66
66
|
def configuration_hash
|
@@ -131,7 +131,7 @@ class Post < ActiveRecord::Base
|
|
131
131
|
def content
|
132
132
|
@content ||= begin
|
133
133
|
content = read_attribute('content')
|
134
|
-
Content.new(content.fetch('raw', ''), content.fetch('html', ''))
|
134
|
+
Content.new(content.fetch('raw', ''), content.fetch('html', '').html_safe)
|
135
135
|
end
|
136
136
|
end
|
137
137
|
|
@@ -13,6 +13,10 @@ class User < ActiveRecord::Base
|
|
13
13
|
|
14
14
|
validates_confirmation_of :password, if: ->{ password.present? }
|
15
15
|
|
16
|
+
def display_name
|
17
|
+
self.email
|
18
|
+
end
|
19
|
+
|
16
20
|
def password
|
17
21
|
return if self.encrypted_password.blank?
|
18
22
|
@password ||= Password.new(self.encrypted_password)
|
@@ -19,14 +19,7 @@
|
|
19
19
|
<% input[:name] = 'posts[title]' %>
|
20
20
|
<% input[:class] << 'search' %>
|
21
21
|
<% input[:form] = 'PostsFilter' %>
|
22
|
-
|
23
|
-
<% if search_posts_params[:status] == 'draft' %>
|
24
|
-
<% input[:placeholder] = 'Search for a draft' %>
|
25
|
-
<% elsif search_posts_params[:status] == 'published' %>
|
26
|
-
<% input[:placeholder] = 'Search for a published post' %>
|
27
|
-
<% else %>
|
28
|
-
<% input[:placeholder] = 'Search for any post' %>
|
29
|
-
<% end %>
|
22
|
+
<% input[:placeholder] = 'Search' %>
|
30
23
|
|
31
24
|
<% end %>
|
32
25
|
|
@@ -1 +1 @@
|
|
1
|
-
e.HTML = "<%= j render('documentation') %>"
|
1
|
+
e.HTML = ObserveJS.HTML.parse("<%= j render('documentation') %>")
|
@@ -1,25 +1,48 @@
|
|
1
|
-
<% content_for '
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
1
|
+
<% content_for 'Content::Style', 'split' %>
|
2
|
+
<% content_for 'Content::Class', 'list' %>
|
3
|
+
|
4
|
+
<aside>
|
5
|
+
<%= link_to 'New Post', new_admin_post_path, class: %w(button new) %>
|
6
|
+
|
7
|
+
<ol>
|
8
|
+
<li>
|
9
|
+
<%= content_tag :a, href: admin_posts_path do |a| %>
|
10
|
+
<% if action_name.eql?('index') %>
|
11
|
+
<% a.css << 'selected' %>
|
12
|
+
<% end %>
|
13
|
+
All
|
14
|
+
<% end %>
|
15
|
+
</li>
|
16
|
+
|
17
|
+
<li>
|
18
|
+
<%= content_tag :a, href: drafts_admin_posts_path do |a| %>
|
19
|
+
<% if action_name.eql?('drafts') %>
|
20
|
+
<% a.css << 'selected' %>
|
21
|
+
<% end %>
|
22
|
+
Drafts
|
23
|
+
<% end %>
|
24
|
+
</li>
|
25
|
+
|
26
|
+
<li>
|
27
|
+
<%= content_tag :a, href: published_admin_posts_path do |a| %>
|
28
|
+
<% if action_name.eql?('published') %>
|
29
|
+
<% a.css << 'selected' %>
|
30
|
+
<% end %>
|
31
|
+
Published
|
32
|
+
<% end %>
|
33
|
+
</li>
|
34
|
+
</ol>
|
35
|
+
|
36
|
+
</aside>
|
21
37
|
|
22
38
|
<section id='PostsIndexList' class='posts'>
|
39
|
+
<% if action_name.eql?('drafts') %>
|
40
|
+
<h2>Draft Posts</h2>
|
41
|
+
<% elsif action_name.eql?('published') %>
|
42
|
+
<h2>Published Posts</h2>
|
43
|
+
<% else %>
|
44
|
+
<h2>All Posts</h2>
|
45
|
+
<% end %>
|
23
46
|
|
24
47
|
<%= form_for :posts, url: {controller: 'admin/posts', action: action_name}, method: 'GET', html: {class: %w(search), name: 'posts', id: 'PostsFilter', as: 'Posts.Filter'} do |f| %>
|
25
48
|
<%= render('search') %>
|
@@ -1 +1 @@
|
|
1
|
-
e.HTML = "<%= j content_tag(:ul, render(@posts)) %>"
|
1
|
+
e.HTML = ObserveJS.HTML.parse("<%= j content_tag(:ul, render(@posts)) %>")
|
@@ -8,6 +8,6 @@
|
|
8
8
|
<%= render 'admin/posts/header/base', post: @post %>
|
9
9
|
<% end %>
|
10
10
|
|
11
|
-
<section
|
12
|
-
<%= content_tag :article, @post.
|
11
|
+
<section id='PostPreview'>
|
12
|
+
<%= content_tag :article, @post.content.html %>
|
13
13
|
<section>
|
@@ -1,2 +1,2 @@
|
|
1
|
-
e.HTML = "<%= j render('admin/posts/tags/tag', tag: @tag, post: @post) %>"
|
2
|
-
e.TagsHTML = "<%= j post_tags(@post) %>"
|
1
|
+
e.HTML = ObserveJS.HTML.parse("<%= j render('admin/posts/tags/tag', tag: @tag, post: @post) %>")
|
2
|
+
e.TagsHTML = ObserveJS.HTML.parse("<%= j post_tags(@post) %>")
|
@@ -1 +1 @@
|
|
1
|
-
e.HTML = "<%= j popup_tag(render('admin/posts/tags/tags', post: @post, tags: @tags), class: %w(tags)) %>"
|
1
|
+
e.HTML = ObserveJS.HTML.parse("<%= j popup_tag(render('admin/posts/tags/tags', post: @post, tags: @tags), class: %w(tags)) %>")
|
@@ -1,2 +1,2 @@
|
|
1
|
-
e.HTML = "<%= j render('admin/posts/tags/tag', tag: @tag, post: @post) %>"
|
2
|
-
e.TagsHTML = "<%= j post_tags(@post) %>"
|
1
|
+
e.HTML = ObserveJS.HTML.parse("<%= j render('admin/posts/tags/tag', tag: @tag, post: @post) %>")
|
2
|
+
e.TagsHTML = ObserveJS.HTML.parse("<%= j post_tags(@post) %>")
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<% if @title.errors.any? %>
|
2
|
-
e.ErrorHTML = "<%= j content_tag(:div, @title.errors.to_a.to_sentence, class: %w(errors)) %>"
|
2
|
+
e.ErrorHTML = ObserveJS.HTML.parse("<%= j content_tag(:div, @title.errors.to_a.to_sentence, class: %w(errors)) %>")
|
3
3
|
<% else %>
|
4
|
-
e.HTML = "<%= j render('admin/posts/titles/title', title: @title) %>"
|
4
|
+
e.HTML = ObserveJS.HTML.parse("<%= j render('admin/posts/titles/title', title: @title) %>")
|
5
5
|
<% end %>
|
6
6
|
|
@@ -1,2 +1,2 @@
|
|
1
|
-
e.HTML = "<%= j popup_tag(render('admin/posts/titles/form', post: @post, title: @title), class: %w(popup titles)) %>"
|
1
|
+
e.HTML = ObserveJS.HTML.parse("<%= j popup_tag(render('admin/posts/titles/form', post: @post, title: @title), class: %w(popup titles)) %>")
|
2
2
|
|
@@ -1 +1 @@
|
|
1
|
-
e.HTML = "<%= j render('admin/posts/titles/title', title: @title) %>"
|
1
|
+
e.HTML = ObserveJS.HTML.parse("<%= j render('admin/posts/titles/title', title: @title) %>")
|
@@ -1 +1 @@
|
|
1
|
-
e.HTML = "<%= j render("menu") %>"
|
1
|
+
e.HTML = ObserveJS.HTML.parse("<%= j render("menu") %>")
|
@@ -1 +1 @@
|
|
1
|
-
e.HTML = "<%= j render('admin/posts/tags/dialog/tag', tag: @tag, post: @post) %>"
|
1
|
+
e.HTML = ObserveJS.HTML.parse("<%= j render('admin/posts/tags/dialog/tag', tag: @tag, post: @post) %>")
|
@@ -1 +1 @@
|
|
1
|
-
e.HTML = "<%= j popup_tag(render('admin/tags/tags', tags: @tags), id: 'TagsPopup') %>"
|
1
|
+
e.HTML = ObserveJS.HTML.parse("<%= j popup_tag(render('admin/tags/tags', tags: @tags), id: 'TagsPopup') %>")
|
@@ -1,2 +1,2 @@
|
|
1
1
|
e.ObjectID = <%= @tag.id %>
|
2
|
-
e.HTML = "<%= j render('admin/posts/tags/tag', post: @post, tag: @tag)%>"
|
2
|
+
e.HTML = ObserveJS.HTML.parse("<%= j render('admin/posts/tags/tag', post: @post, tag: @tag)%>")
|
@@ -1 +1 @@
|
|
1
|
-
e.HTML = "<%= j render('title', post: post) %>"
|
1
|
+
e.HTML = ObserveJS.HTML.parse("<%= j render('title', post: post) %>")
|
@@ -1 +1 @@
|
|
1
|
-
e.HTML = "<%= j render('titles', post: post) %>"
|
1
|
+
e.HTML = ObserveJS.HTML.parse("<%= j render('titles', post: post) %>")
|
@@ -4,11 +4,29 @@
|
|
4
4
|
<title>Ecrire</title>
|
5
5
|
<link rel="shortcut icon" href="<%= image_url("favicon.ico")%>" />
|
6
6
|
<%= stylesheet_link_tag "admin", media: "all" %>
|
7
|
-
<%= javascript_include_tag "admin" %>
|
7
|
+
<%= javascript_include_tag "admin", 'data-turbolinks-track' => "reload" %>
|
8
8
|
<%= csrf_meta_tags %>
|
9
9
|
</head>
|
10
10
|
<%= content_tag :body, class: [action_name, controller_name] do %>
|
11
|
-
|
11
|
+
<nav id='AdminNavigation'>
|
12
|
+
<%= link_to '/', class: %w(home) do %>
|
13
|
+
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" id="Arrow_circled_left" x="0px" y="0px" viewBox="0 0 20 20" enable-background="new 0 0 20 20" xml:space="preserve">
|
14
|
+
<path d="M10,0.4c-5.303,0-9.601,4.298-9.601,9.6c0,5.303,4.298,9.601,9.601,9.601c5.301,0,9.6-4.298,9.6-9.601 C19.6,4.698,15.301,0.4,10,0.4z M9.999,17.6c-4.197,0-7.6-3.402-7.6-7.6s3.402-7.6,7.6-7.6S17.6,5.803,17.6,10 S14.196,17.6,9.999,17.6z M10,5.5L5.5,10l4.5,4.5V12h4V8h-4V5.5z"/>
|
15
|
+
</svg>
|
16
|
+
Back to your blog
|
17
|
+
<% end %>
|
18
|
+
|
19
|
+
<div>
|
20
|
+
<%= link_to 'Posts', admin_posts_path %>
|
21
|
+
<%= link_to 'Tags', admin_tags_path %>
|
22
|
+
<a>Settings</a>
|
23
|
+
</div>
|
24
|
+
|
25
|
+
<a class='profile'>
|
26
|
+
<%= current_user.display_name %>
|
27
|
+
</a>
|
28
|
+
</nav>
|
29
|
+
<%= main_tag class: [content_for('Content::Class')], 'data-style' => content_for('Content::Style') || 'plain' do %>
|
12
30
|
<%= yield %>
|
13
31
|
<% end %>
|
14
32
|
<% end %>
|
data/lib/ecrire/application.rb
CHANGED
@@ -5,6 +5,7 @@ require 'kaminari'
|
|
5
5
|
require 'observejs'
|
6
6
|
require 'written'
|
7
7
|
require 'pg_search'
|
8
|
+
require 'autoprefixer-rails'
|
8
9
|
|
9
10
|
module Ecrire
|
10
11
|
##
|
@@ -23,15 +24,7 @@ module Ecrire
|
|
23
24
|
#
|
24
25
|
#
|
25
26
|
class Application < Rails::Application
|
26
|
-
|
27
|
-
|
28
|
-
config.before_initialize do
|
29
|
-
if paths['config/database'].existent.any?
|
30
|
-
require 'ecrire/theme/engine'
|
31
|
-
else
|
32
|
-
require 'ecrire/onboarding/engine'
|
33
|
-
end
|
34
|
-
end
|
27
|
+
attr_writer :pwd
|
35
28
|
|
36
29
|
##
|
37
30
|
# There seems to be a crack between when the configuration
|
@@ -58,35 +51,66 @@ module Ecrire
|
|
58
51
|
end
|
59
52
|
|
60
53
|
##
|
61
|
-
#
|
54
|
+
# Override Rails secrets management as
|
55
|
+
# it doesn't allow us to do what we want.
|
56
|
+
# Then, Ecrire will merge anything that is
|
57
|
+
# through environment variables
|
62
58
|
#
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
59
|
+
def secrets
|
60
|
+
@secrets ||= begin
|
61
|
+
secrets = ActiveSupport::OrderedOptions.new
|
62
|
+
yaml = config.paths["config/secrets"].first
|
63
|
+
|
64
|
+
if File.exist?(yaml)
|
65
|
+
require "erb"
|
66
|
+
content = YAML.load(ERB.new(IO.read(yaml)).result) || {}
|
67
|
+
secrets.merge!(content.deep_symbolize_keys)
|
68
|
+
end
|
69
|
+
|
70
|
+
if ENV.has_key?(Ecrire::SECRET_ENVIRONMENT_KEY)
|
71
|
+
require 'json'
|
72
|
+
secrets.merge!(JSON.parse(ENV[Ecrire::SECRET_ENVIRONMENT_KEY]).deep_symbolize_keys)
|
73
|
+
end
|
74
|
+
|
75
|
+
# Fallback to config.secret_key_base if secrets.secret_key_base isn't set
|
76
|
+
secrets.secret_key_base ||= config.secret_key_base
|
77
|
+
# Fallback to config.secret_token if secrets.secret_token isn't set
|
78
|
+
secrets.secret_token ||= config.secret_token
|
79
|
+
|
80
|
+
secrets
|
81
|
+
end
|
76
82
|
end
|
77
83
|
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
+
def config
|
85
|
+
@config ||= Ecrire::Configuration.new(Pathname.new(self.class.called_from))
|
86
|
+
end
|
87
|
+
|
88
|
+
class << self
|
89
|
+
|
90
|
+
##
|
91
|
+
# Returns true if Ecrire::Onboarding::Engine is loaded
|
92
|
+
# in the application runtime
|
93
|
+
#
|
94
|
+
def onboarding?
|
95
|
+
secrets.fetch(:onboarding, true)
|
96
|
+
end
|
97
|
+
|
84
98
|
end
|
85
99
|
|
86
100
|
Rails::Application::Bootstrap.initializers.select do |initializer|
|
87
101
|
initializer.name.eql? :bootstrap_hook
|
88
102
|
end.first.instance_variable_set :@block, Proc.new {}
|
89
103
|
|
104
|
+
config.before_initialize do
|
105
|
+
require 'ecrire/config/environment'
|
106
|
+
if onboarding?
|
107
|
+
require 'ecrire/onboarding/engine'
|
108
|
+
else
|
109
|
+
require 'ecrire/theme/engine'
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
|
90
114
|
end
|
91
115
|
|
92
116
|
end
|