[Git][noosfero/noosfero][master] 2 commits: routes: include plugins config/routes.rb file in routes loading

Rodrigo Souto gitlab at mg.gitlab.com
Wed Jul 5 15:12:37 BRT 2017


Rodrigo Souto pushed to branch master at Noosfero / noosfero


Commits:
75068e63 by Rodrigo Souto at 2017-07-04T11:45:49-03:00
routes: include plugins config/routes.rb file in routes loading

Also removing the check that changes the plugins root path from
"{baseplugins,config/plugins}" to "plugins" on test environments since
rake testing already deals with enabling the plugins being tested and
also plugins routes might break each others tests.

To allow plugin tests, I included the test/plugins folder with a
symbolic link to 'FooPlugin'. This folder is included on the
plugins_root on
test environment.

- - - - -
84294166 by Rodrigo Souto at 2017-07-05T18:11:34+00:00
Merge branch 'plugins-custom-routes' into 'master'

routes: include plugins config/routes.rb file in routes loading

See merge request !1262
- - - - -


4 changed files:

- config/routes/50_plugins.rb
- + config/routes/plugins/README
- script/noosfero-plugins
- + test/plugins/foo


Changes:

=====================================
config/routes/50_plugins.rb
=====================================
--- a/config/routes/50_plugins.rb
+++ b/config/routes/50_plugins.rb
@@ -1,6 +1,6 @@
 paths              = {}
 profile_format     = /#{Noosfero.identifier_format}/i
-plugins_root       = if Rails.env.test? then 'plugins' else '{baseplugins,config/plugins}' end
+plugins_root       = "{baseplugins,config/plugins#{Rails.env.test? ? ',test/plugins' : ''}}"
 prefixes_by_folder = {
   public:    'plugin',
   profile:   'profile/:profile/plugin',


=====================================
config/routes/plugins/README
=====================================
--- /dev/null
+++ b/config/routes/plugins/README
@@ -0,0 +1,2 @@
+This directory must contain symbolink links to the Noosfero plugins custom
+routes.


=====================================
script/noosfero-plugins
=====================================
--- a/script/noosfero-plugins
+++ b/script/noosfero-plugins
@@ -142,8 +142,10 @@ _enable(){
       ln -s "$source" "$target"
       plugins_public_dir="$NOOSFERO_DIR/public/plugins"
       plugins_features_dir="$NOOSFERO_DIR/features/plugins"
+      plugins_routes_dir="$NOOSFERO_DIR/config/routes/plugins"
       test -d "$target/public" && ln -s "$target/public" "$plugins_public_dir/$plugin"
       test -d "$NOOSFERO_DIR/features" && test -d "$target/features" && ln -s "$target/features" "$plugins_features_dir/$plugin"
+      test -f "$target/config/routes.rb" && ln -s "$target/config/routes.rb" "$plugins_routes_dir/$plugin.rb"
       _say "$plugin enabled"
       run "$source/after_enable.rb"
       needs_migrate=true
@@ -165,6 +167,7 @@ _disable(){
   target="$enabled_plugins_dir/$plugin"
   plugins_public_dir="$NOOSFERO_DIR/public/plugins"
   plugins_features_dir="$NOOSFERO_DIR/features/plugins"
+  plugins_routes_dir="$NOOSFERO_DIR/config/routes/plugins"
 
   if [ -h "$base_plugins_dir/$plugin" ]; then
     _say "$plugin is a base plugin and cannot be disabled"
@@ -175,6 +178,7 @@ _disable(){
     rm "$target"
     test -h "$plugins_public_dir/$plugin" && rm "$plugins_public_dir/$plugin"
     test -h "$plugins_features_dir/$plugin" && rm "$plugins_features_dir/$plugin"
+    test -h "$plugins_routes_dir/$plugin.rb" && rm "$plugins_routes_dir/$plugin.rb"
     _say "$plugin disabled"
     run "$source/after_disable.rb"
   else


=====================================
test/plugins/foo
=====================================
--- /dev/null
+++ b/test/plugins/foo
@@ -0,0 +1 @@
+../../plugins/foo/
\ No newline at end of file



View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/f7278e72bfc183adde8c5ce2d6e2f8bff8b81c74...84294166ffd3a056e7a4ae5bde77497dbe517301

---
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/f7278e72bfc183adde8c5ce2d6e2f8bff8b81c74...84294166ffd3a056e7a4ae5bde77497dbe517301
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20170705/e549f827/attachment-0001.html>


More information about the Noosfero-dev mailing list