Browse Source

Prepend "protocol less" urls with http:// (fix #6)

Also remove an embarrassing debug print :s
master
The Dod 11 years ago
parent
commit
a27f51c84b
  1. 1
      swizzler.py
  2. 7
      twister.py

1
swizzler.py

@ -209,7 +209,6 @@ if __name__ == '__main__': @@ -209,7 +209,6 @@ if __name__ == '__main__':
cherrypy.tree.mount(app,'/',config='{0}/cherrypy.config'.format(APPDIR))
conf = cherrypy.tree.apps[''].config
u,p = conf['swizzler'].get('browser_user'),conf['swizzler'].get('browser_password')
print u,p
if u and p:
conf['/'].update({ 'tools.basic_auth.on': True,
'tools.basic_auth.realm': 'Swizzler VIP lounge',

7
twister.py

@ -1,6 +1,9 @@ @@ -1,6 +1,9 @@
import time
from bitcoinrpc.authproxy import AuthServiceProxy
from functioncache import functioncache,SkipCache
import re
RE_URL_TWEAK = re.compile('^https?://',re.I)
def timestamp2iso(t):
return time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(t))
@ -76,6 +79,10 @@ class Twister: @@ -76,6 +79,10 @@ class Twister:
if not user.get('fullname'): # happens
user['fullname'] = username.capitalize() # Buddha is in the details
user['bio'] = self._format_message(user.get('bio',''))
# Tweak for "protcol-less" urls
u = user.get('url')
if u and not RE_URL_TWEAK.match(u):
user['url'] = 'http://{0}'.format(u)
try:
user['avatar'] = self.twister.dhtget(username,'avatar','s')[0]['p']['v']
if user['avatar']=='img/genericPerson.png': # ugly patch

Loading…
Cancel
Save