Esempio n. 1
0
    def __get_catalog_page_list(self, d):
        """
        XXX: Only for root and one level dir.
        """
        catalog_page_list = {}
        sub_dirs = [unicode(_, "utf-8") for _ in \
                utils.listdir_nohidden(d)]
        for sub_dir in sub_dirs:
            abs_sub_dir = osp.join(self.site_settings["source"], sub_dir)
            # If file under the root of content directory, ignore it.
            # TODO: support root level.
            if not osp.isdir(abs_sub_dir):
                continue
            catalog_page_list[sub_dir] = []
            for f in utils.listdir_nohidden(abs_sub_dir):
                if osp.isdir(f):
                    catalog_page_list[sub_dir][f] = {}
                if not utils.check_extension(f):
                    continue
                fn = osp.join(abs_sub_dir, f)
                pg = PageGenerator(self.site_settings, self.base_path, fn)
                metadata, _ = pg.get_metadata_and_content()
                r, e = osp.splitext(f)
                metadata.update(name = r)
                catalog_page_list[sub_dir].append(metadata)
            catalog_page_list[sub_dir].sort(
                key = lambda p: p["title"].lower()
            )

        return catalog_page_list
Esempio n. 2
0
    def get_first_page(self):
        nohidden_dir = listdir_nohidden(osp.join(self.current_dir, "content/"))
        # If there is directory under content, do not create first page
        if next(nohidden_dir, False):
            return

        src_fabfile = osp.join(osp.dirname(__file__), "conf_templates/gettingstarted.md")
        dst_fabfile = osp.join(self.current_dir, "content/intro/gettingstarted.md")
        self.get_file(src_fabfile, dst_fabfile)
Esempio n. 3
0
    def get_demo_page(self):
        nohidden_dir = listdir_nohidden(os.path.join(self.target_path, self.config["source"]))
        # If there is file/directory under content, do not create first page
        if next(nohidden_dir, False):
            return

        src_demo = os.path.join(self.source_path, self.conf_template_dn, self.demo_fn)
        dst_demo = os.path.join(self.target_path, "content", "intro", self.demo_fn)
        self.get_file(src_demo, dst_demo)
Esempio n. 4
0
    def get_first_page(self):
        nohidden_dir = listdir_nohidden(osp.join(self.current_dir, "content/"))
        # If there is directory under content, do not create first page
        if next(nohidden_dir, False):
            return

        src_fabfile = osp.join(osp.dirname(__file__),
                               "conf_templates/gettingstarted.md")
        dst_fabfile = osp.join(self.current_dir,
                               "content/intro/gettingstarted.md")
        self.get_file(src_fabfile, dst_fabfile)
Esempio n. 5
0
    def get_first_page(self):
        nohidden_dir = listdir_nohidden(
            os.path.join(self.target_path, "content"))
        # If there is file/directory under content, do not create first page
        if next(nohidden_dir, False):
            return

        src_fabfile = os.path.join(self.source_path, "conf_templates",
                                   "gettingstarted.md")
        dst_fabfile = os.path.join(self.target_path, "content", "intro",
                                   "gettingstarted.md")
        self.get_file(src_fabfile, dst_fabfile)
Esempio n. 6
0
    def get_demo_page(self):
        nohidden_dir = listdir_nohidden(
            os.path.join(self.target_path, self.config['source']))
        # If there is file/directory under content, do not create first page
        if next(nohidden_dir, False):
            return

        src_demo = os.path.join(self.source_path, self.conf_template_dn,
                                self.demo_fn)
        dst_demo = os.path.join(self.target_path, "content", "intro",
                                self.demo_fn)
        self.get_file(src_demo, dst_demo)
Esempio n. 7
0
    def get_first_page(self):
        nohidden_dir = listdir_nohidden(
            os.path.join(self.target_path, "content")
        )
        # If there is file/directory under content, do not create first page
        if next(nohidden_dir, False):
            return

        src_fabfile = os.path.join(
            self.source_path,
            "conf_templates",
            "gettingstarted.md"
        )
        dst_fabfile = os.path.join(
            self.target_path,
            "content",
            "intro",
            "gettingstarted.md"
        )
        self.get_file(src_fabfile, dst_fabfile)
Esempio n. 8
0
 def test_listdir_nohidden(self):
     fs = utils.listdir_nohidden(self.content)
     assert sorted(list(fs)) == sorted([
         u"Simiki介绍.md", u"hellosimiki.md", u"simiki.md",
         u"zen_of_python.txt", u"介绍.md"
     ])
Esempio n. 9
0
 def test_listdir_nohidden(self):
     fs = utils.listdir_nohidden(os.path.join(self.content, '其它'))
     expected_listdir = ['hello.txt', 'helloworld.markdown', '维基.md']
     assert sorted(list(fs)) == sorted(expected_listdir)
Esempio n. 10
0
 def test_listdir_nohidden(self):
     fs = utils.listdir_nohidden(self.content)
     assert sorted(list(fs)) == sorted([u"Simiki介绍.md", u"hellosimiki.md",
                                        u"simiki.md", u"zen_of_python.txt",
                                        u"介绍.md"])
Esempio n. 11
0
 def test_listdir_nohidden(self):
     fs = utils.listdir_nohidden(os.path.join(self.content, '其它'))
     expected_listdir = ['hello.txt', 'helloworld.markdown', '维基.md']
     assert sorted(list(fs)) == sorted(expected_listdir)