@dhyasama/totem-models 6.17.1 → 6.17.3
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/Organization.js +56 -3
- package/package-lock.json +1829 -0
- package/package.json +1 -1
package/.npmignore
ADDED
package/lib/Organization.js
CHANGED
|
@@ -665,9 +665,9 @@ module.exports = function(mongoose, config) {
|
|
|
665
665
|
type: 'Location',
|
|
666
666
|
key: 'organization.contact.address',
|
|
667
667
|
isStandard: true,
|
|
668
|
-
order: standardFields.
|
|
669
|
-
colspan: standardFields.
|
|
670
|
-
showOnFilter: standardFields.
|
|
668
|
+
order: standardFields.location.order * 10,
|
|
669
|
+
colspan: standardFields.location.colspan || 1,
|
|
670
|
+
showOnFilter: standardFields.location.showOnFilter === true ? true : false
|
|
671
671
|
});
|
|
672
672
|
}
|
|
673
673
|
|
|
@@ -1297,6 +1297,59 @@ module.exports = function(mongoose, config) {
|
|
|
1297
1297
|
this.find({ 'slug': { $in : slugs } }).exec(cb);
|
|
1298
1298
|
};
|
|
1299
1299
|
|
|
1300
|
+
Organization.statics.findBySocial = function findBySocial(value, cb) {
|
|
1301
|
+
|
|
1302
|
+
// Extract stand-alone username and append it to our standardized domains
|
|
1303
|
+
|
|
1304
|
+
var self = this;
|
|
1305
|
+
|
|
1306
|
+
var getUsername = function getUsername(val) {
|
|
1307
|
+
|
|
1308
|
+
var URL = require('url');
|
|
1309
|
+
var result = URL.parse(val);
|
|
1310
|
+
|
|
1311
|
+
result = result.pathname;
|
|
1312
|
+
|
|
1313
|
+
if (result.indexOf('/') === 0) { result = result.replace('/', ''); }
|
|
1314
|
+
if (result.indexOf('in/') === 0) { result = result.replace('in/', ''); }
|
|
1315
|
+
if (result.indexOf('/') >= 0) { result = result.split('/')[0]; }
|
|
1316
|
+
|
|
1317
|
+
console.log(val, '-->', result);
|
|
1318
|
+
|
|
1319
|
+
};
|
|
1320
|
+
|
|
1321
|
+
var domains = {
|
|
1322
|
+
facebook: 'https://facebook.com',
|
|
1323
|
+
linkedin: 'https://linkedin.com',
|
|
1324
|
+
twitter: 'https://twitter.com'
|
|
1325
|
+
};
|
|
1326
|
+
|
|
1327
|
+
var username = getUsername(value);
|
|
1328
|
+
|
|
1329
|
+
// todo - tests
|
|
1330
|
+
// getUsername('dhyasama');
|
|
1331
|
+
// getUsername('in/dhyasama');
|
|
1332
|
+
// getUsername('http://facebook.com/dhyasama');
|
|
1333
|
+
// getUsername('http://linkedin.com/in/dhyasama');
|
|
1334
|
+
// getUsername('https://twitter.com/dhyasama');
|
|
1335
|
+
// getUsername('http://www.facebook.com/dhyasama');
|
|
1336
|
+
// getUsername('http://www.linkedin.com/dhyasama/');
|
|
1337
|
+
// getUsername('http://www.twitter.com/dhyasama?hello=world');
|
|
1338
|
+
// getUsername('http://www.facebook.com');
|
|
1339
|
+
|
|
1340
|
+
self
|
|
1341
|
+
.find({ $or:
|
|
1342
|
+
[
|
|
1343
|
+
{ 'social.facebook': domains.facebook + '/' + username },
|
|
1344
|
+
{ 'social.linkedin': domains.linkedin + '/in/' + username },
|
|
1345
|
+
{ 'social.twitter': domains.twitter + '/' + username }
|
|
1346
|
+
],
|
|
1347
|
+
'deleted': { $ne: true }
|
|
1348
|
+
})
|
|
1349
|
+
.exec(cb);
|
|
1350
|
+
|
|
1351
|
+
};
|
|
1352
|
+
|
|
1300
1353
|
Organization.statics.findDupes = function findDupes(org, options, cb) {
|
|
1301
1354
|
|
|
1302
1355
|
if (!cb) throw new Error('cb is required');
|