Skip to content
This repository has been archived by the owner on May 9, 2021. It is now read-only.

Commit

Permalink
new feature: convert issue no. text into the issue url
Browse files Browse the repository at this point in the history
  • Loading branch information
satrun77 committed Jan 30, 2014
1 parent 8b9e91b commit 4e9e1d4
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 2 deletions.
5 changes: 4 additions & 1 deletion app/application/models/project/issue/comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ public static function delete_comment($comment)
*/
public static function format($body)
{
return \Sparkdown\Markdown($body);
$body = \Sparkdown\Markdown($body);

// convert issue numbers into issue url
return preg_replace('/((?:' . __('tinyissue.issue') . ')?)(\s*)#(\d+)/i', '<a href="' . \URL::to('/project/0/issue/$3') . '" title="$1 #$3" class="issue-link">$1 #$3</a>', $body);
}
}
17 changes: 16 additions & 1 deletion app/application/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,11 @@

Route::filter('project', function()
{
// find project id from issue object
if (Request::route()->parameters[0] == 0) {
return;
}

Project::load_project(Request::route()->parameters[0]);

if(!Project::current())
Expand All @@ -126,9 +131,19 @@
{
return Response::error('404');
}

// load project
if (Request::route()->parameters[0] == 0) {
Request::route()->parameters = array(
Project\Issue::current()->project_id,
Project\Issue::current()->id
);

Project::load_project(Request::route()->parameters[0]);
}
});

Route::filter('permission', function($permission)
{
if(!Auth::user()->permission($permission)) return Response::error('500');
});
});

0 comments on commit 4e9e1d4

Please sign in to comment.