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

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 58 of file __init__.py.

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

Member Function Documentation

◆ __repr__()

searx.infopage.InfoPage.__repr__ ( self)

Definition at line 114 of file __init__.py.

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

◆ content()

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

Definition at line 68 of file __init__.py.

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

References get_ctx(), and 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 95 of file __init__.py.

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

Referenced by 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 84 of file __init__.py.

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

◆ raw_content()

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

Definition at line 62 of file __init__.py.

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

References fname.

Referenced by content(), and 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 75 of file __init__.py.

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

References raw_content().

+ Here is the call graph for this function:

Member Data Documentation

◆ content

searx.infopage.InfoPage.content

◆ fname

searx.infopage.InfoPage.fname = fname

Definition at line 59 of file __init__.py.

Referenced by raw_content().


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