Adds folderstatus extension for aai mode. Updates default options for upcoming release.

This commit is contained in:
Lars Jung 2012-10-14 18:32:25 +02:00
parent 57d6ef9520
commit 138fc4d43c
6 changed files with 84 additions and 59 deletions

View file

@ -82,13 +82,10 @@ modulejs.define('ext/crumb', ['_', '$', 'core/settings', 'core/resource', 'core/
_.each(crumb, function (e) { _.each(crumb, function (e) {
$ul.append(update(e)); $ul.append(update(e));
// needed by aai
// e.fetchStatus(function (e) { update(e); });
}); });
event.sub('entry.created', onContentChanged); // event.sub('entry.created', onContentChanged);
event.sub('entry.removed', onContentChanged); // event.sub('entry.removed', onContentChanged);
event.sub('entry.changed', onContentChanged); event.sub('entry.changed', onContentChanged);
}; };

View file

@ -0,0 +1,30 @@
modulejs.define('ext/folderstatus', ['_', '$', 'core/settings', 'core/event', 'core/entry'], function (_, $, allsettings, event, entry) {
var settings = _.extend({
enabled: false,
maxChecks: 16,
delay: 2000
}, allsettings.folderstatus),
init = function () {
if (!settings.enabled) {
return;
}
event.sub('ready', function () {
var count = 0;
_.each(entry.content, function (e) {
if (e.isFolder() && e.status === null && count <= settings.maxChecks) {
count += 1;
setTimeout(function () { e.fetchStatus(); }, settings.delay);
}
});
});
};
init();
});

View file

@ -110,6 +110,10 @@ modulejs.define('model/entry', ['$', '_', 'core/types', 'core/event', 'core/sett
var self = getEntry(absHref); var self = getEntry(absHref);
if (!_.isFunction(callback)) {
callback = function () {};
}
if (self.status !== null) { if (self.status !== null) {
callback(self); callback(self);
} else { } else {
@ -130,6 +134,10 @@ modulejs.define('model/entry', ['$', '_', 'core/types', 'core/event', 'core/sett
var self = getEntry(absHref); var self = getEntry(absHref);
if (!_.isFunction(callback)) {
callback = function () {};
}
if (self.isContentFetched) { if (self.isContentFetched) {
callback(self); callback(self);
} else { } else {

View file

@ -2,11 +2,8 @@
modulejs.define('view/extended', ['_', '$', 'core/settings', 'core/resource', 'core/format', 'core/event', 'core/entry'], function (_, $, allsettings, resource, format, event, entry) { modulejs.define('view/extended', ['_', '$', 'core/settings', 'core/resource', 'core/format', 'core/event', 'core/entry'], function (_, $, allsettings, resource, format, event, entry) {
var settings = _.extend({ var settings = _.extend({
modes: ['details', 'icons'],
setParentFolderLabels: false, setParentFolderLabels: false,
binaryPrefix: false, binaryPrefix: false
maxFolders: 16,
delay: 2000
}, allsettings.view), }, allsettings.view),
template = '<li class="entry">' + template = '<li class="entry">' +
@ -153,20 +150,6 @@ modulejs.define('view/extended', ['_', '$', 'core/settings', 'core/resource', 'c
}); });
} }
}); });
// needed by aai
if (_.size(entry.content) <= settings.maxFolders) {
_.each(entry.content, function (e) {
if (e.isFolder() && e.status === null) {
setTimeout(function () {
e.fetchStatus(function (e) { update(e); });
}, settings.delay);
}
});
}
}; };
init(entry); init(entry);

View file

@ -1,12 +1,11 @@
modulejs.define('view/viewmode', ['_', '$', 'core/settings', 'core/resource', 'core/store'], function (_, $, allsettings, resource, store) { modulejs.define('view/viewmode', ['_', '$', 'core/settings', 'core/resource', 'core/store'], function (_, $, allsettings, resource, store) {
var defaults = { var modes = ['details', 'list', 'grid', 'icons'],
modes: ['details', 'list', 'grid', 'icons'],
setParentFolderLabels: false
},
settings = _.extend({}, defaults, allsettings.view), settings = _.extend({}, {
modes: modes
}, allsettings.view),
storekey = 'h5ai.viewmode', storekey = 'h5ai.viewmode',
@ -24,7 +23,7 @@ modulejs.define('view/viewmode', ['_', '$', 'core/settings', 'core/resource', 'c
viewmode = _.indexOf(settings.modes, viewmode) >= 0 ? viewmode : settings.modes[0]; viewmode = _.indexOf(settings.modes, viewmode) >= 0 ? viewmode : settings.modes[0];
store.put(storekey, viewmode); store.put(storekey, viewmode);
_.each(defaults.modes, function (mode) { _.each(modes, function (mode) {
if (mode === viewmode) { if (mode === viewmode) {
$('#view-' + mode).addClass('current'); $('#view-' + mode).addClass('current');
$extended.addClass('view-' + mode).show(); $extended.addClass('view-' + mode).show();
@ -39,10 +38,10 @@ modulejs.define('view/viewmode', ['_', '$', 'core/settings', 'core/resource', 'c
var $navbar = $('#navbar'); var $navbar = $('#navbar');
settings.modes = _.intersection(settings.modes, defaults.modes); settings.modes = _.intersection(settings.modes, modes);
if (settings.modes.length > 1) { if (settings.modes.length > 1) {
_.each(defaults.modes.reverse(), function (mode) { _.each(modes.reverse(), function (mode) {
if (_.indexOf(settings.modes, mode) >= 0) { if (_.indexOf(settings.modes, mode) >= 0) {
$(template.replace(/\[MODE\]/g, mode)) $(template.replace(/\[MODE\]/g, mode))
.appendTo($navbar) .appendTo($navbar)

View file

@ -6,8 +6,9 @@ Options
*/ */
{ {
/* /* [all]
Spacing of the main content. Spacing of the main content.
Left and right will be added to a minimum of 30px. Top and bottom Left and right will be added to a minimum of 30px. Top and bottom
are calculated relative to the top and bottom bar heights. are calculated relative to the top and bottom bar heights.
*/ */
@ -19,28 +20,25 @@ Options
"left": "auto" "left": "auto"
}, },
/* /* [all]
An array of view modes the user may choose from. Currently there General view options.
are two possible values: "details", "icons", "grid", and "list".
The first value indicates the default view mode. If only one value
is given the view mode is fixed and the selector buttons are hidden.
The user selected view mode is also stored local in modern browsers
so that it will be persistent.
- setParentFolderLabels [all]: set parent folder labels to real folder names - modes: array of "details", "icons", "grid" and/or "list"
- binaryPrefix [all]: set to true uses 1024B=1KiB when formatting file sizes the first value indicates the default view mode. If only one value
(see http://en.wikipedia.org/wiki/Binary_prefix) is given the view mode is fixed and the selector buttons are hidden.
- indexFiles [php]: consider folder with those files as non {{pkg.name}} folders The user selected view mode is also stored local in modern browsers
- ignore [php]: don't list items matching these regular expressions so that it will be persistent.
- maxFolders [aai]: max folders to trigger folder status checks - setParentFolderLabels: set parent folder labels to real folder names
- binaryPrefix: set to true uses 1024B=1KiB when formatting file sizes (see http://en.wikipedia.org/wiki/Binary_prefix)
- indexFiles [php only]: consider folder with those files as non {{pkg.name}} folders
- ignore [php only]: don't list items matching these regular expressions
*/ */
"view": { "view": {
"modes": ["details", "list", "grid", "icons"], "modes": ["details", "icons"],
"setParentFolderLabels": true, "setParentFolderLabels": true,
"binaryPrefix": false, "binaryPrefix": false,
"indexFiles": ["index.html", "index.htm", "index.php"], "indexFiles": ["index.html", "index.htm", "index.php"],
"ignore": ["^\\.", "^_{{pkg.name}}"], "ignore": ["^\\.", "^_{{pkg.name}}"]
"maxFolders": 16
}, },
@ -48,14 +46,12 @@ Options
/*** Extensions (in alphabetical order) ***/ /*** Extensions (in alphabetical order) ***/
/* [php] /* [php]
Watch current folder content. Watch and update current folder content.
Folders possibly visible in the tree view that are not the
current folder might not be updated.
- interval: number, update interval in milliseconds, at least 1000 - interval: number, update interval in milliseconds, at least 1000
*/ */
"autorefresh": { "autorefresh": {
"enabled": true, "enabled": false,
"interval": 5000 "interval": 5000
}, },
@ -71,7 +67,7 @@ Options
in each folder. in each folder.
*/ */
"custom": { "custom": {
"enabled": true, "enabled": false,
"header": "_{{pkg.name}}.header.html", "header": "_{{pkg.name}}.header.html",
"footer": "_{{pkg.name}}.footer.html" "footer": "_{{pkg.name}}.footer.html"
}, },
@ -80,7 +76,7 @@ Options
Allow file deletion. Allow file deletion.
*/ */
"delete": { "delete": {
"enabled": true "enabled": false
}, },
/* [php, EXPERIMENTAL] /* [php, EXPERIMENTAL]
@ -91,7 +87,7 @@ Options
- maxfilesize: number, file size is in MB - maxfilesize: number, file size is in MB
*/ */
"dropbox": { "dropbox": {
"enabled": true, "enabled": false,
"maxfiles": 10, "maxfiles": 10,
"maxfilesize": 1000 "maxfilesize": 1000
}, },
@ -104,7 +100,7 @@ Options
- packageName: basename of the download package, null for current foldername - packageName: basename of the download package, null for current foldername
*/ */
"download": { "download": {
"enabled": true, "enabled": false,
"execution": "shell", "execution": "shell",
"format": "zip", "format": "zip",
"packageName": null "packageName": null
@ -130,6 +126,18 @@ Options
"enabled": true "enabled": true
}, },
/* [aai]
Fetch status for subfolders of the current folder.
- maxChecks: number, max number of status requests in the current folder
- delay: number, delay in milliseconds after "dom-ready" before starting the requests
*/
"folderstatus": {
"enabled": false,
"maxChecks": 16,
"delay": 2000
},
/* [all] /* [all]
Adds Google Analytics asynchronous tracking code. Adds Google Analytics asynchronous tracking code.
@ -144,7 +152,7 @@ Options
see: http://support.google.com/googleanalytics/bin/topic.py?hl=en&topic=27612 see: http://support.google.com/googleanalytics/bin/topic.py?hl=en&topic=27612
*/ */
"google-analytics": { "google-analytics": {
"enabled": true, "enabled": false,
"gaq": [] "gaq": []
}, },
@ -178,7 +186,7 @@ Options
2: mode, servername and -version 2: mode, servername and -version
*/ */
"mode": { "mode": {
"enabled": true, "enabled": false,
"display": 2 "display": 2
}, },
@ -248,7 +256,7 @@ Options
- size: width and height in pixel - size: width and height in pixel
*/ */
"qrcode": { "qrcode": {
"enabled": true, "enabled": false,
"size": 150 "size": 150
}, },