Page 1 of 1

Find and Replace, Relative Paths to Images folder...ug!

Posted: Tue Dec 02, 2008 8:46 am
by beagley
Can I use absolute paths for images in the Flare project and still keep my project mobile? Is there some absolute path for the Project that doesn't include the file system? Are there Find and Replace tools that will let me work on the XML code for a bunch of topics all at once?

Here's my situation:

1. I am importing topics by pasting in HTML. This is more time consuming than dumping the files into the project, but I've got a lot of work to do on each topics anyway.

2. The HTML I paste automatically points to external images. That actually works great as a temporary solution. The project compiles, the images appear. Yay. But topic-by-topic, I want to bring images into the Flare project so I don't have to get fancy when dealing with single sourcing.

3. After I move my images to the Resources/Images folder, I want to go into the code of my topics and change all the <img src="http://server/location"> to <img src="../Flare/Location">. For hundreds of images in hundreds of topics. This is my FIRST problem: Flare's global find and replace seems to only look at the text inside topics, there is no way to point it at the code. I have to manually OPEN all the topics in the Internal Text editor and then tell the Find + Replace to search all open files. That works okay, though it is time consuming. Any tips would be welcome.

4. Then we hit the relative path problem. My topics are organized into folders, sub-folders, etc. Therefore my find-replace won't work, because sometimes I'd need to change the path to "../Resources/Images" and sometimes I'd need to change it to "../../Resources/Images." And so forth.

On the small scale, I can hack this up and just do multiple find-replaces. But when this expands to thousands of topics in hundreds of sub-folders... yikes.

Maybe Flare has some kind of absolute path for the project? Like "<img src="Content/Resources/Images/name.png">? And then it would be clever enough to resolve that when building the project? Anybody know?

Any other tips? I need the flexibility of relative paths so that I can drag and drop my compiled project anywhere, but I can't see how to do find/replace on all my images without an absolute path.

What I'm trying to avoid, obviously, is going topic by topic and reinserting every image. I write image-heavy software documentation.

Someone please cry foul if I'm going about this all wrong...

-Douglas

Re: Find and Replace, Relative Paths to Images folder...ug!

Posted: Tue Dec 02, 2008 9:21 am
by RamonS
beagley wrote:Can I use absolute paths for images in the Flare project and still keep my project mobile? Is there some absolute path for the Project that doesn't include the file system? Are there Find and Replace tools that will let me work on the XML code for a bunch of topics all at once?
I wouldn't use absolute paths for any reason, because they make your project to be immobile unless you happen to find a different system that can provide the exact same folder structure. In any case, as you already know, there is no good reason to use anything else than relative paths.
beagley wrote:3. After I move my images to the Resources/Images folder, I want to go into the code of my topics and change all the <img src="http://server/location"> to <img src="../Flare/Location">. For hundreds of images in hundreds of topics. This is my FIRST problem: Flare's global find and replace seems to only look at the text inside topics, there is no way to point it at the code. I have to manually OPEN all the topics in the Internal Text editor and then tell the Find + Replace to search all open files. That works okay, though it is time consuming. Any tips would be welcome.
AFAIK there is a check box called "Find in source code" that allows for directing the project wide search to apply to the source code. That combined with "Find in" set to "Whole project" should do what you need.
beagley wrote:4. Then we hit the relative path problem. My topics are organized into folders, sub-folders, etc. Therefore my find-replace won't work, because sometimes I'd need to change the path to "../Resources/Images" and sometimes I'd need to change it to "../../Resources/Images." And so forth.
That is indeed true and quite an annoyance.
beagley wrote:On the small scale, I can hack this up and just do multiple find-replaces. But when this expands to thousands of topics in hundreds of sub-folders... yikes.
Maybe it is a good time to re-evaluate the structure and flatten it. Flat structures are much better and I can't think of any reason why one would really need more than three levels. Even with that, it will still be a lot of find and replace going on. But think of it like that: it is most likely more time saving to just go ahead and do it than to spend a lot of time figuring out some tricked out way just to come to the conclusion that there is none. And ideally you only have to do it once. The issue isn't Flare or the find and replace or the amount of levels, the issue is that you inherited the flaws from the source HTML that itself does not use relative paths (assuming that the images are served from the same web server, otherwise it is not a flaw, but a necessity). You now need to fix what someone else did not do.
beagley wrote:Maybe Flare has some kind of absolute path for the project? Like "<img src="Content/Resources/Images/name.png">? And then it would be clever enough to resolve that when building the project? Anybody know?
But then Flare would need to know where to find "Content/Resources/Images/name.png", which could be in C:\project\images or D:\work\images\firstlevel\secondlevel or such. So it really wouldn't help. Even if there is some magic way to guess it I for sure wouldn't trust a piece of software to guess right. The problem is that computer systems are gosh darn stupid and you need to tell them every single detail. Flare is no exception.
beagley wrote:What I'm trying to avoid, obviously, is going topic by topic and reinserting every image. I write image-heavy software documentation.
I don't know anything about the project you work on, but the question to be asked should still be this one: do you really need all the images? If it is application help it is safe to assume that the application is open so that there is no need to show in the help what the user already sees on screen anyway. But maybe in this case you are already working with the least amount of images you can get away with. It all depends, but less is more especially going forward doing more maintenance.
beagley wrote:Someone please cry foul if I'm going about this all wrong...
Nah, you are not going about this wrong, you just try to get out of a lot of braindead and tedious work. Everybody would try that. Let us know if the project wide find and replace in the source code doesn't help. There is also an option to do the find and replace only on all those documents in a specific folder, which may come in handy for getting the ../../ thingies right the first time.

In any case, make frequent backups. It is much better to spend the few minutes on a backup and then figuring out that the past three hours of work were no good and now take three hours to be fixed.

Re: Find and Replace, Relative Paths to Images folder...ug!

Posted: Tue Dec 02, 2008 9:24 am
by LTinker68
beagley wrote:3. ... Flare's global find and replace seems to only look at the text inside topics, there is no way to point it at the code. ...
In the find-and-replace screen, about mid-screen, there is a field that says something like "Find in source code". Put a checkmark in that field -- as it searches it'll open the topics in the Internal Text Editor, so that you can see that it's found the code.
beagley wrote:4. Then we hit the relative path problem. My topics are organized into folders, sub-folders, etc. Therefore my find-replace won't work, because sometimes I'd need to change the path to "../Resources/Images" and sometimes I'd need to change it to "../../Resources/Images." And so forth.
The easiest thing would probably to put all of the images in one parent folder (Resources/Images). Then as you organize your topics into folders, create a corresponding folder under the Images folder and move the relevant images into that sub-folder. When Flare asks if you want to update links, click Yes -- it'll then automatically change the path in the code to point to the correct location. You can move multiple images/files simultaneously by turning on the "Show Files" option in the Content Explorer (I think that's what it's called, I don't have Flare open at the moment). Although I wouldn't move more than a couple dozen images at a time.

Re: Find and Replace, Relative Paths to Images folder...ug!

Posted: Wed Dec 03, 2008 6:43 am
by KevinDAmery
LTinker68 wrote:
beagley wrote:4. Then we hit the relative path problem. My topics are organized into folders, sub-folders, etc. Therefore my find-replace won't work, because sometimes I'd need to change the path to "../Resources/Images" and sometimes I'd need to change it to "../../Resources/Images." And so forth.
The easiest thing would probably to put all of the images in one parent folder (Resources/Images). Then as you organize your topics into folders, create a corresponding folder under the Images folder and move the relevant images into that sub-folder. When Flare asks if you want to update links, click Yes -- it'll then automatically change the path in the code to point to the correct location. You can move multiple images/files simultaneously by turning on the "Show Files" option in the Content Explorer (I think that's what it's called, I don't have Flare open at the moment). Although I wouldn't move more than a couple dozen images at a time.
Actually, I don't think that will work in this case, because the original images aren't in the Flare project to begin with; I don't think it will track properly in that scenario. It would work if the topics in Flare were pointing to /Resources/Images, but since their currently pointing to <img src="http://server/location"> Flare won't recognize the links as belonging to the moved files.

Under normal circumstances, the workflow you're suggesting would be exactly what I would do, but sadly these aren't normal circumstances.

Re: Find and Replace, Relative Paths to Images folder...ug!

Posted: Wed Dec 03, 2008 8:53 am
by LTinker68
beagley wrote:3. After I move my images to the Resources/Images folder ...
According to that, it sounds like they are in the project.

Re: Find and Replace, Relative Paths to Images folder...ug!

Posted: Wed Dec 03, 2008 10:31 am
by KevinDAmery
Yeah, but just before that we've got
2. The HTML I paste automatically points to external images. That actually works great as a temporary solution. The project compiles, the images appear. Yay. But topic-by-topic, I want to bring images into the Flare project so I don't have to get fancy when dealing with single sourcing.

Re: Find and Replace, Relative Paths to Images folder...ug!

Posted: Wed Dec 03, 2008 12:42 pm
by bbuchko
Heya Douglas, use Snippets for your relative paths. I've used them successfully to create relative paths to content outside of my project, as described in the following topic:

http://forums.madcapsoftware.com/viewto ... =13&t=7223

You'd need to figure out the code for adding the snippet for when you do your find/replace, but then Flare should adjust the path automatically.

EDIT: Gonna test this possible solution just to be sure. More to come...

EDIT 2: Sorry, not gonna work, Douglas. You'd need to modify the relative path to the snippet, sadly, to make it appear in your topics, so you'd be right back to your original problem. Ah well. The snippet solution will still work for future references to info outside of your project, however.

Re: Find and Replace, Relative Paths to Images folder...ug!

Posted: Fri Dec 05, 2008 8:14 am
by beagley
Thanks to everyone who has replied to this topic!

Of especial use was the "look in the code" feature. I thought I'd examined the Find-Replace window thoroughly, but I completely missed that function. My thanks to both the folks who posted it!

You guys have also given me some possible workflows to try.

The situation is that I am importing HTML which points to external images, but I DO want to move them all inside the project. So I'll be putting everything in subfolders in Resources/Images.

I've worked out a system where I can find/replace the img src paths in clumps, based loosely on the structure in which the images were kept in our previous documentation setup. So I have managed to get rid of SOME of the grunt work, though not all. :)

Re: Find and Replace, Relative Paths to Images folder...ug!

Posted: Fri Dec 05, 2008 8:50 am
by RamonS
beagley wrote:So I have managed to get rid of SOME of the grunt work, though not all. :)
Well, you try to fit the square peg through a round hole....or no hole at all.

Re: Find and Replace, Relative Paths to Images folder...ug!

Posted: Fri Dec 05, 2008 8:53 am
by KevinDAmery
RamonS wrote:
beagley wrote:So I have managed to get rid of SOME of the grunt work, though not all. :)
Well, you try to fit the square peg through a round hole....or no hole at all.
What do you do if the bolt doesn't fit? Get a bigger air-wrench....