Ejemplo n.º 1
0
});
</script>
<div class="clearfix"></div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="container">
<section id="main">

<div class="content">
<div class="gallery">'''
    #Discover tab is to show all the tweet of all the users
    user = libw.getUser()
    cur = libw.sql_query("SELECT * from `tweets` ORDER BY timestamp DESC")
    for row in cur.fetchall():
        print '''
			<div class="twit t-wit">
			<span class="line"></span>
			<i class="twit-icon"></i>
			<span class="line"></span>
			<div style="text-align: right;color:#fff">'''
        print str(row[3]) + '</div><p>'  #timestamp
        print row[2]  #tweet
        print "</p><small><a href='profile.py?q=" + str(row[1]) + "'>@" + str(
            row[1]) + "</a></small></div>"
    print '''
</div>
</div>
Ejemplo n.º 2
0
});
});
</script>
<div class="clearfix"></div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="container">
<section id="main">
<div class="content">
<div class="gallery">'''
	#printing the tweets of all the following users in decreasing order of timestamp by inner joining three tables users, follows and tweets  
	cur = libw.sql_query('select Distinct f.user, u.user, t.tweet, t.timestamp from users inner join follows f on (f.user = "******") inner join users u on (u.user= f.follow) inner join tweets t on (t.user = f.follow) ORDER BY t.timestamp DESC')
	for row in cur.fetchall():
		print '''
<div class="twit t-wit">
<span class="line"></span>
<i class="twit-icon"></i>
<span class="line"></span>
<div style="text-align: right;color:#fff">'''
		print str(row[3])+'</div><p>' #timestamp
		print row[2]#tweet
		print "</p><small><a href='profile.py?q="+str(row[1])+"'>@"+str(row[1])+"</a></small></div>" #following user 
	print '''
</div>
</div>
</section>
</div>
Ejemplo n.º 3
0
cgitb.enable()

form = cgi.FieldStorage()

ret = libw.auth_cookie()
print "Content-type: text/html\n\n"

#follow and unFollow a person
if ret == 0:
    print '<meta http-equiv="refresh" content="0;url=http://localhost" />'
else:
    if ("a" in form) and ("q" in form):
        q = cgi.escape(form["q"].value)
        if cgi.escape(form["a"].value) == "unfollow":
            query = "delete from `follows` where `user`='" + str(
                libw.getUser()) + "' and `follow` = '" + str(q) + "'"
            cur = libw.sql_query(query)
            print '<meta http-equiv="refresh" content="0;url=profile.py?q=' + str(
                q) + '" />'
        else:
            query = "insert into `follows` (`user`, `follow`) values ('" + str(
                libw.getUser()) + "','" + str(q) + "')"
            cur = libw.sql_query(query)
            print '<meta http-equiv="refresh" content="0;url=profile.py?q=' + str(
                q) + '" />'
    elif ("q" in form):
        q = cgi.escape(form["q"].value)
        query = "insert into `follows` (`user`, `follow`) values ('" + str(
            libw.getUser()) + "','" + str(q) + "')"
        cur = libw.sql_query(query)
        print '<meta http-equiv="refresh" content="0;url=profile.py?q=' + str(
Ejemplo n.º 4
0
#!/usr/bin/env python
import cgi
import sys
import cgitb

#import libw from one dir back
sys.path.insert(0, '../')
import lib_web as libw

cgitb.enable()

# adding tweet into the tweets table
form = cgi.FieldStorage()
print "Content-type: text/html\n\n"
ret = libw.auth_cookie()
if ret == 1:
    if ("q" not in form):
        print 'Failed to update status'
    else:
        cur = libw.sql_query(
            'insert into `tweets` (`user`, `tweet`) values ("' +
            str(libw.getUser()) + '","' + str(cgi.escape(form["q"].value)) +
            '")')
else:
    print 'Failed to update status'
Ejemplo n.º 5
0
#!/usr/bin/env python
import sys
import cgitb, cgi

#import libw from one dir back
sys.path.insert(0, '../')
import lib_web as libw

cgitb.enable()
form=cgi.FieldStorage()

if ("q" in form):
	user = cgi.escape(form["q"].value)
else:
	user = libw.getUser()

user = user.lower()
ret = libw.auth_cookie()
print "Content-type: text/html\n\n"

if ret == 0:
	print '<meta http-equiv="refresh" content="0;url=http://localhost" />'
else:

	print '''
<!DOCTYPE HTML>
<html>
<head>
<title>Twitter Clone Profile</title>
<link href="css/bootstrap.css" rel='stylesheet' type='text/css' media="all" />
<script src="js/jquery-1.11.0.min.js"></script>
Ejemplo n.º 6
0
</script>
<div class="clearfix"></div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="container">
<section id="main">

<div class="content">
<div class="gallery">
<p>'''
	#showing all the following users of the login user into boxes and you can click on the user handle to open his/her profile 
	cur = libw.sql_query('select Distinct f.user, u.user from users inner join follows f on (f.user = "******") inner join users u on (u.user= f.follow)')
	for row in cur.fetchall():
		print '''
<div class="twit t-wit-follows">
<span class="line"></span>
<i class="twit-icon"></i>
<span class="line"></span>
<div style="text-align: right;color:#fff">''''</div><p>'
		print "</p><small><a href='profile.py?q="+str(row[1])+"'>@"+str(row[1])+"</a></small></div>"
	print '''
</div>
</div>
</section>
</div>

</body>