From 8b7755b83422f423931d7d56a26de8af417bba2f Mon Sep 17 00:00:00 2001 From: epriestley Date: Fri, 4 Feb 2011 16:18:08 -0800 Subject: [PATCH] Changeset anchor links. --- .../storage/changeset/DifferentialChangeset.php | 4 ++++ .../DifferentialChangesetDetailView.php | 7 ++++++- .../DifferentialDiffTableOfContentsView.php | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/applications/differential/storage/changeset/DifferentialChangeset.php b/src/applications/differential/storage/changeset/DifferentialChangeset.php index db925ee0b9..794ef437b0 100644 --- a/src/applications/differential/storage/changeset/DifferentialChangeset.php +++ b/src/applications/differential/storage/changeset/DifferentialChangeset.php @@ -139,5 +139,9 @@ class DifferentialChangeset extends DifferentialDAO { } return implode("\n", $file); } + + public function getAnchorName() { + return substr(md5($this->getFilename()), 0, 8); + } } diff --git a/src/applications/differential/view/changesetdetailview/DifferentialChangesetDetailView.php b/src/applications/differential/view/changesetdetailview/DifferentialChangesetDetailView.php index ccba6739db..8f1ac14a27 100644 --- a/src/applications/differential/view/changesetdetailview/DifferentialChangesetDetailView.php +++ b/src/applications/differential/view/changesetdetailview/DifferentialChangesetDetailView.php @@ -54,7 +54,12 @@ class DifferentialChangesetDetailView extends AphrontView { ), 'class' => $class, ), - ''. + phutil_render_tag( + 'a', + array( + 'name' => $changeset->getAnchorName(), + ), + ''). implode('', $this->buttons). '

'.phutil_escape_html($display_filename).'

'. '
'. diff --git a/src/applications/differential/view/difftableofcontents/DifferentialDiffTableOfContentsView.php b/src/applications/differential/view/difftableofcontents/DifferentialDiffTableOfContentsView.php index f755c0571f..96adacee77 100644 --- a/src/applications/differential/view/difftableofcontents/DifferentialDiffTableOfContentsView.php +++ b/src/applications/differential/view/difftableofcontents/DifferentialDiffTableOfContentsView.php @@ -65,7 +65,7 @@ final class DifferentialDiffTableOfContentsView extends AphrontView { $link = phutil_render_tag( 'a', array( - 'href' => '#', // TODO: filename normalizer + 'href' => '#'.$changeset->getAnchorName(), ), phutil_escape_html($display_file)); if ($type == DifferentialChangeType::TYPE_MOVE_HERE) {