Commit d697f370 authored by Cédric Le Ninivin's avatar Cédric Le Ninivin

AppList: Provides only a sample app-list

* The idea is to not overwrite the app list of the user upon CribJS
update
* Add Application_path parameter in order to edit the whole application
when the default landing page of the app is not index.html
parent 48d6fb59
......@@ -3,7 +3,8 @@
encodeURIComponent */
(function (window, rJS, jIO) {
"use strict";
var DEFAULT_APP_LIST_DOC = "app-list.json";
var DEFAULT_APP_LIST_DOC = "app-list.json",
SAMPLE_APP_LIST_DOC = "sample-app-list.json";
function getParameterDict() {
var hash = window.location.hash.substring(1),
......@@ -46,7 +47,10 @@
function getApplicationList(gadget) {
return RSVP.Queue()
.push(function () {
return gadget.crib_sw_get(DEFAULT_APP_LIST_DOC);
return gadget.crib_sw_get(DEFAULT_APP_LIST_DOC)
.push(undefined, function () {
return gadget.crib_sw_get(SAMPLE_APP_LIST_DOC);
});
})
.push(function (data) {
return jIO.util.readBlobAsText(data, data.type);
......@@ -58,9 +62,10 @@
function loadCribJSFromZip(gadget, event) {
var app_list = [],
redirect_to = gadget.props
.element.querySelector("form.crib-load-from-zip .load-zip-to-path").value +
"/" + gadget.props.element.querySelector("form.crib-load-from-zip .redirect-url").value;
to_path = gadget.props
.element.querySelector("form.crib-load-from-zip .load-zip-to-path").value + "/",
redirect_to = to_path +
gadget.props.element.querySelector("form.crib-load-from-zip .redirect-url").value;
if (gadget.props.element
.querySelector("form.crib-load-from-zip .load-zip-file").files.length === 0 &&
gadget.props.element
......@@ -91,6 +96,7 @@
application_image_url: undefined,
application_description: undefined,
application_url: redirect_to,
application_path: to_path,
application_edit_page: redirect_to,
application_title: gadget.props.element.querySelector(".app-name").value,
application_category: undefined
......
......@@ -2,11 +2,15 @@
/*global window, rJS, document, jIO, RSVP, domsugar, JSON */
(function (window, rJS, domsugar, jIO) {
"use strict";
var DEFAULT_APP_LIST_DOC = "app-list.json";
var DEFAULT_APP_LIST_DOC = "app-list.json",
SAMPLE_APP_LIST_DOC = "sample-app-list.json";
function displayAppList(gadget) {
var app_list = [];
return gadget.crib_sw_get(DEFAULT_APP_LIST_DOC)
.push(undefined, function () {
return gadget.crib_sw_get(SAMPLE_APP_LIST_DOC);
})
.push(function (data) {
return jIO.util.readBlobAsText(data, data.type);
})
......@@ -17,11 +21,11 @@
promise_list.push(RSVP.all([
gadget.getUrlFor({
page: "url_list",
pattern: app_list[i].application_url
pattern: app_list[i].application_path
}),
gadget.getUrlFor({
page: "save_load",
zip_download_path: app_list[i].application_url,
zip_download_path: app_list[i].application_path,
zip_name: app_list[i].application_title + ".zip",
start_zip_download: true
})
......
......@@ -6,6 +6,7 @@
"application_toc_accept": false,
"application_description":"Hello World",
"application_url":"hello-world/",
"application_path":"hello-world/",
"application_edit_page":"hello-world/index.html",
"application_title":"Hello World",
"application_category":"Development"
......@@ -16,6 +17,7 @@
"application_image_url": "pdf_viewer_app_logo.svg",
"application_description":"Read and manage you PDF Offline",
"application_url":"",
"application_path":"",
"application_edit_page":"gadget/gadget_cribjs_page_cribjs_home.html",
"application_title":"CribJS",
"application_category":"Documents"
......
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