mirror of
https://dev.iopsys.eu/feed/iopsys.git
synced 2026-03-02 15:34:05 +01:00
Added draft for static compilation script
This commit is contained in:
parent
f12fbcbd4d
commit
af4743eb95
5 changed files with 79 additions and 13 deletions
23
luciexpress/compile.sh
Normal file
23
luciexpress/compile.sh
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
LIBFILES=(htdocs/lib/js/async.js htdocs/lib/js/js-schema.min.js htdocs/lib/js/require.js htdocs/lib/js/jquery.min.js htdocs/lib/js/angular.min.js htdocs/lib/js/angular-ui.min.js htdocs/lib/js/angular-ui-router.min.js htdocs/lib/js/angular-gettext.min.js htdocs/lib/js/bootstrap-select.min.js htdocs/lib/js/select.min.js htdocs/lib/js/angular-animate.min.js htdocs/lib/js/angular-ui-bootstrap-luci.min.js htdocs/lib/js/jquery-jsonrpc.js htdocs/lib/js/translations.js htdocs/lib/js/bootstrap.min.js htdocs/lib/js/angular-ui-switch.min.js htdocs/lib/js/angular-modal-service.min.js htdocs/lib/js/angular-checklist-model.js)
|
||||
PLUGINFILES=$(find htdocs/plugins -type f -name "*js" | grep -v "test-")
|
||||
THEMEFILES=$(find htdocs/themes -type f -name "*js" | grep -v "test-")
|
||||
COREFILES=(htdocs/js/rpc.js htdocs/js/uci.js htdocs/js/juci.js htdocs/js/app.js htdocs/js/localStorage.js htdocs/js/config.js htdocs/js/navigation.js htdocs/js/status.js htdocs/js/session.js htdocs/js/tr.js htdocs/js/theme.js htdocs/js/timeout.js)
|
||||
FILES=("${LIBFILES[@]}" "${COREFILES[@]}" "${PLUGINFILES[@]}" "${THEMEFILES[@]}");
|
||||
|
||||
echo "var JUCI_COMPILED = 1;" > htdocs/__all.js
|
||||
for file in ${FILES[@]}; do
|
||||
echo "FILE: $file";
|
||||
echo ";" >> htdocs/__all.js;
|
||||
cat $file >> htdocs/__all.js;
|
||||
done;
|
||||
|
||||
HTMLFILES=$(find htdocs -type f -name "*html"|grep -v "index.html" | grep -v "__all.html")
|
||||
|
||||
echo "" > htdocs/__all.html
|
||||
for file in ${HTMLFILES[@]}; do
|
||||
file=$(echo $file | sed 's/htdocs\///gi')
|
||||
echo "HTML: $file";
|
||||
echo "<script type='text/ng-template' id='/$file'>" >> htdocs/__all.html;
|
||||
cat htdocs/$file >> htdocs/__all.html;
|
||||
echo '</script>' >> htdocs/__all.html;
|
||||
done;
|
||||
|
|
@ -21,8 +21,9 @@
|
|||
<div ui-view="content" style="min-height: 1000px;"></div>
|
||||
|
||||
<div style="margin-bottom: 40px"></div>
|
||||
|
||||
<!--<script src="__all.js"></script>-->
|
||||
<script src="lib/js/async.js"></script>
|
||||
<!--<script src="lib/js/js-schema.min.js"></script>-->
|
||||
<script src="lib/js/require.js"></script>
|
||||
<script src="lib/js/jquery.min.js"></script>
|
||||
<script src="lib/js/angular.min.js"></script>
|
||||
|
|
@ -40,11 +41,6 @@
|
|||
<script src="lib/js/angular-modal-service.min.js"></script>
|
||||
<script src="lib/js/angular-checklist-model.js"></script>
|
||||
|
||||
<!--<script src="lib/js/jasmine-core/jasmine.js"></script>
|
||||
<script src="lib/js/jasmine-core/jasmine-html.js"></script>
|
||||
<script src="lib/js/jasmine-core/boot.js"></script>-->
|
||||
|
||||
<!-- ###---### -->
|
||||
<script src="js/rpc.js"></script>
|
||||
<script src="js/uci.js"></script>
|
||||
<script src="js/juci.js"></script>
|
||||
|
|
@ -57,6 +53,5 @@
|
|||
<script src="js/tr.js"></script>
|
||||
<script src="js/theme.js"></script>
|
||||
<script src="js/timeout.js"></script>
|
||||
<!-- ###---### -->
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,8 @@
|
|||
//! Author: Martin K. Schröder <mkschreder.uk@gmail.com>
|
||||
|
||||
// TODO: make this automatic
|
||||
var JUCI_COMPILED = 0;
|
||||
|
||||
$.jsonRPC.setup({
|
||||
endPoint: '/ubus',
|
||||
namespace: 'luci'
|
||||
|
|
@ -177,6 +180,43 @@ JUCI.app.config(function ($stateProvider, $locationProvider, $compileProvider, $
|
|||
}
|
||||
}}]);
|
||||
|
||||
/*
|
||||
JUCI.app.factory('$templateCache', function($cacheFactory, $http, $injector) {
|
||||
var cache = $cacheFactory('templates');
|
||||
var allTplPromise;
|
||||
|
||||
return {
|
||||
get: function(url) {
|
||||
var fromCache = cache.get(url);
|
||||
|
||||
// already have required template in the cache
|
||||
if (fromCache) {
|
||||
return fromCache;
|
||||
}
|
||||
|
||||
// first template request ever - get the all tpl file
|
||||
if (!allTplPromise) {
|
||||
allTplPromise = $http.get('__all.html').then(function(response) {
|
||||
// compile the response, which will put stuff into the cache
|
||||
$injector.get('$compile')(response.data);
|
||||
return response;
|
||||
});
|
||||
}
|
||||
|
||||
// return the all-tpl promise to all template requests
|
||||
return allTplPromise.then(function(response) {
|
||||
return {
|
||||
status: response.status,
|
||||
data: cache.get(url)
|
||||
};
|
||||
});
|
||||
},
|
||||
|
||||
put: function(key, value) {
|
||||
cache.put(key, value);
|
||||
}
|
||||
};
|
||||
});*/
|
||||
// make autofocus directive work as expected
|
||||
JUCI.app.directive('autofocus', ['$timeout', function($timeout) {
|
||||
return {
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
var plugin = self.plugins[name];
|
||||
var juci = self;
|
||||
return {
|
||||
plugin_root: plugin.plugin_root,
|
||||
plugin_root: ((plugin||{}).plugin_root||"plugins/"+name+"/"),
|
||||
directive: function(name, fn){
|
||||
return angular.module("luci").directive(name, fn);
|
||||
},
|
||||
|
|
@ -64,7 +64,7 @@
|
|||
$.getJSON(plugin_root + "/plugin.json")
|
||||
.done(function(data){
|
||||
console.log("found plugin "+id);
|
||||
$juci.module(id, plugin_root, data);
|
||||
$juci.module(id, plugin_root, {});
|
||||
$juci.plugins[id] = data;
|
||||
if(data && data.scripts){
|
||||
data.scripts.map(function(x){scripts.push(plugin_root + "/" + x); });
|
||||
|
|
@ -166,9 +166,13 @@
|
|||
});
|
||||
},
|
||||
function(next){
|
||||
require(scripts, function(module){
|
||||
if(!JUCI_COMPILED){
|
||||
require(scripts, function(module){
|
||||
next();
|
||||
});
|
||||
} else {
|
||||
next();
|
||||
});
|
||||
}
|
||||
},
|
||||
function(next){
|
||||
// get the menu navigation
|
||||
|
|
|
|||
|
|
@ -21,9 +21,13 @@
|
|||
if(data.scripts){
|
||||
async.eachSeries(data.scripts, function(script, next){
|
||||
console.log("Loading "+theme_root + "/"+script);
|
||||
require([theme_root + "/"+script], function(module){
|
||||
if(!JUCI_COMPILED){
|
||||
require([theme_root + "/"+script], function(module){
|
||||
next();
|
||||
});
|
||||
} else {
|
||||
next();
|
||||
});
|
||||
}
|
||||
}, function(){
|
||||
deferred.resolve(data);
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue