예제 #1
0
파일: cli.py 프로젝트: ferstar/simiki
 def generate_catalog(self, pages):
     logger.info("Generate catalog page.")
     catalog_generator = CatalogGenerator(self.config, self.target_path,
                                          pages)
     html = catalog_generator.generate_catalog_html()
     ofile = os.path.join(self.target_path, self.config["destination"],
                          "index.html")
     write_file(ofile, html)
예제 #2
0
 def generate_catalog(self, pages):
     logger.info("Generate catalog page.")
     if self.configs["index"]:
         cgen = CustomCatalogGenerator(self.configs, os.getcwd(), None)
     else:
         cgen = CatalogGenerator(self.configs, os.getcwd(), pages)
     html = cgen.generate_catalog_html()
     ofile = osp.join(os.getcwd(), self.configs["destination"],
                      "index.html")
     write_file(html, ofile, "index")
예제 #3
0
파일: cli.py 프로젝트: sushimuyu/simiki
 def generate_catalog(self, pages):
     logger.info("Generate catalog page.")
     if self.configs["index"]:
         cgen = CustomCatalogGenerator(self.configs, self.target_path)
     else:
         cgen = CatalogGenerator(self.configs, self.target_path, pages)
     html = cgen.generate_catalog_html()
     ofile = os.path.join(self.target_path, self.configs["destination"],
                          "index.html")
     write_file(html, ofile, "index")
예제 #4
0
    def setUp(self):
        self.default_config = get_default_config()

        self.wiki_path = os.path.join(test_path, 'mywiki_for_generator')

        os.chdir(self.wiki_path)

        self.config_file = os.path.join(base_path, 'simiki', 'conf_templates',
                                        '_config.yml.in')

        self.config = parse_config(self.config_file)

        s_themes_path = os.path.join(base_path, 'simiki',
                                     self.default_config['themes_dir'])
        self.d_themes_path = os.path.join('./',
                                          self.default_config['themes_dir'])
        if os.path.exists(self.d_themes_path):
            shutil.rmtree(self.d_themes_path)
        copytree(s_themes_path, self.d_themes_path)

        self.pages = {
            'content/other/page1.md': {
                'content': '',
                'collection': 'mycoll',
                'date': '2016-06-02 00:00',
                'layout': 'page',
                'title': 'Page 1'
            },
            'content/other/page2.md': {
                'content': '',
                'date': '2016-06-02 00:00',
                'layout': 'page',
                'title': 'Page 2'
            },
            'content/other/page3.md': {
                'content': '',
                'collection': 'mycoll',
                'date': '2016-06-02 00:00',
                'layout': 'page',
                'title': 'Page 3'
            },
        }

        self.generator = CatalogGenerator(self.config, self.wiki_path,
                                          self.pages)
예제 #5
0
    def generate_catalog():
        pg = PageGenerator(_site_config, _base_path)
        pages = {}

        for root, dirs, files in os.walk(_site_config["source"]):
            files = [f for f in files if not f.startswith(".")]
            dirs[:] = [d for d in dirs if not d.startswith(".")]
            for filename in files:
                if not filename.endswith(_site_config["default_ext"]):
                    continue
                md_file = os.path.join(root, filename)
                pg.src_file = md_file
                meta, _ = pg.get_meta_and_content(do_render=False)
                pages[md_file] = meta

        cg = CatalogGenerator(_site_config, _base_path, pages)
        html = cg.generate_catalog_html()
        ofile = os.path.join(_base_path, _site_config['destination'],
                             "index.html")
        write_file(ofile, html)
        logging.debug('Regenerating catalog')