From 73c49775c12b64b290d0822d65d0e067c6d0648e Mon Sep 17 00:00:00 2001 From: Anh Nhan Nguyen Date: Mon, 8 Apr 2013 11:54:49 -0700 Subject: [PATCH] Displaying links instead of dumping raw remarkup in Phriction mails Summary: Fixes T2900 - Display link to document version and diff for edited Phriction Documents. Also display the target document for moved pages. Test Plan: Edited/Moved some pages, verified that the links are linking to the correct versions. Reviewers: epriestley Reviewed By: epriestley CC: adityar7, aran, Korvin Maniphest Tasks: T2900 Differential Revision: https://secure.phabricator.com/D5615 --- .../editor/PhrictionDocumentEditor.php | 23 +++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/applications/phriction/editor/PhrictionDocumentEditor.php b/src/applications/phriction/editor/PhrictionDocumentEditor.php index 55ebdfe22d..55c0c50a5f 100644 --- a/src/applications/phriction/editor/PhrictionDocumentEditor.php +++ b/src/applications/phriction/editor/PhrictionDocumentEditor.php @@ -294,12 +294,19 @@ final class PhrictionDocumentEditor extends PhabricatorEditor { $author_phid = $this->getActor()->getPHID(); $document = $this->document; $content = $document->getContent(); + $slug_uri = PhrictionDocument::getSlugURI($document->getSlug()); + $diff_uri = new PhutilURI('/phriction/diff/'.$document->getID().'/'); + $prod_uri = PhabricatorEnv::getProductionURI(''); + + $vs_head = $diff_uri + ->alter('l', $old_content->getVersion()) + ->alter('r', $content->getVersion()); $old_title = $old_content->getTitle(); $title = $content->getTitle(); // TODO: Currently, this produces something like - // Phrictioh Document Xyz was Edit + // Phriction Document Xyz was Edit // I'm too lazy to build my own action string everywhere // Plus, it does not have pht() anyway $action = PhrictionChangeType::getChangeTypeLabel( @@ -315,9 +322,17 @@ final class PhrictionDocumentEditor extends PhabricatorEditor { $old_title, $title); } - // The Remarkup text renderer comes in handy - // TODO: Consider sending a diff instead? - $body[] = pht("Content was changed to \n%s", $content->getContent()); + $body[] = pht("Link to new version:\n%s", + $prod_uri.$slug_uri.'?v='.$content->getVersion()); + + $body[] = pht("Link to diff:\n%s", $prod_uri.$vs_head); + } else if ($content->getChangeType() == + PhrictionChangeType::CHANGE_MOVE_AWAY) { + + $target_document = id(new PhrictionDocument()) + ->load($content->getChangeRef()); + $slug_uri = PhrictionDocument::getSlugURI($target_document->getSlug()); + $body[] = pht("Link to destination document:\n%s", $prod_uri.$slug_uri); } $body = implode("\n\n", $body);