1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
import os
from .page import Page
def redact_email(email):
if email is None or len(email) == 0:
return ''
if '@' not in email:
return email[0] + '...' + email[-1]
local, domain = email.split('@')
redacted_local = local[0] + '...' + local[-1] if len(local) > 0 else ''
redacted_domain = domain.replace('.', '...')
return redacted_local + '@' + redacted_domain
class CommitPage(Page):
def __init__(self, out_dir, name, commit, content_subdir):
super(CommitPage, self).__init__('commit.md', out_dir, os.path.join(commit.hexsha, '_index.md'), name, content_subdir)
self.commit = commit
def context(self):
return {
'commit': self.commit,
'title': self.name + ': ' + self.commit.hexsha,
'redacted_email': redact_email(self.commit.author.email),
'content_subdir': self.content_subdir
}
|