wiki-plugin-assets
Advanced tools
Comparing version 0.1.6 to 0.1.7
(function() { | ||
var bind, emit, expand, fetch; | ||
var bind, context, emit, expand, fetch; | ||
@@ -8,7 +8,19 @@ expand = function(text) { | ||
fetch = function($item, item) { | ||
var $p, assets, link, remote, render, site, trouble; | ||
$p = $item.find('p'); | ||
assets = item.text.match(/([\w\/-]*)/)[1]; | ||
remote = $item.parents('.page').data('site'); | ||
context = function($item) { | ||
var action, i, journal, len, ref, sites; | ||
sites = [location.host]; | ||
journal = $item.parents('.page').data('data').journal; | ||
ref = journal.slice(0).reverse(); | ||
for (i = 0, len = ref.length; i < len; i++) { | ||
action = ref[i]; | ||
if ((action.site != null) && !sites.includes(action.site)) { | ||
sites.push(action.site); | ||
} | ||
} | ||
console.log('context', sites); | ||
return sites; | ||
}; | ||
fetch = function($report, assets, remote) { | ||
var link, render, site, trouble; | ||
site = remote != null ? "//" + remote : ''; | ||
@@ -22,11 +34,11 @@ link = function(file) { | ||
if (data.error.code === 'ENOENT') { | ||
return $p.text("no files"); | ||
return $report.text("no files"); | ||
} | ||
return $p.text("plugin reports: " + data.error.code); | ||
return $report.text("plugin reports: " + data.error.code); | ||
} | ||
files = data.files; | ||
if (files.length === 0) { | ||
return $p.text("no files"); | ||
return $report.text("no files"); | ||
} | ||
return $p.html(((function() { | ||
return $report.html(((function() { | ||
var i, len, results; | ||
@@ -42,3 +54,3 @@ results = []; | ||
trouble = function(e) { | ||
return $p.text("plugin error: " + e.statusText + " " + (e.responseText || '')); | ||
return $report.text("plugin error: " + e.statusText + " " + (e.responseText || '')); | ||
}; | ||
@@ -57,3 +69,3 @@ return $.ajax({ | ||
emit = function($item, item) { | ||
var uploader; | ||
var $report, assets, i, len, ref, results, site, uploader; | ||
uploader = function() { | ||
@@ -65,4 +77,12 @@ if ($item.parents('.page').hasClass('remote')) { | ||
}; | ||
$item.append("<div style=\"background-color:#eee;padding:15px;\">\n <p>fetching asset list</p>\n " + (uploader()) + "\n</div>"); | ||
return fetch($item, item); | ||
$item.append("<div style=\"background-color:#eee;padding:15px;\">\n <dl style=\"margin:0;color:gray\"></dl>\n " + (uploader()) + "\n</div>"); | ||
assets = item.text.match(/([\w\/-]*)/)[1]; | ||
ref = context($item); | ||
results = []; | ||
for (i = 0, len = ref.length; i < len; i++) { | ||
site = ref[i]; | ||
$report = $item.find('dl').prepend("<dt><img width=12 src=\"//" + site + "/favicon.png\"> " + site + "</dt>\n<dd style=\"margin:8px;\"></dd>"); | ||
results.push(fetch($report.find('dd:first'), assets, site)); | ||
} | ||
return results; | ||
}; | ||
@@ -69,0 +89,0 @@ |
{ | ||
"name": "wiki-plugin-assets", | ||
"version": "0.1.6", | ||
"version": "0.1.7", | ||
"description": "Federated Wiki - Assets Plugin", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
17908
276