This commit is contained in:
j 2014-05-17 16:42:46 +02:00
parent 660512e38f
commit 42c3f38f35
12 changed files with 180 additions and 152 deletions

41
README
View File

@ -1,41 +0,0 @@
Open Media Library
== Install ==
soon
== Networking ==
At this time you need a working IPv6 connection to use Open Media Libary.
If you dont have native IPv6 you can use Teredo/Miredo (apt-get install miredo)
or get a tunnel Hurricane Electric (https://tunnelbroker.net/)
or SixSS (https://sixxs.net).
== Platform ==
If you install Open Media Library on a architecture thats not directly supported,
you need a working python 2.7.x installation and the following packages:
apt-get install \
python-pypdf python-stdnum python-html5lib python-chardet python-openssl \
python-simplejson python-lxml
pip install -r requirements.txt
On Linux you need to always install:
apt-get install \
python-imaging python-lxml ghostscript
== Development ==
mkdir client
cd client
git clone https://git.0x2620.org/openmedialibrary.git
git clone https://git.0x2620.org/openmedialibrary_platform.git platform
ln -s openmedialibrary/ctl ctl
./ctl update_static
./ctl db upgrade
./ctl setup
# and start it
./ctl debug

View File

@ -39,7 +39,6 @@ Development
git clone https://git.0x2620.org/openmedialibrary_platform.git platform git clone https://git.0x2620.org/openmedialibrary_platform.git platform
ln -s openmedialibrary/ctl ctl ln -s openmedialibrary/ctl ctl
./ctl update_static ./ctl update_static
./ctl db upgrade
./ctl setup ./ctl setup
# and start it # and start it

View File

@ -19,7 +19,7 @@ oml.ui.deleteListDialog = function() {
oml.api.removeList({ oml.api.removeList({
id: ui._list id: ui._list
}, function() { }, function() {
oml.updateLists(function() { oml.$ui.folders.updateOwnLists(function() {
oml.UI.set({ oml.UI.set({
find: { find: {
conditions: [{ conditions: [{

View File

@ -3,19 +3,19 @@
oml.ui.findElement = function() { oml.ui.findElement = function() {
var ui = oml.user.ui, var ui = oml.user.ui,
findIndex = ui._findState.index, findIndex = ui._findState.index,
findKey = ui._findState.key, findKey = ui._findState.key,
findValue = ui._findState.value, findValue = ui._findState.value,
hasPressedClear = false, hasPressedClear = false,
previousFindKey = findKey, previousFindKey = findKey,
that = Ox.FormElementGroup({ that = Ox.FormElementGroup({
elements: [ elements: [
oml.$ui.findScopeSelect = renderFindScopeSelect(), oml.$ui.findInSelect = renderFindInSelect(),
oml.$ui.findSelect = Ox.Select({ oml.$ui.findSelect = Ox.Select({
id: 'select', id: 'select',
items: [].concat( items: [].concat(
oml.config.findKeys.map(function(key) { oml.config.findKeys.map(function(key) {
@ -86,7 +86,7 @@ oml.ui.findElement = function() {
} }
}, },
submit: function(data) { submit: function(data) {
var scope = oml.$ui.findScopeSelect.value(), var scope = oml.$ui.findInSelect.value(),
key = oml.$ui.findSelect.value(), key = oml.$ui.findSelect.value(),
conditions = [].concat( conditions = [].concat(
scope == 'list' ? [{ scope == 'list' ? [{
@ -106,24 +106,23 @@ oml.ui.findElement = function() {
}] : [] }] : []
); );
oml.UI.set({ oml.UI.set({
find: { find: {
conditions: conditions, conditions: conditions,
operator: '&' operator: '&'
} }
}); });
} }
}) })
]
] })
}) .css({
.css({ float: 'right',
float: 'right', margin: '4px 4px 4px 2px'
margin: '4px 4px 4px 2px' })
})
.bindEvent({ .bindEvent({
oml_find: function() { oml_find: function() {
that.replaceElement( that.replaceElement(
0, oml.$ui.findScopeSelect = renderFindScopeSelect() 0, oml.$ui.findInSelect = renderFindInSelect()
); );
} }
}); });
@ -138,11 +137,11 @@ oml.ui.findElement = function() {
key: key, key: key,
query: { query: {
conditions: ui._list conditions: ui._list
&& oml.$ui.findScopeSelect.value() == 'list' && oml.$ui.findInSelect.value() == 'list'
? [{ ? [{
key: 'list', key: 'list',
operator: '==', operator: '==',
value: ui._list value: ui._list
}] }]
: [], : [],
operator: '&' operator: '&'
@ -158,17 +157,17 @@ oml.ui.findElement = function() {
} : null; } : null;
} }
function renderFindScopeSelect() { function renderFindInSelect() {
var scope = !ui._list ? 'all' var scope = !ui._list ? 'all'
: Ox.endsWith(ui._list, ':') ? 'user' : Ox.endsWith(ui._list, ':') ? 'user'
: 'list'; : 'list';
return Ox.Select({ var $select = Ox.Select({
items: [ items: [
{id: 'all', title: Ox._('Find: All Libraries')}, {id: 'all', title: Ox._('Find In: All Libraries')},
].concat(scope != 'all' ? [ ].concat(scope != 'all' ? [
{id: 'user', title: Ox._('Find: This Library')}, {id: 'user', title: Ox._('Find In: This Library')},
] : []).concat(scope == 'list' ? [ ] : []).concat(scope == 'list' ? [
{id: 'list', title: Ox._('Find: This List')} {id: 'list', title: Ox._('Find In: This List')}
] : []), ] : []),
overlap: 'right', overlap: 'right',
style: 'squared', style: 'squared',
@ -179,13 +178,22 @@ oml.ui.findElement = function() {
}) })
.bindEvent({ .bindEvent({
change: function(data) { change: function(data) {
oml.$ui.findScopeSelect.options({ oml.$ui.findInSelect.options({
title: data.value == 'all' ? 'data' : data.value, title: data.value == 'all' ? 'data' : data.value,
tooltip: data.title tooltip: data.title
}); });
oml.$ui.findInput.focusInput(true); oml.$ui.findInput.focusInput(true);
} }
}); });
$select.superValue = $select.value;
$select.value = function(value) {
if (arguments.length == 1) {
Ox.print('I AM HERE')
$select.options({title: value == 'all' ? 'data' : value});
}
$select.superValue.apply($select, arguments);
}
return $select;
} }
that.updateElement = function() { that.updateElement = function() {

View File

@ -63,7 +63,7 @@ oml.ui.folders = function() {
}) })
.bindEvent({ .bindEvent({
load: function() { load: function() {
oml.api.find({query: getFind()}, function(result) { oml.api.find({query: getFind('')}, function(result) {
oml.$ui.librariesList.value('', 'items', result.data.items); oml.$ui.librariesList.value('', 'items', result.data.items);
}); });
}, },
@ -220,7 +220,12 @@ oml.ui.folders = function() {
oml.addList(ui._list); oml.addList(ui._list);
}, },
load: function() { load: function() {
// ... // FIXME: too much
items.forEach(function(item) {
oml.api.find({query: getFind(item.id)}, function(result) {
oml.$ui.folderList[index].value(item.id, 'items', result.data.items);
});
});
}, },
move: function(data) { move: function(data) {
lists[user.id] = data.ids.map(function(listId) { lists[user.id] = data.ids.map(function(listId) {
@ -268,6 +273,32 @@ oml.ui.folders = function() {
}; };
that.updateItems = function() {
oml.getUsersAndLists(function(users, lists) {
Ox.Request.clearCache('find');
$lists.forEach(function($list) {
$list.reloadList();
});
});
};
that.updateOwnLists = function(callback) {
oml.getUsersAndLists(function(users, lists) {
var items = lists.filter(function(list) {
return list.user == oml.user.preferences.username
&& list.type != 'library';
});
oml.$ui.folderList[0].options({
items: items
})
.css({height: items.length * 16 + 'px'})
.size();
oml.$ui.folder[0].$content
.css({height: 16 + items.length * 16 + 'px'});
callback && callback();
});
};
return that.updateElement(); return that.updateElement();
}; };

View File

@ -131,6 +131,7 @@ oml.ui.identifyDialog = function(data) {
that.options({content: Ox.LoadingScreen().start()}); that.options({content: Ox.LoadingScreen().start()});
that.disableButtons(); that.disableButtons();
oml.api.edit(edit, function(result) { oml.api.edit(edit, function(result) {
Ox.print('EDITED', result.data);
that.close(); that.close();
Ox.Request.clearCache('find'); Ox.Request.clearCache('find');
oml.$ui.browser.reloadList(true); oml.$ui.browser.reloadList(true);

View File

@ -119,16 +119,16 @@ oml.ui.importExportDialog = function(selected) {
); );
}); });
return [ return [
{id: ':', title: Ox._('Library')} {id: '', title: Ox._('Library')}
].concat( ].concat(
lists.length ? [{}] : [] lists.length ? [{}] : []
).concat( ).concat(
lists.map(function(list) { lists.map(function(list) {
return {id: list.id, title: list.name}; return {id: list.name, title: list.name};
}) })
).concat(selected == 'import' ? [ ).concat(selected == 'import' ? [
{}, {},
{id: '', title: Ox._('New List...')} {id: 'FIXME', title: Ox._('New List...')}
] : []); ] : []);
} }
@ -223,7 +223,7 @@ oml.ui.importExportDialog = function(selected) {
labelWidth: 128, labelWidth: 128,
max: 1, max: 1,
min: 1, min: 1,
value: ':', value: '',
width: 480 width: 480
}), }),
Ox.Select({ Ox.Select({
@ -271,7 +271,7 @@ oml.ui.importExportDialog = function(selected) {
Ox.print('FORM CHANGE', data); Ox.print('FORM CHANGE', data);
if (data.id == 'list') { if (data.id == 'list') {
// FIXME: WRONG // FIXME: WRONG
if (data.data.value[0] != ':') { if (data.data.value[0] != '') {
$form.values('list', oml.validateName(data.data.value, getListNames())) $form.values('list', oml.validateName(data.data.value, getListNames()))
} }
} }

View File

@ -240,26 +240,24 @@ oml.ui.infoView = function(identifyData) {
$elements = $elements $elements = $elements
? Ox.makeArray($elements) ? Ox.makeArray($elements)
: [$cover, $info, $data]; : [$cover, $info, $data];
Ox.print('DEBUG, $ELEMENTS', $elements);
(data ? Ox.noop : oml.api.get)({ (data ? Ox.noop : oml.api.get)({
id: id, id: id,
keys: [] keys: []
}, function(result) { }, function(result) {
if (!identifyData && ui.item != id) { if (!identifyData && id && id != ui.item) {
return; return;
} }
if (result) { if (result) {
data = result.data; data = result.data;
} }
Ox.print('BOOK DATA', data)
var $mediaButton, var $mediaButton,
isEditable = !data.mainid && data.mediastate == 'available', isEditable = !data.mainid && data.mediastate == 'available',
src = !identifyData src = !identifyData
? '/' + data.id + '/cover256.jpg' ? '/' + data.id + '/cover256.jpg?' + data.modified
: data.cover, : data.cover,
ratio = data.coverRatio || oml.config.coverRatio, ratio = data.coverRatio || oml.config.coverRatio,
size = 256, size = 256,

View File

@ -23,7 +23,8 @@ oml.ui.list = function() {
oml.clipboard.copy(data.ids, 'item'); oml.clipboard.copy(data.ids, 'item');
oml.doHistory('cut', data.ids, ui._list, function() { oml.doHistory('cut', data.ids, ui._list, function() {
oml.UI.set({listSelection: []}); oml.UI.set({listSelection: []});
oml.reloadList(); oml.$ui.folders.updateElement();
oml.$ui.list.updateElement();
}); });
} }
}, },
@ -33,16 +34,18 @@ oml.ui.list = function() {
oml.clipboard.add(data.ids, 'item'); oml.clipboard.add(data.ids, 'item');
oml.doHistory('cut', data.ids, ui._list, function() { oml.doHistory('cut', data.ids, ui._list, function() {
oml.UI.set({listSelection: []}); oml.UI.set({listSelection: []});
oml.reloadList(); oml.$ui.folders.updateElement();
oml.$ui.list.updateElement();
}); });
} }
}, },
'delete': function() { 'delete': function(data) {
var listData = oml.getListData(); var listData = oml.getListData();
if (listData.editable && listData.type == 'static') { if (listData.editable && listData.type == 'static') {
oml.doHistory('delete', data.ids, ui._list, function() { oml.doHistory('delete', data.ids, ui._list, function() {
oml.UI.set({listSelection: []}); oml.UI.set({listSelection: []});
oml.reloadList(); oml.$ui.folders.updateItems();
oml.$ui.list.updateElement();
}); });
} }
}, },
@ -107,6 +110,7 @@ oml.ui.list = function() {
oml.enableDragAndDrop(that); oml.enableDragAndDrop(that);
that.updateElement = function() { that.updateElement = function() {
Ox.Request.clearCache('find');
that.reloadList(true); that.reloadList(true);
}; };

View File

@ -43,12 +43,7 @@ oml.ui.listDialog = function() {
closeButton: true, closeButton: true,
content: Ox.LoadingScreen().start(), content: Ox.LoadingScreen().start(),
height: 264, height: 264,
title: Ox._('List {0}', [ title: getTitle(list),
ui._list == '' ? Ox._('All Libraries')
: ui._list
.replace(/^:/, oml.user.preferences.username + ':')
.replace(/:$/, Ox._(':Library'))
]),
width: 648 + Ox.UI.SCROLLBAR_SIZE width: 648 + Ox.UI.SCROLLBAR_SIZE
}); });
@ -71,12 +66,18 @@ oml.ui.listDialog = function() {
.bindEvent({ .bindEvent({
change: function(data) { change: function(data) {
var value = oml.validateName(data.value, listNames); var value = oml.validateName(data.value, listNames);
that.options({title: getTitle(':' + value)})
$nameInput.value(value); $nameInput.value(value);
// FIXME: UGLY
listNames[listNames.indexOf(listData.name)] = value;
listData.name = value;
//
Ox.print(listData.name, 'LIST NAMES ???', listNames)
oml.api.editList({ oml.api.editList({
id: list, id: ui._list,
name: value name: value
}, function(result) { }, function(result) {
oml.updateLists(function() { oml.$ui.folders.updateOwnLists(function() {
oml.UI.set({ oml.UI.set({
find: { find: {
conditions: [{ conditions: [{
@ -102,6 +103,15 @@ oml.ui.listDialog = function() {
that.options({content: $content}); that.options({content: $content});
}); });
function getTitle(list) {
return Ox._('List {0}', [
list == '' ? Ox._('All Libraries')
: list
.replace(/^:/, oml.user.preferences.username + ':')
.replace(/:$/, Ox._(':Library'))
]);
}
return that; return that;
}; };

View File

@ -223,39 +223,7 @@ oml.ui.mainMenu = function() {
} }
] ]
}, },
{ getFindMenu(),
id: 'findMenu',
title: Ox._('Find'),
items: [
{
id: 'finditems',
title: Ox._('Find'),
items: [
{
group: 'find',
title: Ox._('Find'),
min: 1,
max: 1,
items: oml.config.findKeys.map(function(key) {
var checked = key.id == findState.key;
return {
id: key.id,
title: Ox._(key.title),
checked: checked,
keyboard: checked ? 'control f' : ''
};
})
},
]
},
{
id: 'advancedfind',
title: Ox._('Advanced Find'),
keyboard: 'shift control f'
}
]
},
{ {
id: 'helpMenu', id: 'helpMenu',
title: Ox._('Help'), title: Ox._('Help'),
@ -333,12 +301,21 @@ oml.ui.mainMenu = function() {
operator: value == 'ascending' ? '+' : '-' operator: value == 'ascending' ? '+' : '-'
}] }]
}); });
} else if (id == 'findin') {
oml.$ui.findInSelect.value(value);
if (ui._findState.key == 'advanced') {
// ...
} else {
oml.$ui.findInput.focusInput(true);
}
} else if (id == 'find') { } else if (id == 'find') {
if (value) { if (value) {
oml.$ui.findSelect.value(value); oml.$ui.findSelect.value(value);
if (ui._findState.key == 'advanced') { if (ui._findState.key == 'advanced') {
// fixme: autocomplete function doesn't get updated // fixme: autocomplete function doesn't get updated
pandora.$ui.findInput.options({placeholder: ''}); oml.$ui.findInput.options({placeholder: ''});
} else {
oml.$ui.findInput.focusInput(true);
} }
} }
} else { } else {
@ -505,6 +482,7 @@ oml.ui.mainMenu = function() {
oml_find: function() { oml_find: function() {
that.replaceMenu('listMenu', getListMenu()); that.replaceMenu('listMenu', getListMenu());
that.replaceMenu('editMenu', getEditMenu()); that.replaceMenu('editMenu', getEditMenu());
that.replaceMenu('findMenu', getFindMenu());
/* /*
var action = Ox.startsWith(ui._list, ':') && ui._list != ':' var action = Ox.startsWith(ui._list, ':') && ui._list != ':'
? 'enableItem' : 'disableItem'; ? 'enableItem' : 'disableItem';
@ -678,7 +656,59 @@ oml.ui.mainMenu = function() {
} }
function getFindMenu() { function getFindMenu() {
return ; var isLibraries = !ui._list,
isLibrary = Ox.endsWith(ui._list, ':'),
isList = !isLibraries && !isLibrary;
return {
id: 'findMenu',
title: Ox._('Find'),
items: [
{
id: 'findlists',
title: Ox._('Find In'),
items: [
{
group: 'findin',
min: 1,
max: 1,
items: [
{id: 'all', title: Ox._('All Libraries'), checked: isLibraries}
].concat(!isLibraries ? [
{id: 'user', title: Ox._('This Library'), checked: isLibrary}
] : []).concat(isList ? [
{id: 'list', title: Ox._('This List'), checked: isList}
] : [])
}
]
},
{
id: 'finditems',
title: Ox._('Find'),
items: [
{
group: 'find',
min: 1,
max: 1,
items: oml.config.findKeys.map(function(key) {
var checked = key.id == findState.key;
return {
id: key.id,
title: Ox._(key.title),
checked: checked,
keyboard: checked ? 'control f' : ''
};
})
},
]
},
{
id: 'advancedfind',
title: Ox._('Advanced Find'),
keyboard: 'shift control f'
}
]
};
} }
function getListMenu() { function getListMenu() {
@ -755,11 +785,13 @@ oml.ui.mainMenu = function() {
that.updateElement = function(menu) { that.updateElement = function(menu) {
( (
menu ? Ox.makeArray(menu) : ['listMenu', 'editMenu'] menu ? Ox.makeArray(menu) : ['listMenu', 'editMenu', 'findMenu']
).forEach(function(menu) { ).forEach(function(menu) {
that.updateMenu( that.updateMenu(
menu, menu,
menu == 'listMenu' ? getListMenu() : getEditMenu() menu == 'listMenu' ? getListMenu()
: menu == 'editMenu' ? getEditMenu()
: getFindMenu()
); );
}); });
return that; return that;

View File

@ -4,6 +4,7 @@ oml.addList = function() {
isDuplicate = args.length == 1, isDuplicate = args.length == 1,
isSmart, isFrom, list, listData, data, isSmart, isFrom, list, listData, data,
username = oml.user.preferences.username; username = oml.user.preferences.username;
Ox.Request.clearCache('getLists');
oml.api.getLists(function(result) { oml.api.getLists(function(result) {
var lists = result.data.lists, var lists = result.data.lists,
listNames = lists.filter(function(list) { listNames = lists.filter(function(list) {
@ -92,7 +93,7 @@ oml.addList = function() {
oml.$ui.listDialog = oml.ui.listDialog().open(); oml.$ui.listDialog = oml.ui.listDialog().open();
} }
}); });
oml.updateLists(); oml.$ui.folders.updateOwnLists();
}); });
} }
}; };
@ -397,7 +398,10 @@ oml.enableDragAndDrop = function($list, canMove) {
*/ */
cleanup(250); cleanup(250);
}); });
drag.action == 'move' && oml.reloadList(); oml.$ui.folders.updateItems();
if (drag.action == 'move') {
oml.$ui.list.updateElement();
}
}); });
} else { } else {
cleanup() cleanup()
@ -876,24 +880,6 @@ oml.updateFilterMenus = function() {
}); });
}; };
oml.updateLists = function(callback) {
// FIXME: can this go somewhere else?
Ox.Request.clearCache('getLists');
oml.getUsersAndLists(function(users, lists) {
var items = lists.filter(function(list) {
return list.user == oml.user.preferences.username;
});
oml.$ui.folderList[0].options({
items: items
})
.css({height: items.length * 16 + 'px'})
.size();
oml.$ui.folder[0].$content
.css({height: 16 + items.length * 16 + 'px'});
callback && callback();
});
};
oml.validateName = function(value, names) { oml.validateName = function(value, names) {
var index = 1, length = 256, suffix; var index = 1, length = 256, suffix;
value = Ox.clean(Ox.clean(value).slice(0, length)); value = Ox.clean(Ox.clean(value).slice(0, length));