index.py
changeset 18 17e1136cc257
parent 17 301725d72e29
child 19 0187eddad3eb
equal deleted inserted replaced
17:301725d72e29 18:17e1136cc257
     1 #!/usr/bin/python2.5
     1 #!/usr/bin/python2.5
       
     2 # Copyright 2009 Tero Marttila
       
     3 #
       
     4 #   This program is free software: you can redistribute it and/or modify
       
     5 #   it under the terms of the GNU General Public License as published by
       
     6 #   the Free Software Foundation, either version 3 of the License, or
       
     7 #   (at your option) any later version.
       
     8 #
       
     9 #   This program is distributed in the hope that it will be useful,
       
    10 #   but WITHOUT ANY WARRANTY; without even the implied warranty of
       
    11 #   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
       
    12 #   GNU General Public License for more details.
       
    13 #
       
    14 #   You should have received a copy of the GNU General Public License
       
    15 #   along with this program.  If not, see <http://www.gnu.org/licenses/>.
       
    16 #
       
    17 
     2 import werkzeug
    18 import werkzeug
     3 from werkzeug.exceptions import HTTPException
    19 from werkzeug.exceptions import HTTPException
     4 
    20 
     5 from PIL import Image, ImageDraw, ImageFont, ImageEnhance
    21 from PIL import Image, ImageDraw, ImageFont, ImageEnhance
     6 from cStringIO import StringIO
    22 from cStringIO import StringIO
    78 
    94 
    79 FONT_SIZE_MAX = 1024
    95 FONT_SIZE_MAX = 1024
    80 IMG_SIZE_MAX  = 1024
    96 IMG_SIZE_MAX  = 1024
    81 
    97 
    82 TILE_SIZE = (100, 100)
    98 TILE_SIZE = (100, 100)
       
    99 
       
   100 SITE_URL = "http://qmsk.net/stuff/aaltologo/"
       
   101 SOURCE_URL = "http://hg.qmsk.net/aaltologotin"
    83 
   102 
    84 # enable debugging
   103 # enable debugging
    85 DEBUG = True
   104 DEBUG = True
    86 
   105 
    87 
   106 
   546     width: 150px;
   565     width: 150px;
   547 }
   566 }
   548 
   567 
   549 div.param {
   568 div.param {
   550     padding: 3px;
   569     padding: 3px;
       
   570 }
       
   571 
       
   572 div#footer {
       
   573     text-align: center;
       
   574     font-size: x-small;
       
   575     font-style: italic;
   551 }
   576 }
   552         </style>
   577         </style>
   553     </head>
   578     </head>
   554     <body>
   579     <body>
   555         <div id='logo'>
   580         <div id='logo'>
   565 %(form_fields)s
   590 %(form_fields)s
   566                     <input type="submit" value="Logota!" />
   591                     <input type="submit" value="Logota!" />
   567                 </fieldset>
   592                 </fieldset>
   568             </form>
   593             </form>
   569         </div>
   594         </div>
       
   595         <div id='footer'>
       
   596             <a href="%(site_url)s">Aaltologotin</a> &copy; 2009 Tero Marttila :: GPL <a href="%(source_url)s">Source code</a>
       
   597         </div>
   570     </body>
   598     </body>
   571 </html>""" % dict(
   599 </html>""" % dict(
   572         img_url     = img_url,
   600         img_url     = img_url,
   573         script_url  = req.url_root,
   601         script_url  = req.url_root,
   574         form_fields = "\n".join(
   602         form_fields = "\n".join(
   575             "\t%s" % opt.build_form(opts) for opt in options.options
   603             "\t%s" % opt.build_form(opts) for opt in options.options
   576         ),
   604         ),
       
   605         site_url    = SITE_URL,
       
   606         source_url  = SOURCE_URL,
   577     ), mimetype='text/html')
   607     ), mimetype='text/html')
   578 
   608 
   579 def handle_request (req) :
   609 def handle_request (req) :
   580     if req.path == '/' :
   610     if req.path == '/' :
   581         return handle_index(OPTIONS, req)
   611         return handle_index(OPTIONS, req)