diff --git a/bt5/erp5_officejs_afs_directory/PathTemplateItem/web_page_module/gadget_erp5_afs_storage_js.js b/bt5/erp5_officejs_afs_directory/PathTemplateItem/web_page_module/gadget_erp5_afs_storage_js.js index 9ef01d71656ce5a84bfe1378fb7deada083251cd..f88b8f21c1b3d88245d70437ef196ab3329b8fd7 100644 --- a/bt5/erp5_officejs_afs_directory/PathTemplateItem/web_page_module/gadget_erp5_afs_storage_js.js +++ b/bt5/erp5_officejs_afs_directory/PathTemplateItem/web_page_module/gadget_erp5_afs_storage_js.js @@ -1,52 +1,40 @@ -/* - * Copyright 2016, Nexedi SA - * Released under the LGPL license. - * http://www.gnu.org/licenses/lgpl.html - */ - /*jslint nomen: true*/ -/*global jIO, RSVP, DOMParser, Blob */ - -(function (jIO, RSVP, JSON, UriTemplate) { +/*global jIO, RSVP, JSON */ +(function (jIO, RSVP, JSON) { "use strict"; - - var DOCUMENT_URL = "{document_id}", - document_url_template = UriTemplate.parse(DOCUMENT_URL); - - function ajax(storage, options) { - if (options === undefined) { - options = {}; - } - - return new RSVP.Queue() - .push(function () { - return jIO.util.ajax(options); - }); - } function PublisherStorage(spec) { + + // NOTE: requires Website Layout Configuration CSP modification + // => connect-src 'self' https://raw.githubusercontent.com https://api.github.com data:; + + //https://api.github.com/repos/Nexedi/awesome-free-software + //https://api.github.com/repos/Nexedi/awesome-free-software/contents/?ref=master + //https://api.github.com/repos/Nexedi/awesome-free-software/contents/alfresco.json + //https://raw.githubusercontent.com/Nexedi/awesome-free-software/master/alfresco.json + + this._href = spec.href || 'https://api.github.com/repos/'; + this._user = spec.user || 'Nexedi'; + this._repo = spec.repo || 'awesome-free-software'; } PublisherStorage.prototype.get = function (id) { - var context = this; - return new RSVP.Queue() .push(function () { - return ajax(context, { - type: "GET", - url: document_url_template.expand({document_id: id}), - dataType: "text", - }); + return jIO.util.ajax({type: "GET", url: id, dataType: "text"}); }) - .push(function (response) { - return JSON.parse(response.target.response || response.target.responseText); - }, function (error) { - if ((error.target !== undefined) && - (error.target.status === 404)) { - throw new jIO.util.jIOError("Cannot find document", 404); + .push( + function (response) { + return JSON.parse(response.target.response || response.target.responseText); + }, + function (error) { + if ((error.target !== undefined) && + (error.target.status === 404)) { + throw new jIO.util.jIOError("Cannot find document", 404); + } + throw error; } - throw error; - }); + ); }; PublisherStorage.prototype.hasCapacity = function (name) { @@ -54,32 +42,32 @@ }; PublisherStorage.prototype.buildQuery = function (options) { - var context = this, - rows = []; + var url = this._href + this._user + '/' + this._repo + '/contents/?ref=master'; return new RSVP.Queue() - .push(function () { - return ajax(context, { - type: "GET", - url: document_url_template.expand({document_id: 'publisher_list.txt'}) - }); - }) - .push(function (response) { - var response_list = (response.target.response || response.target.responseText).split('\n'); - - for (var entry in response_list) { - if (response_list[entry] !== "") { - rows.push({ - id: response_list[entry], - value: {} - }); + .push(function () { + return jIO.util.ajax({"type": "GET", "url": url}); + }) + .push(function (data) { + var data_list = JSON.parse(data.target.response || data.target.responseText), + result_list = [], + data_entry, + len, + i; + + for (i = 0, len = data_list.length; i < len; i += 1) { + data_entry = data_list[i]; + if (data_entry.path !== "README.md") { + result_list.push({ + id: data_entry.download_url, + value: {} + }); + } } - } - - return rows; - }); + return result_list; + }); }; jIO.addStorage('publisher_storage', PublisherStorage); -}(jIO, RSVP, JSON, UriTemplate)); \ No newline at end of file +}(jIO, RSVP, JSON)); \ No newline at end of file diff --git a/bt5/erp5_officejs_afs_directory/PathTemplateItem/web_site_module/afs.xml b/bt5/erp5_officejs_afs_directory/PathTemplateItem/web_site_module/afs.xml index d5684cc504f464049c472b8d36980e2f01bef1e4..0fbac7bb03af946f75e260d41557217170f3d803 100644 --- a/bt5/erp5_officejs_afs_directory/PathTemplateItem/web_site_module/afs.xml +++ b/bt5/erp5_officejs_afs_directory/PathTemplateItem/web_site_module/afs.xml @@ -337,7 +337,7 @@ </item> <item> <key> <string>configuration_content_security_policy</string> </key> - <value> <string>default-src \'self\'; img-src \'self\' * data:; media-src \'self\' blob:; connect-src \'self\' data:; script-src \'self\' \'unsafe-eval\'; font-src \'self\'; style-src \'self\' data:; frame-src \'self\' data:</string> </value> + <value> <string>default-src \'self\'; img-src \'self\' * data:; media-src \'self\' blob:; connect-src \'self\' https://raw.githubusercontent.com https://api.github.com data:; script-src \'self\' \'unsafe-eval\'; font-src \'self\'; style-src \'self\' data:; frame-src \'self\' data:</string> </value> </item> <item> <key> <string>configuration_default_view_action_reference</string> </key> @@ -614,7 +614,7 @@ </item> <item> <key> <string>serial</string> </key> - <value> <string>953.59466.37233.9915</string> </value> + <value> <string>954.25873.23492.36983</string> </value> </item> <item> <key> <string>state</string> </key> @@ -632,7 +632,7 @@ </tuple> <state> <tuple> - <float>1473847779.13</float> + <float>1475681337.69</float> <string>UTC</string> </tuple> </state>