enable/disable plugins by config option
This commit is contained in:
parent
6d98be6d22
commit
64bb8e043d
21 changed files with 65 additions and 15 deletions
|
@ -104,6 +104,19 @@ class ApplicationController < ActionController::Base
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Many plugins can be turned on and off on the fly with a `use_` configuration option.
|
||||||
|
# To disable a controller in the plugin, you can use this as a `before_action`:
|
||||||
|
#
|
||||||
|
# class MypluginController < ApplicationController
|
||||||
|
# before_filter -> { require_plugin_enabled FoodsoftMyplugin }
|
||||||
|
# end
|
||||||
|
#
|
||||||
|
def require_plugin_enabled(plugin)
|
||||||
|
unless plugin.enabled?
|
||||||
|
redirect_to root_path, alert: I18n.t('application.controller.error_plugin_disabled')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
# Redirect to the login page, used in authenticate, plugins can override this.
|
# Redirect to the login page, used in authenticate, plugins can override this.
|
||||||
def redirect_to_login(options={})
|
def redirect_to_login(options={})
|
||||||
redirect_to login_url, options
|
redirect_to login_url, options
|
||||||
|
|
|
@ -67,6 +67,12 @@ default: &defaults
|
||||||
# Members of a user's groups and administrators can still see full names.
|
# Members of a user's groups and administrators can still see full names.
|
||||||
use_nick: false
|
use_nick: false
|
||||||
|
|
||||||
|
# Most plugins can be enabled/disabled here as well. Messages and wiki are enabled
|
||||||
|
# by default and need to be set to false to disable. Most other plugins needs to
|
||||||
|
# be enabled before they do anything.
|
||||||
|
#use_wiki: true
|
||||||
|
#use_messages: true
|
||||||
|
|
||||||
# Base font size for generated PDF documents
|
# Base font size for generated PDF documents
|
||||||
#pdf_font_size: 12
|
#pdf_font_size: 12
|
||||||
# Page size for generated PDF documents
|
# Page size for generated PDF documents
|
||||||
|
@ -86,8 +92,8 @@ default: &defaults
|
||||||
notification:
|
notification:
|
||||||
error_recipients:
|
error_recipients:
|
||||||
- admin@foodcoop.test
|
- admin@foodcoop.test
|
||||||
sender_address: "\"FoodSoft Error\" <foodsoft@foodcoop.test>"
|
sender_address: "\"Foodsoft Error\" <foodsoft@foodcoop.test>"
|
||||||
email_prefix: "[FoodSoft]"
|
email_prefix: "[Foodsoft]"
|
||||||
|
|
||||||
# Access to sharedLists, the external article-database
|
# Access to sharedLists, the external article-database
|
||||||
shared_lists:
|
shared_lists:
|
||||||
|
|
|
@ -288,6 +288,7 @@ en:
|
||||||
error_denied: You are not allowed to view the requested page. If you think you should, ask an administrator to give you appropriate permissions. If you have access to multiple user accounts, you might want to %{sign_in}.
|
error_denied: You are not allowed to view the requested page. If you think you should, ask an administrator to give you appropriate permissions. If you have access to multiple user accounts, you might want to %{sign_in}.
|
||||||
error_denied_sign_in: sign in as another user
|
error_denied_sign_in: sign in as another user
|
||||||
error_members_only: This action is only available to members of the group!
|
error_members_only: This action is only available to members of the group!
|
||||||
|
error_plugin_disabled: This feature is currently disabled.
|
||||||
error_token: Access denied (invalid token)!
|
error_token: Access denied (invalid token)!
|
||||||
article_categories:
|
article_categories:
|
||||||
create:
|
create:
|
||||||
|
|
|
@ -286,6 +286,7 @@ nl:
|
||||||
error_denied: Je hebt geen toegang tot de gevraagde pagina. Als je denkt dat je dat wel zou moeten hebben, vraag dan een beheerder je die rechten te geven. Als je meerdere accounts hebt, wil je mogelijk %{sign_in}.
|
error_denied: Je hebt geen toegang tot de gevraagde pagina. Als je denkt dat je dat wel zou moeten hebben, vraag dan een beheerder je die rechten te geven. Als je meerdere accounts hebt, wil je mogelijk %{sign_in}.
|
||||||
error_denied_sign_in: inloggen als een andere gebruiker
|
error_denied_sign_in: inloggen als een andere gebruiker
|
||||||
error_members_only: Deze actie is alleen beschikbaar voor leden van de groep!
|
error_members_only: Deze actie is alleen beschikbaar voor leden van de groep!
|
||||||
|
error_plugin_disabled: Deze actie is momenteel uitgeschakeld.
|
||||||
error_token: Geen toegang (ongeldig token)!
|
error_token: Geen toegang (ongeldig token)!
|
||||||
article_categories:
|
article_categories:
|
||||||
create:
|
create:
|
||||||
|
|
|
@ -11,5 +11,8 @@ add the following to foodsoft's Gemfile:
|
||||||
gem 'foodsoft_messages', path: 'lib/foodsoft_messages'
|
gem 'foodsoft_messages', path: 'lib/foodsoft_messages'
|
||||||
```
|
```
|
||||||
|
|
||||||
|
This plugin introduces the foodcoop config option `use_messages`, which can be
|
||||||
|
set to `false` to disable messages. May be useful in multicoop deployments.
|
||||||
|
|
||||||
This plugin is part of the foodsoft package and uses the GPL-3 license (see
|
This plugin is part of the foodsoft package and uses the GPL-3 license (see
|
||||||
foodsoft's LICENSE for the full license text).
|
foodsoft's LICENSE for the full license text).
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
class MessagesController < ApplicationController
|
class MessagesController < ApplicationController
|
||||||
|
|
||||||
|
before_filter -> { require_plugin_enabled FoodsoftMessages }
|
||||||
|
|
||||||
# Renders the "inbox" action.
|
# Renders the "inbox" action.
|
||||||
def index
|
def index
|
||||||
@messages = Message.public.page(params[:page]).per(@per_page).order('created_at DESC').includes(:sender)
|
@messages = Message.public.page(params[:page]).per(@per_page).order('created_at DESC').includes(:sender)
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
/ insert_after 'erb:contains("delete")'
|
/ insert_after 'erb:contains("delete")'
|
||||||
= link_to t('.send_message'), new_message_path(:message => {:group_id => @ordergroup.id}), class: 'btn'
|
- if FoodsoftMessages.enabled?
|
||||||
|
= link_to t('.send_message'), new_message_path(:message => {:group_id => @ordergroup.id}), class: 'btn'
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
/ insert_after 'erb:contains("delete")'
|
/ insert_after 'erb:contains("delete")'
|
||||||
= link_to t('.send_message'), new_message_path(:message => {:mail_to => @user.id}), class: 'btn'
|
- if FoodsoftMessages.enabled?
|
||||||
|
= link_to t('.send_message'), new_message_path(:message => {:mail_to => @user.id}), class: 'btn'
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
/ insert_after 'erb:contains("delete")'
|
/ insert_after 'erb:contains("delete")'
|
||||||
= link_to_new_message(message_params: {group_id: @workgroup.id})
|
- if FoodsoftMessages.enabled?
|
||||||
|
= link_to_new_message(message_params: {group_id: @workgroup.id})
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
/ insert_bottom 'tbody tr'
|
/ insert_bottom 'tbody tr'
|
||||||
%td= link_to_new_message(message_params: {group_id: ordergroup.id})
|
- if FoodsoftMessages.enabled?
|
||||||
|
%td= link_to_new_message(message_params: {group_id: ordergroup.id})
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
/ insert_bottom 'tbody tr'
|
/ insert_bottom 'tbody tr'
|
||||||
%td= link_to_new_message(message_params: {mail_to: user.id})
|
- if FoodsoftMessages.enabled?
|
||||||
|
%td= link_to_new_message(message_params: {mail_to: user.id})
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
/ insert_after 'erb:contains("tasks")'
|
/ insert_after 'erb:contains("tasks")'
|
||||||
= link_to_new_message message_params: {group_id: workgroup.id}
|
- if FoodsoftMessages.enabled?
|
||||||
|
= link_to_new_message message_params: {group_id: workgroup.id}
|
||||||
|
|
|
@ -1,2 +1,3 @@
|
||||||
/ insert_after 'erb:contains("tasks")'
|
/ insert_after 'erb:contains("tasks")'
|
||||||
%li= link_to t('.write_message'), new_message_path
|
- if FoodsoftMessages.enabled?
|
||||||
|
%li= link_to t('.write_message'), new_message_path
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
/ insert_after 'erb[silent]:contains("<dashboard_middle_mark>")'
|
/ insert_after 'erb[silent]:contains("<dashboard_middle_mark>")'
|
||||||
- unless Message.public.empty?
|
- if FoodsoftMessages.enabled?
|
||||||
%section#messages
|
- unless Message.public.empty?
|
||||||
%h2= t '.messages.title'
|
%section#messages
|
||||||
= render 'messages/messages', messages: Message.public.order('created_at DESC').limit(5), pagination: false
|
%h2= t '.messages.title'
|
||||||
%p= link_to t('.messages.view_all'), messages_path
|
= render 'messages/messages', messages: Message.public.order('created_at DESC').limit(5), pagination: false
|
||||||
|
%p= link_to t('.messages.view_all'), messages_path
|
||||||
|
|
|
@ -3,4 +3,9 @@ require "foodsoft_messages/user_link"
|
||||||
require "deface"
|
require "deface"
|
||||||
|
|
||||||
module FoodsoftMessages
|
module FoodsoftMessages
|
||||||
|
# Return whether messages are used or not.
|
||||||
|
# Enabled by default since it used to be part of the foodsoft core.
|
||||||
|
def self.enabled?
|
||||||
|
FoodsoftConfig[:use_messages] != false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
module FoodsoftMessages
|
module FoodsoftMessages
|
||||||
class Engine < ::Rails::Engine
|
class Engine < ::Rails::Engine
|
||||||
def navigation(primary, context)
|
def navigation(primary, context)
|
||||||
|
return unless FoodsoftMessages.enabled?
|
||||||
return if primary[:foodcoop].nil?
|
return if primary[:foodcoop].nil?
|
||||||
sub_nav = primary[:foodcoop].sub_navigation
|
sub_nav = primary[:foodcoop].sub_navigation
|
||||||
sub_nav.items <<
|
sub_nav.items <<
|
||||||
|
|
|
@ -6,7 +6,7 @@ module FoodsoftMessages
|
||||||
|
|
||||||
# modify user presentation link to writing a message for the user
|
# modify user presentation link to writing a message for the user
|
||||||
def show_user_link(user=@current_user)
|
def show_user_link(user=@current_user)
|
||||||
if user.nil?
|
if user.nil? or not FoodsoftMessages.enabled?
|
||||||
show_user user
|
show_user user
|
||||||
else
|
else
|
||||||
link_to show_user(user), new_message_path('message[mail_to]' => user.id),
|
link_to show_user(user), new_message_path('message[mail_to]' => user.id),
|
||||||
|
|
|
@ -14,5 +14,8 @@ gem 'acts_as_versioned', git: 'git://github.com/technoweenie/acts_as_versioned.g
|
||||||
gem 'foodsoft_wiki', path: 'lib/foodsoft_wiki'
|
gem 'foodsoft_wiki', path: 'lib/foodsoft_wiki'
|
||||||
```
|
```
|
||||||
|
|
||||||
|
This plugin introduces the foodcoop config option `use_wiki`, which can be set
|
||||||
|
to `false` to disable the wiki. May be useful in multicoop deployments.
|
||||||
|
|
||||||
This plugin is part of the foodsoft package and uses the GPL-3 license (see
|
This plugin is part of the foodsoft package and uses the GPL-3 license (see
|
||||||
foodsoft's LICENSE for the full license text).
|
foodsoft's LICENSE for the full license text).
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
class PagesController < ApplicationController
|
class PagesController < ApplicationController
|
||||||
|
before_filter -> { require_plugin_enabled FoodsoftWiki }
|
||||||
|
|
||||||
skip_before_filter :authenticate, :only => :all
|
skip_before_filter :authenticate, :only => :all
|
||||||
before_filter :only => :all do
|
before_filter :only => :all do
|
||||||
|
|
|
@ -5,4 +5,9 @@ require 'content_for_in_controllers'
|
||||||
require 'foodsoft_wiki/engine'
|
require 'foodsoft_wiki/engine'
|
||||||
|
|
||||||
module FoodsoftWiki
|
module FoodsoftWiki
|
||||||
|
# Return whether the wiki is used or not.
|
||||||
|
# Enabled by default since it used to be part of the foodsoft core.
|
||||||
|
def self.enabled?
|
||||||
|
FoodsoftConfig[:use_wiki] != false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
module FoodsoftWiki
|
module FoodsoftWiki
|
||||||
class Engine < ::Rails::Engine
|
class Engine < ::Rails::Engine
|
||||||
def navigation(primary, ctx)
|
def navigation(primary, ctx)
|
||||||
|
return unless FoodsoftWiki.enabled?
|
||||||
primary.item :wiki, I18n.t('navigation.wiki.title'), '#', id: nil do |subnav|
|
primary.item :wiki, I18n.t('navigation.wiki.title'), '#', id: nil do |subnav|
|
||||||
subnav.item :wiki_home, I18n.t('navigation.wiki.home'), ctx.wiki_path, id: nil
|
subnav.item :wiki_home, I18n.t('navigation.wiki.home'), ctx.wiki_path, id: nil
|
||||||
subnav.item :all_pages, I18n.t('navigation.wiki.all_pages'), ctx.all_pages_path, id: nil
|
subnav.item :all_pages, I18n.t('navigation.wiki.all_pages'), ctx.all_pages_path, id: nil
|
||||||
|
|
Loading…
Reference in a new issue