123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- #!/usr/bin/env python
- # -*- coding: utf-8 -*-
- ########## begin config ##########
- output = 'homepage.html' # output file
- title = 'Speed Dial' # page title
- font = ('Monospace', '14px') # font
- separator = '>' # separator between group title and links
- colors = (
- '#020202', # background
- '#999999', # links
- '#00ff00', # group title
- '#4C4C4C', # separator
- )
- # add your links here
- links = {
- 'Google': [
- ['Google', 'https://www.google.co.uk/'],
- ['Youtube', 'http://www.youtube.com/'],
- ['GMail', 'https://mail.google.com/mail/u/0/?shva=1#inbox/'],
- ],
- 'Social': [
- ['FaceBook', 'http://www.facebook.com'],
- ['Twitter', 'https://twitter.com/'],
- ['Hotmail', 'www.hotmail.co.uk/'],
- ],
- 'Wiki': [
- ['Wiki', 'www.wikipedia.org/'],
- ['ArchWiki', 'https://wiki.archlinux.org/'],
- ['RSWiki', 'http://runescape.wikia.com/wiki/RuneScape_Wiki'],
- ],
- 'Shopping': [
- ['Amazon', 'http://www.amazon.co.uk'],
- ['eBay', 'www.ebay.co.uk/'],
- ],
- 'Games': [
- ['RuneScape', 'http://www.runescape.com'],
- ['Ryzom', 'http://www.ryzom.com/en/'],
- ['Steam', 'http://store.steampowered.com/'],
- ],
- }
- ########## end config ##########
- import os
- css = '''body {
- background-color: %s;
- font-family: "%s";
- font-size: %s;
- font-weight: normal;
- margin-left: 7%%;
- }
- a:link,a:visited,a:active {
- text-decoration: none;
- color: %s;
- font-weight: normal;
- }
- a:hover {
- text-decoration: underline;
- color: %s;
- font-weight: normal;
- }
- table {
- border-spacing: 8px;
- }
- td:first-child {
- font-weight: bold;
- color: %s
- }
- td:nth-child(2) {
- font-weight: normal;
- color: %s;
- }''' % (colors[0], font[0], font[1], colors[1], colors[1], colors[2], colors[3])
- links_html = ''
- for group in sorted(links):
- links_html += '<tr><td align="right">%s</td><td>%s</td><td>' % (group, separator)
- for site in sorted(links[group]):
- links_html += '<a href="%s">%s</a> ' % (site[1], site[0])
- links_html += '</td></tr>'
- html = '''<html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <title>%s</title>
- <link rel="stylesheet" type="text/css" href="style.css" />
- </head>
- <body>
- <table valign="middle" border="0" width="100%%" height="100%%"><tr><td><table>
- %s
- </table></td></tr></table>
- </body>
- </html>''' % (title, links_html)
- with open(output, 'w') as file:
- file.write(html)
- with open('style.css', 'w') as file:
- file.write(css)
- os.system('tidy -utf8 -i -m -q -asxhtml %s' % output)
|