Hi
First of all, I want to say how much I like Gaia and how much time it saved me so far. I was using my own framework based on AS2 and the thought of porting it to AS3 was like a nightmare. Instead of reinventing the wheel I googled for Flash frameworks and i came across Gaia, and wow, that was like a thunderstroke! :-) There is only one thing i miss in Gaia which I had in my own framework: a different SEO approach. So i tried to figure out how i could implement this into Gaia.
Let me explain my way.
There are 2 things I'm not so happy with the Gaia way:1. When I seo scaffold the page with gaia, it creates a physical html page for each content. This is ok if i have just a few pages, but what about hundreds or even thousands? For example on this flash site of mine:
http://www.findanddine.ch. There are more then 13'000 links in the google index. And it is planned to relaunch this site with AS3/Gaia.
2. The deeplinks "stay", that doesn't look nice. And if a person bookmarks the page, the "ugly" url will stay forever... The bookmark looks something like that:
www.mydomain.com/news.html#/about-us/. But I like it more this way:
www.mydomain.com/#/about-us/.
My approach:When you download the examples at
http://www.asual.com/swfaddress/ and look at the SEO examples, there is a nice solution where the url stays "clean". Have a look at this Gaia-Site I just finished, where I implemented this SEO method:
http://kunden.kaegi.net/impactunlimited/. Try e.g. the following link with javascript deactivated and navigate a while on the site:
http://kunden.kaegi.net/impactunlimited/e/unlimited/worldwide. Then activate javascript again and reload. The urls stays "nice", the only thing that is added is the "#". And the cool thing is: it doesn't matter if there are 10 or 10000 links.
The only thing i hade to do was catching the SWFAddressEvent.CHANGE event before Gaia loads the site.xml. So i initialize and setup SWFAddress in main.as. Then I dispatch an event whenever the urls changes. This event i listen to in GaiaSWFAddress.as.
The code in main.as:
public function Main()
{
super();
SWFAddress.addEventListener(SWFAddressEvent.CHANGE, onSWFAddressChange);
SWFAddress.setHistory(false);
// ...
}
private function onSWFAddressChange(e:SWFAddressEvent)
{
var value:String = SWFAddress.getValue();
EventCentral.getInstance().dispatchEvent(new ProjectEvent(ProjectEvent.SWF_ADDRESS, { value:value } ));
}
The changes in GaiaSWFAddress.as:
public function init():void
{
// kaegi-start --------------------------------------------------------------------------------------------
EventCentral.getInstance().addEventListener(ProjectEvent.SWF_ADDRESS, onChange);
var v:String = SWFAddress.getValue();
if (v == "/") v = insertStrictSlashes();
if (v != "/")
{
EventCentral.getInstance().dispatchEvent(new ProjectEvent(ProjectEvent.SWF_ADDRESS, { value:v } ));
} else {
dispatchGoto("index/nav/home");
}
// kaegi-end ----------------------------------------------------------------------------------------------
//
/* original:
SWFAddress.addEventListener(SWFAddressEvent.CHANGE, onChange);
SWFAddress.setHistory(false);
var v:String = SWFAddress.getValue();
if (v == "/") v = insertStrictSlashes();
if (v != "/") SWFAddress.setValue(v);
*/
}
// kaegi-start -----------------------------------------------------
public function onChange(event:ProjectEvent):void
{
_value = stripStrictSlashes(event.params.value);
// kaegi-end ---------------------------------------------------
// original-start
//public function onChange(event:SWFAddressEvent):void
//{
//_value = stripStrictSlashes(event.value);
// original-end
...
...
I used the "EventCentral, ProjectEvent" from here:
http://www.reynaldocolumna.com/blog/archives/event-control-systemThere are even more advantages to this seo method: When I catch the url before gaia loads the site.xml, I can examine the url and take out some code for later use on the site, and give gaia exactly the link it can work with. For example:
www.mydomain.com/books/authors/billy-bully/book2. The part Gaia is interested in is "
www.mydomain.com/books/authors/" the rest (billy-bully/book2) is cut and stored in a central variable. Then, when the books/authors-page is loaded, the "billy-bully/book2" is retrieved and i can do with it whatever i want.
And there is another advantage: When the url is analized before the site.xml is loaded, i can use language specific information in the url (/e/ for english or /d/ for german) to distinguish what to load. If you have a look at the
http://kunden.kaegi.net/impactunlimited/site.xml you can see the i used "{" in the route and title attributes. Because i know which language is active when i load the site.xml, i can read, split and use the corresponding string. If you wonder about all the "btn..." attributes: this is my global navigation i also implemented (I'm going to explain it another time, i have to document it first). I just like to have one xml file where all the structure is in one place. The same site.xml is used to generate the navigation for the seo version:
http://kunden.kaegi.net/impactunlimited/seonavig.php?debug=1 I'm curious what you think about all of this... :-)