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

Detailed Description

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

Definition at line 42 of file __init__.py.

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 45 of file __init__.py.

45 def __init__(self, fname):
46 self.fname = fname
47

Member Function Documentation

◆ __repr__()

searx.infopage.InfoPage.__repr__ ( self)

Definition at line 101 of file __init__.py.

101 def __repr__(self):
102 return f'<{self.__class__.__name__} fname={self.fname!r}>'
103
104

◆ content()

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

Definition at line 55 of file __init__.py.

55 def content(self):
56 """Content of the page (rendered in a Jinja context)"""
57 ctx = self.get_ctx()
58 template = jinja2.Environment().from_string(self.raw_content)
59 return template.render(**ctx)
60

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 82 of file __init__.py.

82 def get_ctx(self):
83 """Jinja context to render :py:obj:`InfoPage.content`"""
84
85 def _md_link(name, url):
86 url = url_for(url, _external=True)
87 return "[%s](%s)" % (name, url)
88
89 def _md_search(query):
90 url = '%s?q=%s' % (url_for('search', _external=True), urllib.parse.quote(query))
91 return '[%s](%s)' % (query, url)
92
93 ctx = {}
94 ctx['GIT_URL'] = GIT_URL
95 ctx['get_setting'] = get_setting
96 ctx['link'] = _md_link
97 ctx['search'] = _md_search
98
99 return ctx
100

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 71 of file __init__.py.

71 def html(self):
72 """Render Markdown (CommonMark_) to HTML by using markdown-it-py_.
73
74 .. _CommonMark: https://commonmark.org/
75 .. _markdown-it-py: https://github.com/executablebooks/markdown-it-py
76
77 """
78 return (
79 MarkdownIt("commonmark", {"typographer": True}).enable(["replacements", "smartquotes"]).render(self.content)
80 )
81

◆ raw_content()

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

Definition at line 49 of file __init__.py.

49 def raw_content(self):
50 """Raw content of the page (without any jinja rendering)"""
51 with open(self.fname, 'r', encoding='utf-8') as f:
52 return f.read()
53

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 62 of file __init__.py.

62 def title(self):
63 """Title of the content (without any markup)"""
64 t = ""
65 for l in self.raw_content.split('\n'):
66 if l.startswith('# '):
67 t = l.strip('# ')
68 return t
69

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 79 of file __init__.py.

◆ fname

searx.infopage.InfoPage.fname

Definition at line 46 of file __init__.py.

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


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