moving the style inside the body

Hi all
just a quick couple of question I am trying to move the style tag and its content so its the first thing in the body?
I tried using the ye old fwMove without much success, not that I have used this very often so I am assuming I probably haven’t understood the manual… so next I thought I would just copy it add it to the body and then delete the style tag
it works but not in the way I thought it would, it basically moves it to the last item before the end of the body…uuuuhhhh thats not what I was expecting or even want… thats not supposed to happen here is is it.
Here is the fragment of code so you can see what I am up to

function fwAfterEndBody()
{
var getStyle = fwDocument.fwTags.fwFind("style");
var getBdy = fwDocument.fwTags.fwFind("body");
getBdy.fwAdd(getStyle);
getStyle.fwDelete();
}

Now I thought when I used fwDocument.fwTags.fwFind(“body”); it would find the first instance of that tag and bung in the contents there. It’s worked in the past!!! or am I just missing something simple

the other big question is how on earth can I find and delete the marks that wrap the style. As I need this out if I am going to make the bring all styles inline with TextMate work, I am not even sure how to look for them in a freeway actions??

any help would sure be appreciated

All the best Max


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

I did this in the PHP Make Insert Page Action (modified from Paul
Dunning’s excellent base action) to move the entire HEAD inside the
BODY before deleting everything except the BODY contents.

Basically, you are nearly there. You just need to do this (I think,
not tested):

function fwAfterEndBody()
{
var getStyle = fwDocument.fwTags.fwFind(“style”);
var getBdy = fwDocument.fwTags.fwFind(“body”);
var wrapper = getBdy.fwEnclosing;
wrapper.fwMove(getStyle,getBdy);
getStyle.fwDelete();
}

As far as removing the CSS comments goes, you’re probably going to
have to resort to a regular expression to strip them out, which means
it should happen as late in publishing as possible because you’ll have
to generate HTML to do this, and that’s a one-way trip.

var strBody = getBdy.fwToHTML().toString();
strBody.replace(//g,‘’);
var wrapper = getBdy.fwAddEnclosing();
wrapper.fwAddRaw(strBody);
getBdy.fwDelete();

//that’s not tested, but it should be fairly close

Walter

On Feb 17, 2009, at 10:51 AM, max wrote:

just a quick couple of question I am trying to move the style tag
and its content so its the first thing in the body?


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

As for removing the comment tags from the CSS block I would be inclined to use
fwFindAllContent() to geta grip on all of the style data and then step through
this looking for valid styles and comments. You can then write these back to
the tag stream directly without having to convert them to text.
I’d write you a sample but I’m away from my Mac at the moment and can’t test
anything I write!
Regards,
Tim.

Quoting Walter Lee Davis email@hidden:

I did this in the PHP Make Insert Page Action (modified from Paul
Dunning’s excellent base action) to move the entire HEAD inside the
BODY before deleting everything except the BODY contents.

Basically, you are nearly there. You just need to do this (I think,
not tested):

function fwAfterEndBody()
{
var getStyle = fwDocument.fwTags.fwFind(“style”);
var getBdy = fwDocument.fwTags.fwFind(“body”);
var wrapper = getBdy.fwEnclosing;
wrapper.fwMove(getStyle,getBdy);
getStyle.fwDelete();
}

As far as removing the CSS comments goes, you’re probably going to
have to resort to a regular expression to strip them out, which means
it should happen as late in publishing as possible because you’ll have
to generate HTML to do this, and that’s a one-way trip.

var strBody = getBdy.fwToHTML().toString();
strBody.replace(//g,‘’);
var wrapper = getBdy.fwAddEnclosing();
wrapper.fwAddRaw(strBody);
getBdy.fwDelete();

//that’s not tested, but it should be fairly close

Walter

On Feb 17, 2009, at 10:51 AM, max wrote:

just a quick couple of question I am trying to move the style tag
and its content so its the first thing in the body?


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


Extend Freeway the way you want with FreewayActions.com
http://www.freewayactions.com


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Thanks walter
It took a little time to undo all the rubbish I had created prior to this bit which half worked, but doing it this way and reworking my original scripts has worked a treat.

The only bit that isn’t is the part
so I will have another look at that tomorrow.

Hi Tim
If your idea is an easy thing to show, it certainly would be handy to see, as an alternative.

Thanks again for all the replies and suggestions

max


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Thanks walter and tim its now working.

max


actionsdev mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options