mirror of
https://github.com/twisterarmy/swizzler.git
synced 2025-03-12 13:31:26 +00:00
Tag unicode bug fix + dht peer count indicator
Don't get your hopes too high. It's not like swizzler now showing unicode tags [yet]. It's just that it doesn't crash if there are unicode errors (i.e. some weird pre-unicode codepage). How does such a thing become a trending hashtag? I wonder :)
This commit is contained in:
parent
969842e924
commit
b7231df882
@ -13,7 +13,7 @@ class TwistParser(ttp.Parser):
|
|||||||
def format_tag(self, tag, text):
|
def format_tag(self, tag, text):
|
||||||
'''Return formatted HTML for a hashtag.'''
|
'''Return formatted HTML for a hashtag.'''
|
||||||
return '<a href="/tag/{0}">{1}{2}</a>'.format(
|
return '<a href="/tag/{0}">{1}{2}</a>'.format(
|
||||||
ttp.urllib.quote(text.lower().encode('utf-8')), tag, text)
|
ttp.urllib.quote(text.lower().encode('utf-8'),'xmlcharrefreplace'), tag, text)
|
||||||
|
|
||||||
def format_username(self, at_char, user):
|
def format_username(self, at_char, user):
|
||||||
'''Return formatted HTML for a username.'''
|
'''Return formatted HTML for a username.'''
|
||||||
@ -58,6 +58,7 @@ class SwizzlerApp(object):
|
|||||||
'rts':rts,
|
'rts':rts,
|
||||||
'any_rts':not not rts,
|
'any_rts':not not rts,
|
||||||
'local_users':twister.local_user_menu()['users'],
|
'local_users':twister.local_user_menu()['users'],
|
||||||
|
'info':twister.get_info(),
|
||||||
'trending':format_trending(twister,conf['num_messages'])
|
'trending':format_trending(twister,conf['num_messages'])
|
||||||
}
|
}
|
||||||
return stache.render(stache.load_template('twist'),result)
|
return stache.render(stache.load_template('twist'),result)
|
||||||
@ -72,6 +73,7 @@ class SwizzlerApp(object):
|
|||||||
'subject':user,
|
'subject':user,
|
||||||
'messages':twister.get_user_posts(username,conf['num_messages']),
|
'messages':twister.get_user_posts(username,conf['num_messages']),
|
||||||
'local_users':twister.local_user_menu()['users'],
|
'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)
|
#the filter avoids some utf etc. that ttf can't handle (TODO: fix or replace format_twist)
|
||||||
'trending':format_trending(twister,conf['num_messages'])
|
'trending':format_trending(twister,conf['num_messages'])
|
||||||
}
|
}
|
||||||
@ -86,6 +88,7 @@ class SwizzlerApp(object):
|
|||||||
'subject':{"fullname":tag},
|
'subject':{"fullname":tag},
|
||||||
'messages':twister.get_tag_posts(tag),
|
'messages':twister.get_tag_posts(tag),
|
||||||
'local_users':twister.local_user_menu()['users'],
|
'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)
|
#the filter avoids some utf etc. that ttf can't handle (TODO: fix or replace format_twist)
|
||||||
'trending':format_trending(twister,conf['num_messages'])
|
'trending':format_trending(twister,conf['num_messages'])
|
||||||
}
|
}
|
||||||
@ -105,6 +108,7 @@ class SwizzlerApp(object):
|
|||||||
'is_feed':mode!='mentions',
|
'is_feed':mode!='mentions',
|
||||||
'title':u"{0} (@{1}): Home - Swizzler".format(menu['active']['fullname'],menu['active']['username']),
|
'title':u"{0} (@{1}): Home - Swizzler".format(menu['active']['fullname'],menu['active']['username']),
|
||||||
'local_users':menu['users'],
|
'local_users':menu['users'],
|
||||||
|
'info':twister.get_info(),
|
||||||
'subject':menu['active'],
|
'subject':menu['active'],
|
||||||
'messages':messages,
|
'messages':messages,
|
||||||
#the filter avoids some utf etc. that ttf can't handle (TODO: fix or replace format_twist)
|
#the filter avoids some utf etc. that ttf can't handle (TODO: fix or replace format_twist)
|
||||||
@ -119,6 +123,7 @@ class SwizzlerApp(object):
|
|||||||
'is_user':True, # i.e. we want to display "bio" and not mentions/DMs/profile buttons
|
'is_user':True, # i.e. we want to display "bio" and not mentions/DMs/profile buttons
|
||||||
'title':"Welcome to Swizzler",
|
'title':"Welcome to Swizzler",
|
||||||
'local_users':twister.local_user_menu('')['users'], # '' means: "Nobody" is active
|
'local_users':twister.local_user_menu('')['users'], # '' means: "Nobody" is active
|
||||||
|
'info':twister.get_info(),
|
||||||
'subject':{ # pseudo-user describing sponsored posts
|
'subject':{ # pseudo-user describing sponsored posts
|
||||||
'fullname':'Sponsored posts',
|
'fullname':'Sponsored posts',
|
||||||
'bio':format_twist("""
|
'bio':format_twist("""
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
<div class="panel panel-primary">
|
<div class="panel panel-primary">
|
||||||
<div class="panel-heading"><h3 class="panel-title"><span class="glyphicon glyphicon-home"></span> Local users</h3></div>
|
<div class="panel-heading">
|
||||||
|
{{#info}}
|
||||||
|
<div class="pull-right badge">Peers: {{dht_nodes}}/{{dht_global_nodes}}</div>
|
||||||
|
{{/info}}
|
||||||
|
<h3 class="panel-title"><span class="glyphicon glyphicon-home"></span> Local users</h3>
|
||||||
|
</div>
|
||||||
<ul class="panel-body list-group media-list">
|
<ul class="panel-body list-group media-list">
|
||||||
{{#local_users}}
|
{{#local_users}}
|
||||||
<li class="media list-group-item avatars32{{#active}} active{{/active}}">
|
<li class="media list-group-item avatars32{{#active}} active{{/active}}">
|
||||||
|
@ -129,3 +129,5 @@ class Twister:
|
|||||||
@functioncache(60,ignore_instance=True)
|
@functioncache(60,ignore_instance=True)
|
||||||
def get_trending_tags(self,num=8):
|
def get_trending_tags(self,num=8):
|
||||||
return self.twister.gettrendinghashtags(num)
|
return self.twister.gettrendinghashtags(num)
|
||||||
|
def get_info(self): # not cached
|
||||||
|
return self.twister.getinfo()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user