Greetings.
This is just an idea for a macro/extension that is running around in my head for some time now. I have neither the time nor the experience to pull something like this, but I know there are very clever people here arround and I hope someone will jump to the opportunity to care for this baby...
Phase5 and Includes:
I used to work with phase5 for a few years. Its a German html editor with a whole load of nice features. The reason why I loved this editor was it's "includes macro".
It worked like this.
Imagine you have an html snippet you'll need inside many different documents. For example a footer with a copyright notice. Next year you would have to open all copyright notices (or use project-wide search/replace, if it is a small snippet) and correct the footer.
How about a macro doing this automatically/on demand?
This is what includes are about.
We'll start with a simlpe text file
Inside, we write
<div id="footer"> <p>Copyright 2009 by dsfdsdf@rtfg.de</p> </div>
and we save it as footer.inc
This will be our include file from which we draw content into other pages.
Now we put the following syntax into all documents we want to contain this ressource.
<!--include:footer.inc/LatestUpdate:10.02.009_12:00:00:--> <div id="footer"> <p>Copyright 2008 by info@web.de</p> </div> <!--/include:footer.inc-->
As far as I remember, you could hit a button and phase5 would search the documents within your project directory for this special "include comment".
Next phase5 would present a table listing each document with outdated includes and you could choose which ones to update.
Finally, another macro would insert the contents of the choosen include files into the comments overwriting the former contents.
The result looked like this
<!--include:footer.inc/LatestUpdate:10.02.009_12:00:00:--> <div id="footer"> <p>Copyright 2009 by sdfgdff@dfsdf.de</p> </div> <!--/include:footer.inc-->
One might argue that nowadays most of us are working with php,phython,etc and so on and includes don't make any sense anymore. Yet I don't think so and I would love to see this feature added to komodo.
If there is anyone out there that feels the same way, please contact me for more details.
Regards,
pepebe "has an email account at" gmx.de
You could probably use Komodo's replace dialog to perform an update such as this, using the "multiline" and/or "regular expression" options to ensure a match.
Note: I know there may be other cases where this does not always work as well - and the macro idea you have may make things easier there.
Cheers,
Todd
It seems there are several ways to do this that are easy and wouldn't require an update to Komodo. To me, the easiest is a client-side method that would use an external javascript file (say updates.js), which would be referenced by a script tag in each page's head tag. I would present the entire script, but this forum prohibits use of some of the tags I would need to present, so please bear with my description of the function.
in the body tag, call the function using onload="updateFooter()"
In the body, place a blank div tag pair with an id of "footer"
the javascript file, updates.js would have a function called updateFooter(). That function could use initialized variables (constants, really) to store the beginning and ending pieces of your footer text, including the paragraph tags (everything except the year). Javascript provides a date object that you can create a new instance of. One of the methods of the date object is getFullYear, which returns a 4-digit year. Put this together with the two canned parts of the footer and write it to the div tag's innerHTML.
The forum does allow some of the code to be displayed: here is that part of it which is allowed:
var footerPart1 (put a string here, beginning with the paragraph tag and containg the text up to the year part - a blank space at the end to set the date off)
var footerPart2 (put a string here, starting with a blank space, the remaining text of the footer and a closing paragraph tag)
var dateObj = new Date();
var currentYear = dateObj.getFullYear();
var footer = footerPart1 + currentYear + footerPart2;
document.getElementByID('footer').innerHTML = footer;
Finally, if different pages called for differing footers, you could pass document.title as an argument to the javascript function and switch the canned footer text parts depending on the value of the document's title.
One could also do the same on the server with php by using php page extensions rather than an htm extension and including an equivalent php function in each page that would build the page, including updating the year, but the javascript method seems less cumbersome, and is truly 'client-side' - the only difference is that, what is included is the javascript rather than an include for the footer itself.
@toddw
Yeah, this would be the way to do it right now. But as one might imagine this is prone to cause severe mistakes.
@tdindc
I think you got me wrong on this one.I'm not talking about updating some html code on a webpage. I wouldn't entrust such a thing to javascript anyway.For such things we have content management systems.
What I'm talking about is productivity. A macro like this would allow komodo to behave like a primitive content management system. You can prepare your basic html structure and then concentrate on your contents. If you later find out that something is wrong with your template, you can modify that part in your include file and automatically update all files that use that snippet. Depending on the scope of control, this could develop into a very powerful tool...
You could also try it the other way around.
Create your basic html structure (header, content, footer) and add comments inside those areas where you will have variable content.
Copy/paste that structure to home.html, about.html, etc.
Create *.inc files for all important areas:
header.inc
content_home.inc
content_about.inc
footer.inc
Now you can concentrate on writing stuff instead of updating files over a whole project whenever you have made changes to your original template.
I have worked with phase5 for 4 or 5 years before I made my move away from windows. I never shed a tear but for one thing. phase5 includes rocked!
Regards,
pepebe