Browse Source

We have search (#MostOfUrBase)

Also: support for mounting at non-root level (e.g. /swizzler)
via nginx etc. [might come in handy for public instances]

User search only returns @usernames, because it took too long to
get full name and avatar for all users (ah, the joys of NoJS).
Working on an iframe-based solution.
master
The Dod 11 years ago
parent
commit
04efdbe8d5
  1. 62
      swizzler.py
  2. 14
      templates/message.html
  3. 28
      templates/messages.html
  4. 42
      templates/sidebar.html
  5. 22
      templates/standard.html
  6. 10
      templates/twist.html
  7. 4
      twister.py

62
swizzler.py

@ -12,18 +12,21 @@ from ttp import ttp @@ -12,18 +12,21 @@ from ttp import ttp
class TwistParser(ttp.Parser):
def format_tag(self, tag, text):
'''Return formatted HTML for a hashtag.'''
return '<a href="/tag/{0}">{1}{2}</a>'.format(
return '<a href="{0}/tag/{1}">{2}{3}</a>'.format(
cherrypy.request.base+cherrypy.request.script_name,
ttp.urllib.quote(text.lower().encode('utf-8'),'xmlcharrefreplace'), tag, text)
def format_username(self, at_char, user):
'''Return formatted HTML for a username.'''
return '<a href="/user/{0}">{1}{2}</a>'.format(
user, at_char, user.lower())
return '<a href="{0}/user/{1}">{2}{3}</a>'.format(
cherrypy.request.base+cherrypy.request.script_name,
user, at_char, user.lower())
def format_list(self, at_char, user, list_name):
'''We don't have lists, so we see it as @user followed /something'''
return '<a href="/user/{0}">{1}{2}</a>/{3}'.format(
user, at_char, user.lower(), list_name)
'''We don't have lists, so we see it as "@user" followed by "/something"'''
return '<a href="{0}/user/{1}">{2}{3}</a>/{4}'.format(
cherrypy.request.base+cherrypy.request.script_name,
cherrypy.request.base+cherrypy.request.script_name, user, at_char, user.lower(), list_name)
def format_url(self, url, text):
'''Return formatted HTML for a url.'''
@ -42,10 +45,26 @@ def format_trending(twister,num_messages=8): @@ -42,10 +45,26 @@ def format_trending(twister,num_messages=8):
### The Swizzler app
class SwizzlerApp(object):
def _standard_params(self,twister,q,num_items=8):
result = {'site_root':cherrypy.request.base+cherrypy.request.script_name}
result['here'] = result['site_root']+cherrypy.request.path_info
q=(q or '').strip().split(' ')[0] # ignore anything after the first space if any
if q.startswith('#'): # user said "#sometag", change to "sometag"
q=q[1:]
if q and not q.startswith('@'): # Tag. redirect.
raise cherrypy.HTTPRedirect(result['site_root']+'/tag/{0}'.format(q))
if q:
result['user_prefix'] = q
result['users'] = twister.get_users_by_partial_name(q[1:],num_items)
return result
result['trending'] = format_trending(twister,num_items)
return result
@cherrypy.expose
def twist(self,username,k):
def twist(self,username,k,q=None):
conf = cherrypy.request.app.config['swizzler']
twister = Twister(conf['rpc_url'],format_twist)
params = self._standard_params(twister,q,conf['num_messages']) # called as soon as possible, because it might raise a redirect
twist = twister.get_twist(username,k)
rts = twister.get_twist_rts(username,k)
print rts
@ -59,13 +78,14 @@ class SwizzlerApp(object): @@ -59,13 +78,14 @@ class SwizzlerApp(object):
'any_rts':not not rts,
'local_users':twister.local_user_menu()['users'],
'info':twister.get_info(),
'trending':format_trending(twister,conf['num_messages'])
}
result.update(params)
return stache.render(stache.load_template('twist'),result)
@cherrypy.expose
def user(self,username):
def user(self,username,q=None):
conf = cherrypy.request.app.config['swizzler']
twister = Twister(conf['rpc_url'],format_twist)
params = self._standard_params(twister,q,conf['num_messages']) # called as soon as possible, because it might raise a redirect
user = twister.get_user_info(username)
messages = twister.get_user_posts(username,conf['num_messages'])
result = {
@ -76,14 +96,14 @@ class SwizzlerApp(object): @@ -76,14 +96,14 @@ class SwizzlerApp(object):
'any_messages':not not messages,
'local_users':twister.local_user_menu()['users'],
'info':twister.get_info(),
#the filter avoids some utf etc. that ttf can't handle (TODO: fix or replace format_twist)
'trending':format_trending(twister,conf['num_messages'])
}
result.update(params)
return stache.render(stache.load_template('standard'),result)
@cherrypy.expose
def tag(self,tag):
def tag(self,tag,q=None):
conf = cherrypy.request.app.config['swizzler']
twister = Twister(conf['rpc_url'],format_twist)
params = self._standard_params(twister,q,conf['num_messages']) # called as soon as possible, because it might raise a redirect
messages = twister.get_tag_posts(tag)
result = {
'is_tag':True,
@ -94,13 +114,14 @@ class SwizzlerApp(object): @@ -94,13 +114,14 @@ class SwizzlerApp(object):
'local_users':twister.local_user_menu()['users'],
'info':twister.get_info(),
#the filter avoids some utf etc. that ttf can't handle (TODO: fix or replace format_twist)
'trending':format_trending(twister,conf['num_messages'])
}
result.update(params)
return stache.render(stache.load_template('standard'),result)
@cherrypy.expose
def home(self,localusername,mode='feed'):
def home(self,localusername,mode='feed',q=None):
conf = cherrypy.request.app.config['swizzler']
twister = Twister(conf['rpc_url'],format_twist)
params = self._standard_params(twister,q,conf['num_messages']) # called as soon as possible, because it might raise a redirect
menu = twister.local_user_menu(localusername)
if mode=='mentions':
messages = twister.get_user_mentions(localusername)
@ -116,14 +137,14 @@ class SwizzlerApp(object): @@ -116,14 +137,14 @@ class SwizzlerApp(object):
'subject':menu['active'],
'messages':messages,
'any_messages':not not messages,
#the filter avoids some utf etc. that ttf can't handle (TODO: fix or replace format_twist)
'trending':format_trending(twister,conf['num_messages'])
}
result.update(params)
return stache.render(stache.load_template('standard'),result)
@cherrypy.expose
def messages(self,localusername,remoteusername=None):
def messages(self,localusername,remoteusername=None,q=None):
conf = cherrypy.request.app.config['swizzler']
twister = Twister(conf['rpc_url'],format_twist)
params = self._standard_params(twister,q,conf['num_messages']) # called as soon as possible, because it might raise a redirect
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)
@ -138,13 +159,14 @@ class SwizzlerApp(object): @@ -138,13 +159,14 @@ class SwizzlerApp(object):
'local_users':twister.local_user_menu()['users'],
'info':twister.get_info(),
#the filter avoids some utf etc. that ttf can't handle (TODO: fix or replace format_twist)
'trending':format_trending(twister,conf['num_messages'])
}
result.update(params)
return stache.render(stache.load_template('messages'),result)
@cherrypy.expose
def index(self):
def index(self,q=None):
conf = cherrypy.request.app.config['swizzler']
twister = Twister(conf['rpc_url'],format_twist)
params = self._standard_params(twister,q,conf['num_messages']) # called as soon as possible, because it might raise a redirect
messages = twister.get_sponsored_posts(conf['num_messages'])
result = {
'is_user':True, # i.e. we want to display "bio" and not mentions/DMs/profile buttons
@ -163,8 +185,8 @@ Start mining today, and all this (AND moral satisfaction) can be yours.""") @@ -163,8 +185,8 @@ Start mining today, and all this (AND moral satisfaction) can be yours.""")
'messages':messages,
'any_messages':not not messages,
#the filter avoids some utf etc. that ttf can't handle (TODO: fix or replace format_twist)
'trending':format_trending(twister,conf['num_messages'])
}
result.update(params)
return stache.render(stache.load_template('standard'),result)
if __name__ == '__main__':

14
templates/message.html

@ -1,13 +1,13 @@ @@ -1,13 +1,13 @@
<li class="list-group-item media">
{{#user}}
{{#username}}
<a class="{{#fromMe}}pull-right{{/fromMe}}{{^fromMe}}pull-left{{/fromMe}} thumbnail" href="/user/{{.}}" title="@{{.}}'s profile">
<a class="{{#fromMe}}pull-right{{/fromMe}}{{^fromMe}}pull-left{{/fromMe}} thumbnail" href="{{site_root}}/user/{{.}}" title="@{{.}}'s profile">
<img class="media-object avatar" src="{{#avatar}}{{.}}{{/avatar}}{{^avatar}}/assets/img/genericPerson.png{{/avatar}}" alt="{{fullname}}">
</a>
{{/username}}
{{^username}}
<a class="pull-left thumbnail" href="#">
<img class="media-object avatar" src="/assets/img/twister-64.jpg" alt="{{fullname}}">
<img class="media-object avatar" src="{{site_root}}/assets/img/twister-64.jpg" alt="{{fullname}}">
</a>
{{/username}}
{{/user}}
@ -16,19 +16,19 @@ @@ -16,19 +16,19 @@
{{#username}}
<h5 class="media-heading">
<span class="pull-right small">
<a title="View twist details" href="/twist/{{.}}/{{k}}">{{time}}</a>
<a title="View twist details" href="{{site_root}}/twist/{{.}}/{{k}}">{{time}}</a>
</span>
{{#rt_user}}
<small>
<a href="/user/{{username}}" title="@{{username}}'s profile">{{fullname}}</a>
<a href="{{site_root}}/user/{{username}}" title="@{{username}}'s profile">{{fullname}}</a>
<span class="glyphicon glyphicon-retweet"></span>
</small>
{{/rt_user}}
<a href="/user/{{.}}" title="@{{.}}'s profile"><strong>{{fullname}}</strong></a>
<a href="{{site_root}}/user/{{.}}" title="@{{.}}'s profile"><strong>{{fullname}}</strong></a>
{{^is_twist}}{{#reply}}
<small>
<span class="glyphicon glyphicon-share-alt"></span>
{{#user}}<a title="Re: @{{username}}'s twist" href="/twist/{{username}}/{{k}}">{{fullname}}</a>{{/user}}
{{#user}}<a title="Re: @{{username}}'s twist" href="{{site_root}}/twist/{{username}}/{{k}}">{{fullname}}</a>{{/user}}
</small>
{{/reply}}{{/is_twist}}
</h5>
@ -36,7 +36,7 @@ @@ -36,7 +36,7 @@
{{^username}}
<h5 class="media-heading">
<span class="pull-right small">{{time}}</span>
<a href="/">{{fullname}}</a>
<a href="{{site_root}}/">{{fullname}}</a>
</h5>
{{/username}}
{{/user}}

28
templates/messages.html

@ -5,10 +5,10 @@ @@ -5,10 +5,10 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{title}}</title>
<link rel="icon" type="image/x-icon" href="/favicon.ico">
<link href="/assets/css/bootstrap.min.css" rel="stylesheet">
<link href="/assets/css/bootstrap-theme.min.css" rel="stylesheet">
<link href="/assets/css/swizzler.css" rel="stylesheet">
<link rel="icon" type="image/x-icon" href="{{site_root}}/favicon.ico">
<link href="{{site_root}}/assets/css/bootstrap.min.css" rel="stylesheet">
<link href="{{site_root}}/assets/css/bootstrap-theme.min.css" rel="stylesheet">
<link href="{{site_root}}/assets/css/swizzler.css" rel="stylesheet">
</head>
<body>
<div class="container">
@ -18,12 +18,12 @@ @@ -18,12 +18,12 @@
<div id="header" class="col-md-12 well">
{{#subject}}
<div class="media">
<a class="pull-left thumbnail" href="/user/{{username}}">
<a class="pull-left thumbnail" href="{{site_root}}/user/{{username}}">
<img class="media-object avatar" src="{{#avatar}}{{.}}{{/avatar}}{{^avatar}}/assets/img/twister-64.jpg{{/avatar}}" alt="{{fullname}}">
</a>
<div class="media-body">
<h4 class="media-heading">
<a href="/messages/{{username}}{{#remoteuser}}/{{username}}{{/remoteuser}}"
<a href="{{site_root}}/messages/{{username}}{{#remoteuser}}/{{username}}{{/remoteuser}}"
title="@{{username}}'s messages{{#remoteuser}} with {{username}}{{/remoteuser}}"
><span class="glyphicon glyphicon-envelope"></span></a>
{{fullname}}'s direct messages
@ -31,13 +31,13 @@ @@ -31,13 +31,13 @@
</h4>
{{#remoteuser}}
{{#subject}}
<a href="/messages/{{username}}" title="Back to @{{username}}'s direct message summary"><span
<a href="{{site_root}}/messages/{{username}}" title="Back to @{{username}}'s direct message summary"><span
class="glyphicon glyphicon-arrow-left"></span></a>
{{/subject}}
{{/remoteuser}}
<a href="/home/{{username}}" title="@{{username}}'s home"><span class="glyphicon glyphicon-home"></span></a>
<a href="/home/{{username}}/mentions" title="mentions of @{{username}}"><span class="glyphicon glyphicon-bell"></span></a>
<a href="/user/{{username}}" title="@{{username}}'s profile"><span class="glyphicon glyphicon-user"></span></a>
<a href="{{site_root}}/home/{{username}}" title="@{{username}}'s home"><span class="glyphicon glyphicon-home"></span></a>
<a href="{{site_root}}/home/{{username}}/mentions" title="mentions of @{{username}}"><span class="glyphicon glyphicon-bell"></span></a>
<a href="{{site_root}}/user/{{username}}" title="@{{username}}'s profile"><span class="glyphicon glyphicon-user"></span></a>
</div>
</div>
{{/subject}}
@ -51,8 +51,8 @@ @@ -51,8 +51,8 @@
{{^remoteuser}}
{{#user}}
<div class="label label-info">
<a href="/messages/{{subject.username}}/{{username}}" title="See more messages to/from @{{username}}">{{fullname}}</a>
<a href="/messages/{{subject.username}}/{{username}}" title="See more messages to/from @{{username}}"><span
<a href="{{site_root}}/messages/{{subject.username}}/{{username}}" title="See more messages to/from @{{username}}">{{fullname}}</a>
<a href="{{site_root}}/messages/{{subject.username}}/{{username}}" title="See more messages to/from @{{username}}"><span
class="glyphicon glyphicon-arrow-right"></span></a>
</div>
{{/user}}
@ -60,9 +60,9 @@ @@ -60,9 +60,9 @@
{{#remoteuser}}
{{#subject}}
<div class="label label-info">
<a href="/messages/{{subject.username}}" title="Back to @{{username}}'s direct message summary"><span
<a href="{{site_root}}/messages/{{subject.username}}" title="Back to @{{username}}'s direct message summary"><span
class="glyphicon glyphicon-arrow-left"></span></a>
<a href="/messages/{{subject.username}}" title="Back to @{{username}}'s direct message summary">Back</a>
<a href="{{site_root}}/messages/{{subject.username}}" title="Back to @{{username}}'s direct message summary">Back</a>
</div>
{{/subject}}
{{/remoteuser}}

42
templates/sidebar.html

@ -8,22 +8,22 @@ @@ -8,22 +8,22 @@
<ul class="panel-body list-group media-list">
{{#local_users}}
<li class="media list-group-item avatars32{{#active}} active{{/active}}">
<a {{#username}}title="@{{username}}'s home" {{/username}}class="pull-left thumbnail" href="/{{#username}}home/{{.}}{{/username}}">
<a {{#username}}title="@{{username}}'s home" {{/username}}class="pull-left thumbnail" href="{{site_root}}/{{#username}}home/{{.}}{{/username}}">
<img class="media-object avatar" src="{{#avatar}}{{.}}{{/avatar}}{{^avatar}}/assets/img/twister-64.jpg{{/avatar}}" alt="{{fullname}}">
</a>
<div class="media-body">
<h5 class="media-heading">
{{^active}}
<a {{#username}}title="@{{username}}'s home"{{/username}}
href="/{{#username}}home/{{.}}{{/username}}">{{/active}}{{fullname}}{{^active}}</a>
href="{{site_root}}/{{#username}}home/{{.}}{{/username}}">{{/active}}{{fullname}}{{^active}}</a>
{{/active}}
</h5>
{{^active}}
{{#username}}
<a href="/home/{{.}}" title="@{{.}}'s home"><span class="glyphicon glyphicon-home"></span></a>
<a href="/home/{{.}}/mentions" title="mentions of @{{.}}"><span class="glyphicon glyphicon-bell"></span></a>
<a href="/messages/{{.}}" title="direct messages from/to @{{.}}"><span class="glyphicon glyphicon-envelope"></span></a>
<a href="/user/{{.}}" title="@{{.}}'s profile"><span class="glyphicon glyphicon-user"></span></a>
<a href="{{site_root}}/home/{{.}}" title="@{{.}}'s home"><span class="glyphicon glyphicon-home"></span></a>
<a href="{{site_root}}/home/{{.}}/mentions" title="mentions of @{{.}}"><span class="glyphicon glyphicon-bell"></span></a>
<a href="{{site_root}}/messages/{{.}}" title="direct messages from/to @{{.}}"><span class="glyphicon glyphicon-envelope"></span></a>
<a href="{{site_root}}/user/{{.}}" title="@{{.}}'s profile"><span class="glyphicon glyphicon-user"></span></a>
{{/username}}
{{^username}}
(view sponsored posts)
@ -34,10 +34,30 @@ @@ -34,10 +34,30 @@
{{/local_users}}
</ul>
</div>
<div class="panel panel-primary">
<div class="panel-heading"><h3 class="panel-title"><span class="glyphicon glyphicon-tags"></span> Trending tags</h3></div>
<ul class="panel-body list-group media-list">
{{#trending}}<li class="list-group-item">{{{.}}}</li>{{/trending}}
{{^trending}}<li class="list-group-item"><h2><span class="glyphicon glyphicon-trash"></span>The internet is rubbish today</h2>{{/trending}}
</ul>
<div class="panel-heading">
<form method=get action="{{here}}" class="inline-form" role="search">
<div class="form-group">
<label for="#search"><span class="glyphicon glyphicon-search"></span> Search for tag or partial username</label>
<input id="q" name="q" type="text" class="form-control" placeholder="#twister or @twi"{{#user_prefix}} value="{{.}}"{{/user_prefix}}>
</div>
</form>
</div>
<div class="panel-body">
{{#user_prefix}}
<div class="label label-primary"><span class="glyphicon glyphicon-tags"></span> User prefix search: <strong><em>{{user_prefix}}</em></strong></div>
<ul class="list-group">
{{#users}}<li class="list-group-item"><a href="{{site_root}}/user/{{.}}" title="@{{.}}'s profile">@{{.}}</a></li>{{/users}}
{{^users}}<li class="list-group-item"><h3><small>Nothing. Nada. Rien de rien. &#128557;</small></h3>{{/users}}
</ul>
{{/user_prefix}}
{{^user_prefix}}
<div class="label label-primary"><span class="glyphicon glyphicon-tags"></span> Trending tags</div>
<ul class="list-group">
{{#trending}}<li class="list-group-item">{{{.}}}</li>{{/trending}}
{{^trending}}<li class="list-group-item"><h3>Can't find trending tags. <small>Nothing. Nada. Rien de rien. &#128557;</small></h3>{{/trending}}
</ul>
{{/user_prefix}}
</div>
</div>

22
templates/standard.html

@ -5,10 +5,10 @@ @@ -5,10 +5,10 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{title}}</title>
<link rel="icon" type="image/x-icon" href="/favicon.ico">
<link href="/assets/css/bootstrap.min.css" rel="stylesheet">
<link href="/assets/css/bootstrap-theme.min.css" rel="stylesheet">
<link href="/assets/css/swizzler.css" rel="stylesheet">
<link rel="icon" type="image/x-icon" href="{{site_root}}/favicon.ico">
<link href="{{site_root}}/assets/css/bootstrap.min.css" rel="stylesheet">
<link href="{{site_root}}/assets/css/bootstrap-theme.min.css" rel="stylesheet">
<link href="{{site_root}}/assets/css/swizzler.css" rel="stylesheet">
</head>
<body>
<div class="container">
@ -26,25 +26,25 @@ @@ -26,25 +26,25 @@
{{#username}}
<h4 class="media-heading">
{{#is_feed}}
<a href="/home/{{username}}" title="@{{username}}'s home"><span class="glyphicon glyphicon-home"></span></a> {{fullname}}
<a href="{{site_root}}/home/{{username}}" title="@{{username}}'s home"><span class="glyphicon glyphicon-home"></span></a> {{fullname}}
{{/is_feed}}
{{#is_mentions}}
<a href="/home/{{username}}/mentions" title="mentions of @{{username}}"><span class="glyphicon glyphicon-bell"></span></a> {{fullname}}
<a href="{{site_root}}/home/{{username}}/mentions" title="mentions of @{{username}}"><span class="glyphicon glyphicon-bell"></span></a> {{fullname}}
{{/is_mentions}}
{{#is_messages}}
<a href="/messages/{{username}}" title="direct messages to/from @{{username}}"><span class="glyphicon glyphicon-envelope"></span></a> {{fullname}}
<a href="{{site_root}}/messages/{{username}}" title="direct messages to/from @{{username}}"><span class="glyphicon glyphicon-envelope"></span></a> {{fullname}}
{{/is_messages}}
</h4>
{{^is_feed}}
<a href="/home/{{username}}" title="@{{username}}'s home"><span class="glyphicon glyphicon-home"></span></a>
<a href="{{site_root}}/home/{{username}}" title="@{{username}}'s home"><span class="glyphicon glyphicon-home"></span></a>
{{/is_feed}}
{{^is_mentions}}
<a href="/home/{{username}}/mentions" title="mentions of @{{username}}"><span class="glyphicon glyphicon-bell"></span></a>
<a href="{{site_root}}/home/{{username}}/mentions" title="mentions of @{{username}}"><span class="glyphicon glyphicon-bell"></span></a>
{{/is_mentions}}
{{^is_messages}}
<a href="/messages/{{username}}" title="direct messages from/to @{{username}}"><span class="glyphicon glyphicon-envelope"></span></a>
<a href="{{site_root}}/messages/{{username}}" title="direct messages from/to @{{username}}"><span class="glyphicon glyphicon-envelope"></span></a>
{{/is_messages}}
<a href="/user/{{username}}" title="@{{username}}'s profile"><span class="glyphicon glyphicon-user"></span></a>
<a href="{{site_root}}/user/{{username}}" title="@{{username}}'s profile"><span class="glyphicon glyphicon-user"></span></a>
{{/username}}
{{/is_home}}
{{#is_user}}

10
templates/twist.html

@ -5,10 +5,10 @@ @@ -5,10 +5,10 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>{{title}}</title>
<link rel="icon" type="image/x-icon" href="/favicon.ico">
<link href="/assets/css/bootstrap.min.css" rel="stylesheet">
<link href="/assets/css/bootstrap-theme.min.css" rel="stylesheet">
<link href="/assets/css/swizzler.css" rel="stylesheet">
<link rel="icon" type="image/x-icon" href="{{site_root}}/favicon.ico">
<link href="{{site_root}}/assets/css/bootstrap.min.css" rel="stylesheet">
<link href="{{site_root}}/assets/css/bootstrap-theme.min.css" rel="stylesheet">
<link href="{{site_root}}/assets/css/swizzler.css" rel="stylesheet">
</head>
<body>
<div class="container">
@ -30,7 +30,7 @@ @@ -30,7 +30,7 @@
<h5 class="pull-left"><span class="glyphicon glyphicon-retweet"></span> Retwists:&nbsp;</h5>{{! I know it's ugly. I suck at CSS !}}
{{#rts}}{{#rt_user}}
<div class="thumbnail pull-left">
<a href="/user/{{username}}" title="Retwisted by {{fullname}} (@{{username}})">
<a href="{{site_root}}/user/{{username}}" title="Retwisted by {{fullname}} (@{{username}})">
<img class="media-object avatar" src="{{#avatar}}{{.}}{{/avatar}}{{^avatar}}/assets/img/genericPerson.png{{/avatar}}"
alt="Retwisted by {{fullname}} (@{{username}})">
</a>

4
twister.py

@ -75,7 +75,7 @@ class Twister: @@ -75,7 +75,7 @@ class Twister:
try:
user['avatar'] = self.twister.dhtget(username,'avatar','s')[0]['p']['v']
if user['avatar']=='img/genericPerson.png': # ugly patch
user['avatar'] = '/assets/img/genericPerson.png'
user['avatar'] = None
except:
user['avatar'] = None
#raise SkipCache("couldn't get avatar for @{0}, not caching".format(username),user)
@ -148,6 +148,8 @@ class Twister: @@ -148,6 +148,8 @@ class Twister:
break
result.append(last[0])
return [self._format_post_info(s['p']['v']) for s in result]
def get_users_by_partial_name(self,prefix,num=8):
return self.twister.listusernamespartial(prefix,num)
@functioncache(60,ignore_instance=True)
def get_trending_tags(self,num=8):
return self.twister.gettrendinghashtags(num)

Loading…
Cancel
Save