Commit c37b5c19 authored by Sven Franck's avatar Sven Franck

erp5_officejs_afs_directory: switch to clean converter and publisher storage

parent 6d623b82
/*jslint indent: 2, nomen: true, maxlen: 80*/
/*global window, jIO, RSVP, DOMParser, Object */
(function (window, jIO, RSVP, DOMParser, Object) {
"use strict";
// XXX Bad proxy!
var LOC = 'https://softinst56769.host.vifib.net/erp5/web_site_module/afs/',
ID_LOC = "https://raw.githubusercontent.com/",
ID_PATH = "Nexedi/awesome-free-software/master/",
FETCH = "Software_getAnalysis?url=",
PARSER = new DOMParser();
function garble(str) {
return window.encodeURIComponent(str.replace(/ /g, "-"));
}
function isArray(value) {
return Object.prototype.toString.call(value) === '[object Array]';
}
function isValidCase(success_case) {
return (
success_case !== "N/A" &&
success_case.title !== "" &&
success_case.title !== "N/A"
);
}
// only called on repair, convert publisher storage content into records
// of publishers, software and success cases
function convertDataSet(storage, result_list) {
var response = [];
if (result_list.length === 0) {
return response;
}
return new RSVP.Queue()
.push(function () {
return RSVP.all(result_list.map(function (item) {
return storage.get(item.id);
}));
})
.push(function (publisher_list) {
var publisher,
software_list,
software,
success_case_list,
success_case,
i,
j,
k;
for (i = 0; i < publisher_list.length; i += 1) {
publisher = publisher_list[i];
// XXX parallel promises? title is too unreliable as id
publisher.item_id = result_list[i].id.split("/").pop().split(".")[0];
// add publisher id
response.push({
"id": garble(publisher.item_id),
"value": {}
});
software_list = publisher.free_software_list;
if (isArray(software_list)) {
for (j = 0; j < software_list.length; j += 1) {
software = software_list[j];
// add software id
response.push({
id: garble(publisher.item_id) + "/" + garble(software.title),
value: {}
});
success_case_list = software.success_case_list;
if (isArray(success_case_list)) {
for (k = 0; k < success_case_list.length; k += 1) {
success_case = success_case_list[k];
if (isValidCase(success_case)) {
// add case id
response.push({
id: garble(publisher.item_id) + "/" +
garble(software.title) + "/" +
garble(success_case.title),
value: {}
});
}
}
}
}
}
}
return response;
});
}
function retrieveOpenHubAnalysisTotalLines(software) {
return new RSVP.Queue()
.push(function () {
return jIO.util.ajax({
type: "GET",
url: LOC + FETCH + software.source_code_profile,
dataType: "text"
});
})
.push(function (data) {
var response = data.target.response || data.target.responseText;
return PARSER.parseFromString(response, "text/xml")
.getElementsByTagName("total_code_lines")[0].childNodes[0].nodeValue;
});
}
function postFixProfileUrl(url) {
if (url.indexOf("languages_summary") === -1) {
return url + "/analyses/latest/languages_summary";
}
return url;
}
function isValidProfileUrl(url) {
return url && url !== "" && url.indexOf("hub") > -1;
}
function isInt(value) {
return !isNaN(value) && (function (x) {
if ((x | 0) === x) {
return x;
}
return 0;
})(parseFloat(value));
}
function totalLines(arr) {
return arr.reduce(function (running_total, line) {
return running_total += isInt(line);
}, 0);
}
function retrieveTotalLinesFromPublisher(publisher) {
/*
var unique_software_list = [];
return new RSVP.Queue()
.push(function () {
return RSVP.all(publisher.free_software_list.map(function (software) {
var profile_url;
if (isValidProfileUrl(software.source_code_profile)) {
profile_url = postFixProfileUrl(software.source_code_profile);
if (unique_software_list.indexOf(profile_url) === -1) {
unique_software_list.push(profile_url);
return retrieveOpenHubAnalysisTotalLines(software);
}
}
}).filter(Boolean));
})
.push(function (line_list) {
return totalLines(line_list);
});
*/
return 0;
}
function retrieveSuccessCaseFromSoftware(publisher, path_list) {
return publisher.free_software_list.reduce(function (response, software) {
var software_title = garble(software.title);
if (software_title === path_list[1]) {
if (isArray(software.success_case_list)) {
return software.success_case_list.reduce(function (response, item) {
var case_title = garble(item.title);
if (case_title === path_list[2]) {
item.portal_type = "success_case";
item.software = software.title;
item.software_website = software.website;
item.publisher = software.publisher;
item.publisher_website = software.website;
item.category_list = software.category_list;
item.uid = case_title;
return item;
}
return response;
});
}
}
return response;
}, undefined);
}
function retrieveSoftwareFromPublisher(publisher, path_list) {
return publisher.free_software_list.reduce(function (response, software) {
var software_title = garble(software.title);
if (software_title === path_list[1]) {
software.portal_type = "software";
software.publisher = publisher.title;
software.publisher_website = publisher.website;
software.uid = garble(publisher.title) + "/" + software_title;
return software;
}
return response;
}, undefined);
}
// find and assemble single object from publisher entries
function convertDataItem(storage, id) {
var path_list = id.split("/"),
path_len = path_list.length,
publisher;
return new RSVP.Queue()
.push(function () {
return new RSVP.Queue()
.push(function () {
return storage.get(ID_LOC + ID_PATH + path_list[0] + ".json");
})
.push(function (result) {
if (path_len === 1) {
return RSVP.all([
result,
retrieveTotalLinesFromPublisher(result)
]);
}
return [result];
});
})
.push(function (result_list) {
var response;
publisher = result_list[0];
publisher.portal_type = "publisher";
publisher.uid = garble(publisher.title);
publisher.total_lines = result_list[1] || 0;
if (path_len === 1) {
response = publisher;
} else if (path_len === 2) {
response = retrieveSoftwareFromPublisher(publisher, path_list);
} else if (path_len === 3) {
response = retrieveSuccessCaseFromSoftware(publisher, path_list);
}
return response;
})
.push(null, function (error) {
console.log(error);
throw error;
});
}
function ConverterStorage(spec) {
this._sub_storage = jIO.createJIO(spec.sub_storage);
}
ConverterStorage.prototype.get = function (id) {
return convertDataItem(this._sub_storage, id);
};
ConverterStorage.prototype.repair = function () {
return this._sub_storage.repair.apply(this._sub_storage, arguments);
};
ConverterStorage.prototype.hasCapacity = function (name) {
return (name === "list");
};
ConverterStorage.prototype.buildQuery = function () {
var storage = this._sub_storage,
argument_list = arguments;
return new RSVP.Queue()
.push(function () {
return storage.buildQuery.apply(storage, argument_list);
})
.push(function (result) {
return convertDataSet(storage, result);
});
};
jIO.addStorage('converter_storage', ConverterStorage);
}(window, jIO, RSVP, DOMParser, Object));
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Web Script" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Change_local_roles_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>content_md5</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_erp5_afs_converter_storage.js</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Custom AFS converter storage</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>gadget_erp5_afs_converter_storage_js</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value> <string>en</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Web Script</string> </value>
</item>
<item>
<key> <string>short_title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Gadget AFS Converter Storage</string> </value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>001</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>document_publication_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>edit_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>processing_status_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAU=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>publish_alive</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1501772233.65</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>published_alive</string> </value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>edit</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>961.10719.32474.19694</string> </value>
</item>
<item>
<key> <string>state</string> </key>
<value> <string>current</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1501772147.39</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
<record id="5" aka="AAAAAAAAAAU=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>detect_converted_file</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_processing_state</string> </key>
<value> <string>converted</string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>0.0.0.0</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1501765417.01</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
</ZopeData>
......@@ -9,9 +9,9 @@
<script src="renderjs.js"></script>
<script src="jiodev.js"></script>
<script src="gadget_erp5_afs_storage.js"></script>
<!--script src="gadget_erp5_afs_publisher_storage.js"></script-->
<!--script src="gadget_erp5_afs_converter_storage.js"></script-->
<!--script src="gadget_erp5_afs_storage.js"></script-->
<script src="gadget_erp5_afs_publisher_storage.js"></script>
<script src="gadget_erp5_afs_converter_storage.js"></script>
<script src="gadget_erp5_afs_jio.js"></script>
</head>
<body>
......
......@@ -79,7 +79,7 @@
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Custom AFS storage gadget</string> </value>
<value> <string>Custom AFS Jio gadget</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......@@ -101,7 +101,7 @@
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Gadget AFS Storage</string> </value>
<value> <string>Gadget AFS Jio</string> </value>
</item>
<item>
<key> <string>version</string> </key>
......@@ -232,7 +232,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>961.9243.54613.9181</string> </value>
<value> <string>961.10708.46372.11741</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -250,7 +250,7 @@
</tuple>
<state>
<tuple>
<float>1501689797.72</float>
<float>1501772511.21</float>
<string>UTC</string>
</tuple>
</state>
......
/*global window, rJS, RSVP,
jIO, DOMParser */
/*jslint indent: 2, maxerr: 3, nomen: true */
(function (window, rJS, RSVP) {
/*global window, rJS */
/*jslint indent: 2, nomen: true, maxlen: 80*/
(function (window, rJS) {
"use strict";
var DIRTY_OLOH_LOOKUP_UNTIL_API_WORKS = {
"https://www.openhub.net/p/alfresco/analyses/latest/languages_summary": 62894263,
"https://www.openhub.net/p/swift-lang/analyses/latest/languages_summary": 755449,
"https://www.openhub.net/p/bluemind/analyses/latest/languages_summary": 857795,
"https://www.openhub.net/p/drupalcommerce/analyses/latest/languages_summary": 49743,
"https://www.openhub.net/p/obm/analyses/latest/languages_summary": 363914,
"https://www.openhub.net/p/linshare/analyses/latest/languages_summary": 185407,
"https://www.openhub.net/p/linid-directory-manager/analyses/latest/languages_summary": 725443,
"https://www.openhub.net/p/openpaas/analyses/latest/languages_summary": 228875,
"https://www.openhub.net/p/magento/analyses/latest/languages_summary": 13507099,
"https://www.openhub.net/p/mariadb/analyses/latest/languages_summary": 3163137,
"https://www.openhub.net/p/vscode/analyses/latest/languages_summary": 106972,
"https://www.openhub.net/p/mongodb/analyses/latest/languages_summary": 1734408,
"https://www.openhub.net/p/erp5/analyses/latest/languages_summary": 11685522,
"https://www.openhub.net/p/SlapOS/analyses/latest/languages_summary": 583328,
"https://www.openhub.net/p/wendelin/analyses/latest/languages_summary": 123904,
"https://www.openhub.net/p/renderjs/analyses/latest/languages_summary": 52261,
"https://www.openhub.net/p/odoo/analyses/latest/languages_summary": 2492373,
"https://www.openhub.net/p/mondrian/analyses/latest/languages_summary": 1319124,
"https://www.openhub.net/p/PrestaShop/analyses/latest/languages_summary": 539680,
"https://www.openhub.net/p/symfony/analyses/latest/languages_summary": 1480506,
"https://www.openhub.net/p/php-twig/analyses/latest/languages_summary": 22572,
"https://www.openhub.net/p/fabpots_Silex/analyses/latest/languages_summary": 11586,
"https://www.openhub.net/p/talend-studio/analyses/latest/languages_summary": 287512,
"https://www.openhub.net/p/xwiki/analyses/latest/languages_summary": 7909332
};
/////////////////////////////////////////////////////////////////
// some methods
/////////////////////////////////////////////////////////////////
// XXX... lord have mercy
// XXX: the two methods below should be inside jiodev
function mockupQueryParam(param, select_list) {
var wild_param = param.replace(/[()]/g, "%").replace(/ /g, ''),
return_list = [],
len,
i;
for (i = 0, len = select_list.length; i < len; i += 1) {
return_list.push(select_list[i] + ':"' + wild_param + '"');
}
return ' (' + return_list.join(' OR ') + ')';
var wild_param = param.replace(/[()]/g, "%").replace(/ /g, '');
return ' (' + select_list.map(function (key) {
return key + ':"' + wild_param + '"';
}).join(' OR ') + ')';
}
// XXX... lord, I need more mercy
function updateQuery(query, select_list) {
var query_param_list = query.split("AND"),
function pimpQuery(option_dict) {
var query_param_list = option_dict.query.split("AND"),
query = option_dict.query,
key_list = option_dict.select_list || [],
param,
len,
i;
for (i = 0, len = query_param_list.length; i < len; i += 1) {
param = query_param_list[i];
// search
if (param.split(":").length !== 2) {
return query.replace(param, mockupQueryParam(param, select_list));
return query.replace(param, mockupQueryParam(param, key_list));
}
// hide rows
......@@ -65,275 +39,73 @@
return query;
}
function createDataSheets(gadget) {
gadget.jio_allDocs = gadget.state_parameter_dict.jio_storage.allDocs;
gadget.jio_get = gadget.state_parameter_dict.jio_storage.get;
gadget.jio_put = gadget.state_parameter_dict.jio_storage.put;
return gadget.jio_allDocs()
/////////////////////////////////////////////////////////////////
// Make Publisher datasheets
/////////////////////////////////////////////////////////////////
.push(function (data) {
var uid = 0,
publisher_id_list,
promise_list;
/*
function isReplicate(el) {
return (el.id.indexOf("_replicate_") < 0);
}
*/
function setPortalTypeOnPublisher(el) {
return gadget.jio_get(el.id)
.push(function (publisher_object) {
publisher_object.portal_type = "publisher";
//publisher_object.url = publisher_object.website;
uid += 1;
publisher_object.uid = uid.toString();
return gadget.jio_put(publisher_object.uid, publisher_object);
});
}
publisher_id_list = data.data.rows;
promise_list = publisher_id_list.map(setPortalTypeOnPublisher);
return RSVP.all(promise_list);
})
.push(function () {
return gadget.jio_allDocs({
select_list: ['title', 'free_software_list', 'website', 'lines'],
query: 'portal_type: "publisher"'
});
})
/////////////////////////////////////////////////////////////////
// Create Statistic Sheets
/////////////////////////////////////////////////////////////////
.push(function (result_list) {
var publisher_list = result_list.data.rows,
statistic_list = [],
i_len = publisher_list.length,
i;
// OPENHUB LOOKUP?
// curl https://www.openhub.net/projects/{project_id}/analyses/latest.xml
function createStatisticSheet(my_publisher_row) {
var software_list = my_publisher_row.value.free_software_list,
j_len = software_list.length,
profile_url,
software_analysis,
software_analysis_list = [],
j;
for (j = 0; j < j_len; j += 1) {
profile_url = software_list[j].source_code_profile;
if (profile_url && profile_url !== "") {
// more yuck
software_analysis = DIRTY_OLOH_LOOKUP_UNTIL_API_WORKS[profile_url];
delete DIRTY_OLOH_LOOKUP_UNTIL_API_WORKS[profile_url];
//software_analysis = jIO.util.ajax({
// type: "GET",
// "url": profile_url.replace("/languages_summary", ".xml")
//});
// prevent multiple entries into calculation
}
software_analysis_list.push(software_analysis || 0);
}
return new RSVP.Queue()
.push(function () {
return RSVP.all(software_analysis_list);
})
.push(function (my_stat_list) {
var line_total = 0,
k_len = my_stat_list.length,
k;
for (k = 0; k < k_len; k += 1) {
if (my_stat_list[k]) {
// xml = parser.parseFromString(my_stat_list[k],"text/xml");
//line_total += xml.getElementsByTagName("total_code_lines")[0]
// .childNodes[0].nodeValue;
line_total += my_stat_list[k];
}
}
// actually we need to store this...
return new RSVP.Queue()
.push(function () {
return gadget.jio_get(my_publisher_row.id);
})
.push(function (my_publisher) {
my_publisher.lines = line_total;
// my_publisher_row.value.lines = line_total.toString();
return gadget.jio_put(my_publisher.uid, my_publisher);
});
});
}
for (i = 0; i < i_len; i += 1) {
statistic_list.push(createStatisticSheet(publisher_list[i]));
}
return new RSVP.Queue()
.push(function () {
return RSVP.all(statistic_list);
})
.push(function () {
return result_list;
});
})
/////////////////////////////////////////////////////////////////
// Make Software datasheets
/////////////////////////////////////////////////////////////////
.push(function (publisher_list) {
var uid = 2000,
save_software_promise_list,
publishers,
promise_list;
function saveSoftwareListFromPublisher(j) {
var publisher = j.value.title,
software_list = j.value.free_software_list,
website = j.value.website;
function saveSoftwareDocument(software) {
software.portal_type = "software";
software.publisher = publisher;
software.publisher_website = website;
uid += 1;
software.uid = uid.toString();
return gadget.jio_put(software.uid, software);
}
save_software_promise_list = software_list.map(saveSoftwareDocument);
return RSVP.all(save_software_promise_list);
}
publishers = publisher_list.data.rows;
promise_list = publishers.map(saveSoftwareListFromPublisher);
return RSVP.all(promise_list);
})
.push(function () {
return gadget.jio_allDocs({
select_list: [
'title',
'website',
'success_case_list',
'publisher',
'category_list'
],
query: 'portal_type: "software"'
});
})
/////////////////////////////////////////////////////////////////
// Make Success Case datasheets
/////////////////////////////////////////////////////////////////
.push(function (software_list) {
var uid = 3000,
softwares,
promise_list;
function saveSuccessCaseListFromSoftware(softwareObject) {
var software = softwareObject.value,
publisher = softwareObject.value.publisher,
website = softwareObject.value.website,
success_case_list = softwareObject.value.success_case_list,
save_success_case_promise_list;
function isValid(success_case) {
return (success_case !== "N/A" &&
success_case.title !== "" &&
success_case.title !== "N/A");
}
function addProperties(success_case) {
success_case.portal_type = "success_case";
success_case.software = software.title;
success_case.software_website = software.website;
success_case.publisher = publisher;
success_case.publisher_website = website;
success_case.category_list = software.category_list;
uid += 1;
success_case.uid = uid.toString();
return gadget.jio_put(success_case.uid, success_case);
}
save_success_case_promise_list =
success_case_list.filter(isValid)
.map(addProperties);
return RSVP.all(save_success_case_promise_list);
}
softwares = software_list.data.rows.filter(function (sw) {
return (sw.value.success_case_list !== "N/A");
});
promise_list = softwares.map(saveSuccessCaseListFromSoftware);
return RSVP.all(promise_list);
/*
})
.push(undefined, function (error) {
console.log(error);
*/
});
}
rJS(window)
/////////////////////////////////////////////////////////////////
// ready
/////////////////////////////////////////////////////////////////
.ready(function (gadget) {
// not so nice...
return gadget.getDeclaredGadget('jio')
.push(function (jio_gadget) {
// Initialize the gadget local parameters
gadget.state_parameter_dict = {jio_storage: jio_gadget};
gadget.state_parameter_dict = {"jio_storage": jio_gadget};
});
})
/////////////////////////////////////////////////////////////////
// acquired methods
/////////////////////////////////////////////////////////////////
.declareAcquiredMethod('getSetting', 'getSetting')
.declareAcquiredMethod('redirect', 'redirect')
.declareAcquiredMethod('getUrlFor', 'getUrlFor')
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
.declareMethod('createJio', function () {
var gadget = this;
return new RSVP.Queue()
.push(function () {
return gadget.state_parameter_dict.jio_storage.createJio({
check_local_modification: false,
check_local_creation: false,
check_local_deletion: false,
parallel_operation_amount: 100,
type: "replicate",
local_sub_storage : {
type: "query",
sub_storage: {
type: "memory"
}
},
remote_sub_storage : {
type: "query",
sub_storage: {
type: "publisher_storage",
url: "/"
gadget.state_parameter_dict.jio_storage.createJio({
"type": "replicate",
"check_local_modification": false,
"check_local_creation": false,
"check_local_deletion": false,
"local_sub_storage": {
"type": "query",
"sub_storage": {type: "memory"}
},
"remote_sub_storage": {
"type": "query",
"sub_storage": {
"type": "converter_storage",
"sub_storage": {
"type": "replicate",
"check_local_modification": false,
"check_local_creation": false,
"check_local_deletion": false,
"local_sub_storage": {
"type": "query",
"sub_storage": {type: "memory"}
},
"remote_sub_storage": {
"type": "query",
"sub_storage": {
type: "publisher_storage",
url: "/"
}
}
}
})
.push(function () {
return gadget.state_parameter_dict.jio_storage.repair();
})
.push(function () {
return createDataSheets(gadget);
});
});
}
}
});
return gadget.state_parameter_dict.jio_storage.repair();
})
.declareMethod('allDocs', function (option_dict) {
option_dict.query = updateQuery(option_dict.query, option_dict.select_list);
if (option_dict && option_dict.query) {
option_dict.query = pimpQuery(option_dict);
}
return this.state_parameter_dict.jio_storage.allDocs(option_dict);
})
.declareMethod('getAttachment', function (id, view) {
......@@ -348,4 +120,5 @@
.declareMethod('repair', function () {
return this.state_parameter_dict.jio_storage.repair();
});
}(window, rJS, RSVP));
\ No newline at end of file
}(window, rJS));
......@@ -75,7 +75,7 @@
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Custom AFS storage gadget</string> </value>
<value> <string>Custom AFS Jio gadget JS</string> </value>
</item>
<item>
<key> <string>id</string> </key>
......@@ -97,7 +97,7 @@
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Gadget AFS Storage JS</string> </value>
<value> <string>Gadget AFS Jio JS</string> </value>
</item>
<item>
<key> <string>version</string> </key>
......@@ -228,7 +228,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>959.45138.58632.4420</string> </value>
<value> <string>961.10725.27982.54749</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -246,7 +246,7 @@
</tuple>
<state>
<tuple>
<float>1496066128.63</float>
<float>1501772490.89</float>
<string>UTC</string>
</tuple>
</state>
......
/*jslint indent: 2, nomen: true, maxlen: 80*/
/*global jIO, RSVP, JSON */
(function (jIO, RSVP, JSON) {
"use strict";
var HREF = 'https://api.github.com/repos/',
USER = 'Nexedi',
REPO = 'awesome-free-software',
BRANCH = '/contents/?ref=master';
function fetchUrl(option_dict) {
return new RSVP.Queue()
.push(function () {
return jIO.util.ajax(option_dict);
})
.push(function (data) {
return JSON.parse(data.target.response || data.target.responseText);
});
}
function PublisherStorage(spec) {
this._href = spec.href || HREF;
this._user = spec.user || USER;
this._repo = spec.repo || REPO;
this._branch = spec.branch || BRANCH;
this._url = this._href + this._user + '/' + this._repo + this._branch;
}
PublisherStorage.prototype.get = function (id) {
return new RSVP.Queue()
.push(function () {
return fetchUrl({type: "GET", url: id, dataType: "text"});
})
.push(undefined, function (error) {
if ((error.target !== undefined) && (error.target.status === 404)) {
throw new jIO.util.jIOError("Cannot find document", 404);
}
throw error;
});
};
PublisherStorage.prototype.hasCapacity = function (name) {
return (name === "list");
};
PublisherStorage.prototype.buildQuery = function () {
var url = this._url;
return new RSVP.Queue()
.push(function () {
return fetchUrl({"type": "GET", "url": url});
})
.push(function (data_list) {
var result_list = [],
len = data_list.length,
data_entry,
i;
for (i = 0; i < len; i += 1) {
data_entry = data_list[i];
if (data_entry.path.indexOf(".json") > -1) {
result_list.push({
id: data_entry.download_url,
value: {}
});
}
}
return result_list;
});
};
jIO.addStorage('publisher_storage', PublisherStorage);
}(jIO, RSVP, JSON));
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Web Script" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>_Access_contents_information_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Add_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Change_local_roles_Permission</string> </key>
<value>
<tuple>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_Modify_portal_content_Permission</string> </key>
<value>
<tuple>
<string>Assignee</string>
<string>Assignor</string>
<string>Manager</string>
</tuple>
</value>
</item>
<item>
<key> <string>_View_Permission</string> </key>
<value>
<tuple>
<string>Anonymous</string>
<string>Assignee</string>
<string>Assignor</string>
<string>Associate</string>
<string>Auditor</string>
<string>Manager</string>
<string>Owner</string>
</tuple>
</value>
</item>
<item>
<key> <string>content_md5</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_erp5_afs_publisher_storage.js</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Custom AFS publisher storage</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>gadget_erp5_afs_publisher_storage_js</string> </value>
</item>
<item>
<key> <string>language</string> </key>
<value> <string>en</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Web Script</string> </value>
</item>
<item>
<key> <string>short_title</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Gadget AFS Publisher Storage</string> </value>
</item>
<item>
<key> <string>version</string> </key>
<value> <string>001</string> </value>
</item>
<item>
<key> <string>workflow_history</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAI=</string> </persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="2" aka="AAAAAAAAAAI=">
<pickle>
<global name="PersistentMapping" module="Persistence.mapping"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>data</string> </key>
<value>
<dictionary>
<item>
<key> <string>document_publication_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAM=</string> </persistent>
</value>
</item>
<item>
<key> <string>edit_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAQ=</string> </persistent>
</value>
</item>
<item>
<key> <string>processing_status_workflow</string> </key>
<value>
<persistent> <string encoding="base64">AAAAAAAAAAU=</string> </persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="3" aka="AAAAAAAAAAM=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>publish_alive</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1501772254.98</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
<item>
<key> <string>validation_state</string> </key>
<value> <string>published_alive</string> </value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
<record id="4" aka="AAAAAAAAAAQ=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>edit</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>961.10606.6465.10137</string> </value>
</item>
<item>
<key> <string>state</string> </key>
<value> <string>current</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1501765392.75</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
<record id="5" aka="AAAAAAAAAAU=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key> <string>action</string> </key>
<value> <string>detect_converted_file</string> </value>
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>error_message</string> </key>
<value> <string></string> </value>
</item>
<item>
<key> <string>external_processing_state</string> </key>
<value> <string>converted</string> </value>
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>0.0.0.0</string> </value>
</item>
<item>
<key> <string>time</string> </key>
<value>
<object>
<klass>
<global name="DateTime" module="DateTime.DateTime"/>
</klass>
<tuple>
<none/>
</tuple>
<state>
<tuple>
<float>1501764580.1</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</tuple>
</pickle>
</record>
</ZopeData>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment