ActionsDev
12 replies to this thread. Most Recent
waltd
26 Feb 2007, 12:09 pm
Page-level External Div Style
This would be a hack, but maybe a hack that lets some parties retain their "I use CSS" seal of approval.
(pseudocode, mostly)
divs = fwDocument.getAllStyledItems(); //magic function, no idea how you do this in practice var temp;
for (i in divs){ itemId = (divs[i].id) ? divs[i].id : someUniquId; temp += ‘#’ + itemId + ’ { ‘; temp += divs[i].style temp += ‘}’; divs[i].id = itemId; divs[i].style = null; }
Next, write out temp to a file, name it pageName.css Finally, add a link in the HEAD to that file in standard external css form.
Anyone have the time to follow this to its natural conclusion?
Walter
Freeway user since 1997
Paul
26 Feb 2007, 4:13 pmHi, I have a Freeway 3 Action which did this - but it worked with my old External CS File Action to create a site-wide CSS file, not one file per page. One file per page seems a bit odd to me. Is this what people realy want? I’d have to provide something which opens another can of worms (ie - why has each page got a separate CSS file…call yourself a CSS based web designer, etc.?)
Any external CSS Action would certainly encourage care over ID names.
waltd
26 Feb 2007, 4:36 pmI know, it’s a bit of a hack. The only other way I could see it working is if the Action made up a class for each object in the site, so you would have a massive single css sheet used by every page in the site or folder. You couldn’t have the Action change the IDs on the fly, I don’t think. You could go crazy running a diff on each new class to see if it matched any of the existing, but seriously — until Softpress fixes this in a canonical manner, the only thing for Actions to do is band-aids.
Walter
On Feb 26, 2007, at 12:13 PM, Paul wrote:
[quote:2e01670bc3]Hi, I have a Freeway 3 Action which did this - but it worked with my old External CS File Action to create a site-wide CSS file, not one file per page. One file per page seems a bit odd to me. Is this what people realy want? I’d have to provide something which opens another can of worms (ie - why has each page got a separate CSS file…call yourself a CSS based web designer, etc.?)
Any external CSS Action would certainly encourage care over ID names.
All the best Paul Dunning Freeway 4 Pro 4.3.2 Freeway Actions - www. actionsworld.com (www.actionsworld.com)
www.pauldunning.com (www.pauldunning.com)
[/quote:2e01670bc3]
Freeway user since 1997
Paul
26 Feb 2007, 5:31 pmHi, try this then:
[url]www.actionsworld.com/PageDIVStylesTest.fwaction.zip[/url]
This is a minor re-working of my Page DIV Styles Action with some of my old External CSS Action thrown in.
It takes any or all CSS in a DIV and tosses it into an external CSS file. Like the older Action I cobbled, the CSS file is placed with the very last page in the document to publish.
Some warnings, which are obvious: 1 - This is a test at the moment 2 - The Naming of Divs is a curious matter - it isn’t just one of those everyday things (T.S. Elliot - "Old Possum’s Book of Practical CSS") You need to adopt a serious strategy in naming layered objects on your page. For example, each page could have an "item3" - and that "item3" may (or may not) have the same dimensions and position as another. In this case, master pages are your friends as you can set up your page with properly named items there. After that, make sure to give any local items names which are either going to be consistent with like minded items elsewhere, or just give them truly unique names.
Ideally, Freeway should control all this naming malarky, but as at the moment naming schemes are page-based, this can become very tricky to control from such an Action’s stand point.
Give it a spin, and report back any issues.[/url]
Tim Plumb
26 Feb 2007, 6:17 pmWhy not append a unique class to the outer div "PageDiv"; [code:1:ee091fdeb2]<div id="PageDiv" class="myUniquePageRef">[/code:1:ee091fdeb2] and then prefix each line of the CSS file with the following; [code:1:ee091fdeb2].myUniquePageRef #item1 {position:absolute; left:100px; … etc.[/code:1:ee091fdeb2] The tricky part is creating a unique reference for every page but if you use either the page name, a time stamp, or both then you should be pretty safe I would have thought. It also has the added advantage of telling you which page the style is used on when you view the CSS file. Regards, Tim.
Dan J
2 Mar 2007, 12:25 amPaul, looks like a good action so far. No errors so far just from the previous beta. I think i had an early beta from the site before this one was posted, maybe as to why it gave me those errors.
I’m trying to figure out how to rename the outputted CSS file name to something other than documentcss.css and don’t know what the "options" mean that show up in the action box. I’m sure if this gets released there will be an explanation.
Great work Paul.
My Blog: danjasker.blogspot.com • Freeway 5 Pro • Freeway 5 Express User
Paul
2 Mar 2007, 8:29 amHi, Done some tinkering on the Action. The new version, as well as a test Freeway file, can be found here: [url]http://www.actionsworld.com/pagedivstyles.zip[/url]
This takes on Tim’s suggestion with the classes in the PageDiv, which should allows for unique and changed DIVs to be included locally.
It also lets you change the name of the file name to something of your choosing, as long as it ends with ".css" (if it doesn’t, the extension gets added for you). Note - this is a site-wide change - it will affect every instance of the Action in the document.
Some considerations: the Action is restricted a lot by what Actions can get out of Freeway:
• The last page in the document will always be published, as this page creates the CSS file. Something may have changed layout wise on a page which the Action can not detect. So we have to assume that something has changed.
• The CSS file is not targeted by Actions. If it were, the potential for the whole site to be rebuilt every time would increase, as any file change would be registered by every page. At the moment, the Actions assumes that the file is in the same folder as the last page to be published, using the given file name. If I can work around this, then I will. This is the logic used by my Freeway 3 External CSS Action, which seemed to work very well during its tenure of such things.
• Master Page Items - the Action checks each Action on a page to see if it is derived from a Master Item. If so, the CSS is published "glabally". If not, the CSS is published as "local". Inline DIVs in Master Page items are, it seems, not tagged as Master Items (being content), so they are published locally. This could result in a lot of seemingly duplicate CSS. At the moment, the Action does not rationalise these into lists. It should for neatness.
• Master Page Items 2 - the Action checks the local item against the master item (if it is one) and tests for size and some other stylistic changes. If that change exists, the Action will create a local CSS instance. At the moment, this is whole. It should just publish the new elements as a local instance.
• Each PageDiv is given a class name based on the page name and a time stamp. That should provide a unique name for each page.
• The Action is a Page Action. I am hoping to make is a Folder Action. I’ll have to ponder this some more as I think a folder Action would be helpful in this case. Some logic may have to change. I’m thinking how this can be achieved, as in its current state, it won’t work as a Folder Action.
There are still a few holes around master items having different names to local items - something I’ll have a think about.
Give the new version a spin anyway. Enjoy.
Dan J
21 Mar 2007, 10:55 amI think the action works quite well, nice work Paul. Just dropping in to see if the action is ever going to be released other than beta. There are two things at least I’d like to see in a possible final version. (Thanks for allowing the CSS to be renamed also)
I’d like to be able to have the file be output in the CSS directory with the others to keep things organized.
For some reason the validator doesn’t like the style sheet tag in the HTML. It says "You may have neglected to close an element, or perhaps you meant to "self-close" an element, that is, ending it with "/>" instead of ">". Don’t really know if that matters or not, but that’s what it said.
I really hope to see a final release if and when that ever may happen. Thanks for the hard-work.
My Blog: danjasker.blogspot.com • Freeway 5 Pro • Freeway 5 Express User
Paul
21 Mar 2007, 3:13 pm[quote:c373d3f6b2=”CableGuy2”]I think the action works quite well, nice work Paul. Just dropping in to see if the action is ever going to be released other than beta. There are two things at least I’d like to see in a possible final version. (Thanks for allowing the CSS to be renamed also)
- I’d like to be able to have the file be output in the CSS directory with the others to keep things organized.[/quote:c373d3f6b2] I can not do anything about this - I can have the file in with the Resources, or with the HTML. Unless there is a keepwithcss type flag in Actions which I haven’t been told about….
[quote:c373d3f6b2=”CableGuy2”] 2. For some reason the validator doesn’t like the style sheet tag in the HTML. It says "You may have neglected to close an element, or perhaps you meant to "self-close" an element, that is, ending it with "/>" instead of ">". Don’t really know if that matters or not, but that’s what it said.
I really hope to see a final release if and when that ever may happen. Thanks for the hard-work.[/quote:c373d3f6b2]
Are you building XHTML or HTML? I bet it’s failing on XHTML.
At the moment, it’s probably going to be beta for a while. It’s a gnarly Action which will no doubt fail somewhere along the line. Remember - it’s taking Freeway outside for a kicking behind the bins. I’m forcing a few things which really shouldn’t be forced.
If it’s possible for you to work with it "for real" then I’d be interested to know how you get on.
Dan J
22 Mar 2007, 4:13 amYou’re right, it is failing XHTML.
I’m using the action "for real" on only my home page and it works great. I did some manual edits to fix the code lines for validation (the link to the CSS sheet) and moved the CSS to the CSS folder.
I think it creates cleaner code and makes a more manageable website. It does stamp the "I use CSS" seal of approval.
Hope to see progress updates to this action in the future. Thanks Paul.
My Blog: danjasker.blogspot.com • Freeway 5 Pro • Freeway 5 Express User
Paul
22 Mar 2007, 9:35 amHi, try this version - it should validate in XHTML as well!
[url]http://www.actionsworld.com/pagedivstyles.zip[/url]
Sadly, my hunch that there was an undocumented keepwithcss flag for Actions was unfounded - so the css file will always remain with the last page in Freeway’s database. There could be a fix - if you created a folder called css and put a page in there. If you could rig it that this page was always the last, then you may be able to get what you want. However, the very, very last page in Freeway’s database isn’t always the bottom most one in the site pane.
I’ll have to put in a request for better location of Action generated resources :-)
Dan J
13 Jun 2008, 10:40 pmPaul,
Is there anyway I could get a version of this Action that doesn’t generate the unique page class style. Since I’m creating a template, with styles in the same places across the board, I’d have to cut out the unique ID and I’m trying to strike cleaner code and save some time.
Is that possible? Or can I edit the action somehow? I’ve tried renaming the Freeway action extension to edit it, no luck. TextWrangler and others don’t understand it.
Thanks.
My Blog: danjasker.blogspot.com • Freeway 5 Pro • Freeway 5 Express User