Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, opts, storage, search):
super(Environment, self).__init__()
self.opts = opts
self.storage = storage
self.search = search
self.parser = Parser(create_dialect(creole11_base,
macro_func=macros.dispatcher, wiki_links_base_url="/"),
method="xhtml")
self.templates = TemplateLoader(os.path.join(os.path.dirname(__file__),
"templates"), auto_reload=True)
self.macros = macros.loadMacros()
self.stylesheets = []
self.version = __version__()
self.site = {
"name": self.opts.name,
"author": self.opts.author,
"keywords": self.opts.keywords,
"description": self.opts.description}
#!/usr/bin/env python
import os
import sqlite3
import macros
from creoleparser import Parser, create_dialect, creole11_base
import circuits
from circuits.web import Controller, Logger, Server, Static
text2html = Parser(
create_dialect(creole11_base, macro_func=macros.dispatcher),
method="xhtml"
)
class Wiki(object):
def __init__(self, database):
super(Wiki, self).__init__()
create = not os.path.exists(database)
self._cx = sqlite3.connect(database)
self._cu = self._cx.cursor()
if create:
self._cu.execute("CREATE TABLE pages (name, text)")
def activitylink_macro(macro, environ, *act_name):
return _activitylink(self.offering, macro, environ, *act_name)
def pagelist_macro(macro, environ, prefix=None):
return _pagelist(self.offering, self.pageversion, macro, environ, prefix)
if self.offering:
nb_macros = {
'duedate': duedate_macro,
'duedatetime': duedatetime_macro,
'pagelist': pagelist_macro,
'activitylink': activitylink_macro,
}
else:
nb_macros = None
CreoleBase = creoleparser.creole11_base(non_bodied_macros=nb_macros, add_heading_ids='h-')
class CreoleDialect(CreoleBase):
codeblock = CodeBlock()
abbracronym = AbbrAcronym()
htmlentity = HTMLEntity()
strikethrough = creoleparser.elements.InlineElement('del', '--')
def __init__(self):
self.custom_elements = [self.abbracronym, self.strikethrough]
super(CreoleDialect, self).__init__()
@property
def inline_elements(self):
inline = super(CreoleDialect, self).inline_elements
inline.append(self.abbracronym)
inline.append(self.strikethrough)
def activitylink_macro(macro, environ, *act_name):
return _activitylink(self.offering, macro, environ, *act_name)
def pagelist_macro(macro, environ, prefix=None):
return _pagelist(self.offering, self.pageversion, macro, environ, prefix)
if self.offering:
nb_macros = {
'duedate': duedate_macro,
'duedatetime': duedatetime_macro,
'pagelist': pagelist_macro,
'activitylink': activitylink_macro,
}
else:
nb_macros = None
CreoleBase = creoleparser.creole11_base(non_bodied_macros=nb_macros, add_heading_ids='h-')
class CreoleDialect(CreoleBase):
codeblock = CodeBlock()
abbracronym = AbbrAcronym()
htmlentity = HTMLEntity()
strikethrough = creoleparser.elements.InlineElement('del','--')
def __init__(self):
self.custom_elements = [self.abbracronym, self.strikethrough]
super(CreoleDialect,self).__init__()
@property
def inline_elements(self):
inline = super(CreoleDialect, self).inline_elements
inline.append(self.abbracronym)
inline.append(self.strikethrough)
self.storage = DefaultStorage(
self.config,
self.config.get("repo"),
charset=self.config.get("encoding"),
)
self.search = WikiSearch(
self.dbm.session,
self.config.get("language"),
self.storage,
)
self.parser = Parser(
create_dialect(
creole11_base,
macro_func=macros.dispatcher,
wiki_links_base_url="/",
wiki_links_class_func=self._wiki_links_class_func,
wiki_links_path_func=self._wiki_links_path_func,
),
method="xhtml"
)
template_config = {
"allow_exec": False,
"auto_reload": True,
"default_encoding": self.config.get("encoding"),
"search_path": [
self.storage.path,
os.path.join(self.config.get("theme"), "templates"),
],