Ejemplo n.º 1
0
 def user(self,username='******'):
     if username=='nobody':
         raise cherrypy.HTTPRedirect('/') # promoted posts are nobody's profile
     conf = cherrypy.request.app.config['swizzler']
     twister = Twister(conf['rpc_url'],format_twist)
     user = twister.get_user_info(username)
     messages = twister.get_user_posts(username,conf['num_messages'])
     result = {
         'is_user':True,
         'title':u"{fullname} (@{username}): Profile - Swizzler".format(**user),
         'subject':user,
         'messages':messages,
         'any_messages':not not messages,
         'local_users':twister.local_user_menu()['users'],
         'info':twister.get_info(),
         'site_root':cherrypy.request.base+cherrypy.request.script_name,
     }
     return stache.render(stache.load_template('standard'),result)
Ejemplo n.º 2
0
 def tag(self,tag=''):
     tag = tag.strip().split(' ')[0]
     if tag.startswith('#'): tag = tag[1:]
     if not tag:
         raise cherrypy.HTTPRedirect('/') # go home to promoted posts
     conf = cherrypy.request.app.config['swizzler']
     twister = Twister(conf['rpc_url'],format_twist)
     messages = twister.get_tag_posts(tag)
     result = {
         'is_tag':True,
         'title':u"#{0} - Swizzler".format(tag),
         'subject':{"fullname":tag},
         'messages':messages,
         'any_messages':not not messages,
         'local_users':twister.local_user_menu()['users'],
         'info':twister.get_info(),
         'site_root':cherrypy.request.base+cherrypy.request.script_name,
     }
     return stache.render(stache.load_template('standard'),result)
Ejemplo n.º 3
0
 def messages(self,localusername,remoteusername=None):
     conf = cherrypy.request.app.config['swizzler']
     twister = Twister(conf['rpc_url'],format_twist)
     localuser = twister.get_user_info(localusername)
     remoteuser = remoteusername and twister.get_user_info(remoteusername) or None
     threads = remoteusername and twister.get_user_messages(localusername,remoteusername,conf['num_messages']) or twister.get_user_messages(localusername)
     result = {
         'is_messages':True,
         'title':u"{0} (@{1}): direct messages{2}".format(
             localuser['fullname'],localuser['username'],
             remoteuser and u" with {fullname} (@{username}) - Swizzler".format(**remoteuser) or ""),
         'subject':localuser,
         'remoteuser':remoteuser,
         'threads':threads,
         'any_threads':not not threads,
         'local_users':twister.local_user_menu()['users'],
         'info':twister.get_info(),
         'site_root':cherrypy.request.base+cherrypy.request.script_name,
     }
     return stache.render(stache.load_template('messages'),result)
Ejemplo n.º 4
0
 def twist(self,username,k):
     conf = cherrypy.request.app.config['swizzler']
     twister = Twister(conf['rpc_url'],format_twist)
     twist = twister.get_twist(username,k)
     twist['style_large'] = True
     rts = twister.get_twist_rts(username,k)
     replies = twister.get_twist_replies(username,k)
     result = {
         'is_twist':True,
         'title':u"@{0}: {1} - Swizzler".format(username,twist['time']),
         'twist':twist,
         'in_reply_to':twist.get('reply') and twister.get_twist(twist['reply']['username'],twist['reply']['k']) or None,
         'replies':replies,
         'any_replies':not not replies,
         'rts':rts,
         'any_rts':not not rts,
         'local_users':twister.local_user_menu()['users'],
         'info':twister.get_info(),
         'site_root':cherrypy.request.base+cherrypy.request.script_name,
     }
     return stache.render(stache.load_template('twist'),result)
Ejemplo n.º 5
0
 def home(self,localusername='******',mode='feed'):
     if localusername=='nobody':
         raise cherrypy.HTTPRedirect('/') # promoted posts are nobody's home
     conf = cherrypy.request.app.config['swizzler']
     twister = Twister(conf['rpc_url'],format_twist)
     menu = twister.local_user_menu(localusername)
     if mode=='mentions':
         messages = twister.get_user_mentions(localusername)
     else:
         messages = twister.get_user_feed(localusername,conf['num_messages'])
     result = {
         'is_home':True,
         'is_mentions':mode=='mentions',
         'is_feed':mode!='mentions',
         'title':u"{fullname} (@{username}): {mode} - Swizzler".format(mode=mode=='mentions' and 'Mentions' or 'Home',**menu['active']),
         'local_users':menu['users'],
         'info':twister.get_info(),
         'subject':menu['active'],
         'messages':messages,
         'any_messages':not not messages,
         'site_root':cherrypy.request.base+cherrypy.request.script_name,
     }
     return stache.render(stache.load_template('standard'),result)
Ejemplo n.º 6
0
    def index(self):
        conf = cherrypy.request.app.config['swizzler']
        twister = Twister(conf['rpc_url'],format_twist)
        messages = twister.get_promoted_posts(conf['num_messages'])
        result = {
            'is_user':True, # i.e. we want to display "bio" and not mentions/DMs/profile buttons
            'is_promoted':True, # message template needs to know not to show "permalink"
            'title':"Welcome to Swizzler",
            'local_users':twister.local_user_menu('')['users'], # '' means: "Nobody" is active
            'info':twister.get_info(),
            'subject':{ # pseudo-user describing promoted posts
                'fullname':'Promoted posts',
                'bio':format_twist("""
Mining the twister blockchain protects the #twister-verse from attacks like http://twister.net.co/?p=236
but unlike doge, we don't have shiny coins to offer "our protectors".
Instead, they enjoy occasional minutes of fame in the form of the promoted posts you see here.
We #Respect their hard earned crypto-graffiti by appreciating them on coffee/spliff/soy-milk/etc. breaks, because that's how we roll yo.
Start mining today, and this (𝐚𝐧𝐝 moral satisfaction) can be yours.""")
            },
            'messages':messages,
            'any_messages':not not messages,
            'site_root':cherrypy.request.base+cherrypy.request.script_name,
        }
        return stache.render(stache.load_template('standard'),result)