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 @@
});
}
rJS(window)
.ready(function (g) {
g.props = {};
......@@ -66,6 +65,7 @@
})
.declareAcquiredMethod("crib_sw_get", "crib_sw_get")
.declareAcquiredMethod("crib_sw_put", "crib_sw_put")
.declareAcquiredMethod("setSetting", "setSetting")
.declareAcquiredMethod("getUrlFor", "getUrlFor")
.declareMethod('render', function (options) {
var gadget = this;
......@@ -73,6 +73,12 @@
options = {}
gadget.props.options = options;
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 () {
if (options.url !== undefined) {
gadget.props.element.querySelector("form.crib-editor-get .url").value = options.url;
......
......@@ -22,15 +22,12 @@
<p>Load your Crib from here</p>
</div>
<div class="nav_content container">
<h3>Edit this Site</h3>
<div class="form-group">
<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>
<h3>Start Editing this Site</h3>
<a class="edit-url btn btn-primary" type="text" size="60" href="">Start Editing This Site Now</a>
</div>
<div class="nav_content container">
<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">
<label>Zip Url:
<input name="load-zip-url" class="load-zip-url form-control" type="text" size="60"></label>
......
......@@ -16,6 +16,16 @@
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) {
return RSVP.Queue()
.push(function() {
......@@ -42,8 +52,10 @@
var gadget = this,
getURL = window.location,
site = getURL.protocol + "//" + getURL.host,
params = getParameterDict();
gadget.props.element.querySelector("input.edit-url").value = site + "/gadget/crib-sw-storage-gadget.html";
params = getParameterDict(),
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") ) {
gadget.props.element.querySelector("form.crib-load-from-zip-url .load-from-zip-path").value = params.from_path;
} 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