Showing posts with label web design. Show all posts
Showing posts with label web design. Show all posts

Tuesday, March 4, 2014

POST to Angular.JS by Facebook Canvas App

I was writing a Facebook Canvas App with Flask. Then I decided to move my frontend to AngularJS. I wanted to put the AngularJS static code to a static hosting provider to avoid higher costs. Nevertheless, I realized that I had forgotten that I can't handle POST requests by AngularJS since it doesn't have a dynamic server.

Facebook Canvas performs a POST request with signed_request parameter to your homepage and you should handle that parameter to see who the logged user is.

What I did was: create a Node.JS app with express.js framework. Convert homepage to view, add a hidden input field in the HTML code and handle POST parameter by Node.JS, filling that hidden input.

When I did this, facebook posted the signed_request parameter and I placed that code into the hidden field. Now AngularJS code can post that signed_request code to the backend API server to process it or use it client-side.

Tuesday, January 22, 2013

Designing Django, PHP and HTML Compatible

You may want to design a web site and sell or distribute it. Headers, navigation bars and footers of the pages will be the same for most of the pages. So you may want to re-use these fragments in each page so that when you make a change in the design, it's reflected in all of those pages. Template engines come in handy in these cases. I've been using Django for my projects. Django uses template engine similar to jinja2.

But when I wanted to create a static site, I used Hyde to compile the fragments into complete html files. But this required re-compilation of all the project whenever you make a change in one single file. Perhaps compiling only the changed is possible with some kind of console arguments. Then I thought that'd be nice if there were a hyde server like django development server which recognizes which file has changed and only compiles it and serves it on HTTP. Then I found Hyde web server. I was really excited. Then I thought if I wanted to use this design on a PHP-supporting server, what would I do? I found Twig for this purpose. Wonderful! These are excellent resources for a web designer.