Skip to content

Commit

Permalink
User feed / login bare
Browse files Browse the repository at this point in the history
  • Loading branch information
rochacbruno committed Jan 9, 2012
1 parent feb10e6 commit 0fd434a
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 11 deletions.
10 changes: 10 additions & 0 deletions controllers/person.py
Expand Up @@ -14,6 +14,11 @@ def publictimeline():
return person.render("app/person/publictimeline")


def privatetimeline():
person = Person('privatetimeline')
return person.render("app/person/privatetimeline")


def followers():
person = Person()
person.followers(request.args(0))
Expand Down Expand Up @@ -65,3 +70,8 @@ def board():
def account():
person = Person("account")
return person.render('app/person/account')


def loginbare():
person = Person("loginbare")
return person.render('app/person/loginbare')
27 changes: 26 additions & 1 deletion modules/handlers/person.py
Expand Up @@ -55,6 +55,22 @@ def publictimeline(self):
else:
self.context.TIMELINEFUNCTIONS = '%s/app/person/publictimeline_events.html' % self.context.theme_name

def privatetimeline(self):
self.board(self.session.auth.user.id)
self.contacts()
allowed = list(self.context.following_list) + list(self.context.contacts_list)
allowed.append(self.session.auth.user.id)
query = self.db.UserTimeLine.created_by.belongs(allowed)
if 'limitby' in self.request.vars:
limitby = [int(item) for item in self.request.vars.limitby.split(',')]
else:
limitby = None
self.get_timeline(query, limitby=limitby)
if self.db.request.args(0) == "sidebar":
self.context.TIMELINEFUNCTIONS = '%s/app/person/sidebar_privatetimeline_events.html' % self.context.theme_name
else:
self.context.TIMELINEFUNCTIONS = '%s/app/person/privatetimeline_events.html' % self.context.theme_name

def follow(self):
follower = self.session.auth.user if self.session.auth else None
if not follower and 'profile' in self.request.args:
Expand Down Expand Up @@ -227,7 +243,7 @@ def board(self, uid):
board_text_label = T("Write something on %s's board", user.nickname)

if relation in ['contacts', 'yourself', 'follower']:
self.db.UserBoard.board_text.label = board_text_label
self.db.UserBoard.board_text.label = CAT(board_text_label, A(T(" add photo ")))
self.context.form = SQLFORM(self.db.UserBoard, formstyle='divs', submit_button=T('Post'), separator='').process(onsuccess=lambda form: self.new_board_event(form, writer=self.session.auth.user.id, user=user, relation=relation))
else:
self.context.form = ''
Expand Down Expand Up @@ -305,3 +321,12 @@ def show(self, uid):
def account(self):
self.context.auth = self.db.auth
self.context.form = self.db.auth()

def loginbare(self):
username = self.request.vars.email
password = self.request.vars.password
user = self.db.auth.login_bare(username, password)
if user:
redirect(self.CURL('home', 'index'))
else:
redirect(self.CURL('home', 'index', args=[username, 'error']))
10 changes: 9 additions & 1 deletion static/basic/css/basic.css
Expand Up @@ -217,6 +217,10 @@ img.jqmClose {
color:#ccc;
}

.timeline-item form input[type='text']{
width:98%;
}



.contact-item {
Expand Down Expand Up @@ -245,10 +249,14 @@ img.thumbnail {
.person-box {
margin-bottom:25px;
}
.person-box>h4 {
.person-box>h4, .bottom-line {
border-bottom:2px solid #181818;
margin-bottom:10px;
}

.bottom-line {
margin-top:15px;
}
/*.person-main-info h3 {color:#F5F5F5;}*/

.person-resume {
Expand Down
30 changes: 21 additions & 9 deletions views/basic/app/home.html
Expand Up @@ -24,27 +24,39 @@


{{if session.auth:}}
<h4>
<h4 class="bottom-line">
<img src="{{=URL('static','basic/images/icons', args='monitor.24.png')}}" alt="{{=T('Activities')}}" title="{{=T('Activities')}}">
{{=T("Your Feed")}}
</h4>
{{=LOAD('person','publictimeline.load',args='sidebar' ,vars=dict(limitby='0,8'), ajax=True)}}
{{=LOAD('person','privatetimeline.load' ,vars=dict(limitby='0,8'), ajax=True)}}
{{pass}}

<h4><img src="{{=URL('static','basic/images/icons', args='attach_round.24.png')}}" alt="{{=T('Articles')}}" title="{{=T('Articles')}}">{{=T("Articles")}}</h4>
{{=LOAD('article','list.load',vars=dict(limitby='0,10'), ajax=True)}}
<h4 class="bottom-line">
<img src="{{=URL('static','basic/images/icons', args='attach_round.24.png')}}" alt="{{=T('Articles')}}" title="{{=T('Articles')}}">
{{=T("Articles")}}
</h4>
{{=LOAD('article','list.load',vars=dict(limitby='0,10'), ajax=True)}}



{{block right_sidebar}}
{{if not session.auth:}}
<h4>
<img src="{{=URL('static','basic/images/icons', args='monitor.24.png')}}" alt="{{=T('Activities')}}" title="{{=T('Activities')}}">
<a href="{{=CURL('default', 'user', args='login')}}">{{=T("Sign up")}}</a> {{=T("or login")}}
<h4 class="bottom-line">
<img src="{{=URL('static','basic/images/icons', args='edge_arrow_right.24.png')}}" alt="{{=T('Login')}}" title="{{=T('Login')}}">
<a href="{{=CURL('person', 'account', args='register')}}">{{=T("Sign up")}}</a> {{=T("or login")}}
</h4>

<div>
<form action="{{=URL('person', 'loginbare')}}" method="post">
{{if request.args(1) == 'error':}}
<label style="color:red;">{{=T("Username or password incorrect")}}</label>
{{pass}}
<input type="text" name="email" id="email" placeholder="{{=T('your email')}}" {{response.write("value=%s" % request.args(0) if request.args(1) == 'error' else '')}} />
<input type="password" name="password" id="password" placeholder="{{=T('your password')}}"/>
<button>{{=T("Go")}}</button> <a href="{{=CURL('person', 'account', args='request_reset_password')}}">{{=T("Lost password")}}</a>
</form>
</div>
{{pass}}
<h4>
<h4 class="bottom-line">
<img src="{{=URL('static','basic/images/icons', args='monitor.24.png')}}" alt="{{=T('Activities')}}" title="{{=T('Activities')}}">
{{=T("Public Activities")}}
</h4>
Expand Down
14 changes: 14 additions & 0 deletions views/basic/app/person/privatetimeline.load
@@ -0,0 +1,14 @@
{{include TIMELINEFUNCTIONS}}
<ul class="timeline-wrapper">
<li class="timeline-item row eight columns" style="padding-top:5px;margin:0px;">
{{=form}}
</li>
{{for event in events:}}
{{eventbox(event)}}
{{pass}}
</ul>
{{if events:}}
<a href="{{=CURL('person','privatetimeline', extension=False,vars=dict(limitby='0,25'))}}">{{=T("View all activities")}}</a>
{{else:}}
{{=T("No events on this timeline")}}
{{pass}}
28 changes: 28 additions & 0 deletions views/basic/app/person/privatetimeline_events.html
@@ -0,0 +1,28 @@
{{def eventbox(event):}}
{{
event_info = dict(new_article={'url':CURL('article', 'show', extension=False), 'title':T("%(nickname)s added a new %(event_to)s")},
update_article={'url':CURL('article', 'show', extension=False), 'title':T("%(nickname)s updated an %(event_to)s")},
new_contact={'url':CURL('person', 'show', extension=False), 'title':T("%(nickname)s followed %(event_to)s")},
new_article_comment={'url':CURL('article', 'show', extension=False), 'title':T("%(nickname)s commented on %(event_to)s")},
liked={'url':CURL('article', 'show', extension=False), 'title': T("%(nickname)s liked the %(event_to)s")},
subscribed={'url':CURL('article', 'show', extension=False), 'title':T("%(nickname)s subscribed to %(event_to)s updates")},
favorited={'url':CURL('article', 'show', extension=False), 'title': T("%(nickname)s favorited the %(event_to)s")},
disliked={'url':CURL('article', 'show', extension=False), 'title':T("%(nickname)s disliked the %(event_to)s")},
new_picture={'url':CURL(), 'title':""},
new_picture_comment={'url':CURL(), 'title':""},
wrote_on_wall={'url':CURL('person', 'show', extension=False), 'title':T("%(nickname)s wrote on %(event_to)s's board")})
}}
<li class="timeline-item row eight columns" style="padding-top:5px;margin:0px;" onclick="window.location='{{=event_info[event.event_type]['url']}}/{{=event.event_link}}'">
<div class="one columns alpha">
<img width="50" height="50" src="{{=event.event_image}}">
</div>
<div class="six columns omega timeline-text" style="font-size:14px;line-height:14px;padding:0px;">
{{=event_info[event.event_type]['title'] % event}}
<p>{{=event.event_text}}</p>
</div>
<div class="seven columns" style="text-align:left;font-size:14px;line-height:14px;padding:0px;">{{=pdate(event.created_on)}}</div>
<div class="eight columns" style="text-align:right;font-size:14px;line-height:14px;padding:0px;">
<a>{{=T('reply')}}</a> | <a>{{=T('edit')}}</a> | <a>{{=T('delete')}}</a> &nbsp;&nbsp;
</div>
</li>
{{return}}

0 comments on commit 0fd434a

Please sign in to comment.