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