Exemple #1
0
def blogpost(slug):
    # Redirect for new appcoin slug
    if slug == "appcoins-are-fraudulent":
        return redirect(url_for("blogpost", slug="appcoins-are-snake-oil"))
    bp = BlogPost.query.filter_by(slug=slug).order_by(desc(
        BlogPost.date)).first()
    lang = Language.query.filter_by(ietf="en").first()
    if bp:
        app.logger.info(str(request.remote_addr) + ', mempool, ' + slug)
        page = pages.get(slug)
        translations = [
            translation.language for translation in bp.translations
        ]
        translations.sort(key=lambda x: x.name)
        prev = next = None
        if bp.series:
            prev = BlogPost.query.filter_by(series=bp.series,
                                            series_index=bp.series_index -
                                            1).first()
            next = BlogPost.query.filter_by(series=bp.series,
                                            series_index=bp.series_index +
                                            1).first()
        return render_template('blogpost.html',
                               bp=bp,
                               page=page,
                               lang=lang,
                               translations=translations,
                               prev=prev,
                               next=next)
    else:
        return redirect(url_for("blog"))
Exemple #2
0
def blogposttrans(slug, lang):
    bp = BlogPost.query.filter_by(slug=slug).order_by(desc(
        BlogPost.date)).first()
    lang = lang.lower()
    if bp is not None:
        languages = bp.languages.split(', ')
        if (lang == 'en' or all(lang != l for l in languages)):
            return redirect(url_for("blogpost", slug=slug))
        else:
            app.logger.info(
                str(request.remote_addr) + ', mempool, ' + slug + '-' + lang)
            page = pages.get('%s-%s' % (slug, lang))
            rtl = False
            if lang in ['ar', 'fa']:
                rtl = True
            if page:
                return render_template('blogpost-md.html',
                                       bp=bp,
                                       page=page,
                                       lang=lang,
                                       rtl=rtl)
            return render_template('%s-%s.html' % (slug, lang),
                                   bp=bp,
                                   lang=lang)
    else:
        return redirect(url_for("blog"))
def blogpost(slug):
    # Redirect for new appcoin slug
    if slug == "appcoins-are-fraudulent":
        return redirect(url_for("blogpost", slug="appcoins-are-snake-oil"))
    bp = BlogPost.query.filter_by(slug=slug).order_by(desc(BlogPost.date)).first()
    if bp:
        app.logger.info(str(request.remote_addr) + ', mempool, ' + slug)
        page = pages.get(slug)
        return render_template('blogpost.html', bp=bp, page=page, lang='en')
    else:
        return redirect(url_for("blog"))
Exemple #4
0
def blogpost(slug):
    # Redirect for new appcoin slug
    if slug == "appcoins-are-fraudulent":
        return redirect(url_for("blogpost", slug="appcoins-are-snake-oil"))
    bp = BlogPost.query.filter_by(slug=slug).order_by(desc(
        BlogPost.date)).first()
    if bp:
        app.logger.info(str(request.remote_addr) + ', mempool, ' + slug)
        page = pages.get(slug)
        return render_template('blogpost.html', bp=bp, page=page, lang='en')
    else:
        return redirect(url_for("blog"))
Exemple #5
0
def blogposttrans(slug, lang):
    bp = BlogPost.query.filter_by(slug=slug).order_by(desc(BlogPost.date)).first()
    lang = lang.lower()
    if(bp != None):
        languages = bp.languages.split(', ')
        if(lang == 'en' or all(lang != l for l in languages)):
            return redirect(url_for("blogpost", slug=slug))
        else:
            app.logger.info(str(request.remote_addr) + ', mempool, ' + slug+'-'+lang)
            page = pages.get('%s-%s' % (slug, lang))
            if page:
                return render_template('blogpost-md.html', bp=bp, page=page, lang=lang)
            return render_template('%s-%s.html' % (slug, lang), bp=bp, lang=lang)
    else:
        return redirect(url_for("blog"))
def atomfeed():
    feed = AtomFeed('Mempool | Satoshi Nakamoto Institute',
                    feed_url=request.url, url=request.url_root)
    articles = BlogPost.query.order_by(desc(BlogPost.added)).all()
    for article in articles:
        articleurl = url_for('blogpost', slug=article.slug, _external=True)
        page = pages.get(article.slug)
        content = escape(page.html)
        feed.add(article.title, content,
                 content_type='html',
                 author=article.author[0].first + ' ' + article.author[0].last,
                 url=articleurl,
                 updated=date_to_localized_datetime(article.added),
                 published=date_to_localized_datetime(article.date))
    app.logger.info(str(request.remote_addr) + ', atomfeed')
    return feed.get_response()
Exemple #7
0
def atomfeed():
    feed = AtomFeed('Mempool | Satoshi Nakamoto Institute',
                    feed_url=request.url,
                    url=request.url_root)
    articles = BlogPost.query.order_by(desc(BlogPost.added)).all()
    for article in articles:
        articleurl = url_for('blogpost', slug=article.slug, _external=True)
        page = pages.get(article.slug)
        content = escape(page.html)
        feed.add(article.title,
                 content,
                 content_type='html',
                 author=article.author[0].first + ' ' + article.author[0].last,
                 url=articleurl,
                 updated=date_to_localized_datetime(article.added),
                 published=date_to_localized_datetime(article.date))
    app.logger.info(str(request.remote_addr) + ', atomfeed')
    return feed.get_response()
def blogposttrans(slug, lang):
    bp = BlogPost.query.filter_by(slug=slug).order_by(
        desc(BlogPost.date)
    ).first()
    lang = lang.lower()
    if bp is not None:
        languages = bp.languages.split(', ')
        if(lang == 'en' or all(lang != l for l in languages)):
            return redirect(url_for("blogpost", slug=slug))
        else:
            app.logger.info(str(request.remote_addr) + ', mempool, ' + slug+'-' + lang)
            page = pages.get('%s-%s' % (slug, lang))
            rtl = False
            if lang in ['ar', 'fa', 'he']:
                rtl = True
            return render_template('blogpost.html', bp=bp, page=page, lang=lang, rtl=rtl)
    else:
        return redirect(url_for("blog"))
Exemple #9
0
def blogposttrans(slug, lang):
    bp = BlogPost.query.filter_by(slug=slug).order_by(desc(
        BlogPost.date)).first()
    lang_lower = lang.lower()
    if bp is not None:
        if lang_lower == 'en':
            return redirect(url_for("blogpost", slug=slug))
        elif lang != lang_lower:
            return redirect(
                url_for("blogposttrans", slug=slug, lang=lang_lower))
        post_lang = Language.query.filter_by(ietf=lang_lower).first()
        if post_lang not in [
                translation.language for translation in bp.translations
        ]:
            return redirect(url_for("blogpost", slug=slug))
        else:
            app.logger.info(
                str(request.remote_addr) + ', mempool, ' + slug + '-' +
                lang_lower)
            page = pages.get('%s-%s' % (slug, lang))
            rtl = False
            if lang in ['ar', 'fa', 'he']:
                rtl = True
            translations = [Language.query.get(1)]
            translators = None
            bp_translations = bp.translations
            bp_translations.sort(key=lambda x: x.language.name)
            for translation in bp_translations:
                if translation.language.ietf != lang_lower:
                    translations.append(translation.language)
                else:
                    translators = translation.translators
            return render_template('blogpost.html',
                                   bp=bp,
                                   page=page,
                                   lang=post_lang,
                                   rtl=rtl,
                                   translations=translations,
                                   translators=translators)
    else:
        return redirect(url_for("blog"))