Configure Editors

182 views
Skip to first unread message

Lawrence San

unread,
Jun 10, 2014, 5:39:08 PM6/10/14
to fir...@googlegroups.com
From reading an earlier post in this group, I just discovered the Open With Editor command in Firebug, which I never noticed before.

Background: I run a local devel server (Apache) on the same Mac that I use for browsing and editing web pages, so the "server file" and the "local dev file" is actually the same file residing on the same machine. I normally open it in Firefox as a .dev URL, not as a "file" (so all my scripts will work, among other things).

However, using a Firefox extension called Dafzilla ViewSourceWith, I've been able to set up a mapping that correlates the URLs with the local files. For example, when Firefox shows the URL of the current page as:

   http://sanstudio.dev/test/linktest.html

...I can click on the ViewSourceWith button in the Firefox toolbar, and my text editor (BBEdit) will open the "local" file that my local Apache used to actually generate that URL:

   /Volumes/MyHardDrive/MyDevFolder/test/linktest.html

That's my real master source file, not some cached copy. This is extremely useful to me, but ViewSourceWith doesn't always work with every version of Firefox.

So I thought it might be possible to get a similar mapping into Firebug using the Open With Editor dialog. It was easy to add BBEdit as the editor; that works fine. However, when BBEdit opens a page via Firebug that way, it's always opening the temporary cached file that the browser uses, not the real local source file the way ViewSourceWith does.

So I played with Firebug's "Launch Arguments" in the Configure Editors dialog, trying to figure out how to add a mapping, presumably using the %file parameter. I tried various things like:

    %file /Volumes/MyHardDrive/MyDevFolder/

... and various other things, but when I click the "test" button, every argument format I've tried either opens Firefox's cached temporary file (same as if I had entered no arguments) or does nothing at all.

I did a lot of Googling trying to find *specifically* how you enter the text in the Arguments box, and I looked through the examples in the dialog's popdown menu, and I still got nowhere.

Next to the %file text-entry box there's a hint that says "Path to the local file (or to the temporary copy)" which certainly sounds like it doesn't *have* to be the temporary copy. Is it possible to do what I want with the Configure Editors dialog? Can anybody tell me how to enter the argument? Thanks.

Andrei

unread,
Jun 12, 2014, 11:14:52 AM6/12/14
to fir...@googlegroups.com
Is the same problem I am acing on local machine. On localhost it doesn't do anything, however, it works on a remote URL.
You can see more discussion in this older post:
https://groups.google.com/forum/#!topic/firebug/5gp45wiFtvg

How i configured is using a PHP script
Line commands:
Executable: path to PHP executable
Arguments:c:\path_to_php_file"%url" /%line

inside the PHP file I translate the URL argument($argv[1]) into filesystem path(I use xampp), and then open the file with pspad at line $argv[2]. The localhost condition doesn't work, but you can change the yourdomain.com condition as you need, that one works

<?php

if(preg_match("/^http\:\/\/localhost/",$argv[1])) {
    $argv[1] = preg_replace(array("/^http\:\/\/localhost/","/\?.+$/"), array("C:\xampp\htdocs",""),$argv[1]);
}

if(preg_match("/^http\:\/\/yourdomain.com/",$argv[1])) {// if http://yourdomain.com/styles.css corresponds to C:\xampp\htdocs\project\styles.css
    $argv[1] = preg_replace(array("/^http\:\/\/yourdomain.com/","/\?.+$/"), array("C:\xampp\htdocs\project",""),$argv[1]);
}

system('"c:\\Program Files (x86)\\PSPad editor\\PSPad.exe" '.$argv[1]." ". $argv[2]);
?>

Lawrence San

unread,
Jun 12, 2014, 2:14:37 PM6/12/14
to fir...@googlegroups.com
I'm using MAMP on a Mac, not XAMPP on Windows. Also I only know a little PHP; I can't follow the opening "Line Commands/Executable/Arguments" part of your code. (Is that even code, or just a comment of some kind?) Perhaps a bigger difference is that I'm not using "http://localhost"...  As I said, I've configured Apache + my hosts file so that, if my live page is http://mydomain.com/... then the local equivalent is http://mydomain.dev/...  That's the one I'm trying to get Firebug to open.

I'm surprised I haven't been able to find any clear documentation for how to set up the arguments; what I have seen implies that the argument format would be different for different platforms and editors, and there are a lot of possible combinations.

In that other thread you said "I configured a proxy script that translates the URL into the filesystem path and then the script opens the editor. In this way I can easily edit long .css or .js files."  By proxy script did you mean the PHP code you showed above? Did that mean you DID find a way to have Firebug open your local/dev files with the Open With Editor command? Or are you still limited to having Firebug only open files over the Internet?

As far as I know, there is no real difference between "http://foo.dev" (local Apache) and "http://foo.com" (online Apache). I suspect my problem is just that I can't find any documentation for what the argument should look like. Why would they put a feature into Firebug and then fail to explain it anywhere?

Lawrence San
Business Writing: Santhology.com
Cartoon Stories for Thoughtful People: Sanstudio.com




--
You received this message because you are subscribed to the Google Groups "Firebug" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebug+u...@googlegroups.com.
To post to this group, send email to fir...@googlegroups.com.
Visit this group at http://groups.google.com/group/firebug.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebug/d94e023a-8c0f-43e1-9f9d-b995759e8961%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Andrei

unread,
Jun 13, 2014, 1:55:59 PM6/13/14
to fir...@googlegroups.com
I tried with the hosts trick and it works :)

I attached a print screen with my configuration and the PHP script that I made
You need to change in 2 places:
1 . $arRepl array. For every element, the key is the source canonical URL and the value, is the filesystem directory path

$arRepl = array(
'http://mydomain.dev' => 'C:/xampp/htdocs',
'http://local.host' => 'C:/xampp/htdocs',
'http://localhost' => 'C:/xampp/htdocs'
);


2. the last line:

system('"c:\\Program Files (x86)\\PSPad editor\\PSPad.exe" '.$argv[1]." /". $argv[2]);

is to run pspad on windows, you need to change that too for what editor you use. The editor must support command line to open file $argv[1] and the jump to line $argv[2]
I can give you another example, how to configure the line for vi editor in linux:

system('vi +'.$argv[2]." ". $argv[1]);
PRINT.jpg
a.php

Sebastian Zartner

unread,
Jun 14, 2014, 1:50:40 PM6/14/14
to fir...@googlegroups.com
Firebug currently (up to 2.0) does not offer mappings between URLs and local files. This feature is requested in issue 5035. Therefore you need to use tricks like the one suggested by Andrei.

Sebastian
Message has been deleted

Lawrence San

unread,
Jun 14, 2014, 6:59:05 PM6/14/14
to fir...@googlegroups.com
Ah, I see. So after reading the discussion you linked to, I can guess what the current %file hint means when it says "Path to the local file (or to the temporary copy)" -- I guess that "local file" there means only if you're loading as a file:// path but not as http:// off a dev server. I noticed that the discussion dates back to 2011-2012, which doesn't seem like it's a top-priority issue. I wish it could really happen.

Lawrence San
Business Writing: Santhology.com
Cartoon Stories for Thoughtful People: Sanstudio.com




Sebastian Zartner

unread,
Jun 15, 2014, 12:28:08 AM6/15/14
to fir...@googlegroups.com
Yes, "local file" actually means files in the file system accessed via file://. Though as the local file is currently actually just the temporary file, it should probably be renamed.
As far as I remember there was already a try on creating this mapping before, so the naming might be a remnant.

Sebastian
Reply all
Reply to author
Forward
0 new messages