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
ln -s openmedialibrary/ctl ctl
./ctl update_static
./ctl db upgrade
./ctl setup
# and start it

View file

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

View file

@ -13,7 +13,7 @@ oml.ui.findElement = function() {
elements: [
oml.$ui.findScopeSelect = renderFindScopeSelect(),
oml.$ui.findInSelect = renderFindInSelect(),
oml.$ui.findSelect = Ox.Select({
id: 'select',
@ -86,7 +86,7 @@ oml.ui.findElement = function() {
}
},
submit: function(data) {
var scope = oml.$ui.findScopeSelect.value(),
var scope = oml.$ui.findInSelect.value(),
key = oml.$ui.findSelect.value(),
conditions = [].concat(
scope == 'list' ? [{
@ -113,7 +113,6 @@ oml.ui.findElement = function() {
});
}
})
]
})
.css({
@ -123,7 +122,7 @@ oml.ui.findElement = function() {
.bindEvent({
oml_find: function() {
that.replaceElement(
0, oml.$ui.findScopeSelect = renderFindScopeSelect()
0, oml.$ui.findInSelect = renderFindInSelect()
);
}
});
@ -138,7 +137,7 @@ oml.ui.findElement = function() {
key: key,
query: {
conditions: ui._list
&& oml.$ui.findScopeSelect.value() == 'list'
&& oml.$ui.findInSelect.value() == 'list'
? [{
key: 'list',
operator: '==',
@ -158,17 +157,17 @@ oml.ui.findElement = function() {
} : null;
}
function renderFindScopeSelect() {
function renderFindInSelect() {
var scope = !ui._list ? 'all'
: Ox.endsWith(ui._list, ':') ? 'user'
: 'list';
return Ox.Select({
var $select = Ox.Select({
items: [
{id: 'all', title: Ox._('Find: All Libraries')},
{id: 'all', title: Ox._('Find In: All Libraries')},
].concat(scope != 'all' ? [
{id: 'user', title: Ox._('Find: This Library')},
{id: 'user', title: Ox._('Find In: This Library')},
] : []).concat(scope == 'list' ? [
{id: 'list', title: Ox._('Find: This List')}
{id: 'list', title: Ox._('Find In: This List')}
] : []),
overlap: 'right',
style: 'squared',
@ -179,13 +178,22 @@ oml.ui.findElement = function() {
})
.bindEvent({
change: function(data) {
oml.$ui.findScopeSelect.options({
oml.$ui.findInSelect.options({
title: data.value == 'all' ? 'data' : data.value,
tooltip: data.title
});
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() {

View file

@ -63,7 +63,7 @@ oml.ui.folders = function() {
})
.bindEvent({
load: function() {
oml.api.find({query: getFind()}, function(result) {
oml.api.find({query: getFind('')}, function(result) {
oml.$ui.librariesList.value('', 'items', result.data.items);
});
},
@ -220,7 +220,12 @@ oml.ui.folders = function() {
oml.addList(ui._list);
},
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) {
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();
};

View file

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

View file

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

View file

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

View file

@ -23,7 +23,8 @@ oml.ui.list = function() {
oml.clipboard.copy(data.ids, 'item');
oml.doHistory('cut', data.ids, ui._list, function() {
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.doHistory('cut', data.ids, ui._list, function() {
oml.UI.set({listSelection: []});
oml.reloadList();
oml.$ui.folders.updateElement();
oml.$ui.list.updateElement();
});
}
},
'delete': function() {
'delete': function(data) {
var listData = oml.getListData();
if (listData.editable && listData.type == 'static') {
oml.doHistory('delete', data.ids, ui._list, function() {
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);
that.updateElement = function() {
Ox.Request.clearCache('find');
that.reloadList(true);
};

View file

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

View file

@ -223,39 +223,7 @@ oml.ui.mainMenu = function() {
}
]
},
{
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'
}
]
},
getFindMenu(),
{
id: 'helpMenu',
title: Ox._('Help'),
@ -333,12 +301,21 @@ oml.ui.mainMenu = function() {
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') {
if (value) {
oml.$ui.findSelect.value(value);
if (ui._findState.key == 'advanced') {
// fixme: autocomplete function doesn't get updated
pandora.$ui.findInput.options({placeholder: ''});
oml.$ui.findInput.options({placeholder: ''});
} else {
oml.$ui.findInput.focusInput(true);
}
}
} else {
@ -505,6 +482,7 @@ oml.ui.mainMenu = function() {
oml_find: function() {
that.replaceMenu('listMenu', getListMenu());
that.replaceMenu('editMenu', getEditMenu());
that.replaceMenu('findMenu', getFindMenu());
/*
var action = Ox.startsWith(ui._list, ':') && ui._list != ':'
? 'enableItem' : 'disableItem';
@ -678,7 +656,59 @@ oml.ui.mainMenu = function() {
}
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() {
@ -755,11 +785,13 @@ oml.ui.mainMenu = function() {
that.updateElement = function(menu) {
(
menu ? Ox.makeArray(menu) : ['listMenu', 'editMenu']
menu ? Ox.makeArray(menu) : ['listMenu', 'editMenu', 'findMenu']
).forEach(function(menu) {
that.updateMenu(
menu,
menu == 'listMenu' ? getListMenu() : getEditMenu()
menu == 'listMenu' ? getListMenu()
: menu == 'editMenu' ? getEditMenu()
: getFindMenu()
);
});
return that;

View file

@ -4,6 +4,7 @@ oml.addList = function() {
isDuplicate = args.length == 1,
isSmart, isFrom, list, listData, data,
username = oml.user.preferences.username;
Ox.Request.clearCache('getLists');
oml.api.getLists(function(result) {
var lists = result.data.lists,
listNames = lists.filter(function(list) {
@ -92,7 +93,7 @@ oml.addList = function() {
oml.$ui.listDialog = oml.ui.listDialog().open();
}
});
oml.updateLists();
oml.$ui.folders.updateOwnLists();
});
}
};
@ -397,7 +398,10 @@ oml.enableDragAndDrop = function($list, canMove) {
*/
cleanup(250);
});
drag.action == 'move' && oml.reloadList();
oml.$ui.folders.updateItems();
if (drag.action == 'move') {
oml.$ui.list.updateElement();
}
});
} else {
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) {
var index = 1, length = 256, suffix;
value = Ox.clean(Ox.clean(value).slice(0, length));