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. 9
      twister.py

1
swizzler.py

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

9
twister.py

@ -1,6 +1,9 @@
import time import time
from bitcoinrpc.authproxy import AuthServiceProxy from bitcoinrpc.authproxy import AuthServiceProxy
from functioncache import functioncache,SkipCache from functioncache import functioncache,SkipCache
import re
RE_URL_TWEAK = re.compile('^https?://',re.I)
def timestamp2iso(t): def timestamp2iso(t):
return time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(t)) return time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(t))
@ -75,7 +78,11 @@ class Twister:
user['username'] = username # handy user['username'] = username # handy
if not user.get('fullname'): # happens if not user.get('fullname'): # happens
user['fullname'] = username.capitalize() # Buddha is in the details user['fullname'] = username.capitalize() # Buddha is in the details
user['bio']=self._format_message(user.get('bio','')) 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: try:
user['avatar'] = self.twister.dhtget(username,'avatar','s')[0]['p']['v'] user['avatar'] = self.twister.dhtget(username,'avatar','s')[0]['p']['v']
if user['avatar']=='img/genericPerson.png': # ugly patch if user['avatar']=='img/genericPerson.png': # ugly patch

Loading…
Cancel
Save