j 4 years ago
parent
commit
e41942ea99

+ 2
- 0
.gitignore View File

@@ -1,5 +1,7 @@
1 1
 env
2 2
 *.pyc
3
+*.pyo
4
+*.pyd
3 5
 *.gz
4 6
 *.swp
5 7
 *.min.js

+ 3
- 3
ctl View File

@@ -37,7 +37,7 @@ if [ "$1" == "start" ]; then
37 37
         echo openmedialibrary already running
38 38
         exit 1
39 39
     fi
40
-    python oml server PID &
40
+    python2 oml server PID &
41 41
     exit $?
42 42
 fi
43 43
 if [ "$1" == "debug" ]; then
@@ -47,7 +47,7 @@ if [ "$1" == "debug" ]; then
47 47
         exit 1
48 48
     fi
49 49
     shift
50
-    python oml server $@
50
+    python2 oml server $@
51 51
     exit $?
52 52
 fi
53 53
 if [ "$1" == "stop" ]; then
@@ -75,5 +75,5 @@ if [ "$1" == "open" ]; then
75 75
 fi
76 76
 
77 77
 cd $BASE/$NAME
78
-python oml $@
78
+python2 oml $@
79 79
 exit $?

+ 1
- 0
oml/__main__.py View File

@@ -1,6 +1,7 @@
1 1
 #!/usr/bin/env python
2 2
 # -*- coding: utf-8 -*-
3 3
 # vi:si:et:sw=4:sts=4:ts=4
4
+from __future__ import division
4 5
 
5 6
 import os
6 7
 import sys

+ 1
- 0
oml/app.py View File

@@ -1,5 +1,6 @@
1 1
 # -*- coding: utf-8 -*-
2 2
 # vi:si:et:sw=4:sts=4:ts=4
3
+from __future__ import division
3 4
 
4 5
 from flask import Flask
5 6
 from flask.ext.script import Manager

+ 1
- 0
oml/changelog.py View File

@@ -1,5 +1,6 @@
1 1
 # -*- coding: utf-8 -*-
2 2
 # vi:si:et:sw=4:sts=4:ts=4
3
+from __future__ import division
3 4
 
4 5
 import json
5 6
 from datetime import datetime

+ 6
- 2
oml/commands.py View File

@@ -1,5 +1,6 @@
1 1
 # -*- coding: utf-8 -*-
2 2
 # vi:si:et:sw=4:sts=4:ts=4
3
+from __future__ import division
3 4
 
4 5
 from flask.ext.script import Command
5 6
 
@@ -10,7 +11,10 @@ class Setup(Command):
10 11
         """
11 12
         def run(self):
12 13
             import setup
14
+            import settings
13 15
             setup.create_default_lists()
16
+            settings.db.session.connection().execute("PRAGMA journal_mode=WAL")
17
+            settings.db.session.commit()
14 18
 
15 19
 class UpdateStatic(Command):
16 20
         """
@@ -28,8 +32,8 @@ class UpdateStatic(Command):
28 32
             oxjs = os.path.join(settings.static_path, 'oxjs')
29 33
             if not os.path.exists(oxjs):
30 34
                 r('git', 'clone', 'https://git.0x2620.org/oxjs.git', oxjs)
31
-            r('python', os.path.join(oxjs, 'tools', 'build', 'build.py'))
32
-            r('python', os.path.join(settings.static_path, 'py', 'build.py'))
35
+            r('python2', os.path.join(oxjs, 'tools', 'build', 'build.py'))
36
+            r('python2', os.path.join(settings.static_path, 'py', 'build.py'))
33 37
 
34 38
 class Release(Command):
35 39
         """

+ 1
- 0
oml/directory.py View File

@@ -1,5 +1,6 @@
1 1
 # -*- coding: utf-8 -*-
2 2
 # vi:si:et:sw=4:sts=4:ts=4
3
+from __future__ import division
3 4
 
4 5
 # DHT placeholder
5 6
 

+ 4
- 0
oml/ed25519_utils.py View File

@@ -1,3 +1,7 @@
1
+# -*- coding: utf-8 -*-
2
+# vi:si:et:sw=4:sts=4:ts=4
3
+from __future__ import division
4
+
1 5
 import ed25519
2 6
 ENCODING='base64'
3 7
 

+ 1
- 0
oml/item/add.py View File

@@ -1,5 +1,6 @@
1 1
 # -*- coding: utf-8 -*-
2 2
 # vi:si:et:sw=4:sts=4:ts=4
3
+from __future__ import division
3 4
 
4 5
 import base64
5 6
 import models

+ 2
- 0
oml/item/api.py View File

@@ -1,5 +1,7 @@
1 1
 # -*- coding: utf-8 -*-
2 2
 # vi:si:et:sw=4:sts=4:ts=4
3
+from __future__ import division
4
+
3 5
 from datetime import datetime
4 6
 
5 7
 from flask import json

+ 1
- 0
oml/item/covers.py View File

@@ -1,5 +1,6 @@
1 1
 # -*- coding: utf-8 -*-
2 2
 # vi:si:et:sw=4:sts=4:ts=4
3
+from __future__ import division
3 4
 
4 5
 import sqlite3
5 6
 import Image

+ 4
- 0
oml/item/migrate.py View File

@@ -1,3 +1,7 @@
1
+# -*- coding: utf-8 -*-
2
+# vi:si:et:sw=4:sts=4:ts=4
3
+from __future__ import division
4
+
1 5
 import models
2 6
 from copy import deepcopy
3 7
 

+ 7
- 1
oml/item/models.py View File

@@ -1,5 +1,6 @@
1 1
 # -*- coding: utf-8 -*-
2 2
 # vi:si:et:sw=4:sts=4:ts=4
3
+from __future__ import division
3 4
 
4 5
 import os
5 6
 import re
@@ -198,6 +199,8 @@ class Item(db.Model):
198 199
                         if value:
199 200
                             value = unicode(value)
200 201
                             value = ox.sort_string(value).lower()
202
+                elif isinstance(value, list): #empty list
203
+                    value = ''
201 204
                 setattr(self, 'sort_%s' % key['id'], value)
202 205
 
203 206
     def update_find(self):
@@ -295,11 +298,14 @@ class Item(db.Model):
295 298
 
296 299
     def update_cover(self):
297 300
         cover = None
298
-        if 'cover' in self.meta:
301
+        if 'cover' in self.meta and self.meta['cover']:
299 302
             cover = ox.cache.read_url(self.meta['cover'])
300 303
             #covers[self.id] = requests.get(self.meta['cover']).content
301 304
             if cover:
302 305
                 covers[self.id] = cover
306
+        else:
307
+            if covers[self.id]:
308
+                del covers[self.id]
303 309
         path = self.get_path()
304 310
         if not cover and path:
305 311
             cover = self.extract_cover()

+ 1
- 0
oml/item/person.py View File

@@ -1,5 +1,6 @@
1 1
 # -*- coding: utf-8 -*-
2 2
 # vi:si:et:sw=4:sts=4:ts=4
3
+from __future__ import division
3 4
 
4 5
 import unicodedata
5 6
 

+ 1
- 0
oml/item/query.py View File

@@ -1,5 +1,6 @@
1 1
 # -*- coding: utf-8 -*-
2 2
 # vi:si:et:sw=4:sts=4:ts=4
3
+from __future__ import division
3 4
 
4 5
 import settings
5 6
 import models

+ 2
- 1
oml/item/views.py View File

@@ -1,5 +1,6 @@
1 1
 # -*- coding: utf-8 -*-
2 2
 # vi:si:et:sw=4:sts=4:ts=4
3
+from __future__ import division
3 4
 
4 5
 import os
5 6
 from datetime import datetime
@@ -77,7 +78,7 @@ def cover(id, size=None):
77 78
     if not 'coverRatio' in item.meta:
78 79
         #img = Image.open(StringIO(str(covers[id])))
79 80
         img = Image.open(StringIO(data))
80
-        item.meta['coverRatio'] = float(img.size[0])/img.size[1]
81
+        item.meta['coverRatio'] = img.size[0]/img.size[1]
81 82
         db.session.add(item)
82 83
         db.session.commit()
83 84
     resp = make_response(data)

+ 1
- 0
oml/localnodes.py View File

@@ -1,5 +1,6 @@
1 1
 # -*- coding: utf-8 -*-
2 2
 # vi:si:et:sw=4:sts=4:ts=4
3
+from __future__ import division
3 4
 
4 5
 import socket
5 6
 import thread

+ 4
- 0
oml/meta/__init__.py View File

@@ -7,6 +7,7 @@ import loc
7 7
 import lookupbyisbn
8 8
 import openlibrary
9 9
 import worldcat
10
+import google
10 11
 
11 12
 providers = [
12 13
     ('openlibrary', 'olid'),
@@ -17,9 +18,12 @@ providers = [
17 18
 ]
18 19
 
19 20
 def find(title, author=None, publisher=None, date=None):
21
+    results = google.find(title=title, author=author, publisher=publisher, date=date)
22
+    '''
20 23
     results = openlibrary.find(title=title, author=author, publisher=publisher, date=date)
21 24
     for r in results:
22 25
         r['mainid'] = 'olid'
26
+    '''
23 27
     return results
24 28
 
25 29
 def lookup(key, value):

+ 38
- 0
oml/meta/google.py View File

@@ -0,0 +1,38 @@
1
+# -*- coding: utf-8 -*-
2
+# vi:si:et:sw=4:sts=4:ts=4
3
+from __future__ import division
4
+
5
+import ox.web.google
6
+import stdnum.isbn
7
+
8
+from .utils import find_isbns
9
+
10
+
11
+def find(title, author=None, publisher=None, date=None):
12
+    print 'google.find', title, author, publisher, date
13
+    query = title
14
+    if author:
15
+        if isinstance(author, list):
16
+            author = ' '.join(author)
17
+        query += ' ' + author
18
+    query += ' isbn'
19
+    isbns = []
20
+    for r in ox.web.google.find(query):
21
+        isbns += find_isbns(' '.join(r))
22
+
23
+    results = []
24
+    done = set()
25
+    for isbn in isbns:
26
+        if isbn not in done:
27
+            key = 'isbn%d'%len(isbn)
28
+            #r = lookup(key, isbn)
29
+            #r['mainid'] = key
30
+            r = {
31
+                key: isbn,
32
+                'mainid': key
33
+            }
34
+            results.append(r)
35
+            done.add(isbn)
36
+            if len(isbn) == 10:
37
+                done.add(stdnum.isbn.to_isbn13(isbn))
38
+    return results

+ 4
- 1
oml/meta/loc.py View File

@@ -33,7 +33,10 @@ def lookup(id):
33 33
     info = {
34 34
         'lccn': id
35 35
     }
36
-    info['title'] = ''.join([e.text for e in mods.findall(ns + 'titleInfo')[0]])
36
+    title = mods.findall(ns + 'titleInfo')
37
+    if not title:
38
+        return {}
39
+    info['title'] = ''.join([e.text for e in title[0]])
37 40
     origin = mods.findall(ns + 'originInfo')
38 41
     if origin:
39 42
         info['place'] = []

+ 8
- 4
oml/meta/lookupbyisbn.py View File

@@ -14,6 +14,8 @@ def get_ids(key, value):
14 14
         if m:
15 15
             asin = m[0].split('/')[-3]
16 16
             ids.append(('asin', asin))
17
+    if key == 'isbn10':
18
+        ids.append(('isbn13', stdnum.isbn.to_isbn13(value)))
17 19
     if key == 'asin':
18 20
         if stdnum.isbn.is_valid(value):
19 21
             ids.append(('isbn10', value))
@@ -47,14 +49,16 @@ def lookup(id):
47 49
             r[key] = int(r[key])
48 50
     desc = find_re(data, '<h2>Description:<\/h2>(.*?)<div ')
49 51
     desc = desc.replace('<br /><br />', ' ').replace('<br /> ', ' ').replace('<br />', ' ')
50
-    r['description'] = desc
51
-    if r['description'] == u'Description of this item is not available at this time.':
52
-        r['description'] = ''
52
+    r['description'] = decode_html(strip_tags(desc))
53 53
     r['cover'] = find_re(data, '<img src="(.*?)" alt="Book cover').replace('._SL160_', '')
54 54
     for key in r:
55 55
         if isinstance(r[key], basestring):
56 56
             r[key] = decode_html(strip_tags(r[key])).strip()
57
-    if 'author' in r and isinstance(r['author'], basestring):
57
+    if 'author' in r and isinstance(r['author'], basestring) and r['author']:
58 58
         r['author'] = [r['author']]
59
+    else:
60
+        r['author'] = []
61
+    if r['description'].lower() == u'Description of this item is not available at this time.'.lower():
62
+        r['description'] = ''
59 63
     return r
60 64
 

+ 12
- 1
oml/meta/utils.py View File

@@ -1,5 +1,16 @@
1
-
1
+import re
2
+import stdnum.isbn
2 3
 
3 4
 def normalize_isbn(value):
4 5
     return ''.join([s for s in value if s.isdigit() or s == 'X'])
5 6
 
7
+def find_isbns(text):
8
+    matches = re.compile('\d[\d\-X\ ]+').findall(text)
9
+    matches = [normalize_isbn(value) for value in matches]
10
+    return [isbn for isbn in matches if stdnum.isbn.is_valid(isbn)
11
+        and len(isbn) in (10, 13)
12
+        and isbn not in (
13
+        '0' * 10,
14
+        '0' * 13,
15
+    )]
16
+

+ 1
- 11
oml/utils.py View File

@@ -8,7 +8,7 @@ import stdnum.isbn
8 8
 
9 9
 import ox
10 10
 
11
-from meta.utils import normalize_isbn
11
+from meta.utils import normalize_isbn, find_isbns
12 12
 
13 13
 def valid_olid(id):
14 14
     return id.startswith('OL') and id.endswith('M')
@@ -76,16 +76,6 @@ def sort_title(title):
76 76
     title = re.sub(u'[\'!¿¡,\.;\-"\:\*\[\]]', '', title)
77 77
     return title.strip()
78 78
 
79
-def find_isbns(text):
80
-    matches = re.compile('\d[\d\-X\ ]+').findall(text)
81
-    matches = [normalize_isbn(value) for value in matches]
82
-    return [isbn for isbn in matches if stdnum.isbn.is_valid(isbn)
83
-        and len(isbn) in (10, 13)
84
-        and isbn not in (
85
-        '0' * 10,
86
-        '0' * 13,
87
-    )]
88
-
89 79
 def get_position_by_id(list, key):
90 80
     for i in range(0, len(list)):
91 81
         if list[i]['id'] == key:

+ 2
- 2
static/js/appDialog.js View File

@@ -37,8 +37,8 @@ oml.ui.appDialog = function() {
37 37
                     .css({
38 38
                         position: 'absolute',
39 39
                         left: '16px',
40
-                        right: '24px',
41
-                        top: '24px',
40
+                        right: '16px',
41
+                        top: '16px',
42 42
                         overflowY: 'auto'
43 43
                     })
44 44
                     .html(

+ 44
- 40
static/js/identifyDialog.js View File

@@ -34,7 +34,7 @@ oml.ui.identifyDialog = function(data) {
34 34
 
35 35
         originalData = Ox.clone(data, true),
36 36
 
37
-        editedData,
37
+        idValue, titleValue,
38 38
 
39 39
         $idInputs, $idButtons = {},
40 40
 
@@ -125,12 +125,17 @@ oml.ui.identifyDialog = function(data) {
125 125
                         var edit = Ox.extend(
126 126
                             {id: data.id},
127 127
                             $innerPanel.options('selected') == 'id'
128
-                                ? Ox.extend({}, 'foo', 'bar')
129
-                                : {olid: $list.value($list.options('selected'), 'olid')}
128
+                                ? idValue
129
+                                : titleValue
130 130
                         );
131 131
                         that.options({content: Ox.LoadingScreen().start()});
132
-                        oml.api.edit(edit, function() {
132
+                        that.disableButtons();
133
+                        oml.api.edit(edit, function(result) {
133 134
                             that.close();
135
+                            Ox.Request.clearCache('find');
136
+                            oml.$ui.browser.reloadList(true);
137
+                            Ox.Request.clearCache(data.id);
138
+                            oml.$ui.infoView.update(result.data);
134 139
                         });
135 140
                     }
136 141
                 })
@@ -227,7 +232,7 @@ oml.ui.identifyDialog = function(data) {
227 232
                             var value = $idInputs[index].options('elements')[1].value();
228 233
                             if (data.value) {
229 234
                                 if (value) {
230
-                                    editedData = Ox.extend({}, id.id, value);
235
+                                    idValue = Ox.extend({}, id.id, value);
231 236
                                     $idInputs.forEach(function($input, i) {
232 237
                                         if (i != index) {
233 238
                                             $input.options('elements')[0].value(false);
@@ -251,7 +256,7 @@ oml.ui.identifyDialog = function(data) {
251 256
                     .bindEvent({
252 257
                         submit: function(data) {
253 258
                             if (data.value) {
254
-                                editedData = Ox.extend({}, id.id, data.value);
259
+                                idValue = Ox.extend({}, id.id, data.value);
255 260
                                 $idInputs.forEach(function($input, i) {
256 261
                                     $input.options('elements')[0].options({
257 262
                                         disabled: true,
@@ -336,54 +341,53 @@ oml.ui.identifyDialog = function(data) {
336 341
     }
337 342
 
338 343
     function renderResults(items) {
339
-        items = [Ox.extend({index: '0'}, data)].concat(items);
340 344
         Ox.print('LIST ITEMS::::', items);
341 345
         var $list = Ox.TableList({
342
-                columns: [{
343
-                    format: function(value, data) {
344
-                        return (data.title || '') + (
345
-                            data.author
346
-                                ? ' <span class="OxLight">'
347
-                                    + data.author.join(', ') + '</span>'
348
-                                : ''
349
-                        );
346
+                columns: [
347
+                    {
348
+                        format: function(value) {
349
+                            return Ox.getObjectById(ids, value).title;
350
+                        },
351
+                        id: 'mainid',
352
+                        visible: true,
353
+                        width: 64
350 354
                     },
351
-                    id: 'index',
352
-                    visible: true,
353
-                    width: 192 - Ox.UI.SCROLLBAR_SIZE
354
-                }],
355
+                    {
356
+                        format: function(value, data) {
357
+                            return data[data.mainid]; 
358
+                        },
359
+                        id: 'index',
360
+                        visible: true,
361
+                        width: 128 - Ox.UI.SCROLLBAR_SIZE
362
+                    }
363
+                ],
355 364
                 items: items,
356
-                keys: ['author', 'title', 'olid'],
365
+                keys: ['mainid', 'isbn10', 'isbn13'],
357 366
                 min: 1,
358 367
                 max: 1,
359 368
                 scrollbarVisible: true,
360
-                selected: ['0'],
361
-                sort: [{key: 'index', operator: '+'}],
369
+                sort: [{key: 'mainid', operator: '+'}],
362 370
                 unique: 'index'
363 371
             })
364 372
             .bindEvent({
365 373
                 select: function(data) {
366
-                    var index = data.ids[0], olid;
367
-                    if (index == '0') {
368
-                        $results.replaceElement(1, oml.ui.infoView(data));
369
-                    } else {
370
-                        olid = $list.value(index, 'olid');
371
-                        editedData = {olid: olid};
372
-                        $results.replaceElement(1, Ox.LoadingScreen().start());
373
-                        oml.api.getMetadata({olid: olid}, function(result) {
374
-                            if (index == $list.options('selected')[0]) {
375
-                                $results.replaceElement(1, oml.ui.infoView(result.data));
376
-                                that.options('buttons')[1].options({disabled: false});
377
-                            }
378
-                        });
379
-                    }
380
-
374
+                    var index = data.ids[0], mainid;
375
+                    mainid = $list.value(index, 'mainid');
376
+                    Ox.print('MAINID', mainid)
377
+                    titleValue = Ox.extend({}, mainid, $list.value(index, mainid));
378
+                    $results.replaceElement(1, Ox.LoadingScreen().start());
379
+                    oml.api.getMetadata(titleValue, function(result) {
380
+                        if (index == $list.options('selected')[0]) {
381
+                            $results.replaceElement(1, oml.ui.infoView(result.data));
382
+                            that.options('buttons')[1].options({disabled: false});
383
+                        }
384
+                    });
381 385
                 }
382 386
             }),
383 387
             $results = Ox.SplitPanel({
384 388
                 elements: [
385 389
                     {element: $list, size: 192},
386
-                    {element: oml.ui.infoView(items[0])}
390
+                    {element: Ox.Element()}
387 391
                 ],
388 392
                 orientation: 'horizontal'
389 393
             });
@@ -480,7 +484,7 @@ oml.ui.identifyDialog = function(data) {
480 484
         $idButtons.clear.options({disabled: empty});
481 485
         $idButtons.reset.options({disabled: original});
482 486
         $idButtons.find.options({disabled: empty});
483
-        that.options('buttons')[1].options({disabled: original});
487
+        that[original ? 'disableButton' : 'enableButton']('update');
484 488
     }
485 489
 
486 490
     function updateTitleButtons() {
@@ -493,7 +497,7 @@ oml.ui.identifyDialog = function(data) {
493 497
         $titleButtons.clear.options({disabled: empty});
494 498
         $titleButtons.reset.options({disabled: original});
495 499
         $titleButtons.find.options({disabled: empty});
496
-        that.options('buttons')[1].options({disabled: original});
500
+        that[original ? 'disableButton' : 'enableButton']('update');
497 501
     }
498 502
 
499 503
     return that;

+ 70
- 15
static/js/infoView.js View File

@@ -66,6 +66,12 @@ oml.ui.infoView = function(identifyData) {
66 66
         return '<span class="OxLight">' + str + '</span>';
67 67
     }
68 68
 
69
+    function formatKey(key) {
70
+        var item = Ox.getObjectById(oml.config.itemKeys, key);
71
+        return '<span style="font-weight: bold">'
72
+            + Ox._(Ox.toTitleCase(key)) + ':&nbsp;</span> ';
73
+    }
74
+
69 75
     function formatValue(value, key) {
70 76
         return (Ox.isArray(value) ? value : [value]).map(function(value) {
71 77
             return key ?
@@ -234,6 +240,7 @@ oml.ui.infoView = function(identifyData) {
234 240
         $elements = $elements 
235 241
             ? Ox.makeArray($elements)
236 242
             : [$cover, $info, $data];
243
+        Ox.print('DEBUG, $ELEMENTS', $elements);
237 244
 
238 245
         (data ? Ox.noop : oml.api.get)({
239 246
             id: id,
@@ -308,8 +315,9 @@ oml.ui.infoView = function(identifyData) {
308 315
                             Ox.EditableContent({
309 316
                                 clickLink: oml.clickLink,
310 317
                                 editable: isEditable,
318
+                                placeholder: formatLight(Ox._('Unknown Title')),
311 319
                                 tooltip: isEditable ? oml.getEditTooltip() : '',
312
-                                value: data.title
320
+                                value: data.title || ''
313 321
                             })
314 322
                             .css({
315 323
                                 fontSize: '13px',
@@ -330,7 +338,9 @@ oml.ui.infoView = function(identifyData) {
330 338
                                     clickLink: oml.clickLink,
331 339
                                     editable: isEditable,
332 340
                                     format: function(value) {
333
-                                        return formatValue(value.split(', '), 'author');
341
+                                        return !identifyData
342
+                                            ? formatValue(value.split(', '), 'author')
343
+                                            : value;
334 344
                                     },
335 345
                                     placeholder: formatLight(Ox._('Unknown Author')),
336 346
                                     tooltip: isEditable ? oml.getEditTooltip() : '',
@@ -340,23 +350,65 @@ oml.ui.infoView = function(identifyData) {
340 350
                                     fontSize: '13px',
341 351
                                     fontWeight: 'bold'
342 352
                                 })
353
+                                .bindEvent({
354
+                                    // ...
355
+                                })
343 356
                             )
344 357
                             .appendTo($info);
345 358
                     }
346 359
 
360
+                    if (!isEditable) {
361
+                        $('<div>')
362
+                            .css({
363
+                                marginTop: '8px'
364
+                            })
365
+                            .text(
366
+                                (data.place || '')
367
+                                + (data.place && (data.publisher || data.date) ? ' : ' : '')
368
+                                + (data.publisher || '')
369
+                                + (data.publisher && data.date ? ', ' : '')
370
+                                + (data.date || '')
371
+                            )
372
+                            .appendTo($info);
373
+                    } else {
374
+                        var $div = $('<div>')
375
+                            .addClass('OxSelectable')
376
+                            .css({marginTop: '8px'})
377
+                            .appendTo($info);
378
+                        ['edition', 'publisher', 'date'].forEach(function(key, index) {
379
+                            index && $('<div>').css({float: 'left'}).html(';&nbsp;').appendTo($div);
380
+                            $('<div>')
381
+                                .css({float: 'left'})
382
+                                .html(formatKey(key))
383
+                                .appendTo($div);
384
+                            Ox.EditableContent({
385
+                                    clickLink: oml.clickLink,
386
+                                    format: function(value) {
387
+                                        return formatValue(value.split(', '), key)
388
+                                    },
389
+                                    placeholder: formatLight('unknown'),
390
+                                    tooltip: oml.getEditTooltip(),
391
+                                    value: data[key] || ''
392
+                                })
393
+                                .css({float: 'left'})
394
+                                .bindEvent({
395
+                                    submit: function(event) {
396
+                                        editMetadata(key, event.value);
397
+                                    }
398
+                                })
399
+                                .appendTo($div);
400
+                        });
401
+                    }
347 402
 
348
-                    $('<div>')
349
-                        .css({
350
-                            marginTop: '8px'
351
-                        })
352
-                        .text(
353
-                            (data.place || '')
354
-                            + (data.place && (data.publisher || data.date) ? ' : ' : '')
355
-                            + (data.publisher || '')
356
-                            + (data.publisher && data.date ? ', ' : '')
357
-                            + (data.date || '')
358
-                        )
359
-                        .appendTo($info);
403
+                    if (data.classification) {
404
+                        $('<div>')
405
+                            .css({
406
+                                marginTop: '8px',
407
+                                textAlign: 'justify'
408
+                            })
409
+                            .html(Ox.encodeHTMLEntities(data.classification))
410
+                            .appendTo($info);
411
+                    }
360 412
 
361 413
                     if (data.description) {
362 414
                         $('<div>')
@@ -445,11 +497,14 @@ oml.ui.infoView = function(identifyData) {
445 497
 
446 498
             });
447 499
 
500
+            // FIXME: identify dialog should call this too
448 501
             function editMetadata(key, value) {
449 502
                 var edit;
450 503
                 if (value != data[key]) {
451 504
                     edit = Ox.extend({id: ui.item}, key, value);
452 505
                     oml.api.edit(edit, function(result) {
506
+                        Ox.Request.clearCache('find');
507
+                        oml.$ui.browser.reloadList();
453 508
                         that.update(result.data, $data);
454 509
                     });
455 510
                 }
@@ -469,7 +524,7 @@ oml.ui.infoView = function(identifyData) {
469 524
         transfer: function(data) {
470 525
             if (data.id == ui.item && data.progress == 1) {
471 526
                 Ox.Request.clearCache(); // FIXME: too much
472
-                that.update(ui.item, $data);
527
+                that.update(ui.item, [$info, $data]);
473 528
             }
474 529
         }
475 530
     });

+ 18
- 3
static/js/usersDialog.js View File

@@ -254,8 +254,20 @@ oml.ui.usersDialog = function() {
254 254
                     width: 480
255 255
                 })
256 256
                 .bindEvent({
257
-                    change: function() {
258
-                        // ...
257
+                    change: function(data) {
258
+                        var value = oml.validateName(
259
+                                data.value,
260
+                                users.map(function(user) {
261
+                                    return user.nickname;
262
+                                })
263
+                            );
264
+                        this.value(value);
265
+                        oml.api.editUser({
266
+                            id: user.id,
267
+                            nickname: value
268
+                        }, function() {
269
+                            // ...
270
+                        });
259 271
                     }
260 272
                 })
261 273
                 .appendTo($form);
@@ -480,6 +492,10 @@ oml.ui.usersDialog = function() {
480 492
         }
481 493
     }
482 494
 
495
+    function updateUsers() {
496
+        // ...
497
+    }
498
+
483 499
     that.update = function() {
484 500
 
485 501
         that.options({
@@ -503,7 +519,6 @@ oml.ui.usersDialog = function() {
503 519
                 );
504 520
             });
505 521
 
506
-            Ox.print('FOLDERS::', folders)
507 522
             folders.forEach(function(folder, index) {
508 523
                 $lists.push(
509 524
                     (

BIN
static/png/oml.png View File