ecrire 0.31.1 → 0.31.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +3 -0
  3. data/Gemfile +2 -1
  4. data/Rakefile +1 -45
  5. data/lib/ecrire.rb +12 -0
  6. data/lib/ecrire/app/assets/javascripts/admin/posts/content.coffee +7 -7
  7. data/lib/ecrire/app/assets/javascripts/admin/posts/header.coffee +1 -1
  8. data/lib/ecrire/app/assets/stylesheets/admin/base.scss +12 -3
  9. data/lib/ecrire/app/assets/stylesheets/admin/navigation.scss +0 -31
  10. data/lib/ecrire/app/assets/stylesheets/admin/navigation/base.scss +30 -0
  11. data/lib/ecrire/app/assets/stylesheets/admin/navigation/home.scss +22 -0
  12. data/lib/ecrire/app/assets/stylesheets/admin/posts.scss +0 -50
  13. data/lib/ecrire/app/assets/stylesheets/admin/posts/aside.scss +36 -0
  14. data/lib/ecrire/app/assets/stylesheets/admin/posts/editor.scss +4 -0
  15. data/lib/ecrire/app/assets/stylesheets/admin/posts/header.scss +2 -1
  16. data/lib/ecrire/app/assets/stylesheets/admin/posts/list.scss +61 -0
  17. data/lib/ecrire/app/assets/stylesheets/admin/{preview.scss → posts/preview.scss} +6 -3
  18. data/lib/ecrire/app/assets/stylesheets/editor/blockquote.scss +4 -0
  19. data/lib/ecrire/app/assets/stylesheets/editor/code.scss +1 -0
  20. data/lib/ecrire/app/assets/stylesheets/editor/content.scss +1 -1
  21. data/lib/ecrire/app/assets/stylesheets/editor/html.scss +20 -0
  22. data/lib/ecrire/app/assets/stylesheets/variables.scss +3 -0
  23. data/lib/ecrire/app/controllers/admin/posts_controller.rb +4 -4
  24. data/lib/ecrire/app/helpers/admin/images_helper.rb +4 -4
  25. data/lib/ecrire/app/helpers/admin/posts_helper.rb +4 -4
  26. data/lib/ecrire/app/helpers/application_helper.rb +1 -1
  27. data/lib/ecrire/app/models/admin/image.rb +4 -4
  28. data/lib/ecrire/app/models/post.rb +1 -1
  29. data/lib/ecrire/app/models/user.rb +4 -0
  30. data/lib/ecrire/app/views/admin/posts/_search.html.erb +1 -8
  31. data/lib/ecrire/app/views/admin/posts/help.js.erb +1 -1
  32. data/lib/ecrire/app/views/admin/posts/index.html.erb +43 -20
  33. data/lib/ecrire/app/views/admin/posts/index.js.erb +1 -1
  34. data/lib/ecrire/app/views/admin/posts/show.html.erb +2 -2
  35. data/lib/ecrire/app/views/admin/posts/tags/create.js.erb +2 -2
  36. data/lib/ecrire/app/views/admin/posts/tags/index.js.erb +1 -1
  37. data/lib/ecrire/app/views/admin/posts/tags/toggle.js.erb +2 -2
  38. data/lib/ecrire/app/views/admin/posts/titles/create.js.erb +2 -2
  39. data/lib/ecrire/app/views/admin/posts/titles/index.js.erb +1 -1
  40. data/lib/ecrire/app/views/admin/posts/titles/update.js.erb +1 -1
  41. data/lib/ecrire/app/views/admin/profiles/show.js.erb +1 -1
  42. data/lib/ecrire/app/views/admin/tags/create.js.erb +1 -1
  43. data/lib/ecrire/app/views/admin/tags/index.js.erb +1 -1
  44. data/lib/ecrire/app/views/admin/tags/update.js.erb +1 -1
  45. data/lib/ecrire/app/views/admin/titles/edit.js.erb +1 -1
  46. data/lib/ecrire/app/views/admin/titles/errors.js.erb +1 -1
  47. data/lib/ecrire/app/views/admin/titles/index.js.erb +1 -1
  48. data/lib/ecrire/app/views/layouts/admin/application.html.erb +20 -2
  49. data/lib/ecrire/application.rb +53 -29
  50. data/lib/ecrire/commands/server.rb +12 -2
  51. data/lib/ecrire/configuration.rb +39 -0
  52. data/lib/ecrire/onboarding/controllers/onboarding_controller.rb +2 -0
  53. data/lib/ecrire/onboarding/engine.rb +0 -4
  54. data/lib/ecrire/theme/engine.rb +4 -4
  55. data/lib/ecrire/theme/template/Gemfile +16 -16
  56. data/lib/ecrire/version.rb +1 -1
  57. data/test/configuration/postgresql.rb +60 -11
  58. data/test/editor/initializers.rb +20 -13
  59. data/test/editor/models/image_test.rb +2 -2
  60. data/test/editor/theme/secrets.yml +9 -0
  61. data/test/onboarding/initializers.rb +0 -2
  62. data/test/onboarding/theme/config.ru +0 -0
  63. data/test/task.rb +32 -24
  64. data/test/theme/initializers.rb +17 -12
  65. data/test/{secrets.yml → theme/theme/secrets.yml} +2 -0
  66. metadata +14 -4
@@ -18,8 +18,18 @@ module Ecrire
18
18
 
19
19
  def run!
20
20
  @server.tap do |server|
21
- Dir.chdir(Ecrire::Application.root)
22
- server.start
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)
@@ -44,7 +44,7 @@ module Ecrire
44
44
  #
45
45
  def paths
46
46
  @paths ||= begin
47
- paths = Rails::Paths::Root.new(root_path)
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 *paths.eager_load
124
- app.config.autoload_once_paths.unshift *paths.autoload_once
125
- app.config.autoload_paths.unshift *paths.autoload_paths
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', '~> 4.2'
7
- gem 'observejs', git: 'https://github.com/pothibo/observejs'
8
- gem 'written'
9
- gem 'warden', '~> 1.2'
10
- gem 'bcrypt', '~> 3.1'
11
- gem 'nokogiri', '~> 1.6'
12
- gem 's3', '~> 0.3'
13
- gem 'pg', '~> 0.17'
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', '~> 0.15'
15
+ gem 'kaminari'
16
16
 
17
- gem 'sprockets-rails', '~> 2.1'
18
- gem 'sass-rails', '~> 4.0', '>= 4.0.3'
19
- gem 'coffee-rails', '~> 4.0'
20
- gem 'turbolinks', '~> 2.2'
21
- gem 'bourbon', '~> 3.2'
22
- gem 'uglifier', '~> 2.5'
23
- gem 'jbuilder', '~> 2.2'
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
@@ -1,3 +1,3 @@
1
1
  module Ecrire
2
- VERSION = '0.31.1'
2
+ VERSION = '0.31.2'
3
3
  end
@@ -4,40 +4,89 @@ class Ecrire::Test::Configuration::Postgresql
4
4
 
5
5
  attr_reader :user
6
6
 
7
- def initialize(database, user)
8
- @database = database
9
- @user = User.new(user)
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 #{@database} -U #{@user.name} 2>&1)
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 #{@user.name}..."
22
- message = %x(psql -c 'CREATE ROLE #{@user.name} with superuser login' -d postgres -U postgres 2>&1)
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
- @user= User.new(@user.name)
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 #{@database} if it exists..."
71
+ puts "Resetting #{database} if it exists..."
33
72
  end
34
73
 
35
- ActiveRecord::Tasks::DatabaseTasks.drop({'adapter' => 'postgresql', 'database' => @database, 'user' => user.name})
36
- ActiveRecord::Tasks::DatabaseTasks.create({'adapter' => 'postgresql', 'database' => @database, 'user' => user.name})
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
@@ -1,14 +1,24 @@
1
- Ecrire::Application.paths.add 'config/secrets', with: Dir.pwd + '/test/secrets.yml'
2
- Ecrire::Application.paths.add 'config/database', with: Dir.pwd + '/test/secrets.yml'
1
+ require_relative '../configuration'
3
2
 
4
- Ecrire::Application.initializer 'ecrire.automigrate', after: "active_record.initialize_database" do |app|
5
- path = app.paths['db/migrate'].existent
6
- ActiveRecord::Migrator.migrations_paths = path
7
- if ActiveRecord::Migrator.needs_migration?
8
- ActiveRecord::Migration.verbose = false
9
- ActiveRecord::Migrator.migrate(path)
10
- end
11
- ActiveRecord::Migration.maintain_test_schema!
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['path'] = ""
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['path'] = "my_blog"
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
@@ -0,0 +1,9 @@
1
+ onboarding: false
2
+ secret_key: "2370 128u3o2ujwoi12jw122e12e"
3
+ secret_key_base: "'Mlkasj alskjkdsla jsdkaljsadlkjasd'"
4
+ database:
5
+ adapter: postgresql
6
+ database: ecrire_test
7
+ username: ecrire_test
8
+ s3:
9
+ path: 'test'
@@ -1,5 +1,3 @@
1
- ENV['VERBOSE'] = 'false'
2
-
3
1
  class ActiveSupport::TestCase
4
2
  ActiveSupport.test_order = :random
5
3
  end
File without changes
data/test/task.rb CHANGED
@@ -1,38 +1,46 @@
1
1
  require 'rake/testtask'
2
2
 
3
- class Ecrire::Test::Task < Rake::TestTask
3
+ module Ecrire
4
+ module Test
5
+ class Task < Rake::TestTask
4
6
 
5
- def before(&block)
6
- @callback = block
7
- end
8
-
9
- def define
10
- desc @description
11
- task @name do
7
+ def before(&block)
8
+ @before = block
9
+ end
12
10
 
13
- unless @callback.nil?
14
- @callback.call
11
+ def after(&block)
12
+ @after = block
15
13
  end
16
14
 
17
- Rake::FileUtilsExt.verbose(@verbose) do
18
- args = [
19
- "#{ruby_opts_string} #{run_code} ",
20
- "#{file_list_string} #{option_list}"
21
- ]
15
+ def define
16
+ desc @description
17
+ task @name do
22
18
 
23
- args << @name
19
+ unless @before.nil?
20
+ @before.call
21
+ end
24
22
 
25
- ruby args.join do |ok, status|
26
- if !ok && status.respond_to?(:signaled?) && status.signaled?
27
- raise SignalException.new(status.termsig)
28
- elsif !ok
29
- fail "Command failed with status (#{status.exitstatus}): " +
30
- "[ruby #{args}]"
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
@@ -1,10 +1,20 @@
1
- Ecrire::Application.initializer 'ecrire.automigrate', after: "active_record.initialize_database" do |app|
2
- path = app.paths['db/migrate'].existent
3
- ActiveRecord::Migrator.migrations_paths = path
4
- if ActiveRecord::Migrator.needs_migration?
5
- ActiveRecord::Migrator.migrate(path)
6
- end
7
- ActiveRecord::Migration.maintain_test_schema!
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