Postinstall

This commit is contained in:
Kload 2013-10-01 12:40:59 +02:00
parent 512bfc0f9e
commit 6317f8b0db
2 changed files with 119 additions and 2 deletions

View file

@ -134,7 +134,7 @@ app = Sammy('#main', function (sam) {
* Filters
*
*/
sam.before({except: {path: '#/login'}}, function (req) {
sam.before({except: {path: ['#/login', '#/postinstall']}}, function (req) {
// Store path for further redirections
store.set('path-1', store.get('path'));
@ -183,7 +183,7 @@ app = Sammy('#main', function (sam) {
.success(function() {
$.getJSON('http://'+ domain +':6767/installed', function(data) {
if (!data.installed) {
c.view('postinstall');
c.redirect('#/postinstall');
} else {
c.view('login', { 'domain': domain });
}
@ -227,6 +227,36 @@ app = Sammy('#main', function (sam) {
c.redirect('#/login');
});
sam.get('#/postinstall', function(c) {
c.view('postinstall', {'DDomains': ['.nohost.me', '.noho.st']});
});
sam.post('#/postinstall', function (c) {
if (c.params['password'] == c.params['confirmation']) {
if (c.params['domain'] == '') {
if (c.params['ddomain'] == '') {
c.flash('fail', "You should indicate a domain");
store.clear('slide');
c.redirect('#/domains/add');
}
params = { 'domain': c.params['ddomain'] + c.params['ddomain-ext'] }
} else {
params = { 'domaim': c.params['domain'] }
}
params['password'] = c.params['password']
store.set('url', 'http://'+ window.location.hostname +':6767');
store.set('user', 'admin');
store.set('password', btoa('yunohost'));
c.api('/postinstall', function(data) { // http://api.yunohost.org/#!/tools/tools_postinstall_post_0
c.redirect('#/');
}, 'POST', params);
} else {
c.flash('fail', "Passwords don't match");
}
});
/**
* Users
*

87
views/postinstall.ms Normal file
View file

@ -0,0 +1,87 @@
<form action="#/postinstall" method="POST" class="form-horizontal">
<div class="well">
<p>A last step is necessary to fulfill the installation: You have to link your YunoHost instance to a domain name, and set a new administrator password.</p>
</div>
<div class="br"></div>
<h2>Domain</h2>
<div class="br"></div>
<div class="panel-group" id="accordion">
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion" href="#collapseOne">
I already have a domain name...
</a>
</h4>
</div>
<div id="collapseOne" class="panel-collapse collapse">
<div class="panel-body">
<small>... and I have <a href="http://doc.yunohost.org">set my DNS correctly</a>.</small>
<hr>
<div class="form-group">
<label for="domain" class="col-sm-3 control-label">Domain name</label>
<div class="col-sm-9">
<input type="text" name="domain" class="form-control" placeholder="myserver.org">
</div>
</div>
</div>
</div>
</div>
<div class="panel panel-default">
<div class="panel-heading">
<h4 class="panel-title">
<a class="accordion-toggle" data-toggle="collapse" data-parent="#accordion" href="#collapseTwo">
I don't have a domain name...
</a>
</h4>
</div>
<div id="collapseTwo" class="panel-collapse collapse">
<div class="panel-body">
<small>... and I want a dynamic DNS service.</small>
<hr>
<div class="form-group">
<label for="ddomain" class="col-sm-3 control-label">Domain name</label>
<div class="clearfix visible-xs"></div>
<div class="col-sm-4 col-xs-6">
<input type="text" name="ddomain" class="form-control" placeholder="myserver">
</div>
<div class="col-sm-5 col-xs-6">
<select class="form-control" name="ddomain-ext">
{{#DDomains}}
<option>{{.}}</option>
{{/DDomains}}
</select>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="br"></div>
<h2>Password</h2>
<div class="br"></div>
<div class="form-group">
<label for="password" class="col-sm-3 control-label">New admin password</label>
<div class="col-sm-9">
<input type="password" name="password" class="form-control" placeholder="••••••">
</div>
</div>
<div class="form-group">
<label for="confirmation" class="col-sm-3 control-label">Confirmation</label>
<div class="col-sm-9">
<input type="password" name="confirmation" class="form-control" placeholder="••••••">
</div>
</div>
<div class="br"></div>
<div class="text-center">
<input type="submit" class="btn btn-success" value="Go !">
</div>
</form>