Make link flair in /about/flair subject to link styling.

This commit is contained in:
Logan Hanks
2012-03-06 10:40:36 -08:00
parent 1f095fb828
commit 6a9b8cc635
3 changed files with 27 additions and 7 deletions

View File

@@ -2479,6 +2479,8 @@ class ApiController(RedditController):
target=link, details='flair_edit')
# Push some client-side updates back to the browser.
# TODO: move this to a template
flair = '<span class="flair %s">%s</span>' % (
' '.join('flair-' + c for c in css_class.split()), text)
@@ -2488,6 +2490,8 @@ class ApiController(RedditController):
jquery(title_path).before(flair)
elif c.site.link_flair_position == 'right':
jquery(title_path).after(flair)
# TODO: close the selector popup more gracefully
jquery('body').click()
@validatedForm(secret_used=VAdminOrAdminSecret("secret"),

View File

@@ -227,7 +227,7 @@ class FlairTemplateBySubredditIndex(tdb_cassandra.Thing):
A position value of None means to simply append.
"""
ft_ids = self.iter_template_ids(flair_type)
ft_ids = list(self.iter_template_ids(flair_type))
if position is None:
position = len(ft_ids)
if position < 0 or position > len(ft_ids):

View File

@@ -26,13 +26,29 @@
from r2.models import USER_FLAIR, LINK_FLAIR
%>
<%def name="flair()">
%if thing.flair_template.text or thing.flair_template.css_class:
## TODO: clean this up
<span class=
"flair ${' '.join('flair-' + c for c in thing.flair_template.css_class.split())}">
${thing.flair_template.text}
</span>
%endif
</%def>
%if thing.flair_type is USER_FLAIR:
${thing.wrapped_user}
%elif thing.flair_type is LINK_FLAIR:
<p class="title">
<span class="flair ${thing.flair_template.css_class}">
${thing.flair_template.text}
</span>
<a class="title loggedin" href="javascript://">Link sample</a>
</p>
<div class="thing">
<p class="title">
%if c.site.link_flair_position == 'left':
<%call expr="flair()" />
%endif
<a class="title loggedin" href="javascript://">Link sample</a>
%if c.site.link_flair_position == 'right':
<%call expr="flair()" />
%endif
</p>
</div>
%endif