Hello,
is there any way to add support for non-image files when dragged onto the TM window; these files should be linked and uploaded to the serves as are images?!
thx,
Dan
On 11/1/06, Daniel Käsmayr daniel@kaesmayr.net wrote:
Hello,
is there any way to add support for non-image files when dragged onto the TM window; these files should be linked and uploaded to the serves as are images?!
Check the manual for "Drag Commands":
http://macromates.com/textmate/manual/drag_commands#drag_commands
It should be pretty easy to build a command that suits your needs.
Here's a sample command I use a lot:
echo -n "<link rel="shortcut icon" href="$TM_DROPPED_FILE" />"
It's defined for files of type "ico", and scoped to work for HTML only.
Hope it helps
-- Ale Muñoz http://sofanaranja.com http://appleweblog.com
Thanks Ale,
I will look into doing that… in case the original maintainer of the bundle doesn't feel like he wants to do it himself.
Is there a way to also acceept dragged URLs from other apps and have them be treated as such?
Dan
On Nov 1, 2006, at 12:44 PM, Daniel Käsmayr wrote:
Is there a way to also acceept dragged URLs from other apps and have them be treated as such?
Not yet possible, for the urls. But you CAN set your drag command to accept all files, regardless of exception, by using the wildcard operator "*" in place of file extensions.
Dan
Haris
On 1. Nov 2006, at 18:44, Daniel Käsmayr wrote:
I will look into doing that… in case the original maintainer of the bundle doesn't feel like he wants to do it himself.
Both Brad Choate and I would love a patch for this :) FYI you can use * as extension for a new drag command, then it gets all the drops not handled by the image drag command.
Is there a way to also acceept dragged URLs from other apps and have them be treated as such?
Currently not, no.
Hello Allan,
I don't know about patches, but this will, at least upload files and insert Markdown/<a href> links to the uploaded file… I don't know about textile, so feel free to add that. Of course, it would be much more clean if one had just one method for uploading but the hack works, I believe.
As for the dragged URLs: this would need to be done on a TextMate level, but the dragged item should be noted as URL by the OS, and as such we would just need some mechanism for accepting it ;) I guess it would take Allan about -56 seconds to do so, and yes I have read the "bug reporting how to" by ranchero.com ;)
Just add this to blogging.rb
def upload_file require "#{ENV['TM_SUPPORT_PATH']}/lib/progress.rb" require "#{ENV['TM_SUPPORT_PATH']}/lib/escape.rb" require 'xmlrpc/base64'
# Makes sure endpoint is determined and elements are parsed current_password = password
# The packet we will be constructing data = {}
full_path = ENV['TM_DROPPED_FILEPATH'] upload_name, alt = upload_name_for_path(full_path)
data['name'] = upload_name data['bits'] = XMLRPC::Base64.new(IO.read(full_path))
TextMate.call_with_progress(:title => "Upload File", :message => "Uploading to Server “#{@host}”…") do begin result = client.newMediaObject(self.blog_id, self.username, current_password, data) url = result['url'] if url case ENV['TM_SCOPE'] when /.markdown/ print "[${1:#{alt}}](#{url})" else print %Q{<a href="#{url}" alt="${1:#{CGI::escapeHTML alt}}"#{height_width}#{ENV['TM_XHTML']}>} end else TextMate.exit_show_tool_tip("Error uploading file.") end rescue XMLRPC::FaultException => e TextMate.exit_show_tool_tip("Error uploading file. Check your configuration and try again.") end
Dan
PS: Thanks to the original blogging.rb code and the fact that ruby is so easy to read and understand, even for non-rubyists like myself ;)
This just needs a couple of tweaks. First, the upload_name_for_path should be rewritten for this purpose to preserve the filename whenever possible, replace Upload Image in the dialog box with Upload File, and indicate that the text entered will be the text of the URL. The HTML portion that you've included is incorrect and needs to be something more like: print %Q{<a href="#{url}">#{alt}</a>}. Alt could come back as just plain text without underscores or anything and there's no need for width and height.
Your def is also missing two end statements at the end of it... just for reference ;-).
I also think that, for the sake of inclusiveness, the command should be scoped to handle just about anything besides images but ask first before uploading with a quick yes/no dialog.
I've got a working version right now but am adding some of the above ideas. If anyone is interested I'll tweak it up and send it along to add to the discussion.
Brett
On Nov 1, 2006, at 2:03 PM, Daniel Käsmayr wrote:
Hello Allan,
I don't know about patches, but this will, at least upload files and insert Markdown/<a href> links to the uploaded file… I don't know about textile, so feel free to add that. Of course, it would be much more clean if one had just one method for uploading but the hack works, I believe.
As for the dragged URLs: this would need to be done on a TextMate level, but the dragged item should be noted as URL by the OS, and as such we would just need some mechanism for accepting it ;) I guess it would take Allan about -56 seconds to do so, and yes I have read the "bug reporting how to" by ranchero.com ;)
Just add this to blogging.rb
def upload_file require "#{ENV['TM_SUPPORT_PATH']}/lib/progress.rb" require "#{ENV['TM_SUPPORT_PATH']}/lib/escape.rb" require 'xmlrpc/base64'
# Makes sure endpoint is determined and elements are parsed current_password = password # The packet we will be constructing data = {} full_path = ENV['TM_DROPPED_FILEPATH'] upload_name, alt = upload_name_for_path(full_path) data['name'] = upload_name data['bits'] = XMLRPC::Base64.new(IO.read(full_path)) TextMate.call_with_progress(:title => "Upload File", :message
=> "Uploading to Server “#{@host}”…") do begin result = client.newMediaObject(self.blog_id, self.username, current_password, data) url = result['url'] if url case ENV['TM_SCOPE'] when /.markdown/ print "[${1:#{alt}}](#{url})" else print %Q{<a href="#{url}" alt="${1:#{CGI::escapeHTML alt}}"#{height_width}#{ENV['TM_XHTML']}>} end else TextMate.exit_show_tool_tip("Error uploading file.") end rescue XMLRPC::FaultException => e TextMate.exit_show_tool_tip("Error uploading file. Check your configuration and try again.") end
Dan
PS: Thanks to the original blogging.rb code and the fact that ruby is so easy to read and understand, even for non-rubyists like myself ;) ______________________________________________________________________ For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
Brett Terpstra : Art Director Circle Six Design, Inc. 111 Riverfront Dr, Suite 204 .................................................. p: 507.459.4398 877.858.4332 f: 1.866.540.3063 e: brett@circlesixdesign.com http://www.circlesixdesign.com ..................................................
Brett,
thanks for correcting my quick hack… I was just happy that it works with my stuff and inserts markdown code.
but…
Am 2. Nov 2006 um 03:27 schrieb Brett Terpstra:
I've got a working version right now but am adding some of the above ideas. If anyone is interested I'll tweak it up and send it along to add to the discussion.
…you definitely should post your superified version of it! ;)
Dan
PS: can I have a birthday edition of TM?
I'm probably being daft about something, but could someone take a look at my modification to blogging.rb and tell me why it errors out on different files? It seems to deal alright with small zip files, but files of type dmg or tbz or anything other than zip, or files larger than about 500k cause a variety of errors. I'm not sure if the problem lies with Wordpress or my methods.
Thanks for any help.
Brett
http://pastie.textmate.org/20837
On Nov 2, 2006, at 1:22 AM, Daniel Käsmayr wrote:
Brett,
thanks for correcting my quick hack… I was just happy that it works with my stuff and inserts markdown code.
but…
Am 2. Nov 2006 um 03:27 schrieb Brett Terpstra:
I've got a working version right now but am adding some of the above ideas. If anyone is interested I'll tweak it up and send it along to add to the discussion.
…you definitely should post your superified version of it! ;)
Dan
PS: can I have a birthday edition of TM?
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
Brett Terpstra : Art Director Circle Six Design, Inc. 111 Riverfront Dr, Suite 204 .................................................. p: 507.459.4398 877.858.4332 f: 1.866.540.3063 e: brett@circlesixdesign.com http://www.circlesixdesign.com ..................................................
Just a little more info, here are some specs for successes and failures:
Microformats.zip 4Kb ok
SIMBL.tbz 28Kb Error uploading file. Check your configuration and try again. XMLRPC::FaultException
SurveyGizmo-Plugin.zip 12Kb ok
garyscookbook_2_1.zip 332Kb ok
KeyCue21-Install.dmg 596 Kb Error uploading file. Check your configuration and try again. XMLRPC::FaultException
KeyCue21-Install.dmg.zip 584Kb Ok (I just made an archive from the above file)
Any file larger than that gets this:
/usr/lib/ruby/1.8/xmlrpc/client.rb:535:in /bin/bash: -c: line 1: unexpected EOF while looking for matching `'' /bin/bash: -c: line 3: syntax error: unexpected end of filecall2' from /usr/lib/ruby/1.8/xmlrpc/client.rb:399:in /bin/bash: -c: line 1: unexpected EOF while looking for matching `'' /bin/bash: -c: line 3: syntax error: unexpected end of filenewMediaObject' from /Users/brett/Library/Application Support/TextMate/Pristine Copy/ Bundles/Brett Terpstra’s Bundle.tmbundle/Support/lib/blogging.rb: 833:in /bin/bash: -c: line 1: unexpected EOF while looking for matching `'' /bin/bash: -c: line 3: syntax error: unexpected end of filepopen' from /Users/brett/Library/Application Support/TextMate/Support/lib/ progress.rb:11:in /bin/bash: -c: line 1: unexpected EOF while looking for matching `'' /bin/bash: -c: line 3: syntax error: unexpected end of fileupload_file' from /tmp/temp_textmate.AmdZT3:3
On Nov 2, 2006, at 5:48 AM, Brett Terpstra wrote:
I'm probably being daft about something, but could someone take a look at my modification to blogging.rb and tell me why it errors out on different files? It seems to deal alright with small zip files, but files of type dmg or tbz or anything other than zip, or files larger than about 500k cause a variety of errors. I'm not sure if the problem lies with Wordpress or my methods.
Thanks for any help.
Brett
http://pastie.textmate.org/20837
On Nov 2, 2006, at 1:22 AM, Daniel Käsmayr wrote:
Brett,
thanks for correcting my quick hack… I was just happy that it works with my stuff and inserts markdown code.
but…
Am 2. Nov 2006 um 03:27 schrieb Brett Terpstra:
I've got a working version right now but am adding some of the above ideas. If anyone is interested I'll tweak it up and send it along to add to the discussion.
…you definitely should post your superified version of it! ;)
Dan
PS: can I have a birthday edition of TM?
_ For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
Brett Terpstra : Art Director Circle Six Design, Inc. 111 Riverfront Dr, Suite 204 .................................................. p: 507.459.4398 877.858.4332 f: 1.866.540.3063 e: brett@circlesixdesign.com http://www.circlesixdesign.com ..................................................
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
Brett Terpstra : Art Director Circle Six Design, Inc. 111 Riverfront Dr, Suite 204 .................................................. p: 507.459.4398 877.858.4332 f: 1.866.540.3063 e: brett@circlesixdesign.com http://www.circlesixdesign.com ..................................................
Update for those interested: I registered the offending MIME types with Wordpress and cured some of the errors. For example, setting DMG files to application/octet-stream in Wordpress allowed me to upload smaller DMG files without getting the FaultException from XMLRPC.
I've noticed that in bloggin.rb it never sets the data type before the newMediaObject call. Everything I can find says that this is a required field. What happens when it's not set? Can you force it to ignore or set it to a default? I attempted to add a MIME::Types library and determine the type but it didn't make a difference to Wordpress.
I'm still getting the last error on large files. The upload limit on my server is set to 20 megs, but I think I'm running into a timeout. I can issue a set_time_limit(1000) in the xmlrpc.php file right before the upload, which seems to override it for a couple of minutes but I still get the error, so I'm not sure that the timeout is the answer. If anyone has any suggestions I'd love to hear them.
In short, while I'd love to see this working and a part of the blogging bundle, if it requires this much server hacking I think I'll stick with my usual method of FTP and hand coding links. Actually, it would be relatively simple to set up a Transmit script to send to your wordpress upload folder and then build a drag command to upload the dropped file with docksend and return a url based on the upload directory...
Brett
On Nov 2, 2006, at 5:53 AM, Brett Terpstra wrote:
Just a little more info, here are some specs for successes and failures:
Microformats.zip 4Kb ok
SIMBL.tbz 28Kb Error uploading file. Check your configuration and try again. XMLRPC::FaultException
SurveyGizmo-Plugin.zip 12Kb ok
garyscookbook_2_1.zip 332Kb ok
KeyCue21-Install.dmg 596 Kb Error uploading file. Check your configuration and try again. XMLRPC::FaultException
KeyCue21-Install.dmg.zip 584Kb Ok (I just made an archive from the above file)
Any file larger than that gets this:
/usr/lib/ruby/1.8/xmlrpc/client.rb:535:in /bin/bash: -c: line 1: unexpected EOF while looking for matching `'' /bin/bash: -c: line 3: syntax error: unexpected end of filecall2' from /usr/lib/ruby/1.8/xmlrpc/client.rb:399:in /bin/bash: -c: line 1: unexpected EOF while looking for matching `'' /bin/bash: -c: line 3: syntax error: unexpected end of filenewMediaObject' from /Users/brett/Library/Application Support/TextMate/Pristine Copy/Bundles/Brett Terpstra’s Bundle.tmbundle/Support/lib/ blogging.rb:833:in /bin/bash: -c: line 1: unexpected EOF while looking for matching `'' /bin/bash: -c: line 3: syntax error: unexpected end of filepopen' from /Users/brett/Library/Application Support/TextMate/Support/lib/ progress.rb:11:in /bin/bash: -c: line 1: unexpected EOF while looking for matching `'' /bin/bash: -c: line 3: syntax error: unexpected end of fileupload_file' from /tmp/temp_textmate.AmdZT3:3
On Nov 2, 2006, at 5:48 AM, Brett Terpstra wrote:
I'm probably being daft about something, but could someone take a look at my modification to blogging.rb and tell me why it errors out on different files? It seems to deal alright with small zip files, but files of type dmg or tbz or anything other than zip, or files larger than about 500k cause a variety of errors. I'm not sure if the problem lies with Wordpress or my methods.
Thanks for any help.
Brett
http://pastie.textmate.org/20837
On Nov 2, 2006, at 1:22 AM, Daniel Käsmayr wrote:
Brett,
thanks for correcting my quick hack… I was just happy that it works with my stuff and inserts markdown code.
but…
Am 2. Nov 2006 um 03:27 schrieb Brett Terpstra:
I've got a working version right now but am adding some of the above ideas. If anyone is interested I'll tweak it up and send it along to add to the discussion.
…you definitely should post your superified version of it! ;)
Dan
PS: can I have a birthday edition of TM?
__ For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
Brett Terpstra : Art Director Circle Six Design, Inc. 111 Riverfront Dr, Suite 204 .................................................. p: 507.459.4398 877.858.4332 f: 1.866.540.3063 e: brett@circlesixdesign.com http://www.circlesixdesign.com ..................................................
_ For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
Brett Terpstra : Art Director Circle Six Design, Inc. 111 Riverfront Dr, Suite 204 .................................................. p: 507.459.4398 877.858.4332 f: 1.866.540.3063 e: brett@circlesixdesign.com http://www.circlesixdesign.com ..................................................
For new threads USE THIS: textmate@lists.macromates.com (threading gets destroyed and the universe will collapse if you don't) http://lists.macromates.com/mailman/listinfo/textmate
Brett Terpstra : Art Director Circle Six Design, Inc. 111 Riverfront Dr, Suite 204 .................................................. p: 507.459.4398 877.858.4332 f: 1.866.540.3063 e: brett@circlesixdesign.com http://www.circlesixdesign.com ..................................................
On 2. Nov 2006, at 12:48, Brett Terpstra wrote:
I'm probably being daft about something, but could someone take a look at my modification to blogging.rb and tell me why it errors out on different files? It seems to deal alright with small zip files, but files of type dmg or tbz or anything other than zip, or files larger than about 500k cause a variety of errors. I'm not sure if the problem lies with Wordpress or my methods.
I tested it and found no problems, e.g. 1.8 MB tbz archive uploaded fine, so did a DMG, a PDF, etc.
PHP defaults to a 2 MB upload size limit [1], perhaps yours is somehow set lower.
As for zip versus other file types… maybe something about the server not liking unknown mime-types? You should enable the server log for xmlrpc.php.