Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Let engines mount themselves #247

Merged
merged 3 commits into from
Nov 17, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions decidim-admin/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@ This library adds and administration dashboard so users can manage their
organization, participatory processes and all other entities.

## Usage
Include this library in your Decidim' flavoured Rails app by:

```ruby
# config/routes.rb
mount Decidim::Admin::Engine => '/admin'
```

This will add an admin dashboard to manage an organization an all its entities.
It's included by default with Decidim.

Expand Down
6 changes: 6 additions & 0 deletions decidim-admin/lib/decidim/admin/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,12 @@ module Admin
class Engine < ::Rails::Engine
isolate_namespace Decidim::Admin

initializer "decidim_admin.mount_routes" do |_app|
Decidim::Core::Engine.routes do
mount Decidim::Admin::Engine => "/admin"
end
end

initializer "decidim_admin.assets" do |app|
app.config.assets.precompile += %w(decidim_admin_manifest.js)
end
Expand Down
11 changes: 7 additions & 4 deletions decidim-admin/spec/features/admin_manages_organization_spec.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# coding: utf-8
# frozen_string_literal: true

require "spec_helper"
Expand All @@ -14,10 +15,12 @@

describe "show" do
it "lists the details from the organization" do
expect(page).to have_content(organization.name)
expect(page).to have_content(translated(organization.description))
expect(page).to have_content(translated(organization.description, locale: :es))
expect(page).to have_content(translated(organization.description, locale: :ca))
within ".main-content" do
expect(page).to have_content(organization.name)
expect(page.body).to include(translated(organization.description))
expect(page.body).to include(translated(organization.description, locale: :es))
expect(page.body).to include(translated(organization.description, locale: :ca))
end
end
end

Expand Down
9 changes: 1 addition & 8 deletions decidim-api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,7 @@
This library exposes a [GraphQL](https://facebook.github.io/graphql/) API to programatically interact with the Decidim platform via HTTP.

## Usage
Include this library in your Decidim' flavoured Rails app by:

```ruby
# config/routes.rb
mount Decidim::Api::Engine => '/api'
```

This will expose two nice endpoints:
Including `decidim-api` will get expose two nice endpoints:

* `/api`: The main GraphQL endpoint that holds the actual API.
* `/api/docs`: Nicely-written docs of the entities of the API.
Expand Down
6 changes: 6 additions & 0 deletions decidim-api/lib/decidim/api/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ class Engine < ::Rails::Engine
app.config.assets.precompile += %w(decidim_api_manifest.js)
end

initializer "decidim_api.mount_routes" do |_app|
Decidim::Core::Engine.routes do
mount Decidim::Api::Engine => "/api"
end
end

initializer "decidim-api.middleware" do |app|
app.config.middleware.insert_before 0, Rack::Cors do
allow do
Expand Down
6 changes: 6 additions & 0 deletions decidim-system/lib/decidim/system/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ module System
class Engine < ::Rails::Engine
isolate_namespace Decidim::System

initializer "decidim_system.mount_routes" do |_app|
Decidim::Core::Engine.routes do
mount Decidim::System::Engine => "/system"
end
end

initializer "decidim_system.assets" do |app|
app.config.assets.precompile += %w(decidim_system_manifest.js)
end
Expand Down
3 changes: 0 additions & 3 deletions lib/generators/decidim/install_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ class InstallGenerator < Rails::Generators::Base
desc: "Run migrations after installing decidim"

def install
route "mount Decidim::System::Engine => '/system'"
route "mount Decidim::Admin::Engine => '/admin'"
route "mount Decidim::Api::Engine => '/api'"
route "mount Decidim::Core::Engine => '/'"
end

Expand Down