.oO SearXNG Developer Documentation Oo.
Loading...
Searching...
No Matches
searx.infopage.InfoPage Class Reference

Public Member Functions

 __init__ (self, fname)
 
 raw_content (self)
 
 content (self)
 
 title (self)
 
 html (self)
 
 get_ctx (self)
 
 __repr__ (self)
 

Public Attributes

 fname = fname
 
 content
 

Detailed Description

A page of the :py:obj:`online documentation <InfoPageSet>`.

Definition at line 54 of file __init__.py.

Constructor & Destructor Documentation

◆ __init__()

searx.infopage.InfoPage.__init__ ( self,
fname )

Definition at line 57 of file __init__.py.

57 def __init__(self, fname):
58 self.fname = fname
59

Member Function Documentation

◆ __repr__()

searx.infopage.InfoPage.__repr__ ( self)

Definition at line 113 of file __init__.py.

113 def __repr__(self):
114 return f'<{self.__class__.__name__} fname={self.fname!r}>'
115
116

◆ content()

searx.infopage.InfoPage.content ( self)
Content of the page (rendered in a Jinja context)

Definition at line 67 of file __init__.py.

67 def content(self):
68 """Content of the page (rendered in a Jinja context)"""
69 ctx = self.get_ctx()
70 template = jinja2.Environment().from_string(self.raw_content)
71 return template.render(**ctx)
72

References searx.infopage.InfoPage.get_ctx(), and searx.infopage.InfoPage.raw_content().

+ Here is the call graph for this function:

◆ get_ctx()

searx.infopage.InfoPage.get_ctx ( self)
Jinja context to render :py:obj:`InfoPage.content`

Definition at line 94 of file __init__.py.

94 def get_ctx(self):
95 """Jinja context to render :py:obj:`InfoPage.content`"""
96
97 def _md_link(name, url):
98 url = url_for(url, _external=True)
99 return "[%s](%s)" % (name, url)
100
101 def _md_search(query):
102 url = '%s?q=%s' % (url_for('search', _external=True), urllib.parse.quote(query))
103 return '[%s](%s)' % (query, url)
104
105 ctx = {}
106 ctx['GIT_URL'] = GIT_URL
107 ctx['get_setting'] = get_setting
108 ctx['link'] = _md_link
109 ctx['search'] = _md_search
110
111 return ctx
112

Referenced by searx.infopage.InfoPage.content().

+ Here is the caller graph for this function:

◆ html()

searx.infopage.InfoPage.html ( self)
Render Markdown (CommonMark_) to HTML by using markdown-it-py_.

.. _CommonMark: https://commonmark.org/
.. _markdown-it-py: https://github.com/executablebooks/markdown-it-py

Definition at line 83 of file __init__.py.

83 def html(self):
84 """Render Markdown (CommonMark_) to HTML by using markdown-it-py_.
85
86 .. _CommonMark: https://commonmark.org/
87 .. _markdown-it-py: https://github.com/executablebooks/markdown-it-py
88
89 """
90 return (
91 MarkdownIt("commonmark", {"typographer": True}).enable(["replacements", "smartquotes"]).render(self.content)
92 )
93

◆ raw_content()

searx.infopage.InfoPage.raw_content ( self)
Raw content of the page (without any jinja rendering)

Definition at line 61 of file __init__.py.

61 def raw_content(self):
62 """Raw content of the page (without any jinja rendering)"""
63 with open(self.fname, 'r', encoding='utf-8') as f:
64 return f.read()
65

References searx.infopage.InfoPage.fname.

Referenced by searx.infopage.InfoPage.content(), and searx.infopage.InfoPage.title().

+ Here is the caller graph for this function:

◆ title()

searx.infopage.InfoPage.title ( self)
Title of the content (without any markup)

Definition at line 74 of file __init__.py.

74 def title(self):
75 """Title of the content (without any markup)"""
76 t = ""
77 for l in self.raw_content.split('\n'):
78 if l.startswith('# '):
79 t = l.strip('# ')
80 return t
81

References searx.infopage.InfoPage.raw_content().

+ Here is the call graph for this function:

Member Data Documentation

◆ content

searx.infopage.InfoPage.content

Definition at line 91 of file __init__.py.

◆ fname

searx.infopage.InfoPage.fname = fname

Definition at line 58 of file __init__.py.

Referenced by searx.infopage.InfoPage.raw_content().


The documentation for this class was generated from the following file: