Commit 71405594 authored by Randall Leeds's avatar Randall Leeds

userName -> persona filter and parameterization

Make the userName filter more useful by expanding it to a general
parameterized persona filter.
parent d52868f1
......@@ -316,7 +316,7 @@ username = ['$filter', '$window', ($filter, $window) ->
return unless ctrl?
ctrl.$render = ->
scope.uname = ($filter 'userName') ctrl.$viewValue
scope.uname = ($filter 'persona') ctrl.$viewValue
scope.uclick = (event) ->
event.stopPropagation()
......
......@@ -40,8 +40,9 @@ fuzzyTime = (date) ->
fuzzy = Math.round(delta / year) + ' years ago'
fuzzy
userName = (user) ->
(user?.match /^acct:([^@]+)/)?[1]
persona = (user, part='username') ->
part = ['term', 'username', 'provider'].indexOf(part)
(user?.match /^acct:([^@]+)@(.+)/)?[part]
elide = (text, split_length) ->
if text.length > split_length
......@@ -53,5 +54,5 @@ elide = (text, split_length) ->
angular.module('h.filters', [])
.filter('converter', -> (new Converter()).makeHtml)
.filter('fuzzyTime', -> fuzzyTime)
.filter('userName', -> userName)
.filter('persona', -> persona)
.filter('elide', -> elide)
......@@ -705,7 +705,7 @@ class ViewFilter
this.$inject = ['$filter']
constructor: ($filter) ->
@user_filter = $filter('userName')
@user_filter = $filter('persona')
# Filters a set of annotations, according to a given query.
#
......@@ -747,8 +747,8 @@ class ViewFilter
for category, value of query
switch category
when 'user'
userName = @user_filter annotation.user
unless userName?.toLowerCase() is value
username = @user_filter annotation.user
unless username?.toLowerCase() is value
matches = false
break
when 'text'
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment