diff --git a/tildes/tildes/models/group/group_wiki_page.py b/tildes/tildes/models/group/group_wiki_page.py index 8296a3e..2eddce3 100644 --- a/tildes/tildes/models/group/group_wiki_page.py +++ b/tildes/tildes/models/group/group_wiki_page.py @@ -31,6 +31,7 @@ class GroupWikiPage(DatabaseModel): __tablename__ = "group_wiki_pages" BASE_PATH = "/var/lib/tildes-wiki" + GITLAB_REPO_URL = "https://gitlab.com/tildes/tildes-wiki" group_id: int = Column( Integer, ForeignKey("groups.group_id"), nullable=False, primary_key=True @@ -89,7 +90,22 @@ class GroupWikiPage(DatabaseModel): @property def file_path(self) -> Path: """Return the full path to the page's file.""" - return Path(self.BASE_PATH, str(self.group.path), f"{self.slug}.md") + return Path(self.BASE_PATH, self.relative_path) + + @property + def relative_path(self) -> Path: + """Return a relative path to the page's file.""" + return Path(str(self.group.path), f"{self.slug}.md") + + @property + def history_url(self) -> str: + """Return a url to the page's edit history.""" + return f"{self.GITLAB_REPO_URL}/commits/master/{self.relative_path}" + + @property + def blame_url(self) -> str: + """Return a url to the page's blame view.""" + return f"{self.GITLAB_REPO_URL}/blame/master/{self.relative_path}" @property def markdown(self) -> Optional[str]: diff --git a/tildes/tildes/templates/group_wiki_page.jinja2 b/tildes/tildes/templates/group_wiki_page.jinja2 index 810f67f..f219665 100644 --- a/tildes/tildes/templates/group_wiki_page.jinja2 +++ b/tildes/tildes/templates/group_wiki_page.jinja2 @@ -29,6 +29,10 @@
Last edited
{{ adaptive_date_responsive(page.last_edited_time) }}
+ +
Edit history (on GitLab)
+
Full edit history
+
Line-by-line ("blame") view
{% if request.has_permission("edit", page) %}