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) -> ...@@ -316,7 +316,7 @@ username = ['$filter', '$window', ($filter, $window) ->
return unless ctrl? return unless ctrl?
ctrl.$render = -> ctrl.$render = ->
scope.uname = ($filter 'userName') ctrl.$viewValue scope.uname = ($filter 'persona') ctrl.$viewValue
scope.uclick = (event) -> scope.uclick = (event) ->
event.stopPropagation() event.stopPropagation()
......
...@@ -40,8 +40,9 @@ fuzzyTime = (date) -> ...@@ -40,8 +40,9 @@ fuzzyTime = (date) ->
fuzzy = Math.round(delta / year) + ' years ago' fuzzy = Math.round(delta / year) + ' years ago'
fuzzy fuzzy
userName = (user) -> persona = (user, part='username') ->
(user?.match /^acct:([^@]+)/)?[1] part = ['term', 'username', 'provider'].indexOf(part)
(user?.match /^acct:([^@]+)@(.+)/)?[part]
elide = (text, split_length) -> elide = (text, split_length) ->
if text.length > split_length if text.length > split_length
...@@ -53,5 +54,5 @@ elide = (text, split_length) -> ...@@ -53,5 +54,5 @@ elide = (text, split_length) ->
angular.module('h.filters', []) angular.module('h.filters', [])
.filter('converter', -> (new Converter()).makeHtml) .filter('converter', -> (new Converter()).makeHtml)
.filter('fuzzyTime', -> fuzzyTime) .filter('fuzzyTime', -> fuzzyTime)
.filter('userName', -> userName) .filter('persona', -> persona)
.filter('elide', -> elide) .filter('elide', -> elide)
...@@ -705,7 +705,7 @@ class ViewFilter ...@@ -705,7 +705,7 @@ class ViewFilter
this.$inject = ['$filter'] this.$inject = ['$filter']
constructor: ($filter) -> constructor: ($filter) ->
@user_filter = $filter('userName') @user_filter = $filter('persona')
# Filters a set of annotations, according to a given query. # Filters a set of annotations, according to a given query.
# #
...@@ -747,8 +747,8 @@ class ViewFilter ...@@ -747,8 +747,8 @@ class ViewFilter
for category, value of query for category, value of query
switch category switch category
when 'user' when 'user'
userName = @user_filter annotation.user username = @user_filter annotation.user
unless userName?.toLowerCase() is value unless username?.toLowerCase() is value
matches = false matches = false
break break
when 'text' 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