Example #1
0
  def generate(self, template_list):
    self.print_message()

    for i in self.get_images():
      i.set_local_root(self.get_local_root(False))
      i.set_output_root(self.get_local_output_root(False))
      
    self.hero.set_output_root(self.get_local_output_root(False))
    
    content = util.minify_html(self.generate_html(template_list))

    filenames = []
    filenames.append(self.path)
    filenames.append(path.Path('', self.unique_hash + '/index.html'))

    # for s in self.synonyms:
    #   p = path.Path()
    #   p.copy_from(self.path)
    #   p.set_output_root(os.path.join(util.category_dir(self.category), util.text_to_shortname(s)))
    #   filenames.append(p)

    for s in self.synonyms:
      p = path.Path()
      p.copy_from(self.path)
      p.set_output_root(os.path.join(util.category_dir(self.category), util.text_to_shortname(s)))
      os.makedirs(p.get_local_output_root(), exist_ok=True)

    for filename in filenames:
      os.makedirs(filename.get_local_output_root(), exist_ok=True)
      open(filename.get_local_output_path(), 'w').write(content)
      
    self.copy_files(self.path)
Example #2
0
  def generate_missing_terms(self):
    text = open(os.path.join(dirs.src, 'missing-term.md')).read()
    for term in self.get_missing_terms():
      title = 'The entry for "' + term + '" does not exist.'
      
      page_variables = {}
      variables = {}
      
      page_variables['title'] = title
      page_variables['pagetype'] = 'missing-term'

      variables['title'] = title
      variables['text'] = util.markdown_convert(text.format(term=term))[0]

      filename = os.path.join(util.category_dir('term'), term, 'index.html')
      util.save_to(filename, self.template_list.get('missing-term', variables, page_variables))
Example #3
0
  def set_shortname(self, shortname):
    shortname = util.text_to_shortname(self.unique)
    s = shortname[:]

    i = 0
    while True:
      if self.build.post_shortname_exists(s):
        s = shortname + str(i+1)
        i += 1
        continue
      break
    
    self.shortname = s
    
    if i: print('warning: name ' + shortname + ' already exists, using ' + self.shortname + ' instead.')
    
    self.term = util.text_to_shortname(self.shortname)
    self.path.set_output_root(os.path.join(util.category_dir(self.category), self.shortname))
Example #4
0
    def generate_missing_terms(self):
        text = open(os.path.join(dirs.src, 'missing-term.md')).read()
        for term in self.get_missing_terms():
            title = 'The entry for "' + term + '" does not exist.'

            page_variables = {}
            variables = {}

            page_variables['title'] = title
            page_variables['pagetype'] = 'missing-term'

            variables['title'] = title
            variables['text'] = util.markdown_convert(
                text.format(term=term))[0]

            filename = os.path.join(util.category_dir('term'), term,
                                    'index.html')
            util.save_to(
                filename,
                self.template_list.get('missing-term', variables,
                                       page_variables))
Example #5
0
 def print_message(self):
   print('  ' + util.category_dir(self.category) + ' ' + self.shortname)