Permalink
Browse files

beautify pages

  • Loading branch information...
1 parent 54c159e commit 658a1b28c56f23d5c93343d9b6e79c4bd29a050a David Shieh committed Mar 4, 2010
Showing with 102 additions and 23 deletions.
  1. +77 −16 static/css/styles.css
  2. +7 −0 templates/_leftbar.html
  3. +6 −4 templates/base.html
  4. +7 −1 templates/index.html
  5. +5 −2 views.py
View
@@ -1,39 +1,77 @@
/** CSS Reset **/
-* {padding:0; margin:0;}
-a {text-decoration:none;}
-img {border:none;}
-a:link,
-a:visited {
- color:black;
-}
-a:hover {
- color:#D90000;
-}
-.clearfloat {
- clear:both;
-}
+* { padding:0; margin:0; }
+a { text-decoration:none; }
+img { border:none; }
+.clearfloat { clear:both; }
/** body **/
body {
background-color:#333;
}
+#foot {
+ color:#9FC671;
+ font-size:10px;
+ margin:10px 0;
+}
+#foot a:link,
+#foot a:visited {
+ text-decoration:underline;
+ color:#A76B2E;
+}
#side_bar {
width:200px;
float:left;
+ padding:20px 10px;
+}
+#side_bar a:link,
+#side_bar a:visited {
color:#9FC671;
+ font-size:12px;
+}
+#side_bar a:hover {
+ text-decoration:underline;
+ color:#649EDA;
+}
+.side_bar_component {
+ margin:20px;
+ padding:10px;
+}
+.side_bar_component h2 {
+ color:#98E3FC;
+ font-size:18px;
+ margin:10px 0;
+}
+.side_bar_component ul {
+ list-style:disc;
+ margin-left:20px;
}
#main {
width:740px;
float:left;
+ margin:20px 0;
+}
+#blog_list {
background-color:#FBF8EF;
padding:10px;
- margin:20px 0;
+}
+#blog_list > ul {
+ margin: 10px 0 10px 30px;
+}
+#blog_list > h2 {
+ font-size:14px;
+ color:#3177C1;
+}
+#blog_list > ul a:link,
+#blog_list > ul a:visited {
+ font-size:12px;
+ text-decoration:underline;
+ color:#A76B2E;
}
.blog_each {
padding:10px;
margin:10px 0;
- border-top:1px dashed #FF9595;
- border-top-width:70%;
+ /**border-top:1px dashed #FF9595;
+ border-top-width:70%;**/
}
.blog_each > h1 {
font-size:22px;
@@ -65,3 +103,26 @@ body {
text-decoration:underline;
color:#A76B2E;
}
+.blog_each > div ol,
+.blog_each > div ul {
+ margin-left:20px;
+}
+
+/** page link style **/
+#page_link {
+ font-size:12px;
+}
+#page_link a:link,
+#page_link a:visited {
+ color:#3177C1;
+}
+#pre_page {
+ float:left;
+}
+#next_page {
+ float:right;
+}
+#cur_page {
+ width:100%;
+ text-align:center;
+}
View
@@ -1,5 +1,12 @@
<div id="side_bar">
<div class="side_bar_component">
+ <h2>导航</h2>
+ <ul>
+ <li><a href="/">首页</a></li>
+ <li><a href="http://paste.davidx.me/">大卫粘贴</a></li>
+ <li><a href="/page/about/">关于davidx</a></li>
+ </div>
+ <div class="side_bar_component">
<h2>标签</h2>
{% for tag in tags %}
<span><a href="/tag/{{ tag.name }}/">{{ tag.name }}</a></span>
View
@@ -10,10 +10,12 @@
</head>
<body>
{% include "_leftbar.html" %}
- <div id="main">{% block content %}{% endblock %}</div>
+ <div id="main">
+ {% block content %}{% endblock %}
+ <div id="foot">
+ <p>版权所有©2009 <a href="http://davidx.me/">David Xie</a> | 如有转贴, 请注明出处. @转自<a href="http://davidx.me/">&lt;泥泞的沼泽:http://davidx.me/&gt;</a> | Powered by <a href="http://webpy.org/" target="_blank">web.py</a> | 页面加载耗时 {{ "%.3f" % usedTime }}s</p>
+ </div>
+ </div>
<br class="clearfloat" />
- <div id="foot">
- <p>版权所有©2009 <a href="http://davidx.me/">David Xie</a> | 如有转贴, 请注明出处. @转自<a href="http://davidx.me/">&lt;泥泞的沼泽:http://davidx.me/&gt;</a> | Powered by <a href="http://webpy.org/" target="_blank">web.py</a> | 页面加载耗时 {{ "%.3f" % usedTime }}s</p>
- </div>
</body>
</html>
View
@@ -2,6 +2,12 @@
{% block title %}首页{% endblock %}
{% block content %}
<div id="blog_list">
+ <h2>随机文章:</h2>
+ <ul>
+ {% for entry in randomEntries %}
+ <li><a href="/entry/{{ entry.slug }}/">{{ entry.title }}</a></li>
+ {% endfor %}
+ </ul>
{% if entries %}
{% for entry in entries %}
{% include "_entry.html" %}
@@ -14,7 +20,7 @@
{% if p.page < p.pages %}
<span id="next_page"><a href="/?page={{ p.nextPage }}">下一页</a></span>
{% endif %}
- <span id="cur_page">{{ p.page }}/{{ p.pages }}</span>
+ <p id="cur_page">{{ p.page }}/{{ p.pages }}</p>
</div>
</div>
{% endblock %}
View
@@ -2,6 +2,7 @@
from datetime import datetime
import time
import cgi
+import random
import web
from forms import commentForm
from settings import db, render, pageCount
@@ -55,12 +56,14 @@ class index(object):
def GET(self):
# 读取当前页的文章
i = web.input(page=1)
+ ids = [int(one.id) for one in web.ctx.orm.query(Entry.id).all()]
+ randomEntries = [web.ctx.orm.query(Entry).filter_by(id=id).first() for id in random.sample(ids, 5)]
entryCount = web.ctx.orm.query(Entry).count()
p = Pagination(entryCount, 5, int(i.page))
- d['entries'] = web.ctx.orm.query(Entry).order_by('entries.createdTime DESC')[p.start:p.limit]
+ d['entries'] = web.ctx.orm.query(Entry).order_by('entries.createdTime DESC')[p.start:p.start + p.limit]
d['p'] = p
d['usedTime'] = time.time() - d['startTime']
-
+ d['randomEntries'] = randomEntries
return render.index(**d)
class entry(object):

0 comments on commit 658a1b2

Please sign in to comment.