プロジェクト

全般

プロフィール

Vote #80095

完了

Add support for reloading plugin assets automatically in development mode

Admin Redmine さんが4年以上前に追加. 4年以上前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
Plugin API_20
対象バージョン:
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
20
version_id:
127
issue_org_id:
31457
author_id:
58128
assigned_to_id:
332
comments:
11
status_id:
5
tracker_id:
3
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[Closed]

説明

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.


journals

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.
--------------------------------------------------------------------------------
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:

* https://github.com/rails/rails/blob/master/railties/lib/rails/application/finisher.rb#L203-L204
* https://github.com/redmine/redmine/blob/master/config/environments/production.rb#L7
--------------------------------------------------------------------------------
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.
--------------------------------------------------------------------------------
Thank you for clarification. I understand that the change helps plugin developers a lot.

Setting the target version to 4.1.0.
--------------------------------------------------------------------------------
Committed the patch. Thank you for improving Redmine.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
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
<pre>
set RAILS_ENV=development
bundle exec rails server webrick
</pre>

As soon as I restart rails server - everything works fine.
--------------------------------------------------------------------------------
It's a problem of the redmine_issue_todo_lists plugin. It should not call @unloadable@:

<pre><code class="diff">
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
</code></pre>

Could you report this to the redmine_issue_todo_lists plugin?
--------------------------------------------------------------------------------
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.
--------------------------------------------------------------------------------


related_issues

duplicates,Closed,11993,Reload plugin assets on every request in development mode

Admin Redmine さんが4年以上前に更新

  • カテゴリPlugin API_20 にセット
  • 対象バージョン4.1.0_127 にセット

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0