def clip_text(text, maxsize):
    """ Limit the text to a certain length, inserting dots in the middle. """
    if len(text) > maxsize:
        text = text[:maxsize//2] + '...' + text[-maxsize//2:]
    return text