lino.core.renderer

Defines HtmlRenderer and TextRenderer.

(This module's source code is available here.)

Functions

add_user_language(kw, ar)

jscompress(s)

Classes

HtmlRenderer([front_end])

A Lino renderer for producing HTML content.

JsRenderer([front_end])

A Lino renderer for HTML with JavaScript.

Renderer([front_end])

Base class for all Lino renderers.

TestRenderer(*args, **kw)

Like TextRenderer but returns a string instead of printing to stdout.

TextRenderer(*args, **kw)

Lino renderer which renders tables as reStructuredText to stdout.

class lino.core.renderer.Renderer(front_end=None)

Bases: object

Base class for all Lino renderers.

See Introduction to Front end Renderers.

hide_dashboard_items = False

Don't show dashboard items when rendering admin_main.html.

ar2js(ar, obj, **status)

Return the Javascript code that would run this ar on the client.

render_action_response(ar)

Builds a JSON response from response information stored in given ActionRequest.

class lino.core.renderer.HtmlRenderer(front_end=None)

Bases: lino.core.renderer.Renderer

A Lino renderer for producing HTML content.

cellattrs = {'class': 'text-cell'}

The default attributes to be applied to every table cell.

reload_js()

Returns a js string to go inside of a href in the dashboard for reloading the dashboard.

js2url(js)

There is no Javascript here.

html_text(html)

Render a chunk of HTML text.

This does nothing, it just returns the given chunk of HTML. Except on ExtJS, where it wraps the chunk into an additional <div class="htmlText"></div> tag.

table2story(ar, nosummary=False, stripped=True, show_links=False, header_level=None, display_mode=None, **kwargs)

Returns a HTML element representing the given action request as a table. See ar.show.

Silently ignores the parameters stripped and header_links since for HTML these options have no meaning.

request_handler(ar, *args, **kw)

Return a string with Javascript code that would run the given action request ar.

instance_handler(ar, obj, ba)

Return a string of Javascript code which would open a detail window on the given database object.

href_to_request(ar, tar, text=None, **kw)

Return a string with an URL which would run the given target request tar.

href_button_action(ba, url, text=None, title=None, icon_name=<class 'django.db.models.fields.NOT_PROVIDED'>, **kw)

Return an etree element of a <a href> tag which when clicked would execute the given bound action ba.

href_button(url, text, title=None, icon_name=None, **kw)

Return an etree element of a <a href> tag to the given URL url.

url is what goes into the href part. If url is None, then we return just a <b> tag.

text is what goes between the <a> and the </a>. This can be either a string or a tuple (or list) of strings (or etree elements).

action_call(ar, ba, status)

Returns the action name. This is not a valid link, but it's important to differentiate between clickable and non-clickable obj2html() calls.

open_in_own_window_button(ar)

Return a button which opens the given table request in its own window.

window_action_button(ar, ba, status={}, label=None, title=None, **kw)

Render the given bound action ba as an action button.

Returns a HTML tree element.

quick_add_buttons(ar)

Returns a HTML chunk that displays "quick add buttons" for the given action request: a button [New] followed possibly (if the request has rows) by a [Show last] and a [Show all] button.

See also docs/tickets/56.

obj2html(ar, obj, text=None, **kwargs)

Return a html representation of a pointer to the given database object.

Examples see Pointing to a database object.

menu_item_button(ar, mi, label=None, icon_name=None, **kwargs)

Render the given menu item mi as an action button.

Returns a HTML tree element. Currently supports only window actions.

action_call_on_instance(obj, ar, ba, request_kwargs={}, **st)

Return a string with Javascript code that would run the given action ba on the given model instance obj. The second parameter (ar) is the calling action request.

row_action_button(obj, ar, ba, label=None, title=None, request_kwargs={}, **kw)

Return a HTML fragment that displays a button-like link which runs the bound action ba when clicked.

row_action_button_ar(obj, ar, label=None, title=None, request_kwargs={}, **kw)

Return a HTML fragment that displays a button-like link which runs the action request ar when clicked.

show_story(ar, story, stripped=True, **kwargs)

Render the given story and return it as a raw HTML string.

Ignore stripped because it makes no sense in HTML.

show_menu(ar, mnu, level=1)

Render the given menu as an HTML element. Used for writing test cases.

class lino.core.renderer.TextRenderer(*args, **kw)

Bases: lino.core.renderer.HtmlRenderer

Lino renderer which renders tables as reStructuredText to stdout. Used for doctests and console output. See also TestRenderer.

menu2rst(ar, mnu, level=1)

Used by show_menu().

show_menu(ar, mnu, stripped=True, level=1)

Render the given menu as a reStructuredText formatted bullet list. Called from lino.core.requests.BaseRequest.show_menu().

Stripped

remove lots of blanklines which are necessary for reStructuredText but disturbing in a doctest snippet.

table2story(ar, column_names=None, header_level=None, header_links=None, nosummary=False, stripped=True, show_links=False, display_mode=None, **kwargs)

Render the given table request as reStructuredText to stdout. See ar.show.

show_story(ar, story, stripped=True, **kwargs)

Render the given story as reStructuredText to stdout.

obj2str(ar, obj, text=None, **kwargs)

Used by lino.core.requests.BaseRequest.obj2str().

class lino.core.renderer.TestRenderer(*args, **kw)

Bases: lino.core.renderer.TextRenderer

Like TextRenderer but returns a string instead of printing to stdout.

Experimentally used in lino_book.projects.watch.tests and lino_book.projects.lydia.tests.

class lino.core.renderer.JsRenderer(front_end=None)

Bases: lino.core.renderer.HtmlRenderer

A Lino renderer for HTML with JavaScript. Common base for lino_react.react.renderer.Renderer, lino.modlib.extjs.ext_renderer.ExtRenderer and lino_extjs6.extjs.ext_renderer.ExtRenderer.

reload_js()

Returns a js string to go inside of a href in the dashboard for reloading the dashboard.

goto_instance(ar, obj, detail_action=None, **kw)

Ask the client to display a detail window on the given record. The client might ignore this if Lino does not know a detail window.

This is a utility wrapper around set_response() which sets either data_record or a record_id.

Usually data_record, except if it is a file upload where some mysterious decoding problems (2012-02-09) force us to return a record_id which has the same visible result but using an additional GET.

If the calling window is a detail on the same table, then it should simply get updated to the given record. Otherwise open a new detail window.

If the detail layout of the current actor can be used for the object to be displayed, we don't want to open a new detail window.

This calls obj.get_detail_action.

ar2js(ar, obj, **status)

Implements lino.core.renderer.HtmlRenderer.ar2js().