[web2py] Re: Server-side AngularJS execution?

2012-12-29 Thread Niphlod
I'd not recommend any of the mvc javascript frameworks if you're interested 
in any SEO consistent results. Support for executing javascript by crawlers 
is largely missing and there is no documented way to tell them to crawl 
and execute specific fragments.
If you're positive about implementing it, then you need to render your 
pages as static not using angularjs and provide only those links in your 
sitemap. There is no way to let web2py handle the angularjs logic because 
there are no python adapters for it.

On Saturday, December 29, 2012 5:10:21 AM UTC+1, Alec Taylor wrote:

 Search spiders such as Google—though they now execute AJAX and parse 
 the result—do not work as well with dynamic content as static content. 

 So I was thinking if there was some way to execute the AngularJS as 
 static files; for search-spiders and non-javascript enabled 
 browsers; but when they have JavaScript support execute it 
 client-side. 

 It would also save the trouble of implementing each view twice; once 
 in web2py views the other in AngularJS MVC. 

 Would this be possible? 

 If not, how would you recommend I go about doing this? 

 Thanks for all suggestions, 

 Alec Taylor 


-- 





[web2py] Re: Server-side AngularJS execution?

2012-12-29 Thread Anthony
You might be able to use a headless browser on the server to execute the 
Javascript to generate the HTML. The Meteor 
frameworkhttp://www.meteor.com/blog/2012/08/08/search-engine-optimizationuses 
PhantomJS http://phantomjs.org/ for this purpose. There is also 
Zombie.jshttp://zombie.labnotes.org/, 
which has a Python driver https://github.com/ryanpetrello/python-zombie, 
and the Python based Spynner https://github.com/makinacorpus/spynner.

Anthony

On Friday, December 28, 2012 11:10:21 PM UTC-5, Alec Taylor wrote:

 Search spiders such as Google—though they now execute AJAX and parse 
 the result—do not work as well with dynamic content as static content. 

 So I was thinking if there was some way to execute the AngularJS as 
 static files; for search-spiders and non-javascript enabled 
 browsers; but when they have JavaScript support execute it 
 client-side. 

 It would also save the trouble of implementing each view twice; once 
 in web2py views the other in AngularJS MVC. 

 Would this be possible? 

 If not, how would you recommend I go about doing this? 

 Thanks for all suggestions, 

 Alec Taylor 


-- 





Re: [web2py] Re: Server-side AngularJS execution?

2012-12-29 Thread Alec Taylor
Thanks Anthony, using Spynner now:

import spynner

if __name__=='__main__':
url = http://angular.github.com/angular-phonecat/step-10/app/#/phones;
browser = spynner.Browser()
browser.create_webview(True)
browser.load(url, load_timeout=60)
print browser._get_html()
# ^ Can pipe this to a file, POST it to my server or return it as a string
browser.close()

Doubt I'll find a PaaS to run it though, so might need to run a server
on my desktop that gets pinged by my app on the cloud; then provides
the new HTML.

Do you think any of your others would run on a PaaS like Heroku or OpenShift?

On Sun, Dec 30, 2012 at 7:56 AM, Anthony abasta...@gmail.com wrote:
 You might be able to use a headless browser on the server to execute the
 Javascript to generate the HTML. The Meteor framework uses PhantomJS for
 this purpose. There is also Zombie.js, which has a Python driver, and the
 Python based Spynner.

 Anthony


 On Friday, December 28, 2012 11:10:21 PM UTC-5, Alec Taylor wrote:

 Search spiders such as Google—though they now execute AJAX and parse
 the result—do not work as well with dynamic content as static content.

 So I was thinking if there was some way to execute the AngularJS as
 static files; for search-spiders and non-javascript enabled
 browsers; but when they have JavaScript support execute it
 client-side.

 It would also save the trouble of implementing each view twice; once
 in web2py views the other in AngularJS MVC.

 Would this be possible?

 If not, how would you recommend I go about doing this?

 Thanks for all suggestions,

 Alec Taylor

 --




--