def get_embed_markup(self):
        # logger.debug(u"in get_embed_markup for {tiid}".format(
        #     tiid=self.tiid))

        if self.is_account_product:
            return None

        html = None

        if self.aliases and self.aliases.best_url and "github" in self.aliases.best_url:
            html = embed_markup.get_github_embed_html(self.aliases.best_url)

        elif self.aliases and self.aliases.best_url and "dryad" in self.aliases.best_url:
            html = embed_markup.get_dryad_embed_html(self.aliases.best_url)

        elif self.aliases and self.aliases.best_url and "figshare" in self.aliases.best_url:
            html = embed_markup.get_figshare_embed_html(self.aliases.best_url)

        else:
            if self.has_file or self.get_pdf_url():
                try:
                    this_host = flask.request.url_root.strip("/")
                    # workaround for google docs viewer not supporting localhost urls
                    this_host = this_host.replace("localhost:5000", "staging-impactstory.org")
                except __HOLE__:  # when running as a script
                    this_host = "https://impactstory.org"
                url = u"{this_host}/product/{tiid}/pdf".format(
                    this_host=this_host, tiid=self.tiid)

                if url and ("localhost" in url or "127.0.0.1" in url):
                    html = u"<p>Can't view uploaded file on localhost.  View it at <a href='{url}'>{url}</a>.</p>".format(
                            url=url)
                else:
                    if url:
                        try:
                            html = embed_markup.wrap_in_pdf_reader("embed-pdf", url)
                        except UnicodeEncodeError:
                            pass

        if not html and self.genre not in ["article", "unknown"]:
            if self.aliases and self.aliases.best_url:
                # this is how we embed slides, videos, etc
                html = embed_markup.wrap_with_embedly(self.aliases.best_url)

        return html
dataset/ETHPy150Open Impactstory/total-impact-webapp/totalimpactwebapp/product.py/Product.get_embed_markup