예제 #1
0
파일: generator.py 프로젝트: SPlyer/hyde
    def __init__(self, site):
        super(Generator, self).__init__()
        self.site = site
        self.generated_once = False
        self.deps = Dependents(site.sitepath)
        self.create_context()
        self.template = None
        Plugin.load_all(site)

        self.events = Plugin.get_proxy(self.site)
예제 #2
0
파일: generator.py 프로젝트: wilsoniya/hyde
    def __init__(self, site):
        super(Generator, self).__init__()
        self.site = site
        self.generated_once = False
        self.deps = Dependents(site.sitepath)
        self.create_context()
        self.template = None
        Plugin.load_all(site)

        self.events = Plugin.get_proxy(self.site)
    def __init__(self, site):

        if os.path.isdir('cache'):
            shutil.rmtree('cache')
        os.mkdir('cache')

        Plugin.__init__(self, site)
        self.index = []

        self.globals = {'command_line_help': self.command_line_help,
                        'json_command_line_help': self.json_command_line_help,
                        'page_header': self.page_header,
                        'edit': self.edit}
예제 #4
0
파일: generator.py 프로젝트: chewable/hyde
    def __init__(self, site):
        super(Generator, self).__init__()
        self.site = site
        self.generated_once = False
        self.__context__ = dict(site=site)
        if hasattr(site.config, 'context'):
            site.context = Context.load(site.sitepath, site.config.context)
            self.__context__.update(site.context)

        self.template = None
        Plugin.load_all(site)

        self.events = Plugin.get_proxy(self.site)
예제 #5
0
파일: generator.py 프로젝트: alanhogan/hyde
    def __init__(self, site):
        super(Generator, self).__init__()
        self.site = site
        self.generated_once = False
        self.deps = Dependents(site.sitepath)
        self.__context__ = dict(site=site)
        if hasattr(site.config, 'context'):
            site.context = Context.load(site.sitepath, site.config.context)
            self.__context__.update(site.context)

        self.template = None
        Plugin.load_all(site)

        self.events = Plugin.get_proxy(self.site)
예제 #6
0
    def __init__(self, site):

        if os.path.isdir('cache'):
            shutil.rmtree('cache')
        os.mkdir('cache')

        Plugin.__init__(self, site)
        self.index = []

        self.globals = {
            'command_line_help': self.command_line_help,
            'json_command_line_help': self.json_command_line_help,
            'page_header': self.page_header,
            'edit': self.edit
        }
    def begin_text_resource(self, resource, text):
        text = self.expand_sections(text)

        def acall(*args, **kwargs):
            print args
            print kwargs
        resource.pdb = acall


        resource.xindex = []

        def r_add_index(title, level=1):
            anchor = make_anchor(title)
            xindex = resource.xindex
            while level > 1:
                xindex = xindex[-1][-1]
                level -= 1
            xindex.append([title, anchor, []])
            return link(anchor)

        resource.add_index = r_add_index
        resource.add_subindex = lambda title: r_add_index(title, 2)
        resource.add_subsubindex = lambda title: r_add_index(title, 3)

        self.template.env.globals.update(self.globals)

        return Plugin.begin_text_resource(self, resource, text)
예제 #8
0
    def begin_text_resource(self, resource, text):
        text = self.expand_sections(text)

        def acall(*args, **kwargs):
            print args
            print kwargs

        resource.pdb = acall

        resource.xindex = []

        def r_add_index(title, level=1):
            anchor = make_anchor(title)
            xindex = resource.xindex
            while level > 1:
                xindex = xindex[-1][-1]
                level -= 1
            xindex.append([title, anchor, []])
            return link(anchor)

        resource.add_index = r_add_index
        resource.add_subindex = lambda title: r_add_index(title, 2)
        resource.add_subsubindex = lambda title: r_add_index(title, 3)

        self.template.env.globals.update(self.globals)

        return Plugin.begin_text_resource(self, resource, text)
예제 #9
0
 def __init__(self, site, gopher, gopher_menu):
     self.site = site
     self.gopher = gopher
     self.gopher_menu = gopher_menu
     plugins = Plugin(site)
     plugins.load_all(site)
     self.events = Plugin.get_proxy(site)
     generator_proxy = GeneratorProxy(
         context_for_path=None,
         preprocessor=self.events.begin_text_resource,
         postprocessor=self.events.text_resource_complete,
     )
     self.templates = Template.find_template(site)
     self.templates.configure(self.site, engine=generator_proxy)
     self.events.template_loaded(self.templates)
     self.site.content.load()
     self.templates.env.globals.update(self.site.config.context.data)
     self.events.begin_generation()
     self.events.begin_site()
예제 #10
0
 def template_loaded(self, template):
     Plugin.template_loaded(self, template)
     template.env.globals['now'] = datetime.now()
     template.env.globals['xmldatetime'] = xmldatetime
 def text_resource_complete(self, resource, text):
     for pattern, repl in self.POST_REPLACEMENT_MACROS:
         text = re.sub(pattern, repl, text)
     return Plugin.text_resource_complete(self, resource, text)
예제 #12
0
 def text_resource_complete(self, resource, text):
     for pattern, repl in self.POST_REPLACEMENT_MACROS:
         text = re.sub(pattern, repl, text)
     return Plugin.text_resource_complete(self, resource, text)
예제 #13
0
    def test_can_load_plugin_modules(self):
        assert not len(self.site.plugins)
        Plugin.load_all(self.site)

        assert len(self.site.plugins) == 1
        assert self.site.plugins[0].__class__.__name__ == 'PluginLoaderStub'
예제 #14
0
    def test_can_load_plugin_modules(self):
        assert not len(self.site.plugins)
        Plugin.load_all(self.site)

        assert len(self.site.plugins) == 1
        assert self.site.plugins[0].__class__.__name__ == 'PluginLoaderStub'