New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

wiki-plugin-activity

Package Overview
Dependencies
Maintainers
3
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wiki-plugin-activity - npm Package Compare versions

Comparing version 0.2.2 to 0.2.3

.travis.yml

468

client/activity.js

@@ -10,4 +10,4 @@

(function() {
var bind, emit, escape,
__indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };
var bind, emit, escape, open_conversation, parse, setDefaults,
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; };

@@ -18,123 +18,209 @@ escape = function(line) {

emit = function($item, item) {};
setDefaults = function(query) {
query.since = 0;
query.listing = [];
query.errors = 0;
query.includeNeighbors = true;
query.twins = 0;
query.sortOrder = "date";
query.searchTerm = '';
query.searchResults = '';
query.rosterResults = {};
query.mine = "yes";
query.conversation = false;
return query.narrative = false;
};
bind = function($item, item) {
var display, errors, includeNeighbors, listing, merge, omitted, parse, searchResults, searchTerm, since, sortOrder, twins;
since = 0;
listing = [];
errors = 0;
includeNeighbors = true;
twins = 0;
sortOrder = "date";
searchTerm = '';
searchResults = '';
parse = function(text) {
var arg, days, err, html, line, match, op, today, todayStart, words, _i, _len, _ref, _ref1, _results;
listing = [];
errors = 0;
_ref = text.split(/\r?\n/);
_results = [];
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
line = _ref[_i];
if (!(words = line.match(/\S+/g))) {
continue;
}
html = escape(line);
today = new Date;
todayStart = today.setHours(0, 0, 0, 0);
try {
_ref1 = line.match(/^\s*(\w*)\s*(.*)$/), match = _ref1[0], op = _ref1[1], arg = _ref1[2];
switch (op) {
case '':
break;
case 'SINCE':
if (match = arg.match(/^(\d+) hours?$/i)) {
since = Date.now() - ((+match[1]) * 1000 * 60 * 60);
} else if (match = arg.match(/^(\d+) days?$/i)) {
since = Date.now() - ((+match[1]) * 1000 * 60 * 60 * 24);
} else if (match = arg.match(/^(\d+) weeks?$/i)) {
since = Date.now() - ((+match[1]) * 1000 * 60 * 60 * 24 * 7);
} else if (match = arg.match(/^(sun|mon|tue|wed|thu|fri|sat)[a-z]*$/i)) {
days = ["sun", "mon", "tue", "wed", "thu", "fri", "sat"];
since = todayStart - ((((new Date).getDay() + 7 - (days.indexOf(match[1].toLowerCase()))) % 7) * 1000 * 60 * 60 * 24);
} else if (!(isNaN(Date.parse(arg)))) {
since = Date.parse(arg);
} else {
throw {
message: "don't know SINCE '" + arg + "' argument"
};
open_conversation = function(this_page, uri) {
var results, site, slug, tuples;
tuples = uri.split('/');
tuples.shift();
results = [];
while (tuples.length) {
site = tuples.shift();
slug = tuples.shift();
wiki.doInternalLink(slug, this_page, site);
results.push(this_page = null);
}
return results;
};
parse = function(query, text, $item, item) {
var arg, days, err, html, items, j, len, line, match, op, ref, ref1, results, site, sources, today, todayStart, words;
query.listing = [];
query.errors = 0;
ref = text.split(/\r?\n/);
results = [];
for (j = 0, len = ref.length; j < len; j++) {
line = ref[j];
if (!(words = line.match(/\S+/g))) {
continue;
}
html = escape(line);
today = new Date;
todayStart = today.setHours(0, 0, 0, 0);
try {
ref1 = line.match(/^\s*(\w*)\s*(.*)$/), match = ref1[0], op = ref1[1], arg = ref1[2];
switch (op) {
case '':
break;
case 'SINCE':
if (match = arg.match(/^(\d+) hours?$/i)) {
query.since = Date.now() - ((+match[1]) * 1000 * 60 * 60);
} else if (match = arg.match(/^(\d+) days?$/i)) {
query.since = Date.now() - ((+match[1]) * 1000 * 60 * 60 * 24);
} else if (match = arg.match(/^(\d+) weeks?$/i)) {
query.since = Date.now() - ((+match[1]) * 1000 * 60 * 60 * 24 * 7);
} else if (match = arg.match(/^(sun|mon|tue|wed|thu|fri|sat)[a-z]*$/i)) {
days = ["sun", "mon", "tue", "wed", "thu", "fri", "sat"];
query.since = todayStart - ((((new Date).getDay() + 7 - (days.indexOf(match[1].toLowerCase()))) % 7) * 1000 * 60 * 60 * 24);
} else if (!(isNaN(Date.parse(arg)))) {
query.since = Date.parse(arg);
} else {
throw {
message: "don't know SINCE '" + arg + "' argument"
};
}
break;
case 'NEIGHBORHOOD':
if (arg.match(/^yes/i)) {
query.includeNeighbors = true;
} else if (arg.match(/^no/i)) {
query.includeNeighbors = false;
} else {
throw {
message: "don't know NEIGHBORHOOD '" + arg + "' argument"
};
}
break;
case 'TWINS':
if (match = arg.match(/^(\d+)/)) {
query.twins = +match[1];
} else {
throw {
message: "don't know TWINS '" + arg + "' argument"
};
}
break;
case 'SORT':
if (arg.match(/^titles?$/i)) {
query.sortOrder = "title";
} else if (arg.match(/^date/i)) {
query.sortOrder = "date";
} else {
throw {
message: "don't know SORT '" + arg + "' argument"
};
}
break;
case 'SEARCH':
query.searchTerm = arg;
query.searchResults = wiki.neighborhoodObject.search(query.searchTerm);
break;
case 'ROSTER':
query.includeNeighbors = false;
items = $(".item:lt(" + ($('.item').index($item)) + ")");
sources = items.filter(".roster-source");
sources.each(function(i, source) {
var key, results1, roster, site, value;
console.log('source', source);
roster = source.getRoster();
results1 = [];
for (key in roster) {
value = roster[key];
if (key.toLowerCase().indexOf(arg.toLowerCase()) >= 0) {
results1.push((function() {
var k, len1, results2;
results2 = [];
for (k = 0, len1 = value.length; k < len1; k++) {
site = value[k];
results2.push(query.rosterResults[site] = true);
}
return results2;
})());
} else {
results1.push(void 0);
}
}
break;
case 'NEIGHBORHOOD':
if (arg.match(/^yes/i)) {
includeNeighbors = true;
} else if (arg.match(/^no/i)) {
includeNeighbors = false;
} else {
throw {
message: "don't know NEIGHBORHOOD '" + arg + "' argument"
};
}
break;
case 'TWINS':
if (match = arg.match(/^(\d+)/)) {
twins = +match[1];
} else {
throw {
message: "don't know TWINS '" + arg + "' argument"
};
}
break;
case 'SORT':
if (arg.match(/^titles?$/i)) {
sortOrder = "title";
} else if (arg.match(/^date/i)) {
sortOrder = "date";
} else {
throw {
message: "don't know SORT '" + arg + "' argument"
};
}
break;
case 'SEARCH':
searchTerm = arg;
searchResults = wiki.neighborhoodObject.search(searchTerm);
break;
default:
return results1;
});
if (!query.rosterResults[location.host]) {
query.mine = "no";
}
for (site in query.rosterResults) {
wiki.neighborhoodObject.registerNeighbor(site);
}
break;
case 'MINE':
if (arg.match(/^yes/i)) {
query.mine = "yes";
} else if (arg.match(/^no/i)) {
query.mine = "no";
} else if (arg.match(/^only/i)) {
query.mine = "only";
} else if (arg.match(/^exclude/i)) {
query.mine = "exclude";
} else {
throw {
message: "don't know '" + op + "' command"
message: "don't know MINE '" + arg + "' argument"
};
}
} catch (_error) {
err = _error;
errors++;
html = "<span style=\"background-color:#fdd;width:100%;\" title=\"" + err.message + "\">" + html + "</span>";
}
break;
case 'CONVERSATION':
query.conversation = true;
break;
case 'NARRATIVE':
query.narrative = true;
break;
default:
throw {
message: "don't know '" + op + "' command"
};
}
_results.push(listing.push(html));
} catch (_error) {
err = _error;
query.errors++;
html = "<span style=\"background-color:#fdd;width:100%;\" title=\"" + err.message + "\">" + html + "</span>";
}
return _results;
};
display = function(pages) {
var bigger, context, each, header, i, joint, now, section, sections, sites, smaller, _i, _j, _k, _len, _len1, _len2, _ref;
results.push(query.listing.push(html));
}
return results;
};
emit = function($item, item) {};
bind = function($item, item) {
var display, merge, omitted, query;
display = function(query, pages) {
var bigger, context, conversationLink, each, flags, header, i, j, joint, k, l, len, len1, len2, len3, len4, links, m, n, narrativeLink, now, pageLink, ref, ref1, ref2, section, sections, sites, smaller, style, twin;
$item.empty();
if (errors) {
$item.append(listing);
if (query.errors) {
$item.append(query.listing.join('<br>'));
return;
}
header = "";
if (searchTerm) {
header += "<br/>searching for \"" + (escape(searchTerm)) + "\"";
if (query.searchTerm) {
header += "<br>searching for \"" + (escape(query.searchTerm)) + "\"";
}
if (since) {
header += "<br/>since " + ((new Date(since)).toDateString());
if (query.since) {
header += "<br>since " + ((new Date(query.since)).toDateString());
}
if (twins > 0) {
header += "<br/>more than " + twins + " twins";
if (query.twins > 0) {
header += "<br>more than " + query.twins + " twins";
}
if (sortOrder === "title") {
header += "<br/>sorted by page title";
if (query.sortOrder === "title") {
header += "<br>sorted by page title";
}
if (includeNeighbors === false) {
header += "<br/>excluding neighborhood";
if (query.includeNeighbors === false) {
header += "<br>excluding neighborhood";
}
if (query.mine === 'no') {
header += "<br>excluding my pages";
}
if (query.mine === 'only') {
header += "<br>including only pages I have a twin of";
}
if (query.mine === 'exclude') {
header += "<br>including only pages I don't have a twin of";
}
if (header) {

@@ -174,3 +260,3 @@ $item.append("<p><b>Page Activity " + header + "</b></p>");

];
if (sortOrder === "title") {
if (query.sortOrder === "title") {
bigger = '';

@@ -180,6 +266,22 @@ } else {

}
for (_i = 0, _len = pages.length; _i < _len; _i++) {
sites = pages[_i];
if ((sites.length >= twins) || twins === 0) {
if (sortOrder === "title") {
for (j = 0, len = pages.length; j < len; j++) {
sites = pages[j];
if (((sites.length >= query.twins) || query.twins === 0) && (query.mine === 'only' && (ref = location.host, indexOf.call((function() {
var k, len1, results;
results = [];
for (k = 0, len1 = sites.length; k < len1; k++) {
twin = sites[k];
results.push(twin.site);
}
return results;
})(), ref) >= 0) || !(query.mine === 'only')) && (query.mine === 'exclude' && !(ref1 = location.host, indexOf.call((function() {
var k, len1, results;
results = [];
for (k = 0, len1 = sites.length; k < len1; k++) {
twin = sites[k];
results.push(twin.site);
}
return results;
})(), ref1) >= 0) || !(query.mine === 'exclude'))) {
if (query.sortOrder === "title") {
smaller = sites[0].page.title.substr(0, 1).toUpperCase();

@@ -191,4 +293,4 @@ if (smaller !== bigger) {

smaller = sites[0].page.date;
for (_j = 0, _len1 = sections.length; _j < _len1; _j++) {
section = sections[_j];
for (k = 0, len1 = sections.length; k < len1; k++) {
section = sections[k];
if (section.date > smaller && section.date < bigger) {

@@ -201,9 +303,38 @@ $item.append("<h3> Within " + section.period + " </h3>");

bigger = smaller;
for (i = _k = 0, _len2 = sites.length; _k < _len2; i = ++_k) {
context = sites[0].site === location.host ? "view" : "view => " + sites[0].site;
pageLink = "<a class=\"internal\"\n href=\"/" + sites[0].page.slug + "\"\n data-page-name=\"" + sites[0].page.slug + "\"\n title=\"" + context + "\">\n " + (escape(sites[0].page.title || sites[0].page.slug)) + "\n</a>";
links = '';
if (query.narrative) {
narrativeLink = "" + sites[0].page.slug;
for (i = l = 0, len2 = sites.length; l < len2; i = ++l) {
each = sites[i];
narrativeLink += "@" + each.site;
}
if (query.conversation) {
style = "vertical-align: baseline; position: relative; top: -0.4em;";
} else {
style = "";
}
links += "<a href=\"http://paul90.github.io/wiki-narrative-chart/\#" + narrativeLink + "\"\n title=\"Narrative Chart\"\n target=\"narrative\"\n style=\"" + style + "\">※</a>";
}
if (query.conversation) {
conversationLink = '';
for (i = m = 0, len3 = sites.length; m < len3; i = ++m) {
each = sites[i];
conversationLink += "/" + each.site + "/" + each.page.slug;
}
if (query.narrative) {
style = "margin-left: -0.5em; vertical-align: baseline; position: relative; top: 0.2em;";
} else {
style = "";
}
links += "<a class=\"conversation\"\n href=\"" + conversationLink + "\"\n title=\"Conversation\"\n target=\"conversation\"\n style=\"" + style + "\">»</a>";
}
flags = '';
for (i = n = 0, len4 = sites.length; n < len4; i = ++n) {
each = sites[i];
joint = ((_ref = sites[i + 1]) != null ? _ref.page.date : void 0) === each.page.date ? "" : "&nbsp";
$item.append("<img class=\"remote\"\n title=\"" + each.site + "\n" + (wiki.util.formatElapsedTime(each.page.date)) + "\"\n src=\"http://" + each.site + "/favicon.png\"\n data-site=\"" + each.site + "\"\n data-slug=\"" + each.page.slug + "\">" + joint);
joint = ((ref2 = sites[i - 1]) != null ? ref2.page.date : void 0) === each.page.date ? "" : "&nbsp;";
flags = ("<img class=\"remote\"\n title=\"" + each.site + "\n" + (wiki.util.formatElapsedTime(each.page.date)) + "\"\n src=\"http://" + each.site + "/favicon.png\"\n data-site=\"" + each.site + "\"\n data-slug=\"" + each.page.slug + "\">" + joint) + flags;
}
context = sites[0].site === location.host ? "view" : "view => " + sites[0].site;
$item.append("<a class=\"internal\"\n href=\"/" + sites[0].page.slug + "\"\n data-page-name=\"" + sites[0].page.slug + "\"\n title=\"" + context + "\">\n " + (escape(sites[0].page.title || sites[0].page.slug)) + "\n</a><br>");
$item.append("<div>\n <div style='float:left'>" + pageLink + "</div>\n <div style='text-align: right;'>" + flags + "\n <div style=\"float: right; margin-right: -1em; text-align: left;\">" + links + "</div>\n </div>\n</div>");
} else {

@@ -214,9 +345,16 @@ omitted++;

if (omitted > 0) {
return $item.append("<p><i>" + omitted + " more titles</i></p>");
$item.append("<p><i>" + omitted + " more titles</i></p>");
}
return $item.find('.conversation').click(function(e) {
var this_page;
e.stopPropagation();
e.preventDefault();
if (!e.shiftKey) {
this_page = $item.parents('.page');
}
return open_conversation(this_page, $(this).attr('href'));
});
};
parse(item.text || '');
omitted = 0;
merge = function(neighborhood) {
var each, map, pages, site, sites, slug, _i, _len, _ref;
merge = function(query, neighborhood) {
var each, j, len, map, omitted, pages, ref, site, sites, slug;
pages = {};

@@ -228,14 +366,16 @@ for (site in neighborhood) {

}
if (includeNeighbors || (!includeNeighbors && site === location.host)) {
_ref = map.sitemap;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
each = _ref[_i];
sites = pages[each.slug];
if (sites == null) {
pages[each.slug] = sites = [];
if (query.includeNeighbors || (!query.includeNeighbors && site === location.host) || site === location.host || query.rosterResults[site]) {
if (!(query.mine === "no" && site === location.host)) {
ref = map.sitemap;
for (j = 0, len = ref.length; j < len; j++) {
each = ref[j];
sites = pages[each.slug];
if (sites == null) {
pages[each.slug] = sites = [];
}
sites.push({
site: site,
page: each
});
}
sites.push({
site: site,
page: each
});
}

@@ -251,12 +391,12 @@ }

pages = (function() {
var _results;
_results = [];
var results;
results = [];
for (slug in pages) {
sites = pages[slug];
_results.push(sites);
results.push(sites);
}
return _results;
return results;
})();
pages.sort(function(a, b) {
if (sortOrder === "title") {
if (query.sortOrder === "title") {
return a[0].page.title.localeCompare(b[0].page.title, {

@@ -271,6 +411,7 @@ sensitivity: "accent"

return pages.filter(function(e) {
var finds, willInclude, _ref1;
var finds, ref1, willInclude;
willInclude = true;
if (since) {
if (e[0].page.date <= since) {
if (query.since) {
console.log("Date: ", e[0].page.date);
if (e[0].page.date <= query.since || e[0].page.date === void 0) {
willInclude = false;

@@ -280,13 +421,13 @@ omitted++;

}
if (searchTerm && willInclude) {
if (!(_ref1 = e[0].page, __indexOf.call((function() {
var _j, _len1, _ref2, _results;
_ref2 = searchResults.finds;
_results = [];
for (_j = 0, _len1 = _ref2.length; _j < _len1; _j++) {
finds = _ref2[_j];
_results.push(finds.page);
if (query.searchTerm && willInclude) {
if (!(ref1 = e[0].page, indexOf.call((function() {
var k, len1, ref2, results;
ref2 = query.searchResults.finds;
results = [];
for (k = 0, len1 = ref2.length; k < len1; k++) {
finds = ref2[k];
results.push(finds.page);
}
return _results;
})(), _ref1) >= 0)) {
return results;
})(), ref1) >= 0)) {
willInclude = false;

@@ -299,8 +440,14 @@ omitted++;

};
display(merge(wiki.neighborhood));
query = {};
setDefaults(query);
parse(query, item.text || '', $item, item);
omitted = 0;
display(query, merge(query, wiki.neighborhood));
$('body').on('new-neighbor-done', function(e, site) {
if (searchTerm) {
searchResults = wiki.neighborhoodObject.search(searchTerm);
var searchResults;
if (query.searchTerm) {
searchResults = wiki.neighborhoodObject.search(query.searchTerm);
}
return display(merge(wiki.neighborhood));
omitted = 0;
return display(query, merge(query, wiki.neighborhood));
});

@@ -321,3 +468,6 @@ return $item.dblclick(function() {

if (typeof module !== "undefined" && module !== null) {
module.exports = {};
module.exports = {
escape: escape,
parse: parse
};
}

@@ -324,0 +474,0 @@

{
"name": "wiki-plugin-activity",
"version": "0.2.2",
"version": "0.2.3",
"description": "Federated Wiki - Activity Plug-in",

@@ -32,5 +32,8 @@ "keywords": [

"grunt": "0.4",
"grunt-contrib-coffee": "0.12",
"grunt-contrib-coffee": "0.13",
"grunt-contrib-watch": "0.6",
"grunt-git-authors": "~2"
"grunt-git-authors": "~3",
"mocha": "*",
"expect.js": "*",
"grunt-mocha-test": "~0.12"
},

@@ -51,4 +54,4 @@ "licenses": [

"engines": {
"node": "0.10"
"node": ">=0.10"
}
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc