lino.core.renderer¶
Defines HtmlRenderer
and TextRenderer
.
(This module's source code is available here.)
Functions
|
|
|
Classes
|
A Lino renderer for producing HTML content. |
|
A Lino renderer for HTML with JavaScript. |
|
Base class for all Lino renderers. |
|
Like |
|
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.
-
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.
Return an etree element of a
<a href>
tag which when clicked would execute the given bound action ba.
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.
Return a button which opens the given table request in its own window.
Render the given bound action ba as an action button.
Returns a HTML tree element.
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.
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.
Return a HTML fragment that displays a button-like link which runs the bound action ba when clicked.
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.
Render the given menu as an HTML etree element.
Used by bootstrap3 front end.
-
-
class
lino.core.renderer.
TextRenderer
(*args, **kw)¶ Bases:
lino.core.renderer.HtmlRenderer
Renders things as reStructuredText to stdout.
Used for doctests and console output. See also
TestRenderer
.-
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)¶
-
-
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
andlino_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
andlino_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()
.
-