Launching an editor in HTML documents
I'd like to edit HTML document by adding a button and launching an editor.
For example, I add the button in HTML (/abc/def/hello.html),
<button type="button">Edit Code</button>
And by clicking the Edit Button
, I want to launch an editor (TextMate for example, or any other editing software) opening /abc/def/hello.html
.
Of course, the editing is possible on开发者_运维百科ly with the machine that made the /abc/def/hello.html
file.
How can I do that?
ADDED
If it's not possible to open an editor, is it possible to store the file information into the clipboard or show it with dialog box? I'll give the name of the file, so the job should be easy as it's just showing the file name when user clicks.
You're going to need some server-side scripting to support this.
First invent your own mimtype, call it application/x-prosseek-edit, then make your button a link to a script which generates your 'application/x-prosseek-edit' file (and serves it up with that mime type). The file itself should contain a machine readable version of how to retrieve the file and launch it in your editor. e.g.
<?php
header('Content-Type: application/x-prosseek-edit');
print $_SERVER['DOCUMENT_ROOT'] . $_GET['file_to_edit'] . "\n";
Then create a handler script to associate the mimetype with an application (again using PHP as an example):
#!/usr/bin/php -q
<?php
$fname=file_get_contents($argv[1]);
exec('/usr/bin/my_editor $fname');
With a bit of imagination you can define transport mechanisms to create a local copy of the file and copy it back when editing is complete.
I'm not sure exactly what you are looking for but this may help Firebug Lite
Allows you to embed firebug into any of your pages so that you can edit your code, not sure about saving it.
This is not a general solution, but it works fine with Mac/TextMate that I'm using. Please refer to my other question.
I can just have an action to open txmt protocol, and by clicking a button, I can launch an editor with the file that I want to edit.
<form action="txmt://open/?url=file:///Users/smcho/smcho/bin/rst2html" method="post">
<button type="submit" name="link" value="/Users/smcho/smcho/works/prgtask/ni/gtest_boost_options/readme.txt">Vote</button>
</form>
精彩评论