prepare public api
This commit is contained in:
parent
507b6fed3e
commit
dd0e22a979
18 changed files with 237 additions and 94 deletions
|
|
@ -15,7 +15,7 @@
|
|||
</div>
|
||||
<div id="development">
|
||||
<p>
|
||||
The latest code is in our <a href="https://git.0x2620.org/openmedialibrary.git">git repository</a>.
|
||||
The latest code is in our <a href="https://code.0x2620.org/0x2620/openmedialibrary">git repository</a>.
|
||||
</p>
|
||||
<p>
|
||||
For everything else, there's IRC, and our development mailing list. Your feedback is welcome.
|
||||
|
|
|
|||
|
|
@ -15,14 +15,21 @@ oml.UI = (function() {
|
|||
|
||||
that.reset = function() {
|
||||
var ui = oml.user.ui;
|
||||
oml.api.resetUI({}, function() {
|
||||
|
||||
function reload() {
|
||||
ui = oml.config.user.ui;
|
||||
ui._list = oml.getListState(ui.find);
|
||||
ui._filterState = oml.getFilterState(ui.find);
|
||||
ui._findState = oml.getFindState(ui.find);
|
||||
Ox.Theme(ui.theme);
|
||||
oml.$ui.appPanel.reload();
|
||||
});
|
||||
}
|
||||
if (oml.readOnly) {
|
||||
oml.localStorage('ui', oml.config.user.ui);
|
||||
reload();
|
||||
} else {
|
||||
oml.api.resetUI({}, reload);
|
||||
}
|
||||
};
|
||||
|
||||
// sets oml.user.ui.key to value
|
||||
|
|
@ -161,7 +168,11 @@ oml.UI = (function() {
|
|||
});
|
||||
});
|
||||
if (Ox.len(set)) {
|
||||
oml.api.setUI(set);
|
||||
if (oml.readOnly) {
|
||||
oml.localStorage('ui', oml.user.ui);
|
||||
} else {
|
||||
oml.api.setUI(set);
|
||||
}
|
||||
}
|
||||
if (triggerEvents) {
|
||||
Ox.forEach(trigger, function(value, key) {
|
||||
|
|
@ -182,4 +193,4 @@ oml.UI = (function() {
|
|||
|
||||
return that;
|
||||
|
||||
}());
|
||||
}());
|
||||
|
|
|
|||
|
|
@ -25,12 +25,13 @@ oml.ui.appDialog = function() {
|
|||
title: Ox._('Software Development'),
|
||||
selected: ui.page == 'development'
|
||||
},
|
||||
].concat(oml.readOnly ? [] : [
|
||||
{
|
||||
id: 'contact',
|
||||
title: Ox._('Send Feedback'),
|
||||
selected: ui.page == 'contact'
|
||||
}
|
||||
],
|
||||
]),
|
||||
|
||||
$panel = Ox.TabPanel({
|
||||
content: function(id) {
|
||||
|
|
@ -95,7 +96,7 @@ oml.ui.appDialog = function() {
|
|||
}),
|
||||
|
||||
that = Ox.Dialog({
|
||||
buttons: [
|
||||
buttons: (oml.readOnly ? [] : [
|
||||
Ox.Button({
|
||||
id: 'update',
|
||||
style: 'squared',
|
||||
|
|
@ -106,6 +107,7 @@ oml.ui.appDialog = function() {
|
|||
oml.UI.set({page: 'update'});
|
||||
}
|
||||
}),
|
||||
]).concat([
|
||||
{},
|
||||
Ox.Button({
|
||||
id: 'close',
|
||||
|
|
@ -116,7 +118,7 @@ oml.ui.appDialog = function() {
|
|||
that.close();
|
||||
}
|
||||
})
|
||||
],
|
||||
]),
|
||||
closeButton: true,
|
||||
content: $panel,
|
||||
fixedSize: true,
|
||||
|
|
|
|||
|
|
@ -270,9 +270,10 @@ oml.ui.infoView = function(externalData, isMixed) {
|
|||
items: [
|
||||
{id: 'read', title: Ox._('Read in Open Media Libary')},
|
||||
{id: 'open', title: Ox._('Open in External Reader')},
|
||||
].concat(oml.readOnly ? [] : [
|
||||
{},
|
||||
{id: 'show', title: Ox._('Show File')}
|
||||
],
|
||||
]),
|
||||
overlap: 'left',
|
||||
style: 'squared',
|
||||
title: 'select',
|
||||
|
|
@ -284,7 +285,11 @@ oml.ui.infoView = function(externalData, isMixed) {
|
|||
if (data_.id == 'read') {
|
||||
oml.UI.set({itemView: 'book'});
|
||||
} else if (data_.id == 'open') {
|
||||
oml.api.openFile({id: oml.user.ui.item});
|
||||
if (oml.readOnly) {
|
||||
document.location.href = '/' + oml.user.ui.item + '/get/'
|
||||
} else {
|
||||
oml.api.openFile({id: oml.user.ui.item});
|
||||
}
|
||||
} else {
|
||||
oml.api.openFolder({id: oml.user.ui.item});
|
||||
}
|
||||
|
|
@ -382,9 +387,9 @@ oml.ui.infoView = function(externalData, isMixed) {
|
|||
Ox.print('BOOK DATA', data)
|
||||
|
||||
var $div,
|
||||
isEditable = isMultiple || (
|
||||
isEditable = !oml.readOnly && (isMultiple || (
|
||||
data.mediastate == 'available' && !externalData
|
||||
),
|
||||
)),
|
||||
src = !externalData
|
||||
? '/' + data.id + '/' + ui.icons + '512.jpg?' + data.modified
|
||||
: data.cover,
|
||||
|
|
@ -751,28 +756,29 @@ oml.ui.infoView = function(externalData, isMixed) {
|
|||
].join(', ')
|
||||
)
|
||||
.appendTo($data);
|
||||
if (!oml.readOnly) {
|
||||
renderIdentifyButton(data).appendTo($data);
|
||||
|
||||
renderIdentifyButton(data).appendTo($data);
|
||||
['accessed', 'modified', 'added', 'created'].forEach(function(id) {
|
||||
var title;
|
||||
if (data[id]) {
|
||||
title = Ox.getObjectById(oml.config.itemKeys, id).title;
|
||||
$('<div>')
|
||||
.css({
|
||||
marginTop: '8px',
|
||||
fontWeight: 'bold'
|
||||
})
|
||||
.text(title)
|
||||
.appendTo($data);
|
||||
$('<div>')
|
||||
.text(Ox.formatDate(data[id], '%B %e, %Y'))
|
||||
.appendTo($data);
|
||||
}
|
||||
});
|
||||
|
||||
['accessed', 'modified', 'added', 'created'].forEach(function(id) {
|
||||
var title;
|
||||
if (data[id]) {
|
||||
title = Ox.getObjectById(oml.config.itemKeys, id).title;
|
||||
$('<div>')
|
||||
.css({
|
||||
marginTop: '8px',
|
||||
fontWeight: 'bold'
|
||||
})
|
||||
.text(title)
|
||||
.appendTo($data);
|
||||
$('<div>')
|
||||
.text(Ox.formatDate(data[id], '%B %e, %Y'))
|
||||
.appendTo($data);
|
||||
if (data.mediastate == 'available') {
|
||||
renderShareButton(data).appendTo($data);
|
||||
}
|
||||
});
|
||||
|
||||
if (data.mediastate == 'available') {
|
||||
renderShareButton(data).appendTo($data);
|
||||
}
|
||||
|
||||
$('<div>').css({height: '16px'}).appendTo($data);
|
||||
|
|
|
|||
|
|
@ -7,7 +7,9 @@ oml.ui.mainMenu = function() {
|
|||
fromMenu = false,
|
||||
|
||||
that = Ox.MainMenu({
|
||||
extras: [
|
||||
extras: oml.readOnly ? [
|
||||
oml.$ui.loadingIcon = oml.ui.loadingIcon()
|
||||
] : [
|
||||
oml.$ui.updateButton = oml.ui.updateButton(),
|
||||
oml.$ui.transferButton = oml.ui.transferButton(),
|
||||
oml.$ui.peersButton = oml.ui.peersButton(),
|
||||
|
|
@ -39,6 +41,7 @@ oml.ui.mainMenu = function() {
|
|||
id: 'contact',
|
||||
title: Ox._('Send Feedback')
|
||||
},
|
||||
].concat(oml.readOnly ? [] : [
|
||||
{},
|
||||
{
|
||||
id: 'update',
|
||||
|
|
@ -50,7 +53,7 @@ oml.ui.mainMenu = function() {
|
|||
title: Ox._('Quit Open Media Library'),
|
||||
keyboard: 'control q'
|
||||
}
|
||||
]
|
||||
])
|
||||
},
|
||||
{
|
||||
id: 'userMenu',
|
||||
|
|
@ -61,6 +64,7 @@ oml.ui.mainMenu = function() {
|
|||
title: Ox._('Preferences...'),
|
||||
keyboard: 'control ,'
|
||||
},
|
||||
].concat(oml.readOnly ? [] : [
|
||||
{},
|
||||
{
|
||||
id: 'peers',
|
||||
|
|
@ -70,7 +74,7 @@ oml.ui.mainMenu = function() {
|
|||
id: 'transfers',
|
||||
title: Ox._('Transfers...')
|
||||
}
|
||||
]
|
||||
])
|
||||
},
|
||||
getListMenu(),
|
||||
getEditMenu(),
|
||||
|
|
@ -295,6 +299,7 @@ oml.ui.mainMenu = function() {
|
|||
keyboard: 'shift control s',
|
||||
disabled: true
|
||||
},
|
||||
].concat(oml.readOnly ? [] : [
|
||||
{},
|
||||
{
|
||||
id: 'sorttitles',
|
||||
|
|
@ -304,7 +309,7 @@ oml.ui.mainMenu = function() {
|
|||
id: 'sortnames',
|
||||
title: Ox._('Sort Names...')
|
||||
}
|
||||
]
|
||||
])
|
||||
},
|
||||
getFindMenu(),
|
||||
{
|
||||
|
|
@ -477,15 +482,19 @@ oml.ui.mainMenu = function() {
|
|||
} else if (id == 'invertselection') {
|
||||
oml.$ui.list.invertSelection();
|
||||
} else if (id == 'download') {
|
||||
oml.api.addListItems({
|
||||
items: ui.listSelection.filter(function(id) {
|
||||
return oml.$ui.list.value(id, 'mediastate') == 'unavailable';
|
||||
}),
|
||||
list: ':'
|
||||
}, function(result) {
|
||||
Ox.Request.clearCache();
|
||||
// FIXME: reload?
|
||||
});
|
||||
if (oml.readOnly) {
|
||||
document.location.href = '/' + ui.listSelection[0] + '/get/'
|
||||
} else {
|
||||
oml.api.addListItems({
|
||||
items: ui.listSelection.filter(function(id) {
|
||||
return oml.$ui.list.value(id, 'mediastate') == 'unavailable';
|
||||
}),
|
||||
list: ':'
|
||||
}, function(result) {
|
||||
Ox.Request.clearCache();
|
||||
// FIXME: reload?
|
||||
});
|
||||
}
|
||||
} else if (Ox.contains(['cut', 'cutadd'], id)) {
|
||||
var action = data.id == 'cut' ? 'copy' : 'add';
|
||||
fromMenu = true;
|
||||
|
|
@ -741,7 +750,7 @@ oml.ui.mainMenu = function() {
|
|||
clipboardItems > 1 ? Ox.formatNumber(clipboardItems) + ' ' : ''
|
||||
) + Ox._(clipboardItems == 1 ? 'Book' : 'Books'),
|
||||
canSelect = !ui.item,
|
||||
canDownload = !!unavailableItems,
|
||||
canDownload = !!unavailableItems || (oml.readOnly && selectionItems == 1),
|
||||
canCopy = canSelect && selectionItems,
|
||||
canCut = canCopy && listData.editable,
|
||||
canPaste = listData.editable && clipboardItems,
|
||||
|
|
@ -757,7 +766,7 @@ oml.ui.mainMenu = function() {
|
|||
return {
|
||||
id: 'editMenu',
|
||||
title: Ox._('Edit'),
|
||||
items: [
|
||||
items: [].concat(oml.readOnly ? [] : [
|
||||
{
|
||||
id: 'import',
|
||||
title: Ox._(oml.user.importing ? 'Importing Books...' : 'Import Books...') // FIXME
|
||||
|
|
@ -767,6 +776,7 @@ oml.ui.mainMenu = function() {
|
|||
title: Ox._(oml.user.exporting ? 'Exporting Books...' : 'Export Books...') // FIXME
|
||||
},
|
||||
{},
|
||||
]).concat([
|
||||
{
|
||||
id: 'selectall',
|
||||
title: Ox._('Select All'),
|
||||
|
|
@ -792,6 +802,7 @@ oml.ui.mainMenu = function() {
|
|||
disabled: !canDownload,
|
||||
keyboard: 'control d'
|
||||
},
|
||||
]).concat(oml.readOnly ? [] : [
|
||||
{
|
||||
id: 'cut',
|
||||
title: Ox._('Cut {0}', [selectionItemName]),
|
||||
|
|
@ -865,7 +876,7 @@ oml.ui.mainMenu = function() {
|
|||
title: Ox._('Clear History'),
|
||||
disabled: !historyItems,
|
||||
}
|
||||
]
|
||||
])
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -930,6 +941,14 @@ oml.ui.mainMenu = function() {
|
|||
isLibrary = Ox.endsWith(ui._list, ':'),
|
||||
isList = !isLibraries && !isLibrary,
|
||||
isOwnList = ui._list[0] == ':';
|
||||
|
||||
if (oml.readOnly) {
|
||||
return {
|
||||
id: 'listMenu',
|
||||
title: Ox._('List'),
|
||||
items: []
|
||||
};
|
||||
}
|
||||
return {
|
||||
id: 'listMenu',
|
||||
title: Ox._('List'),
|
||||
|
|
|
|||
|
|
@ -50,8 +50,12 @@
|
|||
$ui: {},
|
||||
config: data.config,
|
||||
user: data.user,
|
||||
readOnly: data.readOnly,
|
||||
version: data.version
|
||||
});
|
||||
if (oml.readOnly) {
|
||||
oml.user.ui = oml.localStorage('ui') || oml.user.ui;
|
||||
}
|
||||
['preferences', 'ui'].forEach(function(key) {
|
||||
// make sure all valid settings are present
|
||||
oml.user[key] = Ox.extend(
|
||||
|
|
|
|||
|
|
@ -142,6 +142,14 @@ oml.ui.preferencesPanel = function() {
|
|||
value: preferences.autostart,
|
||||
help: 'Launch Open Media Library in the background once you login to your computer.'
|
||||
},
|
||||
/*
|
||||
{
|
||||
id: 'enableReadOnlyService',
|
||||
title: 'Read-Only Hidden Service',
|
||||
value: preferences.enableReadOnlyService,
|
||||
help: 'Make a read-only version of your library available as a TOR Hidden service.<br>\n Your library will be available at http://' + oml.user.id + '.onion/'
|
||||
},
|
||||
*/
|
||||
{
|
||||
id: 'showDebugMenu',
|
||||
title: 'Show Debug Menu',
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ oml.ui.userDialog = function() {
|
|||
title: Ox._('Preferences'),
|
||||
selected: ui.page == 'preferences'
|
||||
},
|
||||
].concat(oml.readOnly ? [] : [
|
||||
{
|
||||
id: 'peers',
|
||||
title: Ox._('Peers'),
|
||||
|
|
@ -26,7 +27,7 @@ oml.ui.userDialog = function() {
|
|||
title: Ox._('Transfers'),
|
||||
selected: ui.page == 'transfers'
|
||||
}
|
||||
]
|
||||
])
|
||||
})
|
||||
.bindEvent({
|
||||
change: function(data) {
|
||||
|
|
@ -70,4 +71,4 @@ oml.ui.userDialog = function() {
|
|||
|
||||
return that;
|
||||
|
||||
};
|
||||
};
|
||||
|
|
|
|||
|
|
@ -862,7 +862,7 @@ oml.getUsers = function(callback) {
|
|||
}].concat(
|
||||
Ox.sortBy(result.data.users.filter(function(user) {
|
||||
return user.peered;
|
||||
}), 'index')
|
||||
}), 'index')
|
||||
);
|
||||
ui._users = users;
|
||||
callback(users);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue