mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Tooltip and commas for byte length display, closes #1712
This commit is contained in:
parent
143c105f87
commit
0bc5186b7b
3 changed files with 42 additions and 4 deletions
|
|
@ -11,6 +11,7 @@ from datasette.utils import (
|
|||
add_cors_headers,
|
||||
await_me_maybe,
|
||||
derive_named_parameters,
|
||||
format_bytes,
|
||||
tilde_decode,
|
||||
to_css_class,
|
||||
validate_sql_select,
|
||||
|
|
@ -399,13 +400,18 @@ class QueryView(DataView):
|
|||
).hexdigest(),
|
||||
},
|
||||
)
|
||||
display_value = Markup(
|
||||
'<a class="blob-download" href="{}"><Binary: {} byte{}></a>'.format(
|
||||
formatted = format_bytes(len(value))
|
||||
display_value = markupsafe.Markup(
|
||||
'<a class="blob-download" href="{}"{}><Binary: {:,} byte{}></a>'.format(
|
||||
blob_url,
|
||||
len(display_value),
|
||||
' title="{}"'.format(formatted)
|
||||
if "bytes" not in formatted
|
||||
else "",
|
||||
len(value),
|
||||
"" if len(value) == 1 else "s",
|
||||
)
|
||||
)
|
||||
|
||||
display_row.append(display_value)
|
||||
display_rows.append(display_row)
|
||||
|
||||
|
|
|
|||
|
|
@ -12,10 +12,12 @@ from datasette.utils import (
|
|||
MultiParams,
|
||||
append_querystring,
|
||||
compound_keys_after_sql,
|
||||
format_bytes,
|
||||
tilde_decode,
|
||||
tilde_encode,
|
||||
escape_sqlite,
|
||||
filters_should_redirect,
|
||||
format_bytes,
|
||||
is_url,
|
||||
path_from_row_pks,
|
||||
path_with_added_args,
|
||||
|
|
@ -175,14 +177,18 @@ class RowTableShared(DataView):
|
|||
if plugin_display_value:
|
||||
display_value = plugin_display_value
|
||||
elif isinstance(value, bytes):
|
||||
formatted = format_bytes(len(value))
|
||||
display_value = markupsafe.Markup(
|
||||
'<a class="blob-download" href="{}"><Binary: {} byte{}></a>'.format(
|
||||
'<a class="blob-download" href="{}"{}><Binary: {:,} byte{}></a>'.format(
|
||||
self.ds.urls.row_blob(
|
||||
database,
|
||||
table,
|
||||
path_from_row_pks(row, pks, not pks),
|
||||
column,
|
||||
),
|
||||
' title="{}"'.format(formatted)
|
||||
if "bytes" not in formatted
|
||||
else "",
|
||||
len(value),
|
||||
"" if len(value) == 1 else "s",
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue