@dhyasama/totem-models 6.21.3 → 6.21.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.npmignore +14 -0
- package/lib/Note.js +4 -0
- package/lib/Organization.js +16 -29
- package/lib/Person.js +15 -25
- package/package-lock.json +1829 -0
- package/package.json +1 -1
- package/test/Organization.js +66 -0
- package/test/Person.js +87 -1
package/.npmignore
ADDED
package/lib/Note.js
CHANGED
|
@@ -44,6 +44,10 @@ module.exports = function(mongoose, config) {
|
|
|
44
44
|
|
|
45
45
|
};
|
|
46
46
|
|
|
47
|
+
// Note.statics.getByCreator = function(personId, cb) {
|
|
48
|
+
// this.find({ 'createdBy': personId }).exec(cb);
|
|
49
|
+
// };
|
|
50
|
+
|
|
47
51
|
Note.statics.getById = function(id, cb) {
|
|
48
52
|
this.findOne({
|
|
49
53
|
'_id': id,
|
package/lib/Organization.js
CHANGED
|
@@ -922,7 +922,7 @@ module.exports = function(mongoose, config) {
|
|
|
922
922
|
|
|
923
923
|
Organization.methods.merge = function(id) {
|
|
924
924
|
if (this.merged.indexOf(id) == -1) {
|
|
925
|
-
this.merged.
|
|
925
|
+
this.merged = this.merged.concat([id]);
|
|
926
926
|
return true;
|
|
927
927
|
}
|
|
928
928
|
else {
|
|
@@ -1306,48 +1306,35 @@ module.exports = function(mongoose, config) {
|
|
|
1306
1306
|
var getUsername = function getUsername(val) {
|
|
1307
1307
|
|
|
1308
1308
|
var URL = require('url');
|
|
1309
|
-
var
|
|
1309
|
+
var parsedUrl = URL.parse(val);
|
|
1310
|
+
var protocol = parsedUrl.protocol;
|
|
1310
1311
|
|
|
1311
|
-
|
|
1312
|
+
if (!protocol) { parsedUrl = URL.parse('http://' + val); }
|
|
1312
1313
|
|
|
1313
|
-
|
|
1314
|
-
if (result.indexOf('in/') === 0) { result = result.replace('in/', ''); }
|
|
1315
|
-
if (result.indexOf('organization/') === 0) { result = result.replace('organization/', ''); }
|
|
1316
|
-
if (result.indexOf('/') >= 0) { result = result.split('/')[0]; }
|
|
1314
|
+
var pathname = parsedUrl.pathname;
|
|
1317
1315
|
|
|
1318
|
-
|
|
1316
|
+
if (pathname.indexOf('/') === 0) { pathname = pathname.replace('/', ''); }
|
|
1317
|
+
if (pathname.indexOf('company/') === 0) { pathname = pathname.replace('company/', ''); }
|
|
1318
|
+
if (pathname.indexOf('organization/') === 0) { pathname = pathname.replace('organization/', ''); }
|
|
1319
|
+
if (pathname.indexOf('/') >= 0) { pathname = pathname.split('/')[0]; }
|
|
1319
1320
|
|
|
1320
|
-
|
|
1321
|
+
console.log('Username:', val, '-->', pathname);
|
|
1321
1322
|
|
|
1322
|
-
|
|
1323
|
+
return pathname;
|
|
1323
1324
|
|
|
1324
|
-
var domains = {
|
|
1325
|
-
facebook: 'https://facebook.com',
|
|
1326
|
-
linkedin: 'https://linkedin.com/company',
|
|
1327
|
-
twitter: 'https://twitter.com',
|
|
1328
|
-
crunchbase: 'https://crunchbase.com/organization'
|
|
1329
1325
|
};
|
|
1330
1326
|
|
|
1331
1327
|
var username = getUsername(value);
|
|
1332
1328
|
|
|
1333
|
-
|
|
1334
|
-
// getUsername('dhyasama');
|
|
1335
|
-
// getUsername('in/dhyasama');
|
|
1336
|
-
// getUsername('http://facebook.com/dhyasama');
|
|
1337
|
-
// getUsername('http://linkedin.com/in/dhyasama');
|
|
1338
|
-
// getUsername('https://twitter.com/dhyasama');
|
|
1339
|
-
// getUsername('http://www.facebook.com/dhyasama');
|
|
1340
|
-
// getUsername('http://www.linkedin.com/dhyasama/');
|
|
1341
|
-
// getUsername('http://www.twitter.com/dhyasama?hello=world');
|
|
1342
|
-
// getUsername('http://www.facebook.com');
|
|
1329
|
+
if (!username) { return cb(null, []); }
|
|
1343
1330
|
|
|
1344
1331
|
self
|
|
1345
1332
|
.find({ $or:
|
|
1346
1333
|
[
|
|
1347
|
-
{ 'social.facebook':
|
|
1348
|
-
{ 'social.linkedin':
|
|
1349
|
-
{ 'social.twitter':
|
|
1350
|
-
{ 'crunchbase.url':
|
|
1334
|
+
{ 'social.facebook': new RegExp('facebook.com/' + username, 'i') },
|
|
1335
|
+
{ 'social.linkedin': new RegExp('linkedin.com/company/' + username, 'i') },
|
|
1336
|
+
{ 'social.twitter': new RegExp('twitter.com/' + username, 'i') },
|
|
1337
|
+
{ 'crunchbase.url': new RegExp('crunchbase.com/organization/' + username, 'i') }
|
|
1351
1338
|
],
|
|
1352
1339
|
'deleted': { $ne: true }
|
|
1353
1340
|
})
|
package/lib/Person.js
CHANGED
|
@@ -223,7 +223,7 @@ module.exports = function(mongoose, config) {
|
|
|
223
223
|
|
|
224
224
|
Person.methods.addMerged = function(id) {
|
|
225
225
|
if (this.merged.indexOf(id) == -1) {
|
|
226
|
-
|
|
226
|
+
this.merged = this.merged.concat([id]);
|
|
227
227
|
return true;
|
|
228
228
|
}
|
|
229
229
|
else {
|
|
@@ -715,43 +715,33 @@ module.exports = function(mongoose, config) {
|
|
|
715
715
|
var getUsername = function getUsername(val) {
|
|
716
716
|
|
|
717
717
|
var URL = require('url');
|
|
718
|
-
var
|
|
718
|
+
var parsedUrl = URL.parse(val);
|
|
719
|
+
var protocol = parsedUrl.protocol;
|
|
719
720
|
|
|
720
|
-
|
|
721
|
+
if (!protocol) { parsedUrl = URL.parse('http://' + val); }
|
|
721
722
|
|
|
722
|
-
|
|
723
|
-
if (result.indexOf('in/') === 0) { result = result.replace('in/', ''); }
|
|
724
|
-
if (result.indexOf('/') >= 0) { result = result.split('/')[0]; }
|
|
723
|
+
var pathname = parsedUrl.pathname;
|
|
725
724
|
|
|
726
|
-
|
|
725
|
+
if (pathname.indexOf('/') === 0) { pathname = pathname.replace('/', ''); }
|
|
726
|
+
if (pathname.indexOf('in/') === 0) { pathname = pathname.replace('in/', ''); }
|
|
727
|
+
if (pathname.indexOf('/') >= 0) { pathname = pathname.split('/')[0]; }
|
|
727
728
|
|
|
728
|
-
|
|
729
|
+
console.log('Username:', val, '-->', pathname);
|
|
730
|
+
|
|
731
|
+
return pathname;
|
|
729
732
|
|
|
730
|
-
var domains = {
|
|
731
|
-
facebook: 'https://facebook.com',
|
|
732
|
-
linkedin: 'https://linkedin.com',
|
|
733
|
-
twitter: 'https://twitter.com'
|
|
734
733
|
};
|
|
735
734
|
|
|
736
735
|
var username = getUsername(value);
|
|
737
736
|
|
|
738
|
-
|
|
739
|
-
// getUsername('dhyasama');
|
|
740
|
-
// getUsername('in/dhyasama');
|
|
741
|
-
// getUsername('http://facebook.com/dhyasama');
|
|
742
|
-
// getUsername('http://linkedin.com/in/dhyasama');
|
|
743
|
-
// getUsername('https://twitter.com/dhyasama');
|
|
744
|
-
// getUsername('http://www.facebook.com/dhyasama');
|
|
745
|
-
// getUsername('http://www.linkedin.com/dhyasama/');
|
|
746
|
-
// getUsername('http://www.twitter.com/dhyasama?hello=world');
|
|
747
|
-
// getUsername('http://www.facebook.com');
|
|
737
|
+
if (!username) { return cb(null, []); }
|
|
748
738
|
|
|
749
739
|
self
|
|
750
740
|
.find({ $or:
|
|
751
741
|
[
|
|
752
|
-
{ 'social.facebook':
|
|
753
|
-
{ 'social.linkedin':
|
|
754
|
-
{ 'social.twitter':
|
|
742
|
+
{ 'social.facebook': new RegExp('facebook.com/' + username, 'i') },
|
|
743
|
+
{ 'social.linkedin': new RegExp('linkedin.com/in/' + username, 'i') },
|
|
744
|
+
{ 'social.twitter': new RegExp('twitter.com/' + username, 'i') }
|
|
755
745
|
],
|
|
756
746
|
'deleted': { $ne: true }
|
|
757
747
|
})
|