# HG changeset patch # User Tero Marttila # Date 1234019641 -7200 # Node ID 79ea0e2a6cc2d0bbc298d3e06c02d81bdcc537e3 # Parent 09196d5b2a39bbb6a6ca03767cecf89e99da75d9 move pages/ -> sites/www.qmsk.net/pages/ diff -r 09196d5b2a39 -r 79ea0e2a6cc2 lib/map.py --- a/lib/map.py Sat Feb 07 17:10:06 2009 +0200 +++ b/lib/map.py Sat Feb 07 17:14:01 2009 +0200 @@ -5,13 +5,13 @@ import http import handler -class MappingError (http.ResponseError) : +class MapperError (http.ResponseError) : """ URL could not be mapped """ def __init__ (self, url) : - super(MappingError, self).__init__("URL not found: %s" % (url, ), status='404 Not Found') + super(MapperError, self).__init__("URL not found: %s" % (url, ), status='404 Not Found') class Mapper (handler.RequestHandler) : """ @@ -59,7 +59,7 @@ def test (self, request) : xxx -class StaticMapping (Mapper) : +class StaticMapper (Mapper) : """ Translates requests to handlers using a list of pre-determined Mapping's """ @@ -85,7 +85,7 @@ if not handler : # fail, not found - raise MappingError(request.get_page_name()) + raise MapperError(request.get_page_name()) # passthrough return handler.handle_request(request) diff -r 09196d5b2a39 -r 79ea0e2a6cc2 pages/about.html --- a/pages/about.html Sat Feb 07 17:10:06 2009 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,15 +0,0 @@ -

About me

- -

- My name is Tero Marttila. I'm a student at Helsinki University of Techonology, living in Otaniemi. -

- -

Contact

- -

- I am best reached via IRC, under the nickname of SpComb on any of IRCNet, freenode, OFTC. -

- -

- Alternatively, I'm also reached via email: terom@fixme.fi -

diff -r 09196d5b2a39 -r 79ea0e2a6cc2 pages/debug.tmpl --- a/pages/debug.tmpl Sat Feb 07 17:10:06 2009 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,12 +0,0 @@ - -
-${page_tree.dump() | h}
-
- -
- List of request env variables - -% for key, val in request.env.iteritems() : -
${key}
${val}
-% endfor -
diff -r 09196d5b2a39 -r 79ea0e2a6cc2 pages/index.tmpl --- a/pages/index.tmpl Sat Feb 07 17:10:06 2009 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,9 +0,0 @@ -

- -
-

What's qmsk?

- -

- I'm not sure, but it doesn't have any vowels. -

-
diff -r 09196d5b2a39 -r 79ea0e2a6cc2 pages/list --- a/pages/list Sat Feb 07 17:10:06 2009 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,9 +0,0 @@ - - : Index -projects : Projects - qmsk.net : qmsk.net - evsql : evsql - nr-ttd : Nr-TTD - kg : Kišna Glista -about : About - diff -r 09196d5b2a39 -r 79ea0e2a6cc2 pages/projects/evsql.html --- a/pages/projects/evsql.html Sat Feb 07 17:10:06 2009 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,5 +0,0 @@ -

evsql

-

Evsql is a C-language SQL library designed for use with libevent, and primarily PostgreSQL's libpq.

- -

For more information, read the Doxygen documentation, or look at the Mercurial repo (currently part of evfuse).

- diff -r 09196d5b2a39 -r 79ea0e2a6cc2 pages/projects/foo.html --- a/pages/projects/foo.html Sat Feb 07 17:10:06 2009 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,1 +0,0 @@ -The foo project diff -r 09196d5b2a39 -r 79ea0e2a6cc2 pages/projects/index.html --- a/pages/projects/index.html Sat Feb 07 17:10:06 2009 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,14 +0,0 @@ -

Projects

- -

I've worked on a variety of projects over the years, leaving them in various stages of completion.

- -

Some of the perhaps more noteworthy ones have their own project pages here (see menu to the left).

- -

Nr-TTD

- -

A bunch of Microsoft batch-file code that functions as an installer for TTD Patch, a third-party binary patch for an old game.

- -

Kišna Glista

- -

An open-source Liero clone (the 985th one).

- diff -r 09196d5b2a39 -r 79ea0e2a6cc2 pages/projects/kg.html --- a/pages/projects/kg.html Sat Feb 07 17:10:06 2009 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,6 +0,0 @@ -

Kišna Glista

- -

Kišna Glista is a (yet another) Liero clone written in C++, with GPL source code, running on Linux platforms.

- -

Visit the project website for more information

- diff -r 09196d5b2a39 -r 79ea0e2a6cc2 pages/projects/nr-ttd.html --- a/pages/projects/nr-ttd.html Sat Feb 07 17:10:06 2009 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,49 +0,0 @@ -

Summary

- -

nr-TTD (originally No Registry - TTD) is a batch file installer for TTD. It can download and install TTD, TTD Patch, TTD Patch Configurator as well as a (poor) selection of newgrf files.

- -

Please note that the project is not under any form of active development anymore.

- -

Install

- -
    -
  1. Download the latest version
  2. -
  3. Extract/unzip the file into the folder you want to install TTD into
  4. -
  5. Double-click install.bat
  6. -
  7. Answer the questions, make the choices
  8. -
  9. Done
  10. -
- -

Playing

- -

Usually, you can play TTD by simply running ttdpatchw.exe in the folder that you unzipped Nr-TTD to. For added convenience you can create a shortcut to the ttdpatchw.exe file:

- -
    -
  1. Right-click ttdpatchw.exe
  2. -
  3. From the Send To menu, select Send to Desktop (create shortcut)
  4. -
  5. Rename the resulting shortcut on your Desktop (right click -> Rename) to, say, TTD Patch
  6. -
- -

Then simply run this shortcut to play TTD.

- -

Registry errors

- -

In case you get registry errors when running ttdpatchw.exe (as may be the case when installing on top of previous installs of TTD), you should simply use run-forcenoreg.bat instead of ttdpatchw.exe. This instructs TTD Patch to ignore the windows registry, which should solve all registry problems.

- -

Configuring

- -

Nr-TTD also installs the TTD Patch Configurator, which can be used to change your TTD Patch configuration. This enables you to tweak your gameplay in many different ways, and it is highly recommended that you look through the available settings. Refer to the TTD Patch Manual for further information on the induvidual switches.

- -

Simply run ttdpc.exe from the TTD folder.

- -

Requirements

-

Nr-TTD uses fairly new batch file syntax, and hence probably only works on Windows XP SP2 or later. Space requirements are about 20MB or so. Total download size is some 9 MB without newgrfs, and then a couple hundred KB per newgrf.

- -

TTD Patch should work on Windows Vista as well, provided you have a recent enough version (grab the file called TTDPatch-nightly-rXXXX-win32.zip), which you may need to download yourself.

- -

Problems? Suggestions?

- -

Not working? Cryptic error messages? Turned your default language into swahili? Unfortunately, there is nobody actively fixing bugs, but you can try asking for help.

- -

Discuss Nr-TTD using the appropriate TT-Forums topic.

- diff -r 09196d5b2a39 -r 79ea0e2a6cc2 pages/projects/qmsk.net.html --- a/pages/projects/qmsk.net.html Sat Feb 07 17:10:06 2009 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,6 +0,0 @@ -

qmsk.net

-

This is the code that runs this website itself.

- -

It's a relatively simple WSGI-based CGI script that renders various kinds of pages from the filesystem, along with a nice menu.

- -

Mercurial repo

diff -r 09196d5b2a39 -r 79ea0e2a6cc2 sites/irclogs.qmsk.net/urls.py --- a/sites/irclogs.qmsk.net/urls.py Sat Feb 07 17:10:06 2009 +0200 +++ b/sites/irclogs.qmsk.net/urls.py Sat Feb 07 17:14:01 2009 +0200 @@ -7,14 +7,14 @@ import handlers # library stuff -from lib.map import StaticMapping, map, mapre +from lib.map import StaticMapper, map, mapre def build_mapper () : """ Construct and return the Mapping object """ - return StaticMapping([ + return StaticMapper([ map( '/', handlers.index ), map( '/channel/%s', handlers.channel_view ), mapre( r'^/channel/(\w+)/last/(\d+)(\.\w+)?', handlers.channel_last ), diff -r 09196d5b2a39 -r 79ea0e2a6cc2 sites/www.qmsk.net/__init__.py --- a/sites/www.qmsk.net/__init__.py Sat Feb 07 17:10:06 2009 +0200 +++ b/sites/www.qmsk.net/__init__.py Sat Feb 07 17:14:01 2009 +0200 @@ -3,8 +3,8 @@ """ from lib import template -import map +import lookup # global mapper attribute -handler = map.FilesystemMapper("pages", template=template.TemplateLoader.load("sites/www.qmsk.net/templates/layout.tmpl")) +handler = lookup.PageMapper("sites/www.qmsk.net/pages", template=template.TemplateLoader.load("sites/www.qmsk.net/templates/layout.tmpl")) diff -r 09196d5b2a39 -r 79ea0e2a6cc2 sites/www.qmsk.net/lookup.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sites/www.qmsk.net/lookup.py Sat Feb 07 17:14:01 2009 +0200 @@ -0,0 +1,120 @@ + +import os, os.path + +from lib import http, template, map + +import page, page_tree + +class PageMapper (map.Mapper) : + """ + Translates requests to handlers based on a filesystem directory containing various kinds of files + """ + + # list of page handlers, by type + PAGE_TYPES = [ + ('html', page.HTMLPage ), + (template.TEMPLATE_EXT, page.TemplatePage ), + ] + + def __init__ (self, path, template) : + """ + Create, path is where the pages are stored. The list of pages is loaded from $path/list + """ + + # store + self.path = path + self.template = template + + # load the page tree + self.tree = page_tree.PageTree(path + '/list') + + def _lookup_page_type (self, url, path, filename, basename, extension, tail) : + """ + We found the file that we looked for, now get the correct type + """ + + # find appropriate handler + for handler_ext, type in self.PAGE_TYPES : + # match against file extension? + if handler_ext == extension : + # found handler, return instance + return type(self, url, path, basename, tail) + + # no handler found + raise PageError("No handler found for page %r of type %r" % (url, extension)) + + def _lookup_page (self, name) : + """ + Look up and return a Page object for the given page, or raise an error + """ + + # inital path + path = self.path + url_segments = [] + + # name segments + segments = name.split('/') + + # iterate through the parts of the page segments + while True : + segment = None + + # pop segment + if segments : + segment = segments.pop(0) + + url_segments.append(segment) + + # translate empty -> index + if not segment : + segment = 'index' + + # look for it in the dir + for filename in os.listdir(path) : + # build full file path + file_path = os.path.join(path, filename) + + # stat, recurse into subdirectory? + if os.path.isdir(file_path) and filename == segment : + # use new dir + path = file_path + + # break for-loop to look at next segment + break + + # split into basename + extension + basename, extension = os.path.splitext(filename) + + # ...remove that dot + extension = extension.lstrip('.') + + # match against requested page name? + if basename == segment : + # found the file we wanted + return self._lookup_page_type('/'.join(url_segments), file_path, filename, basename, extension, '/'.join(segments)) + + else : + # inspect next file in dir + continue + + else : + # did not find any dir or file, break out of while loop + break + + # did not find the filename we were looking for in os.listdir + raise map.MapperError(name) + + def handle_request (self, request) : + """ + Looks up the appropriate Page, and then renders it + """ + + # determine the page name + page_name = request.get_page_name() + + # get the page handler + page = self._lookup_page(page_name) + + # pass on + return page.handle_request(request) + diff -r 09196d5b2a39 -r 79ea0e2a6cc2 sites/www.qmsk.net/map.py --- a/sites/www.qmsk.net/map.py Sat Feb 07 17:10:06 2009 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,120 +0,0 @@ - -import os, os.path - -from lib import http, template, map - -import page, page_tree - -class FilesystemMapper (map.Mapper) : - """ - Translates requests to handlers based on a filesystem directory containing various kinds of files - """ - - # list of page handlers, by type - PAGE_TYPES = [ - ('html', page.HTMLPage ), - (template.TEMPLATE_EXT, page.TemplatePage ), - ] - - def __init__ (self, path, template) : - """ - Create, path is where the pages are stored. The list of pages is loaded from $path/list - """ - - # store - self.path = path - self.template = template - - # load the page tree - self.tree = page_tree.PageTree(path + '/list') - - def _lookup_page_type (self, url, path, filename, basename, extension, tail) : - """ - We found the file that we looked for, now get the correct type - """ - - # find appropriate handler - for handler_ext, type in self.PAGE_TYPES : - # match against file extension? - if handler_ext == extension : - # found handler, return instance - return type(self, url, path, basename, tail) - - # no handler found - raise PageError("No handler found for page %r of type %r" % (url, extension)) - - def _lookup_page (self, name) : - """ - Look up and return a Page object for the given page, or raise an error - """ - - # inital path - path = self.path - url_segments = [] - - # name segments - segments = name.split('/') - - # iterate through the parts of the page segments - while True : - segment = None - - # pop segment - if segments : - segment = segments.pop(0) - - url_segments.append(segment) - - # translate empty -> index - if not segment : - segment = 'index' - - # look for it in the dir - for filename in os.listdir(path) : - # build full file path - file_path = os.path.join(path, filename) - - # stat, recurse into subdirectory? - if os.path.isdir(file_path) and filename == segment : - # use new dir - path = file_path - - # break for-loop to look at next segment - break - - # split into basename + extension - basename, extension = os.path.splitext(filename) - - # ...remove that dot - extension = extension.lstrip('.') - - # match against requested page name? - if basename == segment : - # found the file we wanted - return self._lookup_page_type('/'.join(url_segments), file_path, filename, basename, extension, '/'.join(segments)) - - else : - # inspect next file in dir - continue - - else : - # did not find any dir or file, break out of while loop - break - - # did not find the filename we were looking for in os.listdir - raise PageError("Page not found: %s" % name, status='404 Not Found') - - def handle_request (self, request) : - """ - Looks up the appropriate Page, and then renders it - """ - - # determine the page name - page_name = request.get_page_name() - - # get the page handler - page = self._lookup_page(page_name) - - # pass on - return page.handle_request(request) - diff -r 09196d5b2a39 -r 79ea0e2a6cc2 sites/www.qmsk.net/pages/about.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sites/www.qmsk.net/pages/about.html Sat Feb 07 17:14:01 2009 +0200 @@ -0,0 +1,15 @@ +

About me

+ +

+ My name is Tero Marttila. I'm a student at Helsinki University of Techonology, living in Otaniemi. +

+ +

Contact

+ +

+ I am best reached via IRC, under the nickname of SpComb on any of IRCNet, freenode, OFTC. +

+ +

+ Alternatively, I'm also reached via email: terom@fixme.fi +

diff -r 09196d5b2a39 -r 79ea0e2a6cc2 sites/www.qmsk.net/pages/debug.tmpl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sites/www.qmsk.net/pages/debug.tmpl Sat Feb 07 17:14:01 2009 +0200 @@ -0,0 +1,12 @@ + +
+${page_tree.dump() | h}
+
+ +
+ List of request env variables + +% for key, val in request.env.iteritems() : +
${key}
${val}
+% endfor +
diff -r 09196d5b2a39 -r 79ea0e2a6cc2 sites/www.qmsk.net/pages/index.tmpl --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sites/www.qmsk.net/pages/index.tmpl Sat Feb 07 17:14:01 2009 +0200 @@ -0,0 +1,9 @@ +

+ +
+

What's qmsk?

+ +

+ I'm not sure, but it doesn't have any vowels. +

+
diff -r 09196d5b2a39 -r 79ea0e2a6cc2 sites/www.qmsk.net/pages/list --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sites/www.qmsk.net/pages/list Sat Feb 07 17:14:01 2009 +0200 @@ -0,0 +1,9 @@ + + : Index +projects : Projects + qmsk.net : qmsk.net + evsql : evsql + nr-ttd : Nr-TTD + kg : Kišna Glista +about : About + diff -r 09196d5b2a39 -r 79ea0e2a6cc2 sites/www.qmsk.net/pages/projects/evsql.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sites/www.qmsk.net/pages/projects/evsql.html Sat Feb 07 17:14:01 2009 +0200 @@ -0,0 +1,5 @@ +

evsql

+

Evsql is a C-language SQL library designed for use with libevent, and primarily PostgreSQL's libpq.

+ +

For more information, read the Doxygen documentation, or look at the Mercurial repo (currently part of evfuse).

+ diff -r 09196d5b2a39 -r 79ea0e2a6cc2 sites/www.qmsk.net/pages/projects/foo.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sites/www.qmsk.net/pages/projects/foo.html Sat Feb 07 17:14:01 2009 +0200 @@ -0,0 +1,1 @@ +The foo project diff -r 09196d5b2a39 -r 79ea0e2a6cc2 sites/www.qmsk.net/pages/projects/index.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sites/www.qmsk.net/pages/projects/index.html Sat Feb 07 17:14:01 2009 +0200 @@ -0,0 +1,14 @@ +

Projects

+ +

I've worked on a variety of projects over the years, leaving them in various stages of completion.

+ +

Some of the perhaps more noteworthy ones have their own project pages here (see menu to the left).

+ +

Nr-TTD

+ +

A bunch of Microsoft batch-file code that functions as an installer for TTD Patch, a third-party binary patch for an old game.

+ +

Kišna Glista

+ +

An open-source Liero clone (the 985th one).

+ diff -r 09196d5b2a39 -r 79ea0e2a6cc2 sites/www.qmsk.net/pages/projects/kg.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sites/www.qmsk.net/pages/projects/kg.html Sat Feb 07 17:14:01 2009 +0200 @@ -0,0 +1,6 @@ +

Kišna Glista

+ +

Kišna Glista is a (yet another) Liero clone written in C++, with GPL source code, running on Linux platforms.

+ +

Visit the project website for more information

+ diff -r 09196d5b2a39 -r 79ea0e2a6cc2 sites/www.qmsk.net/pages/projects/nr-ttd.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sites/www.qmsk.net/pages/projects/nr-ttd.html Sat Feb 07 17:14:01 2009 +0200 @@ -0,0 +1,49 @@ +

Summary

+ +

nr-TTD (originally No Registry - TTD) is a batch file installer for TTD. It can download and install TTD, TTD Patch, TTD Patch Configurator as well as a (poor) selection of newgrf files.

+ +

Please note that the project is not under any form of active development anymore.

+ +

Install

+ +
    +
  1. Download the latest version
  2. +
  3. Extract/unzip the file into the folder you want to install TTD into
  4. +
  5. Double-click install.bat
  6. +
  7. Answer the questions, make the choices
  8. +
  9. Done
  10. +
+ +

Playing

+ +

Usually, you can play TTD by simply running ttdpatchw.exe in the folder that you unzipped Nr-TTD to. For added convenience you can create a shortcut to the ttdpatchw.exe file:

+ +
    +
  1. Right-click ttdpatchw.exe
  2. +
  3. From the Send To menu, select Send to Desktop (create shortcut)
  4. +
  5. Rename the resulting shortcut on your Desktop (right click -> Rename) to, say, TTD Patch
  6. +
+ +

Then simply run this shortcut to play TTD.

+ +

Registry errors

+ +

In case you get registry errors when running ttdpatchw.exe (as may be the case when installing on top of previous installs of TTD), you should simply use run-forcenoreg.bat instead of ttdpatchw.exe. This instructs TTD Patch to ignore the windows registry, which should solve all registry problems.

+ +

Configuring

+ +

Nr-TTD also installs the TTD Patch Configurator, which can be used to change your TTD Patch configuration. This enables you to tweak your gameplay in many different ways, and it is highly recommended that you look through the available settings. Refer to the TTD Patch Manual for further information on the induvidual switches.

+ +

Simply run ttdpc.exe from the TTD folder.

+ +

Requirements

+

Nr-TTD uses fairly new batch file syntax, and hence probably only works on Windows XP SP2 or later. Space requirements are about 20MB or so. Total download size is some 9 MB without newgrfs, and then a couple hundred KB per newgrf.

+ +

TTD Patch should work on Windows Vista as well, provided you have a recent enough version (grab the file called TTDPatch-nightly-rXXXX-win32.zip), which you may need to download yourself.

+ +

Problems? Suggestions?

+ +

Not working? Cryptic error messages? Turned your default language into swahili? Unfortunately, there is nobody actively fixing bugs, but you can try asking for help.

+ +

Discuss Nr-TTD using the appropriate TT-Forums topic.

+ diff -r 09196d5b2a39 -r 79ea0e2a6cc2 sites/www.qmsk.net/pages/projects/qmsk.net.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/sites/www.qmsk.net/pages/projects/qmsk.net.html Sat Feb 07 17:14:01 2009 +0200 @@ -0,0 +1,6 @@ +

qmsk.net

+

This is the code that runs this website itself.

+ +

It's a relatively simple WSGI-based CGI script that renders various kinds of pages from the filesystem, along with a nice menu.

+ +

Mercurial repo