Ejemplo n.º 1
0
    def __init__(self, project, name):
        self._project = project
        self._name = name
        self._dir = os.path.join(self._project.getConfig(["dirs", "layouts"]), name)
        self._other_files = []

        self._files = {}
        self._files["template"] = os.path.join(self._dir, "template.html")
        self._files["entry"] = os.path.join(self._dir, "blog", "entry.html")
        self._files["separator"] = os.path.join(self._dir, "blog", "separator.html")
        self._files["begin"] = os.path.join(self._dir, "blog", "begin.html")
        self._files["end"] = os.path.join(self._dir, "blog", "end.html")
        self._files["singleentry"] = os.path.join(self._dir, "blog", "singleentry.html")

        self._templates = {}

        print("Found layout: " + self._name)

        # Check if template files exist and read them
        for i in self._files:
            try:
                self._templates[i] = open(self._files[i]).read()
            except IOError as e:
                fail('Error reading "' + self._files[i] + '": ' + str(e))

        # Search other files (CSS, images, ...)
        for f in findFiles(self._dir, [".html"]):
            print("\tFound file: " + f)
            self._other_files.append(OtherFile(self._dir, os.path.relpath(f, self._dir)))
Ejemplo n.º 2
0
 def _read(self):
     for f in findFiles(self.getAbsDir()):
         if isCont(f, self._site):
             # meta = (time, title)
             meta = self._getMeta(f)
             if meta:
                 print("\tFound blog entry: " + f)
                 self._entries[meta[0]] = (meta[1], f)
             else:
                 print("\tWarning: content file with invalid filename for blog: " + f)
         else:
             pass  # FIXME: OtherFile
Ejemplo n.º 3
0
    def read(self):
        # read site specific config
        filename = os.path.join(self.getConfig(["dirs", "sites"]), self._name + ".json")
        if not os.path.isfile(filename):
            fail("Can't find config file: " + filename)
        site_config = Config(filename, Config.site_struct)
        self._config = Config.merge(self._config, site_config, True)

        # create file index
        path = self.getAbsDestPath()
        if os.path.isdir(path):
            self._file_index = findFiles(path)

        # read all pages
        self._readHelper(self.getAbsSrcPath(), self._root)