Move some helper functions into models
Getty Ritter
4 years ago
8 | 8 | class Image(typing.NamedTuple): |
9 | 9 | image: str |
10 | 10 | |
11 | def thumb(self): | |
12 | return self.image[:-4] + '_thumb' + self.image[-4:] | |
13 | ||
11 | 14 | class PageContent: |
12 | 15 | def __init__(self, source): |
13 | 16 | self.source = source |
14 | 17 | |
15 | 18 | def rendered(self): |
16 | 19 | return markdown.markdown(self.source) |
20 | ||
21 | def snipped(self): | |
22 | if len(self.source) < 256: | |
23 | return self.source | |
24 | else: | |
25 | return self.source[:256] + '...' | |
17 | 26 | |
18 | 27 | class Design(typing.NamedTuple): |
19 | 28 | title: str |