Fix canonical tags in notice and in URLs

This commit is contained in:
Adrian Lang 2009-01-26 15:03:38 +01:00 committed by Evan Prodromou
parent 12b9d4346f
commit a80a536e41
2 changed files with 9 additions and 4 deletions

View File

@ -24,13 +24,18 @@ class TagAction extends Action
function prepare($args) function prepare($args)
{ {
parent::prepare($args); parent::prepare($args);
$this->tag = $this->trimmed('tag'); $taginput = $this->trimmed('tag');
$this->tag = common_canonical_tag($taginput);
if (!$this->tag) { if (!$this->tag) {
common_redirect(common_local_url('publictagcloud'), 301); common_redirect(common_local_url('publictagcloud'), 301);
return false; return false;
} }
if ($this->tag != $taginput) {
common_redirect(common_local_url('tag', array('tag' => $this->tag)));
}
$this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1; $this->page = ($this->arg('page')) ? ($this->arg('page')+0) : 1;
return true; return true;
} }

View File

@ -91,11 +91,11 @@ class Notice extends Memcached_DataObject
return true; return true;
} }
/* elide characters we don't want in the tag */
$match[1] = str_replace(array('-', '_', '.'), '', $match[1]);
/* Add them to the database */ /* Add them to the database */
foreach(array_unique($match[1]) as $hashtag) { foreach(array_unique($match[1]) as $hashtag) {
/* elide characters we don't want in the tag */
$hashtag = common_canonical_tag($hashtag);
$tag = DB_DataObject::factory('Notice_tag'); $tag = DB_DataObject::factory('Notice_tag');
$tag->notice_id = $this->id; $tag->notice_id = $this->id;
$tag->tag = $hashtag; $tag->tag = $hashtag;