peclik / clipboard_image_paste

Redmine plugin for pasting cropped image from clipboard as an attachment.
262 stars 119 forks source link

works not in Redmine 4.0.4 #95

Open chmich opened 5 years ago

chmich commented 5 years ago

Test in Redmine 4.0.4 (in Development)

when draging the plugin into the plugins-folder:

=> Booting Puma
=> Rails 5.2.3 application starting in development 
=> Run `rails server -h` for more startup options
Exiting
Traceback (most recent call last):
    65: from /Users/dev/projects-own/invoicing/redmine-4.0.4/bin/rails:4:in `<main>'
    64: from /Users/dev/projects-own/invoicing/redmine-4.0.4/bin/rails:4:in `require'
    63: from /Users/dev/.rvm/gems/ruby-2.5.5/gems/railties-5.2.3/lib/rails/commands.rb:18:in `<top (required)>'
    62: from /Users/dev/.rvm/gems/ruby-2.5.5/gems/railties-5.2.3/lib/rails/command.rb:46:in `invoke'
    61: from /Users/dev/.rvm/gems/ruby-2.5.5/gems/railties-5.2.3/lib/rails/command/base.rb:65:in `perform'
    60: from /Users/dev/.rvm/gems/ruby-2.5.5/gems/thor-0.20.3/lib/thor.rb:387:in `dispatch'
    59: from /Users/dev/.rvm/gems/ruby-2.5.5/gems/thor-0.20.3/lib/thor/invocation.rb:126:in `invoke_command'
    58: from /Users/dev/.rvm/gems/ruby-2.5.5/gems/thor-0.20.3/lib/thor/command.rb:27:in `run'
    57: from /Users/dev/.rvm/gems/ruby-2.5.5/gems/railties-5.2.3/lib/rails/commands/server/server_command.rb:142:in `perform'
    56: from /Users/dev/.rvm/gems/ruby-2.5.5/gems/railties-5.2.3/lib/rails/commands/server/server_command.rb:142:in `tap'
    55: from /Users/dev/.rvm/gems/ruby-2.5.5/gems/railties-5.2.3/lib/rails/commands/server/server_command.rb:147:in `block in perform'
    54: from /Users/dev/.rvm/gems/ruby-2.5.5/gems/railties-5.2.3/lib/rails/commands/server/server_command.rb:51:in `start'
    53: from /Users/dev/.rvm/gems/ruby-2.5.5/gems/railties-5.2.3/lib/rails/commands/server/server_command.rb:89:in `log_to_stdout'
    52: from /Users/dev/.rvm/gems/ruby-2.5.5/gems/rack-2.0.7/lib/rack/server.rb:354:in `wrapped_app'
    51: from /Users/dev/.rvm/gems/ruby-2.5.5/gems/railties-5.2.3/lib/rails/commands/server/server_command.rb:27:in `app'
    50: from /Users/dev/.rvm/gems/ruby-2.5.5/gems/rack-2.0.7/lib/rack/server.rb:219:in `app'
    49: from /Users/dev/.rvm/gems/ruby-2.5.5/gems/rack-2.0.7/lib/rack/server.rb:319:in `build_app_and_options_from_config'
    48: from /Users/dev/.rvm/gems/ruby-2.5.5/gems/rack-2.0.7/lib/rack/builder.rb:40:in `parse_file'
    47: from /Users/dev/.rvm/gems/ruby-2.5.5/gems/rack-2.0.7/lib/rack/builder.rb:49:in `new_from_string'
    46: from /Users/dev/.rvm/gems/ruby-2.5.5/gems/rack-2.0.7/lib/rack/builder.rb:49:in `eval'
    45: from config.ru:in `<main>'
    44: from config.ru:in `new'
    43: from /Users/dev/.rvm/gems/ruby-2.5.5/gems/rack-2.0.7/lib/rack/builder.rb:55:in `initialize'
    42: from /Users/dev/.rvm/gems/ruby-2.5.5/gems/rack-2.0.7/lib/rack/builder.rb:55:in `instance_eval'
    41: from config.ru:3:in `block in <main>'
    40: from config.ru:3:in `require'
    39: from /Users/dev/projects-own/invoicing/redmine-4.0.4/config/environment.rb:14:in `<top (required)>'
    38: from /Users/dev/.rvm/gems/ruby-2.5.5/gems/railties-5.2.3/lib/rails/application.rb:361:in `initialize!'
    37: from /Users/dev/.rvm/gems/ruby-2.5.5/gems/railties-5.2.3/lib/rails/initializable.rb:60:in `run_initializers'
    36: from /Users/dev/.rvm/rubies/ruby-2.5.5/lib/ruby/2.5.0/tsort.rb:205:in `tsort_each'
    35: from /Users/dev/.rvm/rubies/ruby-2.5.5/lib/ruby/2.5.0/tsort.rb:226:in `tsort_each'
    34: from /Users/dev/.rvm/rubies/ruby-2.5.5/lib/ruby/2.5.0/tsort.rb:347:in `each_strongly_connected_component'
    33: from /Users/dev/.rvm/rubies/ruby-2.5.5/lib/ruby/2.5.0/tsort.rb:347:in `call'
    32: from /Users/dev/.rvm/rubies/ruby-2.5.5/lib/ruby/2.5.0/tsort.rb:347:in `each'
    31: from /Users/dev/.rvm/rubies/ruby-2.5.5/lib/ruby/2.5.0/tsort.rb:349:in `block in each_strongly_connected_component'
    30: from /Users/dev/.rvm/rubies/ruby-2.5.5/lib/ruby/2.5.0/tsort.rb:415:in `each_strongly_connected_component_from'
    29: from /Users/dev/.rvm/rubies/ruby-2.5.5/lib/ruby/2.5.0/tsort.rb:415:in `call'
    28: from /Users/dev/.rvm/gems/ruby-2.5.5/gems/railties-5.2.3/lib/rails/initializable.rb:50:in `tsort_each_child'
    27: from /Users/dev/.rvm/gems/ruby-2.5.5/gems/railties-5.2.3/lib/rails/initializable.rb:50:in `each'
    26: from /Users/dev/.rvm/rubies/ruby-2.5.5/lib/ruby/2.5.0/tsort.rb:421:in `block in each_strongly_connected_component_from'
    25: from /Users/dev/.rvm/rubies/ruby-2.5.5/lib/ruby/2.5.0/tsort.rb:431:in `each_strongly_connected_component_from'
    24: from /Users/dev/.rvm/rubies/ruby-2.5.5/lib/ruby/2.5.0/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from'
    23: from /Users/dev/.rvm/rubies/ruby-2.5.5/lib/ruby/2.5.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
    22: from /Users/dev/.rvm/rubies/ruby-2.5.5/lib/ruby/2.5.0/tsort.rb:228:in `block in tsort_each'
    21: from /Users/dev/.rvm/gems/ruby-2.5.5/gems/railties-5.2.3/lib/rails/initializable.rb:61:in `block in run_initializers'
    20: from /Users/dev/.rvm/gems/ruby-2.5.5/gems/railties-5.2.3/lib/rails/initializable.rb:32:in `run'
    19: from /Users/dev/.rvm/gems/ruby-2.5.5/gems/railties-5.2.3/lib/rails/initializable.rb:32:in `instance_exec'
    18: from /Users/dev/.rvm/gems/ruby-2.5.5/gems/railties-5.2.3/lib/rails/engine.rb:613:in `block in <class:Engine>'
    17: from /Users/dev/.rvm/gems/ruby-2.5.5/gems/railties-5.2.3/lib/rails/engine.rb:613:in `each'
    16: from /Users/dev/.rvm/gems/ruby-2.5.5/gems/railties-5.2.3/lib/rails/engine.rb:614:in `block (2 levels) in <class:Engine>'
    15: from /Users/dev/.rvm/gems/ruby-2.5.5/gems/railties-5.2.3/lib/rails/engine.rb:656:in `load_config_initializer'
    14: from /Users/dev/.rvm/gems/ruby-2.5.5/gems/activesupport-5.2.3/lib/active_support/notifications.rb:170:in `instrument'
    13: from /Users/dev/.rvm/gems/ruby-2.5.5/gems/railties-5.2.3/lib/rails/engine.rb:657:in `block in load_config_initializer'
    12: from /Users/dev/.rvm/gems/ruby-2.5.5/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:285:in `load'
    11: from /Users/dev/.rvm/gems/ruby-2.5.5/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:257:in `load_dependency'
    10: from /Users/dev/.rvm/gems/ruby-2.5.5/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:285:in `block in load'
     9: from /Users/dev/.rvm/gems/ruby-2.5.5/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:285:in `load'
     8: from /Users/dev/projects-own/invoicing/redmine-4.0.4/config/initializers/30-redmine.rb:21:in `<top (required)>'
     7: from /Users/dev/projects-own/invoicing/redmine-4.0.4/lib/redmine/plugin.rb:166:in `load'
     6: from /Users/dev/projects-own/invoicing/redmine-4.0.4/lib/redmine/plugin.rb:166:in `each'
     5: from /Users/dev/projects-own/invoicing/redmine-4.0.4/lib/redmine/plugin.rb:175:in `block in load'
     4: from /Users/dev/.rvm/gems/ruby-2.5.5/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `require'
     3: from /Users/dev/.rvm/gems/ruby-2.5.5/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:257:in `load_dependency'
     2: from /Users/dev/.rvm/gems/ruby-2.5.5/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `block in require'
     1: from /Users/dev/.rvm/gems/ruby-2.5.5/gems/activesupport-5.2.3/lib/active_support/dependencies.rb:291:in `require'
/Users/dev/projects-own/invoicing/redmine-4.0.4/plugins/clipboard_image_paste-master/init.rb:32:in `<top (required)>': undefined method `to_prepare' for ActionDispatch::Callbacks:Class (NoMethodError)
Did you mean?  to_param

Process finished with exit code 1
RolandSM commented 4 years ago

Hello, I can conrifrm that also current #85 did not work with Redmine 4.0.4 I changed to_prepare to to_param inside the init.rb but this also wont work. Please help.

ghost commented 4 years ago

Hello, I found a partial solution. It solves this and the plugin appears but when the issue saved I got another issue.

For fixing this, you need to replace this line to init.rb:

ActionDispatch::Callbacks.to_prepare do to these:

dispatcher = Rails.version < '5.1' ? ActionDispatch::Callbacks : ActiveSupport::Reloader dispatcher.to_prepare do After this, you need to patch the attachment_patch.rb replace this line: alias_method_chain :save_attachments, :pasted_images to this: alias_method :save_attachments, :save_attachments_with_pasted_images

After these modification, the plugin works fine, but the saving don't.

Sorry, I give up at this point. (I'm not a ruby developer)

Any help would be greatly appreciated!

RolandSM commented 4 years ago

Great. If the saving process works I will try it again. I´m also not a ruby developer and completely lost in code.

fraoustin commented 4 years ago

You can test my version https://github.com/fraoustin/clipboard_image_paste.git

fraoustin commented 4 years ago

better try https://github.com/thorin/redmine_image_clipboard_paste.git

ghost commented 4 years ago

better try https://github.com/thorin/redmine_image_clipboard_paste.git

It's working. Thanks a lot!

giRobert commented 4 years ago

better try https://github.com/thorin/redmine_image_clipboard_paste.git

It's working. Thanks a lot!

Well here it is not working! Tried it in Redmine 4.0.4.stable. Installation works and drag and drop too. But not copying from clipboard.

fraoustin commented 4 years ago

I use docker for run redmine, my Dockerfile

FROM redmine WORKDIR /usr/src/redmine/plugins RUN git clone https://github.com/thorin/redmine_image_clipboard_paste WORKDIR /usr/src/redmine/

and it's run: copying from clipboard a screenshot

I use chrome and firefox

giRobert commented 4 years ago

I tested it on two machines now with different Firefox versions AND Chrome. Windows 7 and windows 10. Clipboard copy doenst work. Only drag and drop. Can you explain me how you copy from clipboard? I tried it with an existing image by klicking "copy" and also tried it with copying directly from snipping tool. I inserted it with CTRL + V in a comment and in a ticket description.

unfortunately it didnt work.

fraoustin commented 4 years ago

nothing special, just click on "print screen" of my keyboard, after click on input description of my new issue and after CRTL+V ...

fraoustin commented 4 years ago

Do y ou have activate javascript or security in you browser?

giRobert commented 4 years ago

I had no special settings no... i did some more research and found that "image_paste.js" was not loaded. 404 not found. i uninstalled the plugin again, removed the "-master" folder ending in plugins folder and reinstalled it. now it works fine. maybe that was the reason? my plugin folder is now called "redmine_image_clipboard_paste". i have no clue. for sure the problem was that the js was not loaded. now its working. thanks anyway for caring!

giRobert commented 4 years ago

But I found another problem. When I edit an existing ticket comment then I can not paste any screenshot there. It pasted the screenshot insert code but i guess the reference file is not uploaded and so its not be converted into a real image.

I could imagine this is a redmine limitation because there is no file upload when editing comments right?

if thats the reason there should be a check in JS like "If file upload existing => do as it works now => ELSE => dont paste the insert code!" this way we could avoid to confuse the user. The user thinks that paste worked and he looses the screenshot if he is not double checking it. Maybe its event better to paste a message "Screenshot copy is not working here". Then its clear. you know what I mean?

fraoustin commented 4 years ago

I understand: if you change a issue (not add note issue but change description) the CRTL V add "link" but not file ... it's ok ? But on my computer don't have the same bug: when CRTL-V in input note or description it's ok: add link and file. I am sorry, and it's possible to add your problem in https://github.com/thorin/redmine_image_clipboard_paste (I am not a redmine_image_clipboard_paste developper) , maybe the developper can you help

Have you checked your authorization in redmine?

CNPF commented 4 years ago

https://github.com/thorin/redmine_image_clipboard_paste.git

It's working on redmine 4.1.0. Thanks a lot!