Skip to content

Commit

Permalink
new UI
Browse files Browse the repository at this point in the history
  • Loading branch information
bigeagle committed Feb 28, 2011
1 parent 753253a commit a2366cd
Show file tree
Hide file tree
Showing 9 changed files with 265 additions and 108 deletions.
4 changes: 4 additions & 0 deletions app.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ handlers:
upload: static/images/(.*\.(gif|png|jpg))
secure: optional

- url: /(.*\.(css|js))
static_files: template/\1
upload: template/(.*\.(css|js))
secure: optional
# Handle request
- url: /.*
script: index.py
2 changes: 1 addition & 1 deletion config.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,5 +37,5 @@

## 其他参数设置
MENTIONS_COUNT = 15 # 提及页面的显示条数
HOME_COUNT = 30 # 主页面显示条数
HOME_COUNT = 20 # 主页面显示条数

55 changes: 37 additions & 18 deletions index.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,28 +71,47 @@ def get(self):
auth = tweepy.OAuthHandler(config.CONSUMER_KEY, config.CONSUMER_SECRET)
auth.set_access_token(config.ACCESS_TOKEN, config.ACCESS_SECRET)
api = tweepy.API(auth)

max_id = self.request.get('max_id')
#logging.info(max_id)

if max_id=='':
RT=api.list_timeline(owner='xdlinux',slug='rt-2',per_page=count+1,page=2)
#RT = tweepy.Cursor(api.list_timeline,owner='xdlinux',slug='rt-2').items(count)
max_id=RT[-1].id
RT.pop()

user = self.request.get('user')

if user == 'xdlinux':
slug = 'rt-2'
elif user == 'xdlinuxbot':
slug = 'rt'
else:
max_id=int(max_id)
RT=api.list_timeline(owner='xdlinux',slug='rt-2',max_id=max_id,per_page=count+1)
#RT = tweepy.Cursor(api.list_timeline,owner='xdlinux',slug='rt-2',max_id=max_id).items(count)
max_id=RT[-1].id
RT.pop()
user = 'xdlinux'
slug = 'rt-2'

page = self.request.get('page')
if page == '':
page = 1
else:
page = int(page)

RT=api.list_timeline(owner=user,slug=slug,per_page=count,page=page)

logging.info('Check list')

next="RT?max_id=%d" % max_id
logging.info(RT[0].created_at)

#时区调整
for i in range(len(RT)):
Ttime=str(RT[i].created_at)
Ttime=Ttime.replace(':','-')
Ttime=Ttime.replace(' ','-')
T=Ttime.split('-')
for t in range(6):
T[t]=int(T[t])
Ttime=datetime(T[0],T[1],T[2],T[3],T[4],T[5])+timedelta(hours=+8)
RT[i].created_at=Ttime.strftime('%Y-%m-%d %H:%M:%S')

next="RT?user=%s&page=%d" % (user,(page+1))
if page > 1:
prev="RT?user=%s&page=%d" % (user,(page-1))
else:
prev=''

path = os.path.join(os.path.dirname(__file__), 'template/index.html')
self.response.out.write(template.render(path, { 'RT': RT ,'NEXT': next}))
self.response.out.write(template.render(path, { 'RT': RT ,'NEXT': next, 'PREV':prev, 'LIST':user}))

# 自动回Fo所有新的Followers
class FollowAllNewcomers(webapp.RequestHandler):
Expand Down Expand Up @@ -138,7 +157,7 @@ def get(self):
logging.debug('CronJobCheck() access denied!')
logging.critical('如果这个请求不是由你手动触发的话,这意味者你的CronJobKey已经泄漏!请立即修改CronJobKey以防被他人利用')
return
#


mydate = datetime.utcnow() + timedelta(hours=+8)
ts_hour = mydate.time().hour
Expand Down
Binary file added static/images/bg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified static/images/favicon.ico
Binary file not shown.
Binary file added static/images/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
120 changes: 31 additions & 89 deletions template/index.html
Original file line number Diff line number Diff line change
@@ -1,97 +1,35 @@
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="refresh" content="300" />
<title>Timeline @xdlinux</title>
<style>
* {
margin: 0px;
padding: 0px;
}

div {
display: block;
}

#page-outer {
margin: 0px auto;
max-width: 1120px;
min-width: 1000px;
padding-top: 10px;
text-align: center;
}
#component {
margin-left: auto;
margin-right: auto;
max-width: 720px;
min-width: 720px;
width: 720px;
overflow: hidden;
position: relative;
text-align: left;
z-index: 1;
}

.tweet {
padding: 5px 10px 3px 10px;
margin-top: 5px;
border-left: 1px solid #CCCCCC;
border-bottom: 1px solid #CCCCCC;
background-color: #E8F0FC;
}
.tweet-row {
display: block;
line-height: 15px;
position: relative;
color: #333;
}

.tweet-user-block {
float: left;
}
.tweet-user-block img {
height: 48px;
width: 48px;
}
.tweet-user-block-name {
line-height: 18px;
margin-left: 49px;
padding-top: 2px;
padding-left: 10px;
padding-bottom: 2px;
color: #0084B4;
}
.tweet-user-block-desc {
font-size: 14px;
line-height: 16px;
margin-left: 49px;
min-height: 36px;
padding-top: 2px;
padding-left: 10px;
padding-bottom: 4px;
color: #AAA;
}

.tweet-text {
font-family: Arial, 'Helvetica Neue', sans-serif;
line-height: 19px;
padding: 0px;
word-wrap: break-word;
margin-left: 10px;
min-height: 48px;
}
.tweet-timestamp {
font-size: 13px;
line-height: 22px;
margin-left: 10px;
}
.tweet-timestamp a {
color: #999;
}
</style>
<link rel="stylesheet" type="text/css" href="style.css" />
<script src="/jquery-1.5.1.min.js"></script>
<script language="javascript">
$(function(){
//当鼠标滑入时将div的class换成divOver
$('.tweet').hover(function(){
$(this).addClass('tweetHover');
},function(){
//鼠标离开时移除divOver样式
$(this).removeClass('tweetHover');
}
);
});
</script>
</head>
<body>
<div id="page-outer">
<div id="component">
<div id="top">
<div class="logo"><img src ="/logo.png"></div>
<div class="nav-main">
<ul>
<li class={% ifequal LIST 'xdlinux' %}"now"{%else%}"notnow"{%endifequal%}> <a href="/RT?user=xdlinux&page=1">生活圈</a> </li>
<li class={% ifequal LIST 'xdlinuxbot' %}"now"{%else%}"notnow"{%endifequal%}><a href="/RT?user=xdlinuxbot&page=1">实时</a> </li>
</ul>
</div>
</div>
{% for status in RT %}
<div class="tweet">
{% if status.user %}
Expand All @@ -100,11 +38,10 @@
<img src="{{ status.user.profile_image_url }}" />
</div>
<div class="tweet-user-block-name">
<b>@{{ status.user.screen_name }}</b>
<a href="https://twitter.com/{{status.user.screen_name}}"><b>@{{status.user.screen_name}}</b></a>
</div>
<div class="tweet-user-block-desc">
{{ status.user.description }}
{{ status.id}}
</div>
</div>
{% endif %}
Expand All @@ -119,9 +56,14 @@
</div>
</div>
{% endfor %}
</div>
<div id="nav-bar">
{% if PREV %}
<a href={{PREV}}>prev page</a>
{% endif %}
<a href={{NEXT}}>next page</a>
</div>
</div>
</div>

</body>
</html>
16 changes: 16 additions & 0 deletions template/jquery-1.5.1.min.js

Large diffs are not rendered by default.

Loading

0 comments on commit a2366cd

Please sign in to comment.