Esempio n. 1
0
 def test_children(self):
     bts = self.bts
     query = Query()
     query["limit"] = 10
     query["tag"] = "hive"
     d = Discussions_by_children(query, hive_instance=bts)
     self.assertEqual(len(d), 10)
Esempio n. 2
0
def tag(request, tag):
    tag_q = Query(limit=10, tag=tag)
    posts = hvpy.get_discussions_by_trending(tag_q)
    for post in posts:
        if post:
            post = strip(post)
    return render(request, 'blog/post_list.html', {"posts": posts})
Esempio n. 3
0
 def test_comment_payout(self):
     bts = self.bts
     query = Query()
     query["limit"] = 10
     query["tag"] = "hive"
     d = Comment_discussions_by_payout(query, hive_instance=bts)
     self.assertEqual(len(d), 10)
Esempio n. 4
0
 def test_comments(self):
     bts = self.bts
     query = Query()
     query["limit"] = 10
     query["filter_tags"] = ["gtg"]
     query["start_author"] = "gtg"
     d = Discussions_by_comments(query, hive_instance=bts)
     self.assertEqual(len(d), 10)
Esempio n. 5
0
 def test_promoted(self):
     bts = self.bts
     query = Query()
     query["limit"] = 1
     query["tag"] = "hive"
     d = Discussions_by_promoted(query, hive_instance=bts)
     discussions = Discussions(hive_instance=bts)
     d2 = []
     for dd in discussions.get_discussions("promoted", query, limit=10):
         d2.append(dd)
     self.assertEqual(len(d), 1)
     self.assertEqual(len(d2), 1)
Esempio n. 6
0
import markdown
import requests
from django.shortcuts import get_object_or_404, redirect, render
from django.utils import timezone

from bhive import Hive
from bhive.account import Account
from bhive.comment import Comment
from bhive.discussions import Query
from bhive.instance import set_shared_hive_instance
from bhive.utils import construct_authorperm
from hive import Hive as Hivepy
from markupsafe import Markup

#nodes = ["https://api.hive.blog", "https://anyx.io"]
q = Query(limit=10)
hvpy = Hivepy()  # nodes=nodes)
hv = Hive()  # node=nodes)
set_shared_hive_instance(hv)
image_proxy = "https://images.hive.blog/480x0/"


def strip(text):
    text['body'] = markdown.markdown(text['body'], extensions=[
                                     'nl2br', 'codehilite', 'pymdownx.extra', 'pymdownx.magiclink', 'pymdownx.betterem', 'pymdownx.inlinehilite'])
    text['body'] = re.sub("(<h1>|<h2>)", "<h3>", text['body'])
    text['body'] = re.sub(r"<img\b(?=\s)(?=(?:[^>=]|='[^']*'|=\"[^\"]*\"|=[^'\"][^\s>]*)*?\ssrc=['\"]([^\"]*)['\"]?)(?:[^>=]|='[^']*'|=\"[^\"]*\"|=[^'\"\s]*)*\"\s?\/?>",
                          rf'<img src={image_proxy}\1 >', text['body'])
    text['body'] = Markup(text['body'])
    return text
Esempio n. 7
0
 def test_cashout(self):
     bts = self.bts
     query = Query(limit=10)
     Discussions_by_cashout(query, hive_instance=bts)