Let's say you have a web2py application "myapp" and you want it to
look like a existing web site, for example "http://www.reddit.com";,
here is what you do from the web2py/ folder:

./scripts/clone.py -m '.tabmenu' -c '.content' -u 'http://
www.reddit.com'  -o applications/myapp/views/layout.html

Done!

In the script above:
-m '.tabmenu' is the class of the UL menu (. for class and # for id,
jQuery notation)
-c '.content' is the class of DIV that contains the main page
content.
-u is the url of the page you want to clone and
-o is the file you want to generate (a web2py layout).

You will need to look at the page first (possibly with firebug) to
figure out the -m and -c values for the specific page you intend to
clone.

The script converts the page into a web2py layout by inserting web2py
tags in the proper places. It does not download linked static files
but fixes links so that they do not break.

It does not work on non-utf8 pages.

I am not sure this is going to stay but I could use feedback on
whether this is useful or not. If somebody could help fix it for non
utf8 pages it would be great.


The script is in trunk now. If you do not use trunk, just get this
file

    http://web2py.googlecode.com/hg/scripts/clone.py

and store it in web2py/scripts.


DISCLAIMER: Under certain conditions it is illegal to make a page look
too similar to an existing page because it may be considered phishing.
The code provided can help you for a quick demo but it should not be
used to generate production web sites unless the layout of the site
you are cloning explicitly allows it.

Massimo

Reply via email to