Ejemplo n.º 1
0
    def get_best_face_markdown(self):
        if self.check_scholar_photo_valid():
            return DuMark.get_image('../' + self._get_local_scholar_photo_url,
                                    self.get_name())

        if 'face' in self._data:
            return DuMark.get_image(self._data['face'], self.get_name())
        else:
            return ''
Ejemplo n.º 2
0
 def export_html(self, filename):
     """ Exports HTML for debugging only. """
     Utils.set_to_print_web()
     s = DuMark.get_h1('List of publications (temporary)')
     i = 0
     for k in self._keys:
         d = self._data[k]
         if not d.is_visible():
             continue
         d.debug_pdf()
         i += 1
         s += '[%d] ' % i
         s += d.get_authors().get_markdown()
         s += '. '
         s += d.get_title_markdown()
         s += ' '
         s += d.get_lowres_markdown()
         s += ' '
         s += d.get_book()
         s += '. '
         s += d.get_year()
         s += '.'
         s += Utils.get_separator()
     s += DEBUG_HTML_SCRIPT
     s = htmlmin.minify(markdown(s))
     with open(filename, 'w', encoding='utf8') as f:
         f.write(s)
Ejemplo n.º 3
0
 def get_lowres_markdown(self):
     if self._data['lowres']:
         return DuMark.get_paper(
             self.get_filename() + '_lowres', 'lowres',
             self._data['title'] + ' low resolution file')
     else:
         return ''
Ejemplo n.º 4
0
 def get_youtube_markdown(self):
     return DuMark.get_youtube(self._data['youtube'])
Ejemplo n.º 5
0
 def get_supp_markdown(self):
   if 'supp' in self._data:
     return DuMark.get_url(self._data['supp'], 'supp')
   else:
     return ''
Ejemplo n.º 6
0
 def get_code_markdown(self):
   if self._data['code']:
     return DuMark.get_url(self._data['code'], 'code')
   else:
     return ''
Ejemplo n.º 7
0
 def get_video_markdown(self):
   if self._data['video']:
     return DuMark.get_url(self._data['video'], 'video')
   else:
     return ''
Ejemplo n.º 8
0
 def get_teaser_markdown(self):
   """Returns teaser markdown."""
   return DuMark.get_image('/%s/%s.jpg' % (Dir.teasers, self.get_bib_id()),
                           '%s Teaser Image.' % self._data['title'])
Ejemplo n.º 9
0
 def get_doi_markdown(self):
   return DuMark.get_url('https://doi.org/%s' % self.get_doi(), 'doi')
Ejemplo n.º 10
0
 def get_facebook_markdown(self):
     return DuMark.get_facebook(self._data['FB'])
Ejemplo n.º 11
0
 def get_email_markdown(self):
     return DuMark.get_email(self._data['email'])
Ejemplo n.º 12
0
 def get_website_markdown(self):
     return DuMark.get_website(self._data['web'])
Ejemplo n.º 13
0
 def get_face_raw_markdown(self):
     if 'face' in self._data:
         return DuMark.get_image(self._data['face'], self.get_name())
     else:
         return ''
Ejemplo n.º 14
0
 def get_name_google_markdown(self):
     return DuMark.get_google(self.get_name())
Ejemplo n.º 15
0
 def get_researchgate_markdown(self):
     return DuMark.get_researchgate(self._data['gate'])
Ejemplo n.º 16
0
 def get_name_markdown(self):
     if 'web' in self._data and self._data['web'] and not self.is_me():
         return DuMark.get_website(self._data['web'], str(self))
     else:
         return str(self)
Ejemplo n.º 17
0
 def get_twitter_markdown(self):
     return DuMark.get_twitter(self._data['twitter'])
Ejemplo n.º 18
0
 def get_pdf_markdown(self):
   return DuMark.get_paper(self.get_filename(), 'pdf', self._data['title'])
Ejemplo n.º 19
0
 def get_scholar_markdown(self):
     return DuMark.get_scholar(self._data['scholar'])
Ejemplo n.º 20
0
 def get_web_markdown(self):
   return DuMark.get_url(self.get_web_url(), 'website')
Ejemplo n.º 21
0
 def get_linkedin_markdown(self):
     return DuMark.get_linkedin(self._data['linkedin'])
Ejemplo n.º 22
0
 def get_slides_markdown(self):
   if self._data['slides']:
     return DuMark.get_url(self._data['slides'], 'slides')
   else:
     return ''
Ejemplo n.º 23
0
 def get_instagram_markdown(self):
     return DuMark.get_instagram(self._data['instagram'])
Ejemplo n.º 24
0
 def get_demo_markdown(self):
   if self._data['demo']:
     return DuMark.get_url(self._data['demo'], 'demo')
   else:
     return ''
Ejemplo n.º 25
0
 def get_github_markdown(self):
     return DuMark.get_github(self._data['github'])
Ejemplo n.º 26
0
    def compile(self, filename, write_to_file=False):
        """Generates HTML files with Markdown templates.

    Args:
      filename: input filename with predefined grammar rules.

    Returns:
      html: HTML contents of this file.
    """
        if filename in self.built_html:
            logging.info("Reusing HTML: %s" % filename)
            return self.built_html[filename]
        html = ''

        input_filename = os.path.join(Dir.templates, filename)
        output_filename = os.path.join(Dir.builds, filename)

        # Parses the HTML line by line.
        with open(input_filename, 'r', encoding='utf8') as f:
            lines = f.readlines()

        for line in lines:
            # Early pruning for non-special rules.
            if line.find('<!--') == -1 and line.find('{{') == -1:
                html += line
                continue

            # 0. Parses variable meta commands.
            ans = Regex.ASSIGN.search(line)
            if ans:
                lhs = ans.group(1)
                rhs = ans.group(2)
                self._assign_dict[lhs] = rhs
                continue

            # 1. Recursively parses the included file.
            ans = Regex.INCLUDE.search(line)
            if ans:
                include_filename = ans.group(1)
                logging.info('Including HTML: %s' % include_filename)
                include_content = self.compile(include_filename)
                html += include_content
                continue

            # 2. Parses, compresses, and writes the css file.
            ans = Regex.CSS.search(line)
            if ans:
                css_filename = ans.group(1)
                logging.info('Minimizing CSS: %s' % css_filename)
                self.compile_css(css_filename)
                css_filename = os.path.join(Dir.css,
                                            css_filename).replace('\\', '/')
                html += '<link rel="stylesheet" href="/%s" />' % css_filename
                continue

            # 3. Parses, compresses, and writes the js file.
            ans = Regex.JS.search(line)
            if ans:
                js_filename = ans.group(1)
                logging.info("~ Minimizing JS: %s" % js_filename)
                self.compile_js(js_filename)
                js_filename = os.path.join(Dir.js,
                                           js_filename).replace('\\', '/')
                html += '<script src="/%s"></script>' % js_filename
                continue

            # 4. Parses image file inline.
            ans = Regex.IMAGE.search(line)
            if ans:
                image_filename = os.path.join(Dir.images,
                                              ans.group(1)).replace('\\', '/')
                image_description = self.parse_variable(ans.group(2))
                line = DuMark.get_image('/' + image_filename,
                                        image_description)
                line = markdown(line)

            # 5. Parses publication file inline.
            ans = Regex.PUBLICATION.search(line)
            if ans:
                pub_filename = os.path.join(Dir.templates, ans.group(1))
                line = self.compile_publication(pub_filename)

            # 6. Parses art file inline.
            ans = Regex.ART.search(line)
            if ans:
                art_filename = os.path.join(Dir.templates, ans.group(1))
                line = self.compile_art(art_filename)

            # Processes variables.
            line = self.parse_variable(line)

            # Appends this line.
            html += line

        # Outputs the HTML file if required.
        if write_to_file:
            # Minimizes the HTML:
            if App.minimize_html:
                if App.debug_html:
                    print(html)
                html = htmlmin.minify(html,
                                      remove_comments=True,
                                      remove_all_empty_space=True)
            with open(output_filename, 'w', encoding='utf8') as f:
                f.write(html)

        self.built_html[filename] = html
        return html
Ejemplo n.º 27
0
 def get_vimeo_markdown(self):
     return DuMark.get_vimeo(self._data['vimeo'])