User:Nightmareci: Difference between revisions
Nightmareci (talk | contribs) No edit summary |
Nightmareci (talk | contribs) No edit summary |
||
Line 22: | Line 22: | ||
== Other Stuff == | == Other Stuff == | ||
=== Playfield Template Converters === | |||
The old playfield templates are problematic for both bandwidth and server load; the new <playfield> parser extension alleviates those problems, and these can convert pages to the new syntax: | |||
==== Awk Version ==== | |||
I, Nightmareci, made this one; I put it in the public domain, so do as you wish with it. | |||
<pre>#!/bin/awk -f | |||
/\{\{ *pfstart *\}\}/,/\{\{ *pfend *\}\}/ { | |||
sub(/\{\{ *pfstart *\}\}/, "<playfield>") | |||
sub(/\{\{ *(pf|width[3-6]|tnet)row */, "") && gsub(/\||\}\}/, "") && gsub(/ /, ".") | |||
sub(/\{\{ *pfend *\}\}/, "</playfield>") | |||
print | |||
next | |||
} | |||
1 | |||
</pre> | |||
==== Python Version ==== | |||
I, Nightmareci, made this one; I put it in the public domain, so do as you wish with it. | |||
<pre>#!/usr/bin/env python | |||
import fileinput | |||
import re | |||
start = re.compile(r'\{\{pfstart\}\}') | |||
row = re.compile(r'\{\{(?:pf|tnet|width[3-6])row *([^}]*)\}\}') | |||
end = re.compile(r'\{\{pfend\}\}') | |||
# Because we need more explicit control over moving between lines, we must use | |||
# an actual FileInput instance. | |||
files = fileinput.input() | |||
for line in files: | |||
# Find the beginning of the playfield. | |||
if start.search(line): | |||
# Replace '{{pfstart}}' with '<playfield>' | |||
print start.sub('<playfield>', line, 1), | |||
for line in files: | |||
# If the current line is '{{pfend}}', replace with | |||
# '</playfield>' and break out | |||
if end.search(line): | |||
print end.sub('</playfield>', line, 1), | |||
break | |||
# If this is not '{{pfend}}', this line is a row, so | |||
# convert it to the new syntax. | |||
else: | |||
# First, the template arguments are extracted | |||
# from the row, then the pipes, '|', are | |||
# removed, then spaces, ' ', are changed to | |||
# periods, '.'. | |||
print row.sub(r'\1', line, 1).replace('|', | |||
'').replace(' ', '.').upper(), | |||
# This line isn't the beginning of a playfield, so just print. | |||
else: | |||
print line, | |||
</pre> | |||
==== Perl Version ==== | |||
DeHackEd made this one, and I'm not sure what conditions he has over it; just assume it's freeware for now: | |||
<pre>#!/usr/bin/perl | |||
while (<>) { | |||
chomp; | |||
if (/^(.*)\{\{pfstart\}\}(.*)$/) { | |||
print "$1<playfield>$2\n"; | |||
} | |||
elsif (/^\{\{pfrow ?\|(.*)\}\}$/) { | |||
#$begin = $1; | |||
$code = $1; | |||
#$end = $3; | |||
@stuff = split(/\|/, $code); | |||
#print STDERR "$code @stuff\n"; | |||
print join("", @stuff). "\n"; | |||
} | |||
elsif (/\{\{pfend\}\}(.*)$/) { | |||
print "</playfield>$1\n"; | |||
} | |||
else { | |||
print "$_\n"; | |||
} | |||
} | |||
</pre> | |||
<playfield> | <playfield> | ||
ZZZ | ZZZ |
Revision as of 00:29, 25 July 2009
Definitions
Terms in TGM legend and Glossary will be used in my pages, with the original definitions. If you encounter a confusing term, look in TGM legend first, then Glossary if it's not in TGM legend.
Row Numbering
In my pages, row numbering follows this convention:
- Vanish zone
- First visible row
- Second visible row ...
- Nineteenth visible row
- Twentieth visible row (last)
Row number 0 is the topmost row and successive rows are beneath it. In the listing above (which is TGM1's row configuration), there is a total of 21 usable rows.
My Own Pages
Detailed description of Tetris The Grand Master
Other Stuff
Playfield Template Converters
The old playfield templates are problematic for both bandwidth and server load; the new <playfield> parser extension alleviates those problems, and these can convert pages to the new syntax:
Awk Version
I, Nightmareci, made this one; I put it in the public domain, so do as you wish with it.
#!/bin/awk -f /\{\{ *pfstart *\}\}/,/\{\{ *pfend *\}\}/ { sub(/\{\{ *pfstart *\}\}/, "<playfield>") sub(/\{\{ *(pf|width[3-6]|tnet)row */, "") && gsub(/\||\}\}/, "") && gsub(/ /, ".") sub(/\{\{ *pfend *\}\}/, "</playfield>") print next } 1
Python Version
I, Nightmareci, made this one; I put it in the public domain, so do as you wish with it.
#!/usr/bin/env python import fileinput import re start = re.compile(r'\{\{pfstart\}\}') row = re.compile(r'\{\{(?:pf|tnet|width[3-6])row *([^}]*)\}\}') end = re.compile(r'\{\{pfend\}\}') # Because we need more explicit control over moving between lines, we must use # an actual FileInput instance. files = fileinput.input() for line in files: # Find the beginning of the playfield. if start.search(line): # Replace '{{pfstart}}' with '<playfield>' print start.sub('<playfield>', line, 1), for line in files: # If the current line is '{{pfend}}', replace with # '</playfield>' and break out if end.search(line): print end.sub('</playfield>', line, 1), break # If this is not '{{pfend}}', this line is a row, so # convert it to the new syntax. else: # First, the template arguments are extracted # from the row, then the pipes, '|', are # removed, then spaces, ' ', are changed to # periods, '.'. print row.sub(r'\1', line, 1).replace('|', '').replace(' ', '.').upper(), # This line isn't the beginning of a playfield, so just print. else: print line,
Perl Version
DeHackEd made this one, and I'm not sure what conditions he has over it; just assume it's freeware for now:
#!/usr/bin/perl while (<>) { chomp; if (/^(.*)\{\{pfstart\}\}(.*)$/) { print "$1<playfield>$2\n"; } elsif (/^\{\{pfrow ?\|(.*)\}\}$/) { #$begin = $1; $code = $1; #$end = $3; @stuff = split(/\|/, $code); #print STDERR "$code @stuff\n"; print join("", @stuff). "\n"; } elsif (/\{\{pfend\}\}(.*)$/) { print "</playfield>$1\n"; } else { print "$_\n"; } }