Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #64 from yurenju/issue63
Browse files Browse the repository at this point in the history
issue #63: added gaia_dir & gaia_distribution_dir support r=gasolin
  • Loading branch information
yurenju committed Jul 19, 2013
2 parents caddd07 + 044674c commit 58615cb
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 5 deletions.
7 changes: 4 additions & 3 deletions views/index.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@
<fieldset>
<legend>Default paths</legend>
<label for="gaia_dir">Gaia DIR</label>
<input type="file" name="gaia_dir">
<input type="text" id="gaia_dir" name="gaia_dir">
<span class="help-block">specify gaia repository to get build-in app list, used for homescreen customization.</span>
<label for="gaia_distribution_dir">Gaia Distribution DIR</label>
<input type="file" name="gaia_distribution_dir">
<input type="text" id="gaia_distribution_dir" name="gaia_distribution_dir">
<span class="help-block">specify distribution dir for export customization result. read dir files for further customization.</span>
<br />
<!--button type="submit" class="btn">Analysis</button-->
<button id="update-config" class="btn btn-large btn-primary" type="button">Update config</button>
</fieldset>
</form>

</div>
</div>
45 changes: 45 additions & 0 deletions views/js/minilla.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
var Minilla = {
config: null,

getConfig: function minilla_getConfig(url) {
var self = this;
var xhr = new XMLHttpRequest();
xhr.open('GET', url);
xhr.send();
xhr.onreadystatechange = function() {
if (this.readyState === 4) {
var config = JSON.parse(this.responseText);
document.getElementById('gaia_dir').value = config['gaia_dir'];
document.getElementById('gaia_distribution_dir').value = config['gaia_distribution_dir'];
}
};
},

setConfig: function minilla_setConfig(url, config) {
var form = new FormData();
form.append('gaia_dir', config['gaia_dir']);
form.append('gaia_distribution_dir', config['gaia_distribution_dir']);
var xhr = new XMLHttpRequest();
xhr.open('POST', url);
xhr.send(form);
xhr.onreadystatechange= function() {
if (this.readyState === 4) {
var btn = document.getElementById('update-config');
btn.classList.remove('btn-primary');
btn.classList.add('btn-success');
btn.textContent = 'Success!';
}
}
}
};

window.addEventListener('load', function() {
document.getElementById('update-config').addEventListener('click', function() {
var config = {};
config['gaia_dir'] = document.getElementById('gaia_dir').value;
config['gaia_distribution_dir'] = document.getElementById('gaia_distribution_dir').value;
Minilla.setConfig('/config', config);
});
Minilla.getConfig('/config');
});

2 changes: 1 addition & 1 deletion views/main.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="dns-prefetch" href="//ajax.googleapis.com">
<link rel="dns-prefetch" href="//netdna.bootstrapcdn.com">

<script type="text/javascript" src='/js/minilla.js'></script>
<script src='http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js'></script>
<link href='http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.no-icons.min.css' rel='stylesheet'>
<!--script src='http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js'></script-->
Expand Down
22 changes: 21 additions & 1 deletion wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# minilla is a monster named from Ultraman gaia http://en.wikipedia.org/wiki/Minilla
#

from bottle import route, run, template, request, view, app
from bottle import route, run, template, request, view, app, post, static_file, get
import preload
import os, glob, json

Expand Down Expand Up @@ -102,6 +102,26 @@ def apps_available():
# print available
return {'apps-available': available}

@route('/js/<filename>')
def server_static(filename):
return static_file(filename, root='views/js')

@post('/config')
def set_config():
f = open('config.json', 'w');
f.write(json.dumps({
'gaia_dir': request.forms.get('gaia_dir'),
'gaia_distribution_dir': request.forms.get('gaia_distribution_dir')
}))
f.close()

@get('/config')
def get_config():
f = open('config.json', 'r');
ret = f.read();
f.close();
return ret;

# generate package
@route('/utils/customize/', method='post')
def customize():
Expand Down

0 comments on commit 58615cb

Please sign in to comment.