|
@ -4,8 +4,8 @@ |
|
|
"""Contains the GroupWikiPage class.""" |
|
|
"""Contains the GroupWikiPage class.""" |
|
|
|
|
|
|
|
|
from datetime import datetime |
|
|
from datetime import datetime |
|
|
from pathlib import Path |
|
|
|
|
|
from typing import Any, Optional, Sequence, Tuple |
|
|
|
|
|
|
|
|
from pathlib import Path, PurePath |
|
|
|
|
|
from typing import Any, List, Optional, Sequence, Tuple |
|
|
|
|
|
|
|
|
from pygit2 import Repository, Signature |
|
|
from pygit2 import Repository, Signature |
|
|
from pyramid.security import Allow, DENY_ALL, Everyone |
|
|
from pyramid.security import Allow, DENY_ALL, Everyone |
|
@ -104,6 +104,19 @@ class GroupWikiPage(DatabaseModel): |
|
|
"""Return the page's slug, which is also its filename with no extension.""" |
|
|
"""Return the page's slug, which is also its filename with no extension.""" |
|
|
return self.file_path.stem |
|
|
return self.file_path.stem |
|
|
|
|
|
|
|
|
|
|
|
@property |
|
|
|
|
|
def folders(self) -> List[PurePath]: |
|
|
|
|
|
"""Return a list of the folders the page is inside (if any).""" |
|
|
|
|
|
path = PurePath(self.path) |
|
|
|
|
|
|
|
|
|
|
|
# the last element of .parents will be ".", chop that off |
|
|
|
|
|
folders = list(path.parents)[:-1] |
|
|
|
|
|
|
|
|
|
|
|
# reverse the list, since .parents goes "upwards" towards root |
|
|
|
|
|
folders.reverse() |
|
|
|
|
|
|
|
|
|
|
|
return folders |
|
|
|
|
|
|
|
|
@property |
|
|
@property |
|
|
def history_url(self) -> str: |
|
|
def history_url(self) -> str: |
|
|
"""Return a url to the page's edit history.""" |
|
|
"""Return a url to the page's edit history.""" |
|
|