Commit c81e72b1 authored by Sven Franck's avatar Sven Franck Committed by Romain Courteaud

erp5_officejs_afs_directory: speed up afs.one and improve functionality

parent a7d6edba
......@@ -198,114 +198,122 @@
</record>
<record id="6" aka="AAAAAAAAAAY=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</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>1496061557.92</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>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<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>1496061557.92</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>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="7" aka="AAAAAAAAAAc=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</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>959.45174.56579.19421</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>1496061545.81</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</tuple>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<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>959.45174.56579.19421</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>1496061545.81</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -198,114 +198,122 @@
</record>
<record id="6" aka="AAAAAAAAAAY=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</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>1496062819.91</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>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<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>1496062819.91</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>
</value>
</item>
</dictionary>
</pickle>
</record>
<record id="7" aka="AAAAAAAAAAc=">
<pickle>
<global name="WorkflowHistoryList" module="Products.ERP5Type.patches.WorkflowTool"/>
<global name="WorkflowHistoryList" module="Products.ERP5Type.Workflow"/>
</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>959.45196.21805.13124</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>1496062840.28</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</tuple>
<dictionary>
<item>
<key> <string>_log</string> </key>
<value>
<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>959.45196.21805.13124</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>1496062840.28</float>
<string>UTC</string>
</tuple>
</state>
</object>
</value>
</item>
</dictionary>
</list>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -104,6 +104,9 @@
<item>
<key> <string>text_content</string> </key>
<value> <string>CACHE MANIFEST\n
# Last modified by WebSite_checkCacheModificationDateConsistency on 2020/03/27 09:12:7.112010 UTC\n
# Last modified by WebSite_checkCacheModificationDateConsistency on 2020/03/23 09:29:47.867257 UTC\n
# Last modified by WebSite_checkCacheModificationDateConsistency on 2020/03/09 13:53:8.596469 UTC\n
# Last modified by WebSite_checkCacheModificationDateConsistency on 2020/02/17 16:16:46.725895 UTC\n
# Last modified by WebSite_checkCacheModificationDateConsistency on 2020/02/13 13:51:47.480981 UTC\n
# Last modified by WebSite_checkCacheModificationDateConsistency on 2020/02/11 16:56:56.234794 UTC\n
......@@ -121,6 +124,7 @@ font-awesome/font-awesome-webfont.ttf\n
font-awesome/font-awesome-webfont.svg\n
gadget_erp5_afs_camera.png\n
gadget_erp5_afs_logo.png\n
gadget_erp5_page_afs_banner_unsplash?format=\n
URI.js\n
erp5_launcher_nojqm.js\n
gadget_erp5_nojqm.css\n
......@@ -165,6 +169,8 @@ gadget_erp5_page_afs_success_case.html\n
gadget_erp5_page_afs_success_case.js\n
gadget_erp5_page_afs_publisher.html\n
gadget_erp5_page_afs_publisher.js\n
gadget_erp5_page_afs_export.html\n
gadget_erp5_page_afs_export.js\n
gadget_erp5_page_afs_success_case_list.html\n
gadget_erp5_page_afs_success_case_list.js\n
gadget_erp5_page_afs_publisher_list.html\n
......@@ -173,8 +179,8 @@ gadget_erp5_page_afs_publisher_statistic.html\n
gadget_erp5_page_afs_publisher_statistic.js\n
gadget_erp5_page_afs_financial_list.html\n
gadget_erp5_page_afs_financial_list.js\n
gadget_erp5_page_afs_unsplash.html\n
gadget_erp5_page_afs_unsplash.js\n
#gadget_erp5_page_afs_unsplash.html\n
#gadget_erp5_page_afs_unsplash.js\n
gadget_erp5_page_afs_software.html\n
gadget_erp5_page_afs_software.js\n
gadget_erp5_page_afs_directory.html\n
......@@ -183,14 +189,17 @@ gadget_erp5_afs_dygraph.html\n
gadget_erp5_afs_dygraph.js\n
dygraph.js\n
dygraph.css\n
gadget_erp5_afs_jio.html\n
gadget_erp5_afs_jio.js\n
gadget_erp5_afs_publisher_jio.html\n
gadget_erp5_afs_publisher_jio.js\n
gadget_erp5_afs_publisher_storage.js\n
gadget_erp5_afs_export_jio.js\n
gadget_erp5_afs_export_jio.html\n
gadget_erp5_afs_export_storage.js\n
gadget_erp5_afs_panel.html\n
gadget_erp5_afs_panel.js\n
gadget_erp5_afs_router.html\n
gadget_erp5_afs_router.js\n
gadget_erp5_afs.css\n
gadget_erp5_afs_storage.js\n
gadget_erp5_page_afs_software_list.html\n
gadget_erp5_page_afs_software_list.js\n
NETWORK:\n
......@@ -322,7 +331,7 @@ NETWORK:\n
</item>
<item>
<key> <string>actor</string> </key>
<value> <string>zope</string> </value>
<value> <string>System Processes</string> </value>
</item>
<item>
<key> <string>comment</string> </key>
......@@ -336,7 +345,7 @@ NETWORK:\n
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>981.59441.37027.22988</string> </value>
<value> <string>982.51362.63695.51882</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -354,7 +363,7 @@ NETWORK:\n
</tuple>
<state>
<tuple>
<float>1582043182.97</float>
<float>1585300327.14</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -477,7 +477,20 @@ div[data-gadget-scope='panel'] {
text-decoration: underline;
color: lightblue;
}
.ui-hidden-accessible {
position: absolute !important;
height: 1px;
width: 1px;
overflow: hidden;
clip: rect(1px,1px,1px,1px);
visibility: hidden;
}
.ui-content-licence + a {
float: left;
padding-right: 1em;
padding-bottom: 2em;
margin-top: 1.75em;
}
......
......@@ -240,7 +240,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>978.57202.17736.49817</string> </value>
<value> <string>982.51180.26357.7577</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -258,7 +258,7 @@
</tuple>
<state>
<tuple>
<float>1571834038.63</float>
<float>1585229355.54</float>
<string>UTC</string>
</tuple>
</state>
......
<!Doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Jio AFS Export Gadget</title>
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<script src="jiodev.js" type="text/javascript"></script>
<script src="gadget_erp5_afs_export_storage.js" type="text/javascript"></script>
<script src="gadget_erp5_afs_export_jio.js" type="text/javascript"></script>
</head>
<body>
<div data-gadget-url='gadget_jio.html' data-gadget-scope='export'></div>
</body>
</html>
\ No newline at end of file
/*global window, rJS, RSVP, jIO, DOMParser, Object, Intl */
/*jslint indent: 2, maxerr: 3, nomen: true */
(function (window, rJS, RSVP, Object) {
"use strict";
rJS(window)
.ready(function (gadget) {
return gadget.getDeclaredGadget('export')
.push(function (jio_gadget) {
gadget.state_parameter_dict = {jio_storage: jio_gadget};
});
})
.declareMethod('createJio', function (options) {
return this.state_parameter_dict.jio_storage.createJio(options);
})
.declareMethod('allDocs', function (options) {
return this.state_parameter_dict.jio_storage.allDocs(options);
})
.declareMethod('get', function (id) {
return this.state_parameter_dict.jio_storage.get(id);
});
}(window, rJS, RSVP, Object, Intl));
\ No newline at end of file
/*jslint indent: 2, nomen: true, maxlen: 120*/
/*global jIO, RSVP, JSON, Boolean, DOMParser */
(function (jIO, RSVP, JSON, Boolean, DOMParser) {
"use strict";
// NOTE: requires Website Layout Configuration CSP modification
// connect-src 'self' https://raw.githubusercontent.com
// https://api.github.com
// https://www.openhub.net data:;
// NOTE: moved repo
//https://api.github.com/repos/Fonds-de-Dotation-du-Libre/awesome-free-software
//https://api.github.com/repos/Nexedi/awesome-free-software
// NOTE: doesn't scale, requires index or concatination as source. We concat.
// NOTE: using OpenHub API which requires an API-Key (max 1000 calls/day)
// https://github.com/blackducksoftware/ohloh_api#ohloh-api-documentation
// TODO: needs a debugger to stop point out broken profiles
var BLANK = "";
var LANG = "/languages_summary";
var XML = ".xml";
var KEY = "?api_key=";
var BUG = "/analyses/latest/languages_summary";
var REMOTE = "ERP5Site_getHTTPResource?url=";
var MASTER = "/contents/?ref=master";
function ExportStorage(spec) {
this._href = spec.href || 'https://api.github.com/repos/';
this._user = spec.user || 'Fonds-de-Dotation-du-Libre';
this._repo = spec.repo || 'awesome-free-software';
this._api_key = spec.api_key;
this._parser = new DOMParser();
}
ExportStorage.prototype.get = function (id) {
var api = this._api_key;
var parser = this._parser;
return new RSVP.Queue()
.push(function () {
return jIO.util.ajax({type: "GET", url: id, dataType: "text"});
})
.push(function (obj) {
var item = JSON.parse(obj.target.response || obj.target.responseText);
item.line_total = 0;
if (!api || api.length !== 64) {
return item;
}
// note: OpenHub API is not accessible from the client, so we need a
// server roundtrip. This means statistical data can only be exported
// when working with a proper (dev) backend. The frontend static app
// will not fetch anything from OpenHub
return new RSVP.Queue()
.push(function () {
return RSVP.all(item.free_software_list.map(function (software) {
var profile_url = software.source_code_profile.replace(" ", BLANK);
if (profile_url && profile_url !== BLANK && profile_url !== BUG) {
return new RSVP.Queue()
.push(function () {
return jIO.util.ajax({
type: "GET",
url: REMOTE + profile_url.replace(LANG, XML) + KEY + api,
xhrFields: {withCredentials: true}
});
})
.push(null, function (error) {
if ((error.target !== undefined) &&
(error.target.status === 404)) {
//DEBUG: console.log("404", profile_url);
return;
}
//DEBUG console.log("no repo-info on profile", profile_url);
throw error;
});
}
return;
}));
})
.push(function (response_list) {
item.free_software_list = item.free_software_list.map(
function (software, index) {
var xml;
var line_total;
var data;
if (response_list[index]) {
data = response_list[index];
xml = parser.parseFromString(
data.target.response || data.target.responseText,
"text/xml"
);
line_total = xml.getElementsByTagName("total_code_lines")[0]
.childNodes[0].nodeValue;
} else {
line_total = "0";
}
software.line_total = parseInt(line_total, 10);
item.line_total += parseInt(line_total, 10);
return software;
});
return item;
});
})
.push(null, function (error) {
if ((error.target !== undefined) &&
(error.target.status === 404)) {
throw new jIO.util.jIOError("Cannot find document", 404);
}
throw error;
});
};
ExportStorage.prototype.hasCapacity = function (name) {
return (name === "list");
};
ExportStorage.prototype.buildQuery = function () {
var url = this._href + this._user + '/' + this._repo + MASTER;
return new RSVP.Queue()
.push(function () {
return jIO.util.ajax({"type": "GET", "url": url});
})
.push(function (data) {
var data_list = JSON.parse(
data.target.response || data.target.responseText
);
var json_file = ".json";
var result_list = data_list.map(function (entry) {
if (entry.path.indexOf(json_file) > -1) {
return {
id: entry.download_url,
value: {}
};
}
}).filter(Boolean);
return result_list;
});
};
jIO.addStorage('export_storage', ExportStorage);
}(jIO, RSVP, JSON, Boolean, DOMParser));
......@@ -37,7 +37,8 @@
<li><a href="{{publisher_href}}" class="ui-btn ui-btn-icon-left ui-icon-university" data-i18n="Publishers" accesskey="a">Publishers</a></li>
<li><a href="{{financial_href}}" class="ui-btn ui-btn-icon-left ui-icon-euro" data-i18n="Financial Data" accesskey="f">Financial Data</a></li>
<li><a href="{{software_href}}" class="ui-btn ui-btn-icon-left ui-icon-cube" data-i18n="Software Products" accesskey="p">Software Products</a></li>
<li class="ui-last-child"><a href="{{success_case_href}}" class="ui-btn ui-btn-icon-left ui-icon-book" data-i18n="Success Cases" accesskey="s">Success Cases</a></li>
<li><a href="{{success_case_href}}" class="ui-btn ui-btn-icon-left ui-icon-book" data-i18n="Success Cases" accesskey="s">Success Cases</a></li>
<li class="ui-last-child"><a href="{{export_href}}" class="ui-btn ui-btn-icon-left ui-icon-download" data-i18n="Export" accesskey="e">Export</a></li>
<!--div>
{{#if language_list}}
<li data-role="collapsible" data-enhanced="true" data-collapsed="true" data-collapsed-icon="comment-o" class="ui-collapsible ui-collapsible-collapsed">
......@@ -68,6 +69,7 @@
<br/>
<p class="ui-custom-content">Powered by: <br/><a href="http://fdl-lef.org">Fonds de Dotation du Libre</a></p>
<p class="ui-custom-content">Contribute on: <br/><a href="https://github.com/Fonds-de-Dotation-du-Libre/awesome-free-software">Awesome Free Software (on Github)</a></p>
<p class="ui-custom-content">Stats by: <br/><a href ="https://www.openhub.net"><img src="https://www.openhub.net/images/badges/mini.gif" width="80" height="15" /></a></p>
</div>
</script>
......
......@@ -238,7 +238,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>979.20371.46763.48657</string> </value>
<value> <string>982.50377.36948.34628</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -256,7 +256,7 @@
</tuple>
<state>
<tuple>
<float>1571908254.8</float>
<float>1585610332.06</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -53,7 +53,8 @@
g.getUrlFor({command: 'display', options: {page: "afs_publisher_list"}}),
g.getUrlFor({command: 'display', options: {page: "afs_software_list"}}),
g.getUrlFor({command: 'display', options: {page: "afs_success_case_list"}}),
g.getUrlFor({command: 'display', options: {page: "afs_financial_list"}})
g.getUrlFor({command: 'display', options: {page: "afs_financial_list"}}),
g.getUrlFor({command: 'display', options: {page: "afs_export"}})
]);
})
.push(function (all_result) {
......@@ -66,7 +67,8 @@
"publisher_href": all_result[2],
"financial_href": all_result[5],
"software_href": all_result[3],
"success_case_href": all_result[4]
"success_case_href": all_result[4],
"export_href": all_result[6]
});
g.element.querySelector("div").innerHTML = tmp;
});
......
......@@ -3,16 +3,14 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Jio Gadget</title>
<title>Jio AFS Publisher Gadget</title>
<!-- renderjs -->
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<script src="jiodev.js" type="text/javascript"></script>
<script src="gadget_erp5_afs_storage.js" type="text/javascript"></script>
<script src="gadget_erp5_afs_jio.js" type="text/javascript"></script>
<script src="gadget_erp5_afs_publisher_storage.js" type="text/javascript"></script>
<script src="gadget_erp5_afs_publisher_jio.js" type="text/javascript"></script>
</head>
<body>
......
/*global window, rJS, RSVP, jIO, DOMParser, Object, Intl */
/*global window, rJS, RSVP, jIO, DOMParser, Object, Intl, encodeURIComponent */
/*jslint indent: 2, maxerr: 3, nomen: true */
(function (window, rJS, RSVP, Object) {
(function (window, rJS, RSVP, Object, Intl, encodeURIComponent) {
"use strict";
var SPACE = " ",
......@@ -16,32 +16,6 @@
2016: getEmptyKpiDict(),
2017: getEmptyKpiDict(),
2018: getEmptyKpiDict()
},
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
};
function getEmptyKpiDict() {
......@@ -73,20 +47,6 @@
});
}
function S4() {
return ('0000' + Math.floor(
Math.random() * 0x10000 /* 65536 */
).toString(16)).slice(-4);
}
function UUID() {
return S4() + S4() + "-" +
S4() + "-" +
S4() + "-" +
S4() + "-" +
S4() + S4() + S4();
}
function setKpi(kpi, data) {
if (kpi === undefined) {
return "";
......@@ -131,7 +91,8 @@
publisher_object.total_assets = setKpi("total_assets", kpi);
publisher_object.earnings = setKpi("earnings", kpi);
publisher_object.uid = UUID();
publisher_object.line_total = publisher_object.line_total || 0;
publisher_object.uid = "publisher_" + publisher_object.title;
return gadget.jio_put(publisher_object.uid, publisher_object);
});
}
......@@ -144,7 +105,7 @@
return RSVP.all(promise_list);
})
.push(function () {
return gadget.jio_put(UUID(), {
return gadget.jio_put("kpi_dict", {
portal_type: "kpi",
data: GLOBAL_KPI_DICT
});
......@@ -153,87 +114,11 @@
.push(function () {
return gadget.jio_allDocs({
select_list: ['title', 'free_software_list', 'website', 'lines'],
select_list: ['title', 'free_software_list', 'website', 'line_total'],
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
/////////////////////////////////////////////////////////////////
......@@ -251,7 +136,7 @@
software.portal_type = "software";
software.publisher = publisher;
software.publisher_website = website;
software.uid = UUID();
software.uid = "software_" + software.title;
return gadget.jio_put(software.uid, software);
}
......@@ -306,7 +191,7 @@
success_case.publisher = publisher;
success_case.publisher_website = website;
success_case.category_list = software.category_list;
success_case.uid = UUID();
success_case.uid = "case_" + success_case.title;
return gadget.jio_put(success_case.uid, success_case);
}
......@@ -393,4 +278,4 @@
.declareMethod('repair', function () {
return this.state_parameter_dict.jio_storage.repair();
});
}(window, rJS, RSVP, Object, Intl));
\ No newline at end of file
}(window, rJS, RSVP, Object, Intl, encodeURIComponent));
\ No newline at end of file
......@@ -71,15 +71,15 @@
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_erp5_afs_jio.js</string> </value>
<value> <string>gadget_erp5_afs_publisher_jio.js</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Custom AFS storage gadget</string> </value>
<value> <string>Custom AFS publisher gadget</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>gadget_erp5_afs_jio_js</string> </value>
<value> <string>gadget_erp5_afs_publisher_jio_js</string> </value>
</item>
<item>
<key> <string>language</string> </key>
......@@ -234,7 +234,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>979.60903.41059.38860</string> </value>
<value> <string>982.58689.51657.16247</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -252,7 +252,7 @@
</tuple>
<state>
<tuple>
<float>1574267756.0</float>
<float>1585728670.64</float>
<string>UTC</string>
</tuple>
</state>
......
/*jslint indent: 2, nomen: true, maxlen: 120*/
/*global jIO, RSVP, JSON, Object */
(function (jIO, RSVP, JSON, Object) {
"use strict";
var PROMISE_DATABASE;
var DICT = {};
var GETTER = {
type: "GET",
url: "https://raw.githubusercontent.com/Fonds-de-Dotation-du-Libre/awesome-free-software/master/dump/afs.json",
dataType: "text"
};
function populatePublisherStorage() {
return new RSVP.Queue()
.push(function () {
return jIO.util.ajax(GETTER);
})
.push(function (dump) {
return JSON.parse(dump.target.response || dump.target.responseText);
})
.push(undefined, function (error) {
if ((error.target !== undefined) &&
(error.target.status === 404)) {
throw new jIO.util.jIOError("Cannot find document", 404);
}
throw error;
});
}
PROMISE_DATABASE = populatePublisherStorage();
function PublisherStorage(spec) {}
PublisherStorage.prototype.get = function (id) {
return new RSVP.Queue(PROMISE_DATABASE)
.push(function (database) {
return database[id];
});
};
PublisherStorage.prototype.hasCapacity = function (name) {
return (name === "list");
};
PublisherStorage.prototype.buildQuery = function () {
return new RSVP.Queue(PROMISE_DATABASE)
.push(function (database) {
return Object.keys(database).map(function (url) {
return {
id: url,
value: DICT
};
});
});
};
jIO.addStorage('publisher_storage', PublisherStorage);
}(jIO, RSVP, JSON, Object));
\ No newline at end of file
......@@ -71,15 +71,15 @@
</item>
<item>
<key> <string>default_reference</string> </key>
<value> <string>gadget_erp5_afs_storage.js</string> </value>
<value> <string>gadget_erp5_afs_publisher_storage.js</string> </value>
</item>
<item>
<key> <string>description</string> </key>
<value> <string>Custom AFS storage</string> </value>
<value> <string>Custom AFS publisher storage</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>gadget_erp5_afs_storage_js</string> </value>
<value> <string>gadget_erp5_afs_publisher_storage_js</string> </value>
</item>
<item>
<key> <string>language</string> </key>
......@@ -97,7 +97,7 @@
</item>
<item>
<key> <string>title</string> </key>
<value> <string>Gadget AFS Storage</string> </value>
<value> <string>Gadget AFS Publisher Storage</string> </value>
</item>
<item>
<key> <string>version</string> </key>
......@@ -234,7 +234,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>978.13614.57660.49134</string> </value>
<value> <string>982.57237.47631.43093</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -252,7 +252,7 @@
</tuple>
<state>
<tuple>
<float>1571909400.76</float>
<float>1585583493.48</float>
<string>UTC</string>
</tuple>
</state>
......
/*jslint nomen: true, indent: 2, maxerr: 3 */
/*global window, rJS */
(function (window, rJS) {
/*global window, rJS, RSVP, Boolean */
(function (window, rJS, RSVP, Boolean) {
"use strict";
rJS(window)
/*
.ready(function (g) {
return g.getDeclaredGadget("router")
.push(function (my_default_router) {
return my_default_router.start();
});
})
*/
.declareAcquiredMethod("getUrlFor", "getUrlFor")
/////////////////////////////////////////////////////////////////
// declared methods
/////////////////////////////////////////////////////////////////
.declareMethod('getCommandUrlForList', function (options_list) {
var i,
result_list = [],
dict,
key,
portal;
for (i = 0; i < options_list.length; i += 1) {
dict = options_list[i];
// XXX better way than to extract from query like this?
if (dict.command === "index") {
key = dict.options.jio_key;
portal = dict.options.query.split(":")[1].split('"')[1];
result_list.push("#/" + key + "?page=afs_" + portal + "&view=view");
}
}
if (result_list.length) {
return result_list;
}
return this.getDeclaredGadget("router")
.push(function (router) {
return router.getCommandUrlForList.apply(router, [options_list]);
var gadget = this;
return new RSVP.Queue()
.push(function () {
var cmd_index = "index";
var result_list = options_list.map(function (opt) {
if (opt.command === cmd_index) {
return gadget.getUrlFor({command: "display", options: {
jio_key: opt.options.jio_key,
page: "afs_" + opt.options.query.split(":")[1].split('"')[1],
view: "view"
}
});
}
}).filter(Boolean);
if (result_list.length) {
return RSVP.all(result_list);
}
return gadget.getDeclaredGadget("router")
.push(function (router) {
return router.getCommandUrlForList.apply(router, [options_list]);
});
});
})
.declareMethod('getCommandUrlFor', function () {
......@@ -50,9 +42,14 @@
// XXX better way than to extract from query like this?
if (dict.command === "index") {
key = dict.options.jio_key;
portal = dict.options.query.split(":")[1].split('"')[1];
return "#/" + key + "?page=afs_" + portal + "&view=view";
//key = dict.options.jio_key;
//portal = dict.options.query.split(":")[1].split('"')[1];
//return "#/" + key + "?page=afs_" + portal + "&view=view";
return this.getUrlFor({command: "index", options: {
jio_key: dict.options.jio_key,
page: "afs_" + dict.options.query.split(":")[1].split('"')[1],
view: "view"
}});
}
return this.getDeclaredGadget("router")
.push(function (router) {
......@@ -94,4 +91,4 @@
});
});
}(window, rJS));
\ No newline at end of file
}(window, rJS, RSVP, Boolean));
\ No newline at end of file
/*jslint indent: 2, nomen: true, maxlen: 120*/
/*global jIO, RSVP, JSON */
(function (jIO, RSVP, JSON) {
"use strict";
function PublisherStorage(spec) {
// NOTE: requires Website Layout Configuration CSP modification
// => connect-src 'self' https://raw.githubusercontent.com https://api.github.com data:;
// NOTE: moved repo
//https://api.github.com/repos/Fonds-de-Dotation-du-Libre/awesome-free-software
//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 || 'Fonds-de-Dotation-du-Libre';
this._repo = spec.repo || 'awesome-free-software';
}
PublisherStorage.prototype.get = function (id) {
return new RSVP.Queue()
.push(function () {
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);
}
throw error;
}
);
};
PublisherStorage.prototype.hasCapacity = function (name) {
return (name === "list");
};
PublisherStorage.prototype.buildQuery = function () {
var url = this._href + this._user + '/' + this._repo + '/contents/?ref=master';
return new RSVP.Queue()
.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.indexOf(".json") > -1) {
result_list.push({
id: data_entry.download_url,
value: {}
});
}
}
return result_list;
});
};
jIO.addStorage('publisher_storage', PublisherStorage);
}(jIO, RSVP, JSON));
\ No newline at end of file
......@@ -14,10 +14,9 @@
<!-- custom script -->
<script src="gadget_global.js" type="text/javascript"></script>
<script src="gadget_erp5_page_afs_directory.js" type="text/javascript"></script>
<!-- templates -->
<script id="frontpage-template" type="text/x-handlebars-template">
<ul class="grid-items">
......@@ -28,7 +27,7 @@
{{/each}}
</ul>
</script>
<script id="list-partial" type="text/x-handlebars-template">
<section class="ui-content-section ui-body-c">
<h1>{{category}}</h1>
......@@ -42,11 +41,23 @@
</head>
<body>
<div data-gadget-url="gadget_erp5_page_afs_unsplash.html"
data-gadget-scope="unsplash"
data-gadget-sandbox="public">
</div>
<!--div data-gadget-url="gadget_erp5_page_afs_unsplash.html"
data-gadget-scope="unsplash"
data-gadget-sandbox="public">
</div-->
<section class="ui-banner-section">
<h1>What can Free Software do for you?</h1>
<img src="gadget_erp5_page_afs_banner_unsplash?format=" alt="Free Software" />
<span>
Photo by
<a target="_blank" href="https://unsplash.com/@laurent_peignault">Laurent Peignault</a>
&nbsp;/&nbsp;
<a target="_blank" href="https://unsplash.com/">Unsplash</a>
</span>
</section>
<section class="ui-responsive ui-masonry-container"></section>
</body>
</html>
......@@ -15,6 +15,7 @@
);
gadget_klass
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareAcquiredMethod("updateHeader", "updateHeader")
.declareAcquiredMethod("jio_allDocs", "jio_allDocs")
......@@ -30,7 +31,7 @@
return new RSVP.Queue()
.push(function () {
return RSVP.all([
gadget.getDeclaredGadget("unsplash"),
//gadget.getDeclaredGadget("unsplash"),
gadget.updateHeader({
page_title: 'Free Software Publisher Directory'
})
......@@ -41,8 +42,8 @@
gadget.jio_allDocs({
select_list: ['category_list'],
query: 'portal_type:"software"'
}),
my_response_list[0].render()
})
//my_response_list[0].render()
]);
})
.push(function (my_response_list) {
......@@ -72,19 +73,33 @@
select_list: [
'title',
'publisher',
'logo'
'logo',
'uid'
],
query: 'category_list:"%' + category + '%" AND portal_type:"software"'
})
.push(function (softwares) {
softwares.data.rows.map(function (sw) {
// XXX hardcoded page and view
sw.value.href = "#/" + sw.id + "?page=afs_software&view=view";
});
return {
category: category,
softwares: softwares.data.rows
};
return new RSVP.Queue()
.push(function () {
return RSVP.all(softwares.data.rows.map(function (sw) {
return gadget.getUrlFor({command: "display", options: {
jio_key: sw.value.uid,
page: "afs_software",
view: "view"
}
})
.push(function (href) {
//sw.value.href = "#!/" + sw.value.uid + "?page=afs_software&view=view";
sw.value.href = href;
});
}));
})
.push(function () {
return {
category: category,
softwares: softwares.data.rows
};
});
});
});
......
<!Doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Export</title>
<link rel="stylesheet" href="gadget_erp5_afs.css" />
<script src="rsvp.js" type="text/javascript"></script>
<script src="renderjs.js" type="text/javascript"></script>
<script src="jiodev.js" type="text/javascript"></script>
<!-- custom script -->
<script src="gadget_global.js" type="text/javascript"></script>
<script src="gadget_erp5_page_afs_export.js" type="text/javascript"></script>
</head>
<body>
<p class="ui-content-licence">
<a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/">
<img alt="Creative Commons License" style="border-width:0" src="https://i.creativecommons.org/l/by-sa/4.0/88x31.png" /></a><br />Please note, that the data presented on this platform is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-sa/4.0/">Creative Commons Attribution-ShareAlike 4.0 International License</a>.
</p>
<div data-gadget-url="gadget_erp5_afs_export_jio.html"
data-gadget-scope="export"
data-gadget-sandbox="public">
</div>
</body>
</html>
\ No newline at end of file
/*globals window, RSVP, rJS, JSON, encodeURIComponent*/
/*jslint indent: 2, nomen: true, maxlen: 80*/
(function (window, RSVP, rJS, JSON, encodeURIComponent) {
"use strict";
rJS(window)
.ready(function (gadget) {
gadget.state_parameter_dict = {};
//var api_key = window.prompt("Enter OpenHub API-Key or click 'Cancel'");
var api_key = "";
return gadget.getDeclaredGadget('export')
.push(function (jio_gadget) {
gadget.state_parameter_dict.jio_storage = jio_gadget;
return gadget.state_parameter_dict.jio_storage.createJio({
type: "export_storage",
api_key: api_key
});
});
})
.declareAcquiredMethod("updateHeader", "updateHeader")
.allowPublicAcquisition('updateHeader', function () {
return;
})
.declareMethod("render", function () {
var gadget = this;
var jio = gadget.state_parameter_dict.jio_storage;
var dump = {};
return new RSVP.Queue()
.push(function () {
gadget.updateHeader({
page_title: 'Download'
});
})
.push(function () {
return jio.allDocs({});
})
.push(function (result_list) {
var queue = new RSVP.Queue();
var result_array = result_list.data.rows;
var process_list = [];
// process in chunks of 40 requests to not overwhelm OpenHub API
while (result_array.length) {
process_list.push(result_array.splice(0, 40));
}
process_list.map(function (process_array) {
queue.push(function () {
return RSVP.all(process_array.map(function (obj) {
return new RSVP.Queue()
.push(function () {
return jio.get(obj.id);
})
.push(function (result) {
obj.value = result;
dump[obj.id] = result;
});
}));
});
});
return queue;
})
.push(function () {
var str = "data:text/json;charset=utf-8," + encodeURIComponent(
JSON.stringify(dump)
);
var download_button = window.document.createElement("a");
download_button.setAttribute("href", str);
download_button.setAttribute("download", "afs.json");
download_button.classList.add("ui-hidden-accessible");
window.document.body.appendChild(download_button);
download_button.click();
download_button.remove();
});
});
}(window, RSVP, rJS, JSON, encodeURIComponent));
......@@ -234,7 +234,7 @@
</item>
<item>
<key> <string>serial</string> </key>
<value> <string>978.13614.57660.49134</string> </value>
<value> <string>982.57241.18670.44629</string> </value>
</item>
<item>
<key> <string>state</string> </key>
......@@ -252,7 +252,7 @@
</tuple>
<state>
<tuple>
<float>1571233280.55</float>
<float>1585585246.47</float>
<string>UTC</string>
</tuple>
</state>
......
......@@ -28,7 +28,7 @@
return this.getUrlParameter(argument_list)
.push(function (result) {
if ((result === undefined) && (argument_list[0] === SORT_STRING)) {
return [['lines', 'descending']];
return [['line_total', 'descending']];
}
return result;
});
......@@ -49,10 +49,10 @@
var column_list = [
['title', 'Title'],
['country', 'Country'],
['lines', 'Total Lines of Code']
['line_total', 'Total Lines of Code']
],
sort_column_list = [
['lines', 'Total Lines of Code']
['line_total', 'Total Lines of Code']
];
return form_gadget.render({
......@@ -69,7 +69,7 @@
"portal_type": [],
"search_column_list": column_list,
"sort_column_list": sort_column_list,
"sort_on": ["lines", "descending"],
"sort_on": ["line_total", "descending"],
"title": "Documents",
"type": "ListBox"
}
......
......@@ -27,9 +27,7 @@
var gadget = this;
return new RSVP.Queue()
.push(function () {
return gadget.updateHeader({
page_title: "Software List"
});
return gadget.updateHeader({page_title: "Software List"});
})
.push(function () {
return gadget.getDeclaredGadget("form_list");
......
......@@ -25,7 +25,17 @@
</span>
</section>
</script>
</head>
<body></body>
<body>
<section class="ui-banner-section">
<h1>What can Free Software do for you?</h1>
<img src="gadget_erp5_page_afs_banner_unsplash?format=" alt="Free Software" />
<span>
Photo by
<a target="_blank" href="https://unsplash.com/@laurent_peignault">Laurent Peignault</a>
&nbsp;/&nbsp;
<a target="_blank" href="https://unsplash.com/">Unsplash</a>
</span>
</section>
</body>
</html>
......@@ -3,6 +3,8 @@
(function (window, RSVP, rJS, Handlebars, jIO) {
"use strict";
// NO LONGER USED
// UNSPLASH API
// API: https://unsplash.com/documentation#creating-a-developer-account
var CID = "3196c4c1a2915c32bd9ca6ba5a88cec7555e06eb7e580546018f079394e9954f",
......
erp5_web_renderjs_ui
\ No newline at end of file
erp5_web_renderjs_ui
erp5_http_proxy
\ No newline at end of file
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