mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 18:54:09 -04:00
make it possible not to include user categories (@foo) in content server field lists.
This commit is contained in:
parent
efcc762e51
commit
b689944a2f
@ -497,6 +497,18 @@ class FieldMetadata(dict):
|
||||
def is_custom_field(self, key):
|
||||
return key.startswith(self.custom_field_prefix)
|
||||
|
||||
def is_ignorable_field(self, key):
|
||||
return self.is_custom_field(key) or key.startswith('@')
|
||||
|
||||
def ignorable_field_keys(self):
|
||||
res = []
|
||||
for k in self._tb_cats.keys():
|
||||
fm = self._tb_cats[k]
|
||||
if fm['kind'] == 'user' or (fm['kind']=='field' and fm['is_custom'] and \
|
||||
(fm['datatype'] != 'composite')):
|
||||
res.append(k)
|
||||
return res
|
||||
|
||||
def is_series_index(self, key):
|
||||
m = self[key]
|
||||
return (m['datatype'] == 'float' and key.endswith('_index') and
|
||||
|
@ -51,7 +51,7 @@ def server_config(defaults=None):
|
||||
return c
|
||||
|
||||
def custom_fields_to_display(db):
|
||||
ckeys = db.custom_field_keys()
|
||||
ckeys = db.field_metadata.ignorable_field_keys()
|
||||
yes_fields = set(tweaks['content_server_will_display'])
|
||||
no_fields = set(tweaks['content_server_wont_display'])
|
||||
if '*' in yes_fields:
|
||||
|
@ -300,7 +300,8 @@ class AjaxServer(object):
|
||||
meta = category_meta.get(category, None)
|
||||
if meta is None:
|
||||
continue
|
||||
if meta['is_custom'] and category not in displayed_custom_fields:
|
||||
if category_meta.is_ignorable_field(category) and \
|
||||
category not in displayed_custom_fields:
|
||||
continue
|
||||
display_name = meta['name']
|
||||
if category.startswith('@'):
|
||||
|
@ -269,7 +269,7 @@ class BrowseServer(object):
|
||||
for x in fm.sortable_field_keys():
|
||||
if x in ('ondevice', 'formats', 'sort'):
|
||||
continue
|
||||
if fm[x]['is_custom'] and x not in displayed_custom_fields:
|
||||
if fm.is_ignorable_field(x) and x not in displayed_custom_fields:
|
||||
continue
|
||||
if x == 'comments' or fm[x]['datatype'] == 'comments':
|
||||
continue
|
||||
@ -369,7 +369,8 @@ class BrowseServer(object):
|
||||
meta = category_meta.get(category, None)
|
||||
if meta is None:
|
||||
continue
|
||||
if meta['is_custom'] and category not in displayed_custom_fields:
|
||||
if self.db.field_metadata.is_ignorable_field(category) and \
|
||||
category not in displayed_custom_fields:
|
||||
continue
|
||||
# get the icon files
|
||||
main_cat = (category.partition('.')[0]) if hasattr(category,
|
||||
@ -836,7 +837,8 @@ class BrowseServer(object):
|
||||
displayed_custom_fields = custom_fields_to_display(self.db)
|
||||
for field, m in list(mi.get_all_standard_metadata(False).items()) + \
|
||||
list(mi.get_all_user_metadata(False).items()):
|
||||
if m['is_custom'] and field not in displayed_custom_fields:
|
||||
if self.db.field_metadata.is_ignorable_field(field) and \
|
||||
field not in displayed_custom_fields:
|
||||
continue
|
||||
if m['datatype'] == 'comments' or field == 'comments' or (
|
||||
m['datatype'] == 'composite' and \
|
||||
|
@ -594,7 +594,7 @@ class OPDSServer(object):
|
||||
meta = category_meta.get(category, None)
|
||||
if meta is None:
|
||||
continue
|
||||
if category_meta.is_custom_field(category) and \
|
||||
if category_meta.is_ignorable_field(category) and \
|
||||
category not in custom_fields_to_display(self.db):
|
||||
continue
|
||||
cats.append((meta['name'], meta['name'], 'N'+category))
|
||||
|
Loading…
x
Reference in New Issue
Block a user