rabbit-shocker/rabbit

print auto title should sanitize / (or use filename?)

Closed this issue · 6 comments

Hi, thanks for rabbit! I had a lot of fun today figuring out how themes work and tailoring my own.

I took some time to understand why rabbit -p gave this error:

Cairo::WriteError: error while writing to output stream
/src/rabbit/lib/rabbit/renderer/printer.rb:198:in `initialize'
/src/rabbit/lib/rabbit/renderer/printer.rb:198:in `new'
/src/rabbit/lib/rabbit/renderer/printer.rb:198:in `find_surface'
/src/rabbit/lib/rabbit/renderer/printer.rb:180:in `create_context'
/src/rabbit/lib/rabbit/renderer/printer.rb:79:in `pre_print'
/src/rabbit/lib/rabbit/renderer/base.rb:256:in `do_print'
/src/rabbit/lib/rabbit/renderer/base.rb:88:in `print'
/src/rabbit/lib/rabbit/canvas.rb:401:in `block in print'
/src/rabbit/lib/rabbit/canvas.rb:713:in `process'
/src/rabbit/lib/rabbit/canvas.rb:400:in `print'
/src/rabbit/lib/rabbit/command/rabbit.rb:812:in `do_print'
/src/rabbit/lib/rabbit/command/rabbit.rb:61:in `block (2 levels) in run'
/src/rabbit/lib/rabbit/command/rabbit.rb:59:in `catch'
/src/rabbit/lib/rabbit/command/rabbit.rb:59:in `block in run'
/usr/share/gems/gems/gobject-introspection-3.2.9/lib/gobject-introspection/loader.rb:587:in `invoke'
/usr/share/gems/gems/gobject-introspection-3.2.9/lib/gobject-introspection/loader.rb:587:in `block in define_method'
/src/rabbit/lib/rabbit/command/rabbit.rb:54:in `block in run'
/usr/share/gems/gems/gobject-introspection-3.2.9/lib/gobject-introspection/loader.rb:587:in `invoke'
/usr/share/gems/gems/gobject-introspection-3.2.9/lib/gobject-introspection/loader.rb:587:in `block in define_method'
/src/rabbit/lib/rabbit/command/rabbit.rb:67:in `run'
/src/rabbit/lib/rabbit/command/rabbit.rb:29:in `run'
/src/rabbit/bin/rabbit:22:in `<main>'

because I assumed it would use the input file name (e.g. talk.rd) and substitute the extension with .pdf ; but it actually uses the talk's title... Which for me contained a /, and that didn't work so well :)

My personal opinion is that using the filename would be more intuitive (that is what I had expected), but if we're going to use the title we'll need to strip the slashes off - something like the following works but it might be better to replace it with... something?

diff --git a/lib/rabbit/renderer/printer.rb b/lib/rabbit/renderer/printer.rb
index 1c4c8bcf..071a541f 100644
--- a/lib/rabbit/renderer/printer.rb
+++ b/lib/rabbit/renderer/printer.rb
@@ -137,7 +137,7 @@ module Rabbit
 
       private
       def default_filename
-        "#{GLib.filename_from_utf8(@canvas.title.gsub(/\n/, ''))}.pdf"
+        "#{GLib.filename_from_utf8(@canvas.title.gsub(/[\n\/]/, ''))}.pdf"
       end
 
       def init_paper

Also, if we're staying with the title, I believe we should print it to the user so they know where the file will be. I'm sure users can figure it out eventually, but if the title is fairly different from the filename like it was in my case that can be confusing.

よろしくお願いします

PS: totally unrelated, the "archive" link in https://rabbit-shocker.org/en/users.html points to http://www.cozmixng.org/~w3ml/index.rb/rabbit-shocker-en/ which gives an internal server error

Oh, just noticed by mistake that the "save current slide to image" key has the same problem (I really can't seem to get the search function to work); except that this one created the directory so it didn't cause an error.

kou commented

Thanks for your report!
I've fixed it.

PS: totally unrelated, the "archive" link in https://rabbit-shocker.org/en/users.html points to http://www.cozmixng.org/~w3ml/index.rb/rabbit-shocker-en/ which gives an internal server error

It's known issue. I want to fix it but ...

Still making it the title and not the file name I see. I'll just have to change my source filename to match the title then! :)

Thank you for both fixes.
Is there an irc channel or some informal place to discuss things? I'm struggling a bit with variables used in themes, but it feels a bit wrong to open an issue for user help, and I'm not ready to join the mailing list yet. 日本語ならいい練習になりそうなので、それでも大歓迎です。

早かったですね、ありがとうございます。

kou commented

Ah, mailing list isn't broken. Mailing list archive is only broken. You can use the shocker-en mailing list.

And mailing list archive is back again. :-)

kou commented

You can use issue for the propose.

It's just not the same :) Thanks again, will get around to sending a mail eventually.