def avatar(self, size=30): if not app.cfg.user_use_gravatar: return None from moin.themes import get_current_theme from flask_theme import static_file_url theme = get_current_theme() email = self.email if not email: return static_file_url(theme, theme.info.get('default_avatar', 'img/default_avatar.png')) param = {} param['gravatar_id'] = hashlib.md5(email.lower()).hexdigest() param['default'] = static_file_url(theme, theme.info.get('default_avatar', 'img/default_avatar.png'), True) param['size'] = str(size) # TODO: use same protocol of Moin site (might be https instead of http)] gravatar_url = "http://www.gravatar.com/avatar.php?" gravatar_url += werkzeug.url_encode(param) return gravatar_url
def test_theme_static(self): app = Flask(__name__) app.config['THEME_PATHS'] = [join(TESTS, 'morethemes')] setup_themes(app, app_identifier='testing') with app.test_request_context('/'): coolurl = static_file_url('cool', 'style.css') cooldata = render_theme_template('cool', 'static.html').strip() assert cooldata == 'Cool Blue v2, %s' % coolurl
def test_theme_include_static(self): app = Flask(__name__) app.config['THEME_PATHS'] = [join(TESTS, 'morethemes')] setup_themes(app, app_identifier='testing') with app.test_request_context('/'): data = render_template('static_parent.html').strip() url = static_file_url('plain', 'style.css') assert data == 'Application, Plain, %s' % url
def test_static_file_url(self): app = Flask(__name__) app.config['THEME_PATHS'] = [join(TESTS, 'morethemes')] setup_themes(app, app_identifier='testing') with app.test_request_context('/'): url = static_file_url('cool', 'style.css') genurl = url_for('_themes.static', themeid='cool', filename='style.css') assert url == genurl