mirror of
https://github.com/twisterarmy/swizzler.git
synced 2025-03-12 13:31:26 +00:00
Tag search no longer goes to iframe :)
Forms and iframes go together like a horse and marriage
This commit is contained in:
parent
08f2c4fab6
commit
ec238a0150
21
swizzler.py
21
swizzler.py
@ -46,18 +46,15 @@ def format_trending(twister,num_messages=8):
|
|||||||
### The Swizzler app
|
### The Swizzler app
|
||||||
class SwizzlerApp(object):
|
class SwizzlerApp(object):
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
def search(self,q=''):
|
def search_embed(self,userprefix=''):
|
||||||
conf = cherrypy.request.app.config['swizzler']
|
conf = cherrypy.request.app.config['swizzler']
|
||||||
twister = Twister(conf['rpc_url'],format_twist)
|
twister = Twister(conf['rpc_url'],format_twist)
|
||||||
result = {'site_root':cherrypy.request.base+cherrypy.request.script_name}
|
result = {'site_root':cherrypy.request.base+cherrypy.request.script_name}
|
||||||
q = q.strip().split(' ')[0] # ignore anything after the first space if any
|
userprefix = userprefix.strip().split(' ')[0]
|
||||||
if q.startswith('#'): # user said "#sometag", change to "sometag"
|
if not userprefix.startswith('@'): userprefix = '@'+userprefix
|
||||||
q=q[1:]
|
if len(userprefix)>1:
|
||||||
if q and not q.startswith('@'): # Tag. redirect.
|
result['user_prefix'] = userprefix
|
||||||
raise cherrypy.HTTPRedirect(result['site_root']+'/tag/{0}'.format(q))
|
result['users'] = twister.get_users_by_partial_name(userprefix[1:],conf['num_messages'])
|
||||||
if q:
|
|
||||||
result['user_prefix'] = q
|
|
||||||
result['users'] = twister.get_users_by_partial_name(q[1:],conf['num_messages'])
|
|
||||||
else:
|
else:
|
||||||
result['trending'] = format_trending(twister,conf['num_messages'])
|
result['trending'] = format_trending(twister,conf['num_messages'])
|
||||||
return stache.render(stache.load_template('search'),result)
|
return stache.render(stache.load_template('search'),result)
|
||||||
@ -112,7 +109,11 @@ class SwizzlerApp(object):
|
|||||||
result['style_{0}'.format(style)] = True
|
result['style_{0}'.format(style)] = True
|
||||||
return stache.render(stache.load_template('user-iframe'),result)
|
return stache.render(stache.load_template('user-iframe'),result)
|
||||||
@cherrypy.expose
|
@cherrypy.expose
|
||||||
def tag(self,tag):
|
def tag(self,tag=''):
|
||||||
|
tag = tag.strip().split(' ')[0]
|
||||||
|
if tag.startswith('#'): tag = tag[1:]
|
||||||
|
if not tag:
|
||||||
|
raise cherrypy.HTTPRedirect('/') # go home to sponsored posts
|
||||||
conf = cherrypy.request.app.config['swizzler']
|
conf = cherrypy.request.app.config['swizzler']
|
||||||
twister = Twister(conf['rpc_url'],format_twist)
|
twister = Twister(conf['rpc_url'],format_twist)
|
||||||
messages = twister.get_tag_posts(tag)
|
messages = twister.get_tag_posts(tag)
|
||||||
|
@ -33,18 +33,25 @@
|
|||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="panel panel-primary">
|
<form method=get action="{{site_root}}/tag" class="form-horizontal" role="search">
|
||||||
<div class="panel-heading">
|
|
||||||
<form target="searchresult" tag="searchresult" method=get action="{{site_root}}/search" class="inline-form" role="search">
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="#search"><span class="glyphicon glyphicon-search"></span> Search for tag or partial username</label>
|
<label class="col-xs-4 text-right" for="#tag">Tag <span class="glyphicon glyphicon-tag"></span></label>
|
||||||
<input id="q" name="q" type="text" class="form-control" placeholder="#twister or @twi"{{#user_prefix}} value="{{.}}"{{/user_prefix}}>
|
<div class="col-xs-8">
|
||||||
|
<input id="tag" name="tag" type="text" class="form-control input-sm" placeholder="#twister"{{#user_prefix}} value="{{.}}"{{/user_prefix}}>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
<form target="searchresult" tag="searchresult" method=get action="{{site_root}}/search_embed" class="form-horizontal" role="search">
|
||||||
</div>
|
<div class="form-group">
|
||||||
|
<label class="col-xs-4 text-right" for="#userprefix">Usernam... <span class="glyphicon glyphicon-user"></span></label>
|
||||||
|
<div class="col-xs-8">
|
||||||
|
<input id="userprefix" name="userprefix" type="text" class="form-control input-sm" placeholder="@twi"{{#user_prefix}} value="{{.}}"{{/user_prefix}}>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</form>
|
||||||
|
|
||||||
<iframe name="searchresult" class="thumbnail media-object {{#fromMe}}pull-right{{/fromMe}}{{^fromMe}}pull-left{{/fromMe}}"
|
<iframe name="searchresult" class="thumbnail media-object {{#fromMe}}pull-right{{/fromMe}}{{^fromMe}}pull-left{{/fromMe}}"
|
||||||
style="width:100%; border:none; padding:0; background:none; overflow:hidden"
|
style="width:100%; border:none; padding:0; background:none; overflow:hidden"
|
||||||
width=100 height=2645 seamless=seamless
|
width=100 height=2645 seamless=seamless
|
||||||
src="{{site_root}}/search"></iframe>
|
src="{{site_root}}/search_embed"></iframe>
|
||||||
</div>
|
</div>
|
||||||
|
@ -15,62 +15,72 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div id="main" class="col-md-8">
|
<div id="main" class="col-md-8">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div id="header" class="col-md-12 well">
|
{{#is_home}}
|
||||||
{{#subject}}
|
<div class="panel panel-primary">
|
||||||
<div class="media">
|
<div class="panel-heading">
|
||||||
<a class="pull-left thumbnail" href="{{#username}}/user/{{.}}{{/username}}{{^username}}#{{/username}}">
|
{{#username}}
|
||||||
<img class="media-object avatar" src="{{#avatar}}{{.}}{{/avatar}}{{^avatar}}/assets/img/twister-64.jpg{{/avatar}}" alt="{{fullname}}">
|
<h3 class="panel-title">
|
||||||
</a>
|
{{#is_feed}}
|
||||||
<div class="media-body">
|
<a class="label label-primary" href="{{site_root}}/home/{{username}}" title="@{{username}}'s home"><span class="glyphicon glyphicon-home"></span>
|
||||||
{{#is_home}}
|
{{fullname}}'s home</a>
|
||||||
{{#username}}
|
{{/is_feed}}
|
||||||
<h3 class="media-heading">
|
{{#is_mentions}}
|
||||||
{{#is_feed}}
|
<a class="label label-primary" href="{{site_root}}/home/{{username}}/mentions" title="mentions of @{{username}}"><span class="glyphicon glyphicon-bell"></span>
|
||||||
<a class="label label-primary" href="{{site_root}}/home/{{username}}" title="@{{username}}'s home"><span class="glyphicon glyphicon-home"></span>
|
Mentions of {{fullname}}</a>
|
||||||
{{fullname}}'s home</a>
|
{{/is_mentions}}
|
||||||
{{/is_feed}}
|
{{#is_messages}}
|
||||||
{{#is_mentions}}
|
<a class="label label-primary" href="{{site_root}}/messages/{{username}}" title="direct messages to/from @{{username}}"><span class="glyphicon glyphicon-envelope"></span>
|
||||||
<a class="label label-primary" href="{{site_root}}/home/{{username}}/mentions" title="mentions of @{{username}}"><span class="glyphicon glyphicon-bell"></span>
|
{{fullname}}</a>
|
||||||
Mentions of {{fullname}}</a>
|
{{/is_messages}}
|
||||||
{{/is_mentions}}
|
</h3>
|
||||||
{{#is_messages}}
|
{{/username}}
|
||||||
<a class="label label-primary" href="{{site_root}}/messages/{{username}}" title="direct messages to/from @{{username}}"><span class="glyphicon glyphicon-envelope"></span>
|
{{^username}}
|
||||||
{{fullname}}</a>
|
{{/username}}
|
||||||
{{/is_messages}}
|
|
||||||
</h3>
|
|
||||||
<h4>
|
|
||||||
{{^is_feed}}
|
|
||||||
<a class="label label-primary" href="{{site_root}}/home/{{username}}" title="@{{username}}'s home"><span class="glyphicon glyphicon-home"></span>Home</a>
|
|
||||||
{{/is_feed}}
|
|
||||||
{{^is_mentions}}
|
|
||||||
<a class="label label-primary" href="{{site_root}}/home/{{username}}/mentions" title="mentions of @{{username}}"><span class="glyphicon glyphicon-bell"></span>Mentions</a>
|
|
||||||
{{/is_mentions}}
|
|
||||||
{{^is_messages}}
|
|
||||||
<a class="label label-primary" href="{{site_root}}/messages/{{username}}" title="direct messages from/to @{{username}}"><span class="glyphicon glyphicon-envelope"></span>Messages</a>
|
|
||||||
{{/is_messages}}
|
|
||||||
<a class="label label-info" href="{{site_root}}{{#username}}/user/{{.}}{{/username}}" title="@{{username}}'s profile"><span class="glyphicon glyphicon-user"></span>Profile</a>
|
|
||||||
</h4>
|
|
||||||
{{/username}}
|
|
||||||
{{/is_home}}
|
|
||||||
{{#is_user}}
|
|
||||||
<h4 class="media-heading">
|
|
||||||
{{#location}}<span class="pull-right small">{{.}}</span>{{/location}}
|
|
||||||
<a class="label label-primary" href="{{site_root}}/user/{{username}}"><span class="glyphicon glyphicon-user"></span>
|
|
||||||
{{fullname}}</a>
|
|
||||||
{{#url}}<small><a target="_blank" href="{{.}}">{{.}}</a></small>{{/url}}</h4>
|
|
||||||
{{{bio}}}
|
|
||||||
{{/is_user}}
|
|
||||||
{{#is_tag}}
|
|
||||||
<h2 class="media-heading">
|
|
||||||
<small><span class="glyphicon glyphicon-tag"></span> Latest twists containing the tag:</small><br>
|
|
||||||
#{{fullname}}
|
|
||||||
</h2>
|
|
||||||
{{/is_tag}}
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
{{/subject}}
|
<div class="panel-body">
|
||||||
</div>
|
<h4>
|
||||||
</div>
|
{{^is_feed}}
|
||||||
|
<a class="label label-primary" href="{{site_root}}/home/{{username}}" title="@{{username}}'s home"><span class="glyphicon glyphicon-home"></span>Home</a>
|
||||||
|
{{/is_feed}}
|
||||||
|
{{^is_mentions}}
|
||||||
|
<a class="label label-primary" href="{{site_root}}/home/{{username}}/mentions" title="mentions of @{{username}}"><span class="glyphicon glyphicon-bell"></span>Mentions</a>
|
||||||
|
{{/is_mentions}}
|
||||||
|
{{^is_messages}}
|
||||||
|
<a class="label label-primary" href="{{site_root}}/messages/{{username}}" title="direct messages from/to @{{username}}"><span class="glyphicon glyphicon-envelope"></span>Messages</a>
|
||||||
|
{{/is_messages}}
|
||||||
|
<a class="label label-info" href="{{site_root}}{{#username}}/user/{{.}}{{/username}}" title="@{{username}}'s profile"><span class="glyphicon glyphicon-user"></span>Profile</a>
|
||||||
|
</h4>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{{/is_home}}
|
||||||
|
{{^is_home}}
|
||||||
|
<div id="header" class="col-md-12 well">
|
||||||
|
{{#subject}}
|
||||||
|
<div class="media">
|
||||||
|
<a class="pull-left thumbnail" href="{{#username}}/user/{{.}}{{/username}}{{^username}}#{{/username}}">
|
||||||
|
<img class="media-object avatar" src="{{#avatar}}{{.}}{{/avatar}}{{^avatar}}/assets/img/twister-64.jpg{{/avatar}}" alt="{{fullname}}">
|
||||||
|
</a>
|
||||||
|
<div class="media-body">
|
||||||
|
{{#is_user}}
|
||||||
|
<h4 class="media-heading">
|
||||||
|
{{#location}}<span class="pull-right small">{{.}}</span>{{/location}}
|
||||||
|
<a class="label label-primary" href="{{site_root}}/user/{{username}}"><span class="glyphicon glyphicon-user"></span>
|
||||||
|
{{fullname}}</a>
|
||||||
|
{{#url}}<small><a target="_blank" href="{{.}}">{{.}}</a></small>{{/url}}</h4>
|
||||||
|
{{{bio}}}
|
||||||
|
{{/is_user}}
|
||||||
|
{{#is_tag}}
|
||||||
|
<h2 class="media-heading">
|
||||||
|
<small><span class="glyphicon glyphicon-tag"></span> Latest twists containing the tag:</small><br>
|
||||||
|
#{{fullname}}
|
||||||
|
</h2>
|
||||||
|
{{/is_tag}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{{/subject}}
|
||||||
|
</div>
|
||||||
|
{{/is_home}}
|
||||||
|
</div><!-- /.row -->
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div id="messages" class="col-md-12">
|
<div id="messages" class="col-md-12">
|
||||||
{{#any_messages}}<ul class="list-group media-list">{{#messages}}{{> message}}{{/messages}}</ul>{{/any_messages}}
|
{{#any_messages}}<ul class="list-group media-list">{{#messages}}{{> message}}{{/messages}}</ul>{{/any_messages}}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user