ecrire 0.23.0 → 0.24.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +14 -46
  3. data/lib/ecrire/app/controllers/application_controller.rb +1 -1
  4. data/lib/ecrire/app/controllers/ecrire/{posts_controller.rb → theme_controller.rb} +1 -1
  5. data/lib/ecrire/app/controllers/sessions_controller.rb +1 -1
  6. data/lib/ecrire/app/controllers/static_controller.rb +1 -1
  7. data/lib/ecrire/app/helpers/posts_helper.rb +6 -0
  8. data/lib/ecrire/app/views/layouts/admin/application.html.erb +1 -1
  9. data/lib/ecrire/application.rb +26 -5
  10. data/lib/ecrire/commands/console.rb +0 -1
  11. data/lib/ecrire/commands/new.rb +1 -1
  12. data/lib/ecrire/config/environment.rb +1 -1
  13. data/lib/ecrire/onboarding/controllers/databases_controller.rb +63 -0
  14. data/lib/ecrire/{app → onboarding}/controllers/onboarding_controller.rb +2 -0
  15. data/lib/ecrire/onboarding/controllers/users_controller.rb +30 -0
  16. data/lib/ecrire/onboarding/engine.rb +73 -0
  17. data/lib/ecrire/onboarding/routes.rb +8 -0
  18. data/lib/ecrire/onboarding/views/{onboarding/databases → databases}/index.html.erb +1 -1
  19. data/lib/ecrire/onboarding/views/onboarding/welcome.html.erb +1 -1
  20. data/lib/ecrire/onboarding/views/{onboarding/users → users}/index.html.erb +1 -1
  21. data/lib/ecrire/routes.rb +29 -0
  22. data/lib/ecrire/theme/engine.rb +66 -0
  23. data/lib/ecrire/{template → theme/template}/Gemfile +2 -2
  24. data/lib/ecrire/{template → theme/template}/assets/stylesheets/code.css.scss +1 -0
  25. data/lib/ecrire/theme/template/controllers/posts_controller.rb +2 -0
  26. data/lib/ecrire/theme/template/routes.rb +14 -0
  27. data/lib/ecrire/{template → theme/template}/views/layouts/application.html.erb +1 -1
  28. data/lib/ecrire/version.rb +1 -1
  29. data/test/editor/controllers/sessions_controller_test.rb +5 -2
  30. data/test/editor/helpers/base_helper_test.rb +2 -0
  31. data/test/editor/models/image_test.rb +1 -0
  32. data/test/editor/models/post_test.rb +1 -0
  33. data/test/editor/models/title_test.rb +1 -1
  34. data/test/editor/models/user_test.rb +1 -0
  35. data/test/editor/test_helper.rb +25 -21
  36. data/test/editor/theme/routes.rb +8 -0
  37. data/test/{themes/template → editor/theme}/secrets.yml +2 -0
  38. data/test/initializations/{railtie_test.rb → engine_test.rb} +6 -8
  39. data/test/onboarding/controllers/databases_controller_test.rb +4 -0
  40. data/test/{editor/controllers/base_controller_test.rb → test_controller.rb} +9 -8
  41. data/test/test_helper.rb +31 -0
  42. data/test/test_task.rb +28 -0
  43. metadata +55 -54
  44. data/lib/ecrire/app/controllers/onboarding/databases_controller.rb +0 -67
  45. data/lib/ecrire/app/controllers/onboarding/users_controller.rb +0 -32
  46. data/lib/ecrire/config/onboarding_routes.rb +0 -11
  47. data/lib/ecrire/config/routes.rb +0 -32
  48. data/lib/ecrire/railtie/onboarding.rb +0 -63
  49. data/lib/ecrire/railtie/theme.rb +0 -69
  50. data/lib/ecrire/railtie.rb +0 -30
  51. data/lib/ecrire/tasks/routes.rake +0 -6
  52. data/lib/ecrire/template/controllers/posts_controller.rb +0 -2
  53. data/test/isolation.rb +0 -16
  54. data/test/themes/onboarding/.keep +0 -0
  55. /data/lib/ecrire/{template → theme/template}/Procfile +0 -0
  56. /data/lib/ecrire/{template → theme/template}/Rakefile +0 -0
  57. /data/lib/ecrire/{app/controllers/concerns → theme/template/assets/images}/.keep +0 -0
  58. /data/lib/ecrire/{template → theme/template}/assets/javascripts/base.js.coffee +0 -0
  59. /data/lib/ecrire/{template → theme/template}/assets/stylesheets/base.css.scss +0 -0
  60. /data/lib/ecrire/{template → theme/template}/assets/stylesheets/footer.css.scss +0 -0
  61. /data/lib/ecrire/{template → theme/template}/assets/stylesheets/header.css.scss +0 -0
  62. /data/lib/ecrire/{template → theme/template}/assets/stylesheets/home.css.scss +0 -0
  63. /data/lib/ecrire/{template → theme/template}/config.ru +0 -0
  64. /data/lib/ecrire/{template → theme/template}/helpers/blog_helper.rb +0 -0
  65. /data/lib/ecrire/{template → theme/template}/views/posts/_post.html.erb +0 -0
  66. /data/lib/ecrire/{template → theme/template}/views/posts/index.html.erb +0 -0
  67. /data/lib/ecrire/{template → theme/template}/views/posts/show.html.erb +0 -0
  68. /data/lib/ecrire/{template → theme/template}/views/static/about.html +0 -0
  69. /data/lib/ecrire/{template → theme/template}/views/static/customize/_helper.html +0 -0
  70. /data/lib/ecrire/{template → theme/template}/views/static/customize/_helper_used.html +0 -0
  71. /data/lib/ecrire/{template → theme/template}/views/static/customize/_image.html +0 -0
  72. /data/lib/ecrire/{template → theme/template}/views/static/customize/_index.html +0 -0
  73. /data/lib/ecrire/{template → theme/template}/views/static/customize/_javascript.html +0 -0
  74. /data/lib/ecrire/{template → theme/template}/views/static/customize/_layout.html.erb +0 -0
  75. /data/lib/ecrire/{template → theme/template}/views/static/customize/_post.html +0 -0
  76. /data/lib/ecrire/{template → theme/template}/views/static/customize.html +0 -0
  77. /data/test/{themes/template → editor/theme}/Gemfile +0 -0
  78. /data/test/{themes/template → editor/theme}/assets/javascripts/blog.js.coffee +0 -0
  79. /data/test/{themes/template → editor/theme}/assets/javascripts/post.js.coffee +0 -0
  80. /data/test/{themes/template → editor/theme}/assets/stylesheets/blog.css.scss +0 -0
  81. /data/test/{themes/template → editor/theme}/assets/stylesheets/post.css.scss +0 -0
  82. /data/test/{themes/template → editor/theme}/config.ru +0 -0
  83. /data/test/{themes/template → editor/theme}/views/layouts/application.html.erb +0 -0
  84. /data/test/{themes/template → editor/theme}/views/posts/index.html.erb +0 -0
  85. /data/{lib/ecrire/template/assets/images → test/onboarding/theme}/.keep +0 -0
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f76b1ffb5a76e8b346bdd15ab2fc6b2b9ddffcbf
4
- data.tar.gz: 996185339a3a617b693bc5781891d926d3334f73
3
+ metadata.gz: 5491fb6276085642111510a2bf4885d7ccd4402c
4
+ data.tar.gz: b85b3e9c8f2bc19192fa81af08d19f528b2e742d
5
5
  SHA512:
6
- metadata.gz: 36e7377ebb0b601c51dfeed39a3b12a8eb4af0bf5068cb2acd2e5b033969473e4560a8b374b6ffca757259e9dcd8ea6768840327b9abbefbee9fa36d02656c9b
7
- data.tar.gz: d8bf17c5c38fb86e482d44f8d30e809142617a81decd9a2340ba5c4b4378ee45c195d7589843f2538a6b3688617a1361ead70f23105141225012c83620c831a2
6
+ metadata.gz: 4ae319240cb15d7bc70b16ef3492e5c7ff32f099c97c203a1fd6199ac4f715166d521a2e625d10b08560a6db3893936a8b1bebca7bb31f67c85dd494051c8862
7
+ data.tar.gz: e312c1b38f18775a2edd4472d5433576a217c7268461aa21fe7a89ae27fd7a327579f14396cb0f4d7e1432dd11b9ae8849544e898e2ce93017394dc8f8cd4fe6
data/Rakefile CHANGED
@@ -2,71 +2,39 @@ $:.push File.expand_path("../lib", __FILE__)
2
2
 
3
3
  ENV['RAILS_ENV'] ||= 'test'
4
4
 
5
- require 'rake/testtask'
6
5
  require 'ecrire'
6
+ require_relative 'test/test_task'
7
7
 
8
8
  task default: :test
9
9
 
10
10
  namespace :database do
11
11
 
12
- task initialize: %w(configure) do
13
-
14
- begin
15
- # ActiveRecord's configuration assignation is done at the same time as the connection is tried
16
- # If it fails, the configurations aren't set in AR::Base.
17
- # This is why this is set here
18
- ActiveRecord::Base.configurations = Rails.application.config.database_configuration
19
-
20
- path = Rails.application.paths['db/migrate'].existent
21
- ActiveRecord::Migrator.migrations_paths = path
22
- if ActiveRecord::Migrator.needs_migration?
23
- ActiveRecord::Migrator.migrate(path)
24
- end
25
- rescue ActiveRecord::NoDatabaseError
26
- puts 'Database does not exist. Creating...'
27
- ActiveRecord::Tasks::DatabaseTasks.create_current
28
- puts 'Database created, migrating now...'
29
- ActiveRecord::Migrator.migrate(path)
30
- puts "Migration completed."
31
- end
32
- end
33
-
34
- task :configure do
35
- Dir.chdir Dir.pwd + '/test/themes/template' do
36
- Ecrire::Application.initialize!
37
- end
38
- end
39
-
40
12
  task :purge do
41
13
  [User, Post, Image, Partial, Title].each(&:delete_all)
42
14
  end
43
15
 
44
16
  end
45
17
 
46
- desc 'Configure postgres and run all tests'
47
-
48
- task :test do
49
- %w(test:initializations test:editor test:themes).each do |name|
50
- Rake::Task[name].invoke
51
- end
52
- end
53
-
54
18
  namespace :test do
55
-
56
- tasks = %w(initializations editor themes).each do |name|
57
- Rake::TestTask.new(name) do |t|
19
+ ['editor', 'onboarding'].each do |name|
20
+ task = Ecrire::TestTask.new(name) do |t|
21
+ t.theme = Dir.pwd + "/test/#{name}/theme"
58
22
  t.libs << "test"
59
23
  t.test_files = FileList["test/#{name}/**/*_test.rb"]
60
- t.verbose = false
61
- Rake::Task['database:initialize'].invoke
24
+ t.verbose = true
62
25
  end
26
+ end
63
27
 
64
- Rake::Task["test:#{name}"].enhance do
65
- Rake::Task['database:purge'].invoke
66
- end
28
+ end
29
+
30
+ task :test do
31
+ %w(test:editor test:onboarding).each do |name|
32
+ Rake::Task[name].invoke
67
33
  end
68
34
  end
69
35
 
70
36
  at_exit do
71
- Rake::Task['database:purge'].invoke
37
+ unless Ecrire::Application.onboarding?
38
+ Rake::Task['database:purge'].invoke
39
+ end
72
40
  end
@@ -23,7 +23,7 @@ class ApplicationController < ::ActionController::Base
23
23
 
24
24
  options[:id] = (options.delete(:title) || post.titles.first).slug
25
25
 
26
- url_for options
26
+ theme.url_for options
27
27
  end
28
28
 
29
29
 
@@ -1,5 +1,5 @@
1
1
  module Ecrire
2
- class PostsController < ::ApplicationController
2
+ class ThemeController < ::ApplicationController
3
3
 
4
4
  before_action :pagination, only: :index
5
5
  protect_from_forgery except: :index
@@ -2,7 +2,7 @@ class SessionsController < ApplicationController
2
2
  before_action :authenticate!, except: [:failed, :new]
3
3
 
4
4
  def create
5
- redirect_to :root
5
+ redirect_to '/'
6
6
  end
7
7
 
8
8
  def destroy
@@ -1,4 +1,4 @@
1
- class StaticController < ApplicationController
1
+ class StaticController < Ecrire::ThemeController
2
2
  def show
3
3
  render params[:view]
4
4
  end
@@ -4,4 +4,10 @@ module PostsHelper
4
4
 
5
5
  link_to t('posts.edit'), edit_admin_post_path(post.id), options
6
6
  end
7
+
8
+ def paginate(scope, options = {}, &block)
9
+ _with_routes Ecrire::Theme::Engine.routes do
10
+ super
11
+ end
12
+ end
7
13
  end
@@ -13,7 +13,7 @@
13
13
  <%= content_tag :nav, id: 'Menu', class: ['admin', controller_name] do %>
14
14
  <section>
15
15
  <div class='back'>
16
- <%= link_to 'Home', :root %>
16
+ <%= link_to 'Home', '/' %>
17
17
  </div>
18
18
  <div class='posts'>
19
19
  <h4>
@@ -7,12 +7,33 @@ require 'observejs'
7
7
  module Ecrire
8
8
  class Application < Rails::Application
9
9
  require 'ecrire/config/environment'
10
- require 'ecrire/railtie'
11
10
 
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
11
+ alias :require_environment! :initialize!
12
+
13
+ initializer 'ecrire.secrets', before: :bootstrap_hook do |app|
14
+ app.paths.add 'config/secrets', with: Dir.pwd + '/secrets.yml'
15
+ end
16
+
17
+ Rails.application.paths.add 'config/database', with: Dir.pwd + '/secrets.yml'
18
+
19
+ if File.exist?(Dir.pwd + '/secrets.yml')
20
+ require 'ecrire/theme/engine'
21
+ else
22
+ require 'ecrire/onboarding/engine'
23
+ end
24
+
25
+ def paths
26
+ @paths ||= begin
27
+ paths = super
28
+ paths.add 'config/routes.rb', with: 'routes.rb'
29
+ paths.add 'config/locales', with: 'locales', glob: "*.{rb,yml}"
30
+ paths
31
+ end
32
+ end
33
+
34
+ def self.onboarding?
35
+ defined?(Ecrire::Onboarding::Engine)
36
+ end
16
37
 
17
38
  end
18
39
  end
@@ -12,7 +12,6 @@ module Ecrire
12
12
 
13
13
  shift_argv!
14
14
  Ecrire::Application.require_environment!
15
- Ecrire::Application.initialize!
16
15
 
17
16
  Rails::Console.start(Ecrire::Application, *ARGV)
18
17
  end
@@ -30,7 +30,7 @@ module Ecrire
30
30
  def generate!
31
31
  Dir.mkdir @path
32
32
  Dir.chdir @path
33
- template = File.expand_path '../../template/*', __FILE__
33
+ template = File.expand_path '../../theme/template/*', __FILE__
34
34
  FileUtils.cp_r(Dir[template], @path)
35
35
  end
36
36
 
@@ -1,4 +1,4 @@
1
- Rails.application.configure do
1
+ Ecrire::Application.configure do
2
2
  config = self.config
3
3
  config.eager_load = true
4
4
 
@@ -0,0 +1,63 @@
1
+ class DatabasesController < OnboardingController
2
+
3
+ helper_method :user, :password, :database
4
+
5
+ def index; end;
6
+
7
+ def create
8
+ info ||= {
9
+ 'adapter' => 'postgresql',
10
+ 'database' => database,
11
+ 'user' => user,
12
+ 'password' => password,
13
+ 'encoding' => 'utf8'
14
+ }
15
+ begin
16
+ ActiveRecord::Base.configurations = {
17
+ 'development' => info,
18
+ 'production' => info
19
+ }
20
+ ActiveRecord::Base.establish_connection
21
+ ActiveRecord::Base.connection
22
+ migrate!
23
+ rescue Exception => e
24
+ @exception = e
25
+ ActiveRecord::Base.clear_all_connections!
26
+ render 'index' and return
27
+ end
28
+
29
+ redirect_to :users
30
+ end
31
+
32
+ protected
33
+
34
+ private
35
+
36
+ def migrate!
37
+ ActiveRecord::Tasks::DatabaseTasks.database_configuration = ActiveRecord::Base.configurations
38
+ ActiveRecord::Migrator.migrations_paths = ActiveRecord::Tasks::DatabaseTasks.migrations_paths
39
+ ActiveRecord::Migration.verbose = ENV["VERBOSE"] ? ENV["VERBOSE"] == "true" : true
40
+ ActiveRecord::Migrator.migrate(ActiveRecord::Migrator.migrations_paths, ENV["VERSION"] ? ENV["VERSION"].to_i : nil) do |migration|
41
+ ENV["SCOPE"].blank? || (ENV["SCOPE"] == migration.scope)
42
+ end
43
+ end
44
+
45
+ def db_params
46
+ params.fetch(:database, {})
47
+ end
48
+
49
+ def user
50
+ @user ||= "ecrire#{SecureRandom.hex(2)}"
51
+ db_params.fetch(:user, @user)
52
+ end
53
+
54
+ def password
55
+ @password ||= SecureRandom.hex(16)
56
+ db_params.fetch(:password, @password)
57
+ end
58
+
59
+ def database
60
+ @database ||= "ecrire"
61
+ db_params.fetch(:name, @database)
62
+ end
63
+ end
@@ -1,4 +1,5 @@
1
1
  class OnboardingController < ApplicationController
2
+ include Ecrire::Onboarding::Engine.routes.url_helpers
2
3
 
3
4
  def index
4
5
  if File.exist?(Rails.application.paths['config/secrets'].expanded.last)
@@ -18,3 +19,4 @@ class OnboardingController < ApplicationController
18
19
  end
19
20
 
20
21
  end
22
+
@@ -0,0 +1,30 @@
1
+ class UsersController < OnboardingController
2
+
3
+ helper_method :user
4
+
5
+ def index;end;
6
+
7
+ def create
8
+ @user = User.find_or_initialize_by(email: user_params[:email])
9
+ @user.update(user_params)
10
+
11
+ if user.errors.blank?
12
+ save_configurations!
13
+ redirect_to :root
14
+ else
15
+ render 'index'
16
+ end
17
+ end
18
+
19
+ protected
20
+
21
+
22
+ def user_params
23
+ params.require(:user).permit(:email, :password, :password_confirmation)
24
+ end
25
+
26
+ def user
27
+ @user ||= User.new
28
+ end
29
+
30
+ end
@@ -0,0 +1,73 @@
1
+ module Ecrire
2
+ module Onboarding
3
+ class Engine < Rails::Engine
4
+
5
+ Rails.application.config.active_record.migration_error = :none
6
+ ActiveRecord::Base.configurations = {}
7
+
8
+ initializer 'ecrire.onboarding.dynamic_settings' do |app|
9
+ app.config.secret_key_base = SecureRandom.hex(16)
10
+ end
11
+
12
+ initializer 'ecrire.load_paths', before: :bootstrap_hook do |app|
13
+ ActiveSupport::Dependencies.autoload_paths.unshift(*self.paths.autoload_paths)
14
+ ActiveSupport::Dependencies.autoload_once_paths.unshift(*self.paths.autoload_once)
15
+ end
16
+
17
+ initializer 'ecrire.append_paths', before: :set_autoload_paths do |app|
18
+ app.config.eager_load_paths.unshift *paths.eager_load
19
+ app.config.autoload_once_paths.unshift *paths.autoload_once
20
+ app.config.autoload_paths.unshift *paths.autoload_paths
21
+ end
22
+
23
+
24
+ def paths
25
+ @paths ||= begin
26
+ paths = Rails::Paths::Root.new(root_path)
27
+ paths.add 'config/routes.rb', with: 'routes.rb'
28
+ paths.add 'app/views', with: 'views'
29
+ paths.add 'app/controllers', with: 'controllers', eager_load: true
30
+ paths.add 'app/assets', with: 'assets', glob: '*'
31
+ paths.add 'app/helpers', with: 'helpers', eager_load: true
32
+
33
+ paths.add 'config/routes.rb', with: 'routes.rb'
34
+ paths.add 'config/locales', with: 'locales', glob: '**/*.{rb,yml}'
35
+ paths.add 'config/environments', with: 'environments', glob: "#{Rails.env}.rb"
36
+
37
+ paths.add 'public', with: 'tmp/public'
38
+
39
+ paths.add "lib/assets", glob: "*"
40
+ paths.add "vendor/assets", glob: "*"
41
+ paths.add "lib/tasks"
42
+ paths
43
+ end
44
+ end
45
+
46
+ def has_migrations?
47
+ false
48
+ end
49
+
50
+ def root_path
51
+ Pathname.new(__FILE__).dirname
52
+ end
53
+
54
+ # This hack is done because ActiveRecord raise an error that makes
55
+ # Ecrire exit which makes it impossible to have an instance working without a
56
+ # database. By doing this, it becomes possible to Ecrire to load the server and
57
+ # serve the onboarding theme for the user.
58
+ ActiveRecord::Railtie.initializers.select do |initializer|
59
+ initializer.name.eql? 'active_record.initialize_database'
60
+ end.first.instance_variable_set :@block, Proc.new { |app|
61
+ ActiveSupport.on_load(:active_record) do
62
+ begin
63
+ establish_connection
64
+ rescue ActiveRecord::NoDatabaseError, ActiveRecord::AdapterNotSpecified => e
65
+ app.config.middleware.delete 'ActiveRecord::QueryCache'
66
+ app.config.middleware.delete 'ActiveRecord::ConnectionAdapters::ConnectionManagement'
67
+ end
68
+ end
69
+ }
70
+
71
+ end
72
+ end
73
+ end
@@ -0,0 +1,8 @@
1
+ Ecrire::Onboarding::Engine.routes.draw do
2
+
3
+ root 'onboarding#index'
4
+
5
+ resources :databases, only: [:index, :create]
6
+ resources :users, only: [:index, :create]
7
+ end
8
+
@@ -15,7 +15,7 @@
15
15
  </div>
16
16
 
17
17
 
18
- <%= form_tag onboarding_databases_path, method: :post do %>
18
+ <%= form_tag databases_path, method: :post do %>
19
19
 
20
20
  <% unless @exception.nil? %>
21
21
  <div class='error' as='Message'>
@@ -7,6 +7,6 @@
7
7
 
8
8
 
9
9
  <section class='welcome'>
10
- <%= link_to 'Configure', onboarding_databases_path, class: %w(button) %>
10
+ <%= link_to 'Configure', databases_path, class: %w(button) %>
11
11
  </section>
12
12
 
@@ -2,7 +2,7 @@
2
2
  <section>
3
3
  <h2>Create a user</h2>
4
4
 
5
- <%= form_for [:onboarding, user], url: onboarding_users_path, method: :post do |f| %>
5
+ <%= form_for user, method: :post do |f| %>
6
6
  <% if user.errors.any? %>
7
7
  <%= content_tag :div, class: %w(error), as: 'Message' do %>
8
8
  <%= content_tag :p, user.errors.full_messages.first %>
@@ -0,0 +1,29 @@
1
+ Ecrire::Application.routes.draw do
2
+
3
+ if defined?(Ecrire::Theme::Engine)
4
+ resource :session, only: [:new, :create, :destroy]
5
+
6
+ namespace :admin do
7
+ root 'posts#index'
8
+ resources :posts do
9
+ collection do
10
+ get 'help', controller: :posts, action: :help
11
+ end
12
+ resources :tags, only: [:index, :create, :update], module: 'posts'
13
+ resources :titles, shallow: true
14
+ resource :image, shallow: true
15
+ resource :properties, only: [:create, :destroy]
16
+ end
17
+
18
+ namespace :configurations do
19
+ resource :images, only: [:show, :create]
20
+ end
21
+ end
22
+
23
+ mount Ecrire::Theme::Engine => '/', as: 'theme'
24
+ else
25
+ mount Ecrire::Onboarding::Engine => '/'
26
+ end
27
+
28
+ end
29
+
@@ -0,0 +1,66 @@
1
+ module Ecrire
2
+ module Theme
3
+ class Engine < Rails::Engine
4
+
5
+ initializer 'ecrire.logs', before: :initialize_logger do |app|
6
+ unless Rails.env.test?
7
+ app.paths.add "log", with: "log/#{Rails.env}.log"
8
+ end
9
+ end
10
+
11
+ initializer 'ecrire.load_paths', before: :bootstrap_hook do |app|
12
+ ActiveSupport::Dependencies.autoload_paths.unshift(*self.paths.autoload_paths)
13
+ ActiveSupport::Dependencies.autoload_once_paths.unshift(*self.paths.autoload_once)
14
+ end
15
+
16
+ initializer 'ecrire.append_paths', before: :set_autoload_paths do |app|
17
+ app.config.eager_load_paths.unshift *paths.eager_load
18
+ app.config.autoload_once_paths.unshift *paths.autoload_once
19
+ app.config.autoload_paths.unshift *paths.autoload_paths
20
+ end
21
+
22
+ def paths
23
+ @paths ||= begin
24
+ paths = Rails::Paths::Root.new(root_path)
25
+ paths.add 'app/views', with: 'views'
26
+ paths.add 'app/controllers', with: 'controllers', eager_load: true
27
+ paths.add 'app/assets', with: 'assets', glob: '*'
28
+ paths.add 'app/helpers', with: 'helpers', eager_load: true
29
+
30
+ paths.add 'config/routes.rb', with: 'routes.rb'
31
+ paths.add 'config/locales', with: 'locales', glob: '**/*.{rb,yml}'
32
+ paths.add 'config/environments', with: 'environments', glob: "#{Rails.env}.rb"
33
+
34
+ paths.add 'public', with: 'tmp/public'
35
+
36
+ paths.add "lib/assets", glob: "*"
37
+ paths.add "vendor/assets", glob: "*"
38
+ paths.add "lib/tasks"
39
+
40
+ paths
41
+ end
42
+ end
43
+
44
+ def has_migrations?
45
+ false
46
+ end
47
+
48
+ def root_path(file = 'config.ru')
49
+ begin
50
+ pathname = Pathname.pwd
51
+
52
+ while !(pathname + file).exist? do
53
+ pathname = pathname.parent
54
+ if pathname.root?
55
+ raise "Could not find #{file}. Type 'ecrire new blog_name' to create a new blog"
56
+ break
57
+ end
58
+ end
59
+
60
+ pathname
61
+ end
62
+ end
63
+
64
+ end
65
+ end
66
+ end
@@ -4,7 +4,7 @@ gem 'ecrire', path: '~/Develop/ecrire'
4
4
 
5
5
  group :required do
6
6
  gem 'rails', '~> 4.2'
7
- gem 'observejs', '~> 0.0'
7
+ gem 'observejs', git: 'https://github.com/pothibo/observejs'
8
8
  gem 'warden', '~> 1.2'
9
9
  gem 'bcrypt', '~> 3.1'
10
10
  gem 'nokogiri', '~> 1.6'
@@ -19,7 +19,7 @@ group :required do
19
19
  gem 'turbolinks', '~> 2.2'
20
20
  gem 'bourbon', '~> 3.2'
21
21
  gem 'uglifier', '~> 2.5'
22
- gem 'jbuilder' '~> 2.2'
22
+ gem 'jbuilder', '~> 2.2'
23
23
  end
24
24
 
25
25
  group :server do
@@ -13,6 +13,7 @@ div.file.preview {
13
13
  padding: 1em;
14
14
  background: rgb(242, 239, 232);
15
15
  border-bottom: 1px solid #CDCBC8;
16
+ box-shadow: inset 0 -1px 0 0 #F9F4EA;
16
17
  text-align: center;
17
18
  word-break: break-all;
18
19
  }
@@ -0,0 +1,2 @@
1
+ class PostsController < Ecrire::ThemeController
2
+ end
@@ -0,0 +1,14 @@
1
+ Ecrire::Theme::Engine.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
+ resources :tags
10
+
11
+ get '/:view', to: 'static#show'
12
+
13
+ end
14
+
@@ -12,7 +12,7 @@
12
12
  <main>
13
13
  <%= admin_navigation %>
14
14
  <header>
15
- <h1><%= link_to 'E', :root %></h1>
15
+ <h1><%= link_to 'E', '/' %></h1>
16
16
  <nav>
17
17
  <%= link_to 'Customize', '/customize' %>
18
18
  <% if !signed_in? %>
@@ -1,3 +1,3 @@
1
1
  module Ecrire
2
- VERSION = '0.23.0'
2
+ VERSION = '0.24.0'
3
3
  end
@@ -1,8 +1,11 @@
1
- class SessionsControllerTest < BaseControllerTest
1
+ require 'test_controller'
2
+ require 'editor/test_helper'
3
+
4
+ class SessionsControllerTest < TestController
2
5
  test 'should be able to log in' do
3
6
  post :create, session: {email: "pothibo@gmail.com", password: "123456789"}
4
7
  assert !proxy.user.nil?, "#{users(:pothibo).email} should be logged in"
5
- assert_redirected_to root_path
8
+ assert_redirected_to '/'
6
9
  end
7
10
 
8
11
 
@@ -1,3 +1,5 @@
1
+ require 'editor/test_helper'
2
+
1
3
  class BaseHelperTest < ActionView::TestCase
2
4
  include Rails.application.routes.url_helpers
3
5
 
@@ -1,3 +1,4 @@
1
+ require 'test_helper'
1
2
  require 'editor/test_helper'
2
3
 
3
4
  class ImageTest < ActiveSupport::TestCase
@@ -1,3 +1,4 @@
1
+ require 'test_helper'
1
2
  require 'editor/test_helper'
2
3
 
3
4
  class PostTest < ActiveSupport::TestCase
@@ -1,5 +1,5 @@
1
+ require 'test_helper'
1
2
  require 'editor/test_helper'
2
- require 'byebug'
3
3
 
4
4
  class TitleTest < ActiveSupport::TestCase
5
5
  test "length of name" do
@@ -1,3 +1,4 @@
1
+ require 'test_helper'
1
2
  require 'editor/test_helper'
2
3
 
3
4
  class UserTest < ActiveSupport::TestCase