Commit 5f50f29bceb6b28fde2a1ab352fe976f4576690a
search: suggest pages when '/' typed
Matt McKegg committed on 4/23/2017, 5:56:19 AMParent: a61adf51b6aeb00c6018ce2fb80cba9383b52625
Files changed
modules/app/html/search.js | changed |
modules/app/html/search.js | ||
---|---|---|
@@ -8,8 +8,10 @@ | ||
8 | 8 | }) |
9 | 9 | |
10 | 10 | exports.gives = nest('app.html.search') |
11 | 11 | |
12 | +var pages = ['/public', '/private', '/mentions', '/all'] | |
13 | + | |
12 | 14 | exports.create = function (api) { |
13 | 15 | return nest('app.html.search', function (setView) { |
14 | 16 | var getProfileSuggestions = api.profile.async.suggest() |
15 | 17 | var getChannelSuggestions = api.channel.async.suggest() |
@@ -33,8 +35,10 @@ | ||
33 | 35 | if (inputText[0] === '@') { |
34 | 36 | cb(null, getProfileSuggestions(inputText.slice(1)), {idOnly: true}) |
35 | 37 | } else if (inputText[0] === '#') { |
36 | 38 | cb(null, getChannelSuggestions(inputText.slice(1))) |
39 | + } else if (inputText[0] === '/') { | |
40 | + cb(null, getPageSuggestions(inputText)) | |
37 | 41 | } |
38 | 42 | }, {cls: 'SuggestBox'}) |
39 | 43 | }) |
40 | 44 | |
@@ -53,6 +57,16 @@ | ||
53 | 57 | setView(`?${value.trim()}`) |
54 | 58 | } |
55 | 59 | } |
56 | 60 | } |
61 | + | |
62 | + function getPageSuggestions (input) { | |
63 | + return pages.sort().filter(p => p.startsWith(input.toLowerCase())).map(p => { | |
64 | + return { | |
65 | + id: p, | |
66 | + value: p, | |
67 | + title: p | |
68 | + } | |
69 | + }) | |
70 | + } | |
57 | 71 | }) |
58 | 72 | } |
Built with git-ssb-web