I created this a while back, but I had forgotten about it until a recent discussion of Drag Commands.
If you're using the pre-insalled Apache under Mac OS X, the DocumentRoot is set to `/Library/WebServer/Documents/`. I try to avoid attachments as much as possible, so I'll usually put a file in that location and just send people a URL that leads them to it. To make this easier, I created a Drag Command that applies to any file in that directory. For example, if I drop /Library/WebServer/ Documents/some.zip in a document, it inserts http:// kendra.oit.gatech.edu/some.zip instead.
It's currently scoped to "text.mail,text.html" and I usually only use it for e-mail, but perhaps it should be scoped for all "text"? Anyway, I thought this might be a useful addition to the Mail or Text bundle.
On a related note, what's the preferred way to say "I thought this might be a useful addition to the XYZ bundle"? :)
FYI - If you're looking at the command and wondering why all the gymnastics to get the Fully Qualified Domain Name for the local machine, it is intended to work in either of these situations:
1. `hostname` returns something appropriate, like "kendra" and `domainname` returns something appropriate like "oit.gatech.edu".
2. `hostname` erroneously returns the FQDN (like "kendra.oit.gatech.edu") and `domainname` returns nothing at all. (For reasons unknown, I think most systems are misconfigured like this by default.)
--- Rob McBroom http://www.skurfer.com/ I didn't "switch" to Apple... my OS did.
On 9. May 2007, at 22:54, Rob McBroom wrote:
I created this a while back, but I had forgotten about it until a recent discussion of Drag Commands.
If you're using the pre-insalled Apache under Mac OS X, the DocumentRoot is set to `/Library/WebServer/Documents/`. I try to avoid attachments as much as possible, so I'll usually put a file in that location and just send people a URL that leads them to it. To make this easier, I created a Drag Command that applies to any file in that directory. For example, if I drop /Library/WebServer/ Documents/some.zip in a document, it inserts http:// kendra.oit.gatech.edu/some.zip instead.
That’s a nice idea. I have something akin to this using Quicksilver, where if I ⌘⎋ a file while in Finder, Quicksilver will upload it to my server, and put the resulting link on the clipboard (unfortunately ⌘⎋ fails me quite often as a hotkey).
Anyway, for this bundle item I have two comments:
1) it doesn’t find my fully qualified domain name, so we need: a) a note about how the user can set it up!?! b) a fallback variable or so for the domain name 2) would be nice if it allowed to copy files not in ~/Sites or / Library/WebServer/Documents to be copied to some “temporary” folder of either location. That way, we can drag arbitrary files to the letter, not just those already located in the right location.
It's currently scoped to "text.mail,text.html" and I usually only use it for e-mail, but perhaps it should be scoped for all "text"? Anyway, I thought this might be a useful addition to the Mail or Text bundle.
I think currently it should be limited to text.mail.
On a related note, what's the preferred way to say "I thought this might be a useful addition to the XYZ bundle"? :)
Just send it here :)
On May 11, 2007, at 5:06 AM, Allan Odgaard wrote:
Anyway, for this bundle item I have two comments:
- it doesn’t find my fully qualified domain name, so we need: a) a note about how the user can set it up!?! b) a fallback variable or so for the domain name
Ah, I suppose that on most systems, the FQDN won't be stored *anywhere* - not even in the wrong place. Instead, you'll see something like "Allan's-PowerBook-G4". Dammit, I thought TextMate users were nerds. ;) If we can't count on the local system, perhaps the command could look for a user defined variable and if it's not set, go to an external service to get a name (similar to the "Get Remote IP" script in Quicksilver's Extra Scripts plug-in). I don't see how we could have a hard-coded fallback that would be appropriate for everyone (unless we made it something awful like `set.TM_WEBSERVER.to.your.systems.fully.qaulified.domain.name.com`), which is a combination of both a and b.
- would be nice if it allowed to copy files not in ~/Sites or /
Library/WebServer/Documents to be copied to some “temporary” folder of either location. That way, we can drag arbitrary files to the letter, not just those already located in the right location.
So you're saying any file dropped into a text.mail scope would be copied to the temporary location (and a link inserted)? I might like that better. I'll have to think about it. Some questions:
* If the temporary location doesn't exist, should the command create it or is that inappropriate?
* How would it decide whether to use ~/Sites or /Library/WebServer/ Documents? Perhaps we could check for TM_DOCUMENTROOT and fall back to /Library/WebServer/Documents if it's not set. This would also be nice for people like Allan who use another system as the web server because the path could be anywhere (as long as it's always mounted, which it sounds like it is in Allan's case).
* Should we use `ln` instead of copying (mostly to prevent the command from waiting on the copy operation, but also for disk space)? Ideally, this is how it should work in my mind:
* If the file is on the same filesystem as the DocumentRoot, create a hard link * If the file is on a remote system and the DocumentRoot is on the local disk, create a symbolic link * If the DocumentRoot is on a remote system, copy the file regardless of where it comes from (this could make the command very slow)
Sound about right?
--- Rob McBroom http://www.skurfer.com/ I didn't "switch" to Apple... my OS did.
After a long delay (been busy with work stuff), I've taken some time to work on this Drag Command according to suggestions.
To refresh your memory, this command lets you drag a file into an e- mail message and have a link to the file on your web server inserted (instead of sending it as an attachment).
On May 11, 2007, at 5:06 AM, Allan Odgaard wrote:
On 9. May 2007, at 22:54, Rob McBroom wrote:
I created this a while back, but I had forgotten about it until a recent discussion of Drag Commands.
Anyway, for this bundle item I have two comments:
- it doesn’t find my fully qualified domain name, so we need: a) a note about how the user can set it up!?! b) a fallback variable or so for the domain name
You can now set TM_FQDN to your machine's fully qualified domain name to override whatever `hostname` and `domainname` return. There is a comment about this in the command's source.
- would be nice if it allowed to copy files not in ~/Sites or /
Library/WebServer/Documents to be copied to some “temporary” folder of either location. That way, we can drag arbitrary files to the letter, not just those already located in the right location.
The command now handles files in either `/Library/WebServer/Documents/ ` or `~/Sites/` correctly, but I didn't implement the "copy from any location part" because of the following concerns.
1. The temporary location would need to be created if it didn't exist. I don't know about you, but I would be irritated if a bundle item created new directories without asking. Perhaps the temp folder's name could be set in a TM_ variable and if it doesn't exist, the command does nothing? Or outputs some warning text?
2. Would the temporary location be a sub-directory of `/Library/ WebServer/Documents/` or `~/Sites/`? Or would the proposed TM_ variable from #1 just contain the whole path?
3. The copy operation could take a long time. (I'm guessing too long in some cases.) This could be solved by hard-linking instead of copying, but that only works if the operation involves a single filesystem. Is it possible to insert the link text and let the copy operation continue in the background (on the assumption that by the time you send your message and someone reads it, the file will be there)?
I think currently it should be limited to text.mail.
Done.
--- Rob http://www.skurfer.com/