Commit 27df4d52 authored by Cédric Le Ninivin's avatar Cédric Le Ninivin

Improve Landing to allow editing site directly

parent 478b0b77
...@@ -51,7 +51,6 @@ ...@@ -51,7 +51,6 @@
}); });
} }
rJS(window) rJS(window)
.ready(function (g) { .ready(function (g) {
g.props = {}; g.props = {};
...@@ -66,6 +65,7 @@ ...@@ -66,6 +65,7 @@
}) })
.declareAcquiredMethod("crib_sw_get", "crib_sw_get") .declareAcquiredMethod("crib_sw_get", "crib_sw_get")
.declareAcquiredMethod("crib_sw_put", "crib_sw_put") .declareAcquiredMethod("crib_sw_put", "crib_sw_put")
.declareAcquiredMethod("setSetting", "setSetting")
.declareAcquiredMethod("getUrlFor", "getUrlFor") .declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareMethod('render', function (options) { .declareMethod('render', function (options) {
var gadget = this; var gadget = this;
...@@ -73,6 +73,12 @@ ...@@ -73,6 +73,12 @@
options = {} options = {}
gadget.props.options = options; gadget.props.options = options;
return new RSVP.Queue() return new RSVP.Queue()
.push(function () {
if (gadget.props.options.crib_enable_url !== undefined) {
return gadget.setSetting("site_editor_gadget_url", gadget.props.options.crib_enable_url);
}
return ;
})
.push(function () { .push(function () {
if (options.url !== undefined) { if (options.url !== undefined) {
gadget.props.element.querySelector("form.crib-editor-get .url").value = options.url; gadget.props.element.querySelector("form.crib-editor-get .url").value = options.url;
......
...@@ -22,15 +22,12 @@ ...@@ -22,15 +22,12 @@
<p>Load your Crib from here</p> <p>Load your Crib from here</p>
</div> </div>
<div class="nav_content container"> <div class="nav_content container">
<h3>Edit this Site</h3> <h3>Start Editing this Site</h3>
<div class="form-group"> <a class="edit-url btn btn-primary" type="text" size="60" href="">Start Editing This Site Now</a>
<label>Edit URL:
<input name="edit-url" class="edit-url form-control" type="text" size="60" readonly value="/gadget/crib-sw-storage-gadget.html"></label>
</div>
</div> </div>
<div class="nav_content container"> <div class="nav_content container">
<form class="crib-load-from-zip-url form-inline"> <form class="crib-load-from-zip-url form-inline">
<h3>Import from zip URL</h3> <h3>Fill This site from a zip URL</h3>
<div class="form-group"> <div class="form-group">
<label>Zip Url: <label>Zip Url:
<input name="load-zip-url" class="load-zip-url form-control" type="text" size="60"></label> <input name="load-zip-url" class="load-zip-url form-control" type="text" size="60"></label>
......
...@@ -16,6 +16,16 @@ ...@@ -16,6 +16,16 @@
function loadCribJSFromZipFile (gadget, event) { function loadCribJSFromZipFile (gadget, event) {
} }
function makeid(length) {
var result = '';
var characters = 'abcdefghijklmnopqrstuvwxyz0123456789';
var charactersLength = characters.length;
for ( var i = 0; i < length; i++ ) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
}
return result;
}
function loadCribJSFromZipUrl (gadget, event) { function loadCribJSFromZipUrl (gadget, event) {
return RSVP.Queue() return RSVP.Queue()
.push(function() { .push(function() {
...@@ -42,8 +52,10 @@ ...@@ -42,8 +52,10 @@
var gadget = this, var gadget = this,
getURL = window.location, getURL = window.location,
site = getURL.protocol + "//" + getURL.host, site = getURL.protocol + "//" + getURL.host,
params = getParameterDict(); params = getParameterDict(),
gadget.props.element.querySelector("input.edit-url").value = site + "/gadget/crib-sw-storage-gadget.html"; edit_url="https://" + makeid(10) + ".cribjs.nexedi.net/crib-editor4/#page=editor&url="
+ site + "&crib_enable_url=" + site + "/gadget/crib-sw-storage-gadget.html";
gadget.props.element.querySelector("a.edit-url").href = edit_url ;
if ( params.hasOwnProperty("from_path") ) { if ( params.hasOwnProperty("from_path") ) {
gadget.props.element.querySelector("form.crib-load-from-zip-url .load-from-zip-path").value = params.from_path; gadget.props.element.querySelector("form.crib-load-from-zip-url .load-from-zip-path").value = params.from_path;
} else { } else {
......
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