调整页面排版,增加摘要控制属性,调整页面时间格式

This commit is contained in:
lzjqsdd 2016-05-09 00:48:19 +08:00
parent 16faed70ce
commit 8ec307455c
6 changed files with 21 additions and 14 deletions

View File

@ -7,6 +7,7 @@ sys.setdefaultencoding('utf-8')
from Cut import Cut
import tools.Global as Global
import jieba
import time
class Search:
def __init__(self):
@ -59,11 +60,18 @@ class Search:
if len(result) == 0:
print 'Not Exists Record!'
newslist=list()
count = 0
for rst in result:
count+=1
if count > Global.listsize:
break
line = cut.getRow(int(rst),Global.cutnews_origin_dir,Global.filesize)
data = json.loads(line)
if isshow:
print data['title'],'\n',data['time'],'\n',data['content'],'\n'
tm = time.localtime(int(data['time']))
data['time'] = time.strftime('%Y-%m-%d %H:%M:%S',tm)
data['content'] = data['content'][0:Global.snippetsize]
newslist.append(data)
return newslist

Binary file not shown.

View File

@ -7,3 +7,5 @@ inverse_dir=project_root+"data/inversedata/"
cutnews_dir=project_root+"data/cutnews/"
cutnews_origin_dir=project_root+"data/orinews"
filesize = 100
snippetsize = 500
listsize = 15

Binary file not shown.

Binary file not shown.

View File

@ -9,9 +9,10 @@ $def with(searchword,newslist)
<script src="http://libs.baidu.com/bootstrap/3.0.3/js/bootstrap.min.js"></script>
</head>
<body>
<div style="padding: 100px 100px 8px;margin-top:10px">
<!--<div style="padding: 100px 100px 8px;margin-top:10px"> -->
<div style="margin-top:30px">
<form class="bs-example bs-example-form" role="form">
<div class="col-lg-8">
<div class="col-lg-8 col-lg-offset-2 ">
<div class="input-group">
<input type="text" class="form-control" name="searchword" placeholder=$searchword>
<span class="input-group-btn">
@ -20,28 +21,25 @@ $def with(searchword,newslist)
</div><!-- /input-group -->
</div><!-- /.col-lg-6 -->
</form>
<div>
</div>
<br><br><br><br>
$if len(newslist) > 0:
$for news in newslist:
<div style="padding: 100px 100px 8px;margin-top:5px">
<div class="col-lg-8">
<div class="col-lg-8 col-lg-offset-2">
<div class="panel panel-info">
<div class="panel-heading">
$news['title'],时间:$news['time']
</div>
<div class="panel-body">
$news['content'][0:100] ... <a href="#">查看全文>>></a>
时间:$news['time'] $news['title']
</div>
<div class="panel-body">
$news['content'] ... <a href="#">查看全文>>></a>
<br><br>
原始网页链接:<a href=$news['url']>$news['url']</a>
</div>
</div>
</div>
</div>
$else:
<div style="padding: 100px 100px 8px;margin-top:5px">
<div class="col-lg-8">
<div class="col-lg-8 col-lg-offset-2">
<div class="panel panel-info">
<div class="panel-heading">
未检索到相关新闻
@ -50,7 +48,6 @@ $else:
</div>
</div>
</div>
</div>
</body>
</html>