19.1.22. camcops_server.cc_modules.cc_html¶
Copyright (C) 2012-2018 Rudolf Cardinal (rudolf@pobox.com).
This file is part of CamCOPS.
CamCOPS is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
CamCOPS is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with CamCOPS. If not, see <http://www.gnu.org/licenses/>.
-
camcops_server.cc_modules.cc_html.
answer
(x: Any, default: str = '?', default_for_blank_strings: bool = False, formatter_answer: Callable[[str], str] = <function bold_webify>, formatter_blank: Callable[[str], str] = <function italic>) → str[source]¶ Formats answer in bold, or the default value if None.
Avoid the word None for the default, e.g. ‘Score indicating likelihood of abuse: None’ … may be misleading! Prefer ‘?’ instead.
-
camcops_server.cc_modules.cc_html.
bold_webify
(x: str) → str[source]¶ Webifies the string, then makes it bold.
-
camcops_server.cc_modules.cc_html.
div
(content: str, div_class: str = '') → str[source]¶ Make simple HTML div.
-
camcops_server.cc_modules.cc_html.
get_data_url
(mimetype: str, data: Union[bytes, memoryview]) → str[source]¶ - Takes data (in binary format) and returns a data URL as per RFC 2397:
- https://tools.ietf.org/html/rfc2397
- such as:
- data:MIMETYPE;base64,B64_ENCODED_DATA
-
camcops_server.cc_modules.cc_html.
get_embedded_img_tag
(mimetype: str, data: Union[bytes, memoryview]) → str[source]¶ Takes a binary image and its MIME type, and produces an HTML tag of the form:
<img src=”DATA_URL”>
-
camcops_server.cc_modules.cc_html.
get_present_absent
(req: CamcopsRequest, x: Any) → str[source]¶ ‘Present’ if x else ‘Absent’
-
camcops_server.cc_modules.cc_html.
get_present_absent_none
(req: CamcopsRequest, x: Any) → Union[str, NoneType][source]¶ Returns ‘Present’ for True, ‘Absent’ for False, or None for None.
-
camcops_server.cc_modules.cc_html.
get_present_absent_unknown
(req: CamcopsRequest, x: str) → str[source]¶ Returns ‘Present’ for True, ‘Absent’ for False, or ‘?’ for None.
-
camcops_server.cc_modules.cc_html.
get_true_false
(req: CamcopsRequest, x: Any) → str[source]¶ ‘True’ if x else ‘False’
-
camcops_server.cc_modules.cc_html.
get_true_false_none
(req: CamcopsRequest, x: Any) → Union[str, NoneType][source]¶ Returns ‘True’ for True, ‘False’ for False, or None for None.
-
camcops_server.cc_modules.cc_html.
get_true_false_unknown
(req: CamcopsRequest, x: Any) → str[source]¶ Returns ‘True’ for True, ‘False’ for False, or ‘?’ for None.
-
camcops_server.cc_modules.cc_html.
get_yes_no
(req: CamcopsRequest, x: Any) → str[source]¶ ‘Yes’ if x else ‘No’
-
camcops_server.cc_modules.cc_html.
get_yes_no_none
(req: CamcopsRequest, x: Any) → Union[str, NoneType][source]¶ Returns ‘Yes’ for True, ‘No’ for False, or None for None.
-
camcops_server.cc_modules.cc_html.
get_yes_no_unknown
(req: CamcopsRequest, x: Any) → str[source]¶ Returns ‘Yes’ for True, ‘No’ for False, or ‘?’ for None.
-
camcops_server.cc_modules.cc_html.
heading_spanning_two_columns
(s: str) → str[source]¶ HTML table heading spanning 2 columns.
-
camcops_server.cc_modules.cc_html.
subheading_spanning_four_columns
(s: str, th_not_td: bool = False) → str[source]¶ HTML table subheading spanning 4 columns.
-
camcops_server.cc_modules.cc_html.
subheading_spanning_three_columns
(s: str, th_not_td: bool = False) → str[source]¶ HTML table subheading spanning 3 columns.
-
camcops_server.cc_modules.cc_html.
subheading_spanning_two_columns
(s: str, th_not_td: bool = False) → str[source]¶ HTML table subheading spanning 2 columns.
-
camcops_server.cc_modules.cc_html.
table
(content: str, table_class: str = '') → str[source]¶ Make simple HTML table.
-
camcops_server.cc_modules.cc_html.
table_row
(columns: List[str], classes: List[str] = None, colspans: List[str] = None, colwidths: List[str] = None, default: str = '', heading: bool = False) → str[source]¶ Make HTML table row.
-
camcops_server.cc_modules.cc_html.
td
(contents: Any, td_class: str = '', td_width: str = '') → str[source]¶ Make simple HTML table data cell.
-
camcops_server.cc_modules.cc_html.
th
(contents: Any, th_class: str = '', th_width: str = '') → str[source]¶ Make simple HTML table header cell.
-
camcops_server.cc_modules.cc_html.
tr
(*args, tr_class: str = '', literal: bool = False) → str[source]¶ Make simple HTML table data row.
Parameters: - *args – Set of columns data.
- literal – Treat elements as literals with their own <td> … </td>, rather than things to be encapsulated.
- tr_class – table row class
-
camcops_server.cc_modules.cc_html.
tr_qa
(q: str, a: Any, default: str = '?', default_for_blank_strings: bool = False) → str[source]¶ Make HTML two-column data row, with right-hand column formatted as an answer.
-
camcops_server.cc_modules.cc_html.
tr_span_col
(x: str, cols: int = 2, tr_class: str = '', td_class: str = '', th_not_td: bool = False) → str[source]¶ HTML table data row spanning several columns.
Parameters: - x – Data.
- cols – Number of columns to span.
- tr_class – CSS class to apply to tr.
- td_class – CSS class to apply to td.
- th_not_td – make it a th, not a td.