Patch #31457

Add support for reloading plugin assets automatically in development mode

Added by Kouhei Sutou about 1 year ago. Updated about 1 month ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Go MAEDA% Done:

0%

Category:Plugin API
Target version:4.1.0

Description

Redmine supports assets for plugin by putting files under plugins/*/assets/.
But Redmine doesn't support reloading (mirroring) plugin assets automatically.

For example, we need to restart bin/rails server process to apply changes when we change plugins/*/asserts/stylesheets/xxx.css.

I attach a path to support this.

add-support-for-auto-reloading-plugin-assets.diff Magnifier (996 Bytes) Kouhei Sutou, 2019-05-27 04:49

chrome_XJsd7k5iS0.png (33.7 KB) Geo Tis, 2020-05-30 11:44


Related issues

Duplicated by Redmine - Feature #11993: Reload plugin assets on every request in development mode Closed

Associated revisions

Revision 18202
Added by Go MAEDA about 1 year ago

Add support for reloading plugin assets automatically in development mode (#31457).

Patch by Kouhei Sutou.

History

#1 Updated by Go MAEDA about 1 year ago

  • Category set to Plugin API

Could you describe use cases for this feature? Since I am not familiar with plugin development, I cannot imagine why you want to update your plugins without restarting Redmine.

My concern for this feature is that it checks updates of assets on every HTTP requests and it may affect the performance of Redmine.

#2 Updated by Kouhei Sutou about 1 year ago

Sure.

In Redmine itself development, we don't need to restart Redmine itself. It's useful. Because we don't need to follow the following steps:

  • Change public/stylesheets/application.css
  • Stop bin/rails server
  • Start bin/rails server again
  • Reload Web browser

We just need to do the following steps:

  • Change public/stylesheets/application.css
  • Reload Web browser

In the current Redmine plugin development, we need to follow the following steps for updating assets:

  • Change plugins/xxx/assets/xxx.css
  • Stop bin/rails server
  • Start bin/rails server again
  • Reload Web browser

In the current Redmine plugin development, we need to follow the following steps for updating codes:

  • Change plugins/xxx/app/models/xxx.rb
  • Reload Web browser

This patch allows Redmine plugin developers to follow the standard Rails application development style. i.e. We can use the following steps for plugin assets:

  • Change plugins/xxx/assets/xxx.css
  • Reload Web browser

My concern for this feature is that it checks updates of assets on every HTTP requests and it may affect the performance of Redmine.

In development mode, it may affect the performance of Redmine. But it's not in production mode.

Rails don't run update checks on production mode. See also:

#3 Updated by Kouhei Sutou about 1 year ago

Ah, use case.
I want to improve style for [Full text search plugin](https://github.com/clear-code/redmine_full_text_search) by [CSS](https://github.com/clear-code/redmine_full_text_search/tree/master/assets/stylesheets). I want to check whether CSS change improves style without restarting Redmine. Restarting Redmine bother me because it's not the standard Rails application development style.

#4 Updated by Go MAEDA about 1 year ago

  • Target version set to 4.1.0

Thank you for clarification. I understand that the change helps plugin developers a lot.

Setting the target version to 4.1.0.

#5 Updated by Go MAEDA about 1 year ago

  • Status changed from New to Closed

Committed the patch. Thank you for improving Redmine.

#6 Updated by Go MAEDA about 1 year ago

  • Subject changed from Add support for reloading plugin assets automatically to Add support for reloading plugin assets automatically in development mode

#7 Updated by Go MAEDA about 1 year ago

  • Assignee set to Go MAEDA

#8 Updated by Go MAEDA 4 months ago

  • Duplicated by Feature #11993: Reload plugin assets on every request in development mode added

#9 Updated by Geo Tis about 1 month ago

Hi.
As soon as I update css and reload redmine page I got error. What I'm doing wrong?
Redmine version: 4.1.1
OS: Windows 10
Using

set RAILS_ENV=development
bundle exec rails server webrick

As soon as I restart rails server - everything works fine.

#10 Updated by Kouhei Sutou about 1 month ago

It's a problem of the redmine_issue_todo_lists plugin. It should not call unloadable:

diff --git a/init.rb b/init.rb
index 3c354f4..17d8906 100644
--- a/init.rb
+++ b/init.rb
@@ -23,12 +23,7 @@ Redmine::Plugin.register :redmine_issue_todo_lists do
   menu :project_menu, :issue_todo_lists, { :controller => 'issue_todo_lists', :action => 'index' }, :caption => :issue_todo_lists_title, :param => :project_id, :after => :activity

   Rails.configuration.to_prepare do
-    unless Project.included_modules.include? RedmineIssueTodoLists::ProjectPatch
-      Project.send(:include, RedmineIssueTodoLists::ProjectPatch)
-    end
-
-    unless Issue.included_modules.include? RedmineIssueTodoLists::IssuePatch
-      Issue.send(:include, RedmineIssueTodoLists::IssuePatch)
-    end
+    Project.send(:include, RedmineIssueTodoLists::ProjectPatch)
+    Issue.send(:include, RedmineIssueTodoLists::IssuePatch)
   end
 end
diff --git a/lib/redmine_issue_todo_lists/issue_patch.rb b/lib/redmine_issue_todo_lists/issue_patch.rb
index 0f3cae8..5a925fa 100644
--- a/lib/redmine_issue_todo_lists/issue_patch.rb
+++ b/lib/redmine_issue_todo_lists/issue_patch.rb
@@ -5,8 +5,6 @@ module RedmineIssueTodoLists
       base.send(:include, InstanceMethods)

       base.class_eval do
-        unloadable
-
         after_save :remove_todo_list_allocations
         has_many :issue_todo_list_items, dependent: :destroy
         has_many :issue_todo_lists, through: :issue_todo_list_items
diff --git a/lib/redmine_issue_todo_lists/project_patch.rb b/lib/redmine_issue_todo_lists/project_patch.rb
index c12628c..012eb5e 100644
--- a/lib/redmine_issue_todo_lists/project_patch.rb
+++ b/lib/redmine_issue_todo_lists/project_patch.rb
@@ -5,8 +5,6 @@ module RedmineIssueTodoLists
       base.send(:include, InstanceMethods)

       base.class_eval do
-        unloadable
-
         has_many :issue_todo_lists, dependent: :destroy
       end
     end

Could you report this to the redmine_issue_todo_lists plugin?

#11 Updated by Geo Tis about 1 month ago

Kouhei Sutou wrote:

It's a problem of the redmine_issue_todo_lists plugin. It should not call unloadable:

[...]

Could you report this to the redmine_issue_todo_lists plugin?

Thank you for such quick reply.
Im developing own version based on original plugin for company needs, so will try to apply fix myself. Also will report it back to original developer.

Also available in: Atom PDF