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
@@ -18,8 +18,18 @@ module Ecrire
|
|
18
18
|
|
19
19
|
def run!
|
20
20
|
@server.tap do |server|
|
21
|
-
|
22
|
-
|
21
|
+
Ecrire::Theme.path = Pathname.new(Dir.pwd)
|
22
|
+
create_tmp_directories
|
23
|
+
|
24
|
+
Dir.chdir(Ecrire::Application.root) do
|
25
|
+
server.start
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def create_tmp_directories
|
31
|
+
%w(cache pids sockets).each do |dir_to_make|
|
32
|
+
FileUtils.mkdir_p(File.join(Ecrire::Theme.path, "tmp", dir_to_make))
|
23
33
|
end
|
24
34
|
end
|
25
35
|
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Ecrire
|
2
|
+
class Configuration < Rails::Application::Configuration
|
3
|
+
|
4
|
+
def secret_key_base
|
5
|
+
SecureRandom.hex(16)
|
6
|
+
end
|
7
|
+
|
8
|
+
def secret_token
|
9
|
+
SecureRandom.hex(16)
|
10
|
+
end
|
11
|
+
|
12
|
+
##
|
13
|
+
# Return paths based off Rails default plus some customization.
|
14
|
+
#
|
15
|
+
# These paths are Ecrire's, not the users's theme.
|
16
|
+
#
|
17
|
+
# For the user's paths, look at Ecrire::Theme::Engine.paths
|
18
|
+
#
|
19
|
+
def paths
|
20
|
+
@paths ||= begin
|
21
|
+
paths = super
|
22
|
+
paths.add 'config/secrets', with: Ecrire::Theme.path + 'secrets.yml'
|
23
|
+
paths.add 'config/database', with: Ecrire::Theme.path + 'secrets.yml'
|
24
|
+
paths.add 'config/routes.rb', with: 'routes.rb'
|
25
|
+
paths.add 'config/locales', with: 'locales', glob: "**/*.{rb,yml}"
|
26
|
+
|
27
|
+
paths.add 'lib/tasks', with: 'tasks', glob: '**/*.rake'
|
28
|
+
paths
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def database_configuration
|
33
|
+
{
|
34
|
+
Rails.env => Ecrire::Application.secrets.database
|
35
|
+
}
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
@@ -15,6 +15,8 @@ class OnboardingController < ApplicationController
|
|
15
15
|
config['development'] ||= {}
|
16
16
|
config['production'] ||= {}
|
17
17
|
config['development']['secret_key_base'] = config['production']['secret_key'] = Rails.application.secrets.secret_key_base
|
18
|
+
config['development']['secret_token'] = config['production']['secret_token'] = Rails.application.secrets.secret_token
|
19
|
+
config['onboarding'] = false
|
18
20
|
file.write(config.to_yaml)
|
19
21
|
end
|
20
22
|
end
|
@@ -5,10 +5,6 @@ module Ecrire
|
|
5
5
|
Rails.application.config.active_record.migration_error = :none
|
6
6
|
ActiveRecord::Base.configurations = {}
|
7
7
|
|
8
|
-
initializer 'ecrire.onboarding.dynamic_settings' do |app|
|
9
|
-
app.config.secret_key_base = SecureRandom.hex(16)
|
10
|
-
end
|
11
|
-
|
12
8
|
initializer 'ecrire.load_paths', before: :bootstrap_hook do |app|
|
13
9
|
ActiveSupport::Dependencies.autoload_paths.unshift(*self.paths.autoload_paths)
|
14
10
|
ActiveSupport::Dependencies.autoload_once_paths.unshift(*self.paths.autoload_once)
|
data/lib/ecrire/theme/engine.rb
CHANGED
@@ -44,7 +44,7 @@ module Ecrire
|
|
44
44
|
#
|
45
45
|
def paths
|
46
46
|
@paths ||= begin
|
47
|
-
paths = Rails::Paths::Root.new(
|
47
|
+
paths = Rails::Paths::Root.new(Ecrire::Theme.path)
|
48
48
|
paths.add 'app/views', with: 'views'
|
49
49
|
paths.add 'app/controllers', with: 'controllers', eager_load: true
|
50
50
|
paths.add 'app/assets', with: 'assets', glob: '*'
|
@@ -120,9 +120,9 @@ module Ecrire
|
|
120
120
|
end
|
121
121
|
|
122
122
|
initializer 'ecrire.append_paths', before: :set_autoload_paths do |app|
|
123
|
-
app.config.eager_load_paths.unshift
|
124
|
-
app.config.autoload_once_paths.unshift
|
125
|
-
app.config.autoload_paths.unshift
|
123
|
+
app.config.eager_load_paths.unshift(*paths.eager_load)
|
124
|
+
app.config.autoload_once_paths.unshift(*paths.autoload_once)
|
125
|
+
app.config.autoload_paths.unshift(*paths.autoload_paths)
|
126
126
|
end
|
127
127
|
|
128
128
|
|
@@ -3,24 +3,24 @@ source 'https://rubygems.org'
|
|
3
3
|
gem 'ecrire'
|
4
4
|
|
5
5
|
group :required do
|
6
|
-
gem 'rails'
|
7
|
-
gem 'observejs', git: 'https://github.com/pothibo/observejs'
|
8
|
-
gem 'written'
|
9
|
-
gem 'warden'
|
10
|
-
gem 'bcrypt'
|
11
|
-
gem 'nokogiri'
|
12
|
-
gem 's3'
|
13
|
-
gem 'pg'
|
6
|
+
gem 'rails'
|
7
|
+
gem 'observejs', git: 'https://github.com/pothibo/observejs.git'
|
8
|
+
gem 'written', git: 'https://github.com/pothibo/written.git'
|
9
|
+
gem 'warden'
|
10
|
+
gem 'bcrypt'
|
11
|
+
gem 'nokogiri'
|
12
|
+
gem 's3'
|
13
|
+
gem 'pg'
|
14
14
|
gem 'pg_search'
|
15
|
-
gem 'kaminari'
|
15
|
+
gem 'kaminari'
|
16
16
|
|
17
|
-
gem 'sprockets-rails'
|
18
|
-
gem 'sass-rails'
|
19
|
-
gem 'coffee-rails'
|
20
|
-
gem 'turbolinks'
|
21
|
-
gem 'bourbon'
|
22
|
-
gem 'uglifier'
|
23
|
-
gem 'jbuilder'
|
17
|
+
gem 'sprockets-rails'
|
18
|
+
gem 'sass-rails'
|
19
|
+
gem 'coffee-rails'
|
20
|
+
gem 'turbolinks'
|
21
|
+
gem 'bourbon'
|
22
|
+
gem 'uglifier'
|
23
|
+
gem 'jbuilder'
|
24
24
|
end
|
25
25
|
|
26
26
|
gem 'byebug', group: :development
|
data/lib/ecrire/version.rb
CHANGED
@@ -4,40 +4,89 @@ class Ecrire::Test::Configuration::Postgresql
|
|
4
4
|
|
5
5
|
attr_reader :user
|
6
6
|
|
7
|
-
def initialize(
|
8
|
-
@
|
9
|
-
|
7
|
+
def initialize(app)
|
8
|
+
@app = app
|
9
|
+
end
|
10
|
+
|
11
|
+
def configure!
|
12
|
+
begin
|
13
|
+
unless configured?
|
14
|
+
puts "It seems you are running the development tests for the first time."
|
15
|
+
puts "Ecrire will try to configure postgresql for you..."
|
16
|
+
|
17
|
+
if user.new?
|
18
|
+
create_user!
|
19
|
+
end
|
20
|
+
|
21
|
+
if !user.superuser?
|
22
|
+
user.superuser!
|
23
|
+
end
|
24
|
+
|
25
|
+
if !user.login?
|
26
|
+
user.login!
|
27
|
+
end
|
28
|
+
|
29
|
+
puts "Done configuring postgresql."
|
30
|
+
end
|
31
|
+
|
32
|
+
rescue Ecrire::Test::Configuration::Error => e
|
33
|
+
puts "Ecrire couldn't configure postgresql."
|
34
|
+
puts "=> #{e.message}"
|
35
|
+
puts "To fix this issue, make sure you have a superuser for #{%x(whoami)}"
|
36
|
+
puts "createuser -l -s postgres"
|
37
|
+
exit
|
38
|
+
end
|
10
39
|
end
|
11
40
|
|
12
41
|
def configured?
|
13
|
-
%x(psql -c '' -d #{
|
42
|
+
%x(psql -c '' -d #{database} -U #{user.name} 2>&1)
|
14
43
|
if $?.to_i != 0
|
15
44
|
return false
|
16
45
|
end
|
17
46
|
return true
|
18
47
|
end
|
19
48
|
|
49
|
+
def migrate!
|
50
|
+
path = @app.paths['db/migrate'].existent
|
51
|
+
ActiveRecord::Migrator.migrations_paths = path
|
52
|
+
if ActiveRecord::Migrator.needs_migration?
|
53
|
+
ActiveRecord::Migration.verbose = false
|
54
|
+
ActiveRecord::Migrator.migrate(path)
|
55
|
+
end
|
56
|
+
ActiveRecord::Migration.maintain_test_schema!
|
57
|
+
ActiveRecord::Base.clear_cache!
|
58
|
+
end
|
59
|
+
|
20
60
|
def create_user!
|
21
|
-
puts "Creating user #{
|
22
|
-
message = %x(psql -c 'CREATE ROLE #{
|
61
|
+
puts "Creating user #{user.name}..."
|
62
|
+
message = %x(psql -c 'CREATE ROLE #{user.name} with superuser login' -d postgres -U postgres 2>&1)
|
23
63
|
if $?.to_i != 0
|
24
64
|
raise PSQLError.new message
|
25
65
|
end
|
26
|
-
|
27
|
-
puts "User #{@user.name} created."
|
66
|
+
puts "User #{user.name} created."
|
28
67
|
end
|
29
68
|
|
30
69
|
def reset_database!(silence = false)
|
31
70
|
unless silence
|
32
|
-
puts "Resetting #{
|
71
|
+
puts "Resetting #{database} if it exists..."
|
33
72
|
end
|
34
73
|
|
35
|
-
ActiveRecord::Tasks::DatabaseTasks.drop({'adapter' => 'postgresql', 'database' =>
|
36
|
-
ActiveRecord::Tasks::DatabaseTasks.create({'adapter' => 'postgresql', 'database' =>
|
74
|
+
ActiveRecord::Tasks::DatabaseTasks.drop({'adapter' => 'postgresql', 'database' => database, 'user' => user.name})
|
75
|
+
ActiveRecord::Tasks::DatabaseTasks.create({'adapter' => 'postgresql', 'database' => database, 'user' => user.name})
|
76
|
+
|
77
|
+
migrate!
|
37
78
|
|
38
79
|
unless silence
|
39
80
|
puts "#{@database} configured."
|
40
81
|
end
|
41
82
|
end
|
42
83
|
|
84
|
+
def user
|
85
|
+
@user ||= User.new(@app.secrets.database[:username])
|
86
|
+
end
|
87
|
+
|
88
|
+
def database
|
89
|
+
@database ||= @app.secrets.database[:database]
|
90
|
+
end
|
91
|
+
|
43
92
|
end
|
data/test/editor/initializers.rb
CHANGED
@@ -1,14 +1,24 @@
|
|
1
|
-
|
2
|
-
Ecrire::Application.paths.add 'config/database', with: Dir.pwd + '/test/secrets.yml'
|
1
|
+
require_relative '../configuration'
|
3
2
|
|
4
|
-
Ecrire::
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
3
|
+
ENV[Ecrire::SECRET_ENVIRONMENT_KEY] = JSON.generate({
|
4
|
+
onboarding: false,
|
5
|
+
secret_key: "2370 128u3o2ujwoi12jw122e12e",
|
6
|
+
secret_key_base: "Mlkasj alskjkdsla jsdkaljsadlkjasd",
|
7
|
+
database: {
|
8
|
+
adapter: 'postgresql',
|
9
|
+
database: 'ecrire_test',
|
10
|
+
username: 'ecrire_test'
|
11
|
+
},
|
12
|
+
s3: {
|
13
|
+
path: 'test'
|
14
|
+
}
|
15
|
+
})
|
16
|
+
|
17
|
+
Dir.chdir "test/editor/theme" do
|
18
|
+
Ecrire::Application.initialize!
|
19
|
+
postgresql = Ecrire::Test::Configuration::Postgresql.new(Ecrire::Application)
|
20
|
+
postgresql.configure!
|
21
|
+
postgresql.reset_database!
|
12
22
|
end
|
13
23
|
|
14
24
|
class ActiveSupport::TestCase
|
@@ -18,6 +28,3 @@ class ActiveSupport::TestCase
|
|
18
28
|
fixtures :all
|
19
29
|
end
|
20
30
|
|
21
|
-
Dir.chdir "test/editor/theme" do
|
22
|
-
Ecrire::Application.initialize!
|
23
|
-
end
|
@@ -11,7 +11,7 @@ class ImageTest < ActiveSupport::TestCase
|
|
11
11
|
end
|
12
12
|
|
13
13
|
test 'path should handle blank base_folder' do
|
14
|
-
Rails.application.secrets.s3[
|
14
|
+
Rails.application.secrets.s3[:path] = ""
|
15
15
|
file = Struct::File.new('some_image.jpg')
|
16
16
|
|
17
17
|
image = Admin::Image.new
|
@@ -21,7 +21,7 @@ class ImageTest < ActiveSupport::TestCase
|
|
21
21
|
end
|
22
22
|
|
23
23
|
test 'path should handle base_folder' do
|
24
|
-
Rails.application.secrets.s3[
|
24
|
+
Rails.application.secrets.s3[:path] = "my_blog"
|
25
25
|
file = Struct::File.new('some_image.jpg')
|
26
26
|
|
27
27
|
image = Admin::Image.new
|
File without changes
|
data/test/task.rb
CHANGED
@@ -1,38 +1,46 @@
|
|
1
1
|
require 'rake/testtask'
|
2
2
|
|
3
|
-
|
3
|
+
module Ecrire
|
4
|
+
module Test
|
5
|
+
class Task < Rake::TestTask
|
4
6
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
def define
|
10
|
-
desc @description
|
11
|
-
task @name do
|
7
|
+
def before(&block)
|
8
|
+
@before = block
|
9
|
+
end
|
12
10
|
|
13
|
-
|
14
|
-
@
|
11
|
+
def after(&block)
|
12
|
+
@after = block
|
15
13
|
end
|
16
14
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
"#{file_list_string} #{option_list}"
|
21
|
-
]
|
15
|
+
def define
|
16
|
+
desc @description
|
17
|
+
task @name do
|
22
18
|
|
23
|
-
|
19
|
+
unless @before.nil?
|
20
|
+
@before.call
|
21
|
+
end
|
24
22
|
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
23
|
+
Rake::FileUtilsExt.verbose(@verbose) do
|
24
|
+
args = [
|
25
|
+
"#{ruby_opts_string} #{run_code} ",
|
26
|
+
"#{file_list_string} #{option_list}"
|
27
|
+
]
|
28
|
+
|
29
|
+
args << @name
|
30
|
+
|
31
|
+
ruby args.join do |ok, status|
|
32
|
+
if !ok && status.respond_to?(:signaled?) && status.signaled?
|
33
|
+
raise SignalException.new(status.termsig)
|
34
|
+
elsif !ok
|
35
|
+
fail "Command failed with status (#{status.exitstatus}): " +
|
36
|
+
"[ruby #{args}]"
|
37
|
+
end
|
38
|
+
end
|
31
39
|
end
|
32
40
|
end
|
41
|
+
self
|
33
42
|
end
|
43
|
+
|
34
44
|
end
|
35
|
-
self
|
36
45
|
end
|
37
|
-
|
38
46
|
end
|
data/test/theme/initializers.rb
CHANGED
@@ -1,10 +1,20 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
1
|
+
require_relative '../configuration'
|
2
|
+
|
3
|
+
ENV[Ecrire::SECRET_ENVIRONMENT_KEY] = JSON.generate({
|
4
|
+
onboarding: false,
|
5
|
+
database: {
|
6
|
+
adapter: 'postgresql',
|
7
|
+
username: 'ecrire_test',
|
8
|
+
database: 'ecrire_test'
|
9
|
+
}
|
10
|
+
})
|
11
|
+
|
12
|
+
Dir.chdir "test/theme/theme" do
|
13
|
+
Ecrire::Application.initialize!
|
14
|
+
postgresql = Ecrire::Test::Configuration::Postgresql.new(Ecrire::Application)
|
15
|
+
postgresql.configure!
|
16
|
+
postgresql.reset_database!
|
17
|
+
|
8
18
|
end
|
9
19
|
|
10
20
|
class ActiveSupport::TestCase
|
@@ -14,9 +24,4 @@ class ActiveSupport::TestCase
|
|
14
24
|
fixtures :all
|
15
25
|
end
|
16
26
|
|
17
|
-
Ecrire::Application.paths.add 'config/secrets', with: Dir.pwd + '/test/secrets.yml'
|
18
|
-
Ecrire::Application.paths.add 'config/database', with: Dir.pwd + '/test/secrets.yml'
|
19
27
|
|
20
|
-
Dir.chdir "test/theme/theme" do
|
21
|
-
Ecrire::Application.initialize!
|
22
|
-
end
|