Browse Source

Tag search no longer goes to iframe :)

Forms and iframes go together like a horse and marriage
master
The Dod 11 years ago
parent
commit
ec238a0150
  1. 21
      swizzler.py
  2. 21
      templates/sidebar.html
  3. 30
      templates/standard.html

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)

21
templates/sidebar.html

@ -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>
<form target="searchresult" tag="searchresult" method=get action="{{site_root}}/search_embed" class="form-horizontal" role="search">
<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>
</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>

30
templates/standard.html

@ -15,16 +15,11 @@
<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">
{{#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_home}} {{#is_home}}
<div class="panel panel-primary">
<div class="panel-heading">
{{#username}} {{#username}}
<h3 class="media-heading"> <h3 class="panel-title">
{{#is_feed}} {{#is_feed}}
<a class="label label-primary" href="{{site_root}}/home/{{username}}" title="@{{username}}'s home"><span class="glyphicon glyphicon-home"></span> <a class="label label-primary" href="{{site_root}}/home/{{username}}" title="@{{username}}'s home"><span class="glyphicon glyphicon-home"></span>
{{fullname}}'s home</a> {{fullname}}'s home</a>
@ -38,6 +33,11 @@
{{fullname}}</a> {{fullname}}</a>
{{/is_messages}} {{/is_messages}}
</h3> </h3>
{{/username}}
{{^username}}
{{/username}}
</div>
<div class="panel-body">
<h4> <h4>
{{^is_feed}} {{^is_feed}}
<a class="label label-primary" href="{{site_root}}/home/{{username}}" title="@{{username}}'s home"><span class="glyphicon glyphicon-home"></span>Home</a> <a class="label label-primary" href="{{site_root}}/home/{{username}}" title="@{{username}}'s home"><span class="glyphicon glyphicon-home"></span>Home</a>
@ -50,8 +50,17 @@
{{/is_messages}} {{/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> <a class="label label-info" href="{{site_root}}{{#username}}/user/{{.}}{{/username}}" title="@{{username}}'s profile"><span class="glyphicon glyphicon-user"></span>Profile</a>
</h4> </h4>
{{/username}} </div>
</div>
{{/is_home}} {{/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}} {{#is_user}}
<h4 class="media-heading"> <h4 class="media-heading">
{{#location}}<span class="pull-right small">{{.}}</span>{{/location}} {{#location}}<span class="pull-right small">{{.}}</span>{{/location}}
@ -70,7 +79,8 @@
</div> </div>
{{/subject}} {{/subject}}
</div> </div>
</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…
Cancel
Save