name = m.group(1)
descr = m.group(2) or name
name = relative_url(name)
+ argv = descr.split('|')
+ descr = argv.pop(0)
+ if argv:
+ args = '?' + '&'.join(argv)
+ else:
+ args = ''
if descr:
# The "extthumb" nonsense works around a limitation of the HTML block model
- return '<div class="extthumb"><div class="thumb"><a href="%s"><img border="0" src="%s" alt="%s" /></a><div class="caption">%s</div></div></div>' % (name, name, descr, descr)
+ return '<div class="extthumb"><div class="thumb"><a href="%s"><img border="0" src="%s" alt="%s" /></a><div class="caption">%s</div></div></div>' \
+ % (name, name + args, descr, descr)
else:
- return '<a href="%s"><img border="0" src="%s" /></a>' % (name, name)
+ return '<a href="%s"><img border="0" src="%s" /></a>' % (name, name + args)
def _email_repl(self, word):
return '<a href="mailto:%s">%s</a>' % (word, word)
raise er
def format_dir(self):
- out = ''
+ out = '== '
+ path = ''
+ for dir in self.page_name.split('/'):
+ path = (path + '/' + dir) if path else dir
+ out += '[[' + path + '|' + dir + ']]/'
+ out += ' ==\n'
+
for file in page_list(self._filename(), file_re):
if img_re.match(file):
- out += ' * {{' + self.page_name + '/' + file + '}}\n'
+ if image_maxwidth:
+ maxwidth_arg = '|maxwidth=' + str(image_maxwidth)
+ out += '{{' + self.page_name + '/' + file + '|' + file + maxwidth_arg + '}}\n'
else:
out += ' * [[' + self.page_name + '/' + file + ']]\n'
return out
else:
send_title(None, msg_text='Read access denied by ACLs', msg_type='notice')
+ def send_image(self, mimetype, args=[]):
+ if 'maxwidth' in args:
+ import subprocess
+ emit_header(mimetype)
+ sys.stdout.flush()
+ subprocess.check_call(['gm', 'convert', self._filename(),
+ '-scale', args['maxwidth'].value + ' >', '-'])
+ else:
+ self.send_raw(mimetype)
+
def _write_file(self, data):
tmp_filename = self._tmp_filename()
open(tmp_filename, 'wb').write(data)
else:
from mimetypes import MimeTypes
type, encoding = MimeTypes().guess_type(query)
- type = type or 'text/plain'
- Page(query).send_raw(mimetype=type)
+ #type = type or 'text/plain'
+ #Page(query).send_raw(mimetype=type)
+ if type:
+ if type.startswith('image/'):
+ Page(query).send_image(mimetype=type,args=form)
+ else:
+ Page(query).send_raw(mimetype=type)
+ else:
+ Page(query).format()
else:
print "Status: 404 Not Found"
send_title(None, msg_text='Can\'t work out query: ' + query)