A music player that connects to your cloud/distributed storage.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Replace current search-engine with lunr.js

+39 -28
+6 -6
package-lock.json
··· 1 1 { 2 2 "name": "Diffuse", 3 - "version": "1.0.0-beta", 3 + "version": "1.0.0", 4 4 "lockfileVersion": 1, 5 5 "requires": true, 6 6 "dependencies": { ··· 2372 2372 "resolved": "https://registry.npmjs.org/ejs/-/ejs-2.6.1.tgz", 2373 2373 "integrity": "sha512-0xy4A/twfrRCnkhfk8ErDi5DqdAsAqeGxht4xkCUrsvhhbQNs7E+4jV0CN7+NKIY0aHE72+XvqtBIXzD31ZbXQ==", 2374 2374 "dev": true 2375 - }, 2376 - "elasticlunr": { 2377 - "version": "0.9.5", 2378 - "resolved": "https://registry.npmjs.org/elasticlunr/-/elasticlunr-0.9.5.tgz", 2379 - "integrity": "sha1-ZVQbswnd3Qz5Ty0ciGGyvmUbsNU=" 2380 2375 }, 2381 2376 "electron": { 2382 2377 "version": "2.0.2", ··· 5059 5054 "pseudomap": "1.0.2", 5060 5055 "yallist": "2.1.2" 5061 5056 } 5057 + }, 5058 + "lunr": { 5059 + "version": "2.3.1", 5060 + "resolved": "https://registry.npmjs.org/lunr/-/lunr-2.3.1.tgz", 5061 + "integrity": "sha1-ETYWorYC3cEJMqe/ik5uV+v+zfI=" 5062 5062 }, 5063 5063 "make-dir": { 5064 5064 "version": "1.3.0",
+1 -1
package.json
··· 17 17 "1-liners": "^0.4.0", 18 18 "blockstack": "^17.2.0", 19 19 "camelcase": "^5.0.0", 20 - "elasticlunr": "^0.9.5", 21 20 "expand-home-dir": "0.0.3", 22 21 "express": "^4.16.3", 23 22 "globby": "^8.0.1", 24 23 "jsmediatags": "^3.8.1", 24 + "lunr": "^2.3.1", 25 25 "pepjs": "^0.4.3", 26 26 "remotestoragejs": "1.0.2", 27 27 "request": "^2.87.0",
+12 -20
src/Js/Workers/search.js
··· 32 32 33 33 const mapTrack = track => ({ 34 34 id: track.id, 35 - album: track.tags.album, 36 - artist: track.tags.artist, 37 - title: track.tags.title 35 + album: [track.tags.album], 36 + artist: [track.tags.artist], 37 + title: [track.tags.title] 38 38 }); 39 39 40 40 ··· 42 42 // 43 43 // Actions 44 44 45 - const FIELDS = { 46 - album: { boost: 1 }, 47 - artist: { boost: 3, bool: "AND" }, 48 - title: { boost: 2 } 49 - }; 50 - 51 - 52 45 function performSearch(searchTerm) { 46 + const properSearchTerm = searchTerm 47 + .replace(" *", ""); 48 + 53 49 const results = index 54 - .search(searchTerm, { bool: "OR", expand: true, fields: FIELDS }) 50 + .search(properSearchTerm) 55 51 .map(s => s.ref); 56 52 57 53 self.postMessage({ ··· 66 62 ? JSON.parse(input) 67 63 : input; 68 64 69 - index = elasticlunr(function() { 70 - const i = this; 71 - 72 - i.setRef("id"); 73 - 74 - i.addField("album"); 75 - i.addField("artist"); 76 - i.addField("title"); 65 + index = lunr(function() { 66 + this.field("album"); 67 + this.field("artist"); 68 + this.field("title"); 77 69 78 70 (tracks || []) 79 71 .map(mapTrack) 80 - .forEach(t => i.addDoc(t)); 72 + .forEach(t => this.add(t)); 81 73 }); 82 74 }
+19
src/Static/Info/Info.md
··· 125 125 - You can select multiple tracks using the SHIFT key and then add that selection 126 126 to the queue or a playlist by right clicking on the selection (desktop only). 127 127 - You can reorder playlist tracks with drag-and-drop. 128 + 129 + ### Search 130 + 131 + Searching is powered by [lunr.js](https://lunrjs.com/), which means you can use all [these wildcards](https://lunrjs.com/guides/searching.html) and other stuff to refine your search. A few examples: 132 + 133 + ```elm 134 + # "Parkway Drive" or "Iron Maiden". 135 + # The non-escaped space (ie. ` `, not `\ `) indicates a new term. 136 + Parkway\ Drive Iron\ Maiden 137 + 138 + # Show me every track of which the artist's name starts with 'park'. 139 + artist:park* 140 + 141 + # Show me every track from Parkway Drive's "Deep Blue" album. 142 + artist:Parkway\ Drive + album:Deep\ Blue 143 + 144 + # Show me every track from Parkway Drive but not their "Atlas" album. 145 + artist:Parkway\ Drive - album:Atlas 146 + ```
+1 -1
src/Vendor/package.js
··· 4 4 self._ = require("1-liners"); 5 5 self.blockstack = require("blockstack"); 6 6 self.camelcase = require("camelcase"); 7 - self.elasticlunr = require("elasticlunr"); 8 7 self.encoding = require("text-encoding"); 8 + self.lunr = require("lunr"); 9 9 self.RemoteStorage = require("remotestoragejs/release/remotestorage"); 10 10 11 11 if (self.document) {