Welcome | Get started | Dive | Contribute | Topics | Reference | Changes | More

lino.core.renderer

Defines HtmlRenderer and TextRenderer.

Functions

add_user_language(kw, ar)

jscompress(s)

text2rst(s)

Classes

HtmlRenderer([front_end])

A Lino renderer for producing HTML content.

JsCacheRenderer(*args, **kwargs)

Mixin for: lino_react.react.renderer.Renderer, lino.modlib.extjs.ext_renderer.ExtRenderer and lino_extjs6.extjs.ext_renderer.ExtRenderer.

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)

Renders things 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.

support_dashboard_layout = 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: Renderer

A Lino renderer for producing HTML content.

cellattrs = {'align': 'left', 'bgcolor': '#ffffff', 'valign': 'top'}

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.

show_detail(ar, obj, display_mode=None, **kwargs)

Show the window that is to be opened by ar.

The output is currently gives no beautiful representation of the window, but at least it renders all content. This is the first intended purpose: to test whether things work.

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, header_level=None, display_mode=None, **kwargs)

Returns an HTML element (or a safe html string) 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, **status)

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

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

Return a string with an URL that 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.

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).

If icon_name is given, the text will be replaced by the corresponding image, which may vary depending on the renderer.

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

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 https://gitlab.com/lino-framework/lino/blob/master/docs/tickets/56.

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

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

Examples see The summary display mode.

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={}, **button_attrs)

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 safe HTML string.

Ignore stripped because it makes no sense in HTML.

show_menu(ar, mnu, level=1)

Render the given menu as an HTML etree element.

Used by bootstrap3 front end.

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

Bases: HtmlRenderer

Renders things as reStructuredText to stdout.

Used for doctests and console output. See also TestRenderer.

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.

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.

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

Bases: TextRenderer

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

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

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

Bases: 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)

Instruct the client to display a detail window on the given record.

ar2js(ar, obj, **status)

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

class lino.core.renderer.JsCacheRenderer(*args, **kwargs)

Bases: JsRenderer

Mixin for: lino_react.react.renderer.Renderer, lino.modlib.extjs.ext_renderer.ExtRenderer and lino_extjs6.extjs.ext_renderer.ExtRenderer.

Includes linoweb.js cacheing functionality.

write_lino_js(f)
Parameters:

f – File object

Returns:

1

build_js_cache(force, verbosity=1)

Build the site cache files for the current user type and the current language. If the file exists and is up to date, don’t generate it unless force is True.