article footer file is named 'tail;' snippet shows title, full text, and link
This commit is contained in:
@@ -9,7 +9,7 @@ def file_to_string(f):
|
|||||||
return text
|
return text
|
||||||
|
|
||||||
def fill_text(f):
|
def fill_text(f):
|
||||||
return file_to_string('../res/head.txt') + file_to_string(f) + file_to_string('../res/foot.txt')
|
return file_to_string('../res/head.txt') + file_to_string(f) + file_to_string('../res/tail.txt')
|
||||||
|
|
||||||
def create_files(files, directory):
|
def create_files(files, directory):
|
||||||
for f in files:
|
for f in files:
|
||||||
|
|||||||
+14
-5
@@ -18,20 +18,21 @@ def list_snippets(articles):
|
|||||||
limit = 4
|
limit = 4
|
||||||
total = len(articles)
|
total = len(articles)
|
||||||
head = count_lines('entries/raw/res/head.txt')
|
head = count_lines('entries/raw/res/head.txt')
|
||||||
|
tail = count_lines('entries/raw/res/tail.txt')
|
||||||
result = []
|
result = []
|
||||||
|
|
||||||
for article in articles:
|
for article in articles:
|
||||||
text = []
|
text = []
|
||||||
a = []
|
a = []
|
||||||
|
length = 0
|
||||||
with open('entries/feature/' + article) as f:
|
with open('entries/feature/' + article) as f:
|
||||||
text = f.readlines()
|
text = f.readlines()
|
||||||
|
length = len(text)
|
||||||
a.append(text[head])
|
a.append(text[head])
|
||||||
a.append(snip_article("words words words"))
|
a.append(snip_article(find_content(article, length, head, tail)))
|
||||||
a.append("11/22/33")
|
a.append(text[head + 1])
|
||||||
a.append("social")
|
a.append("social")
|
||||||
a.append("link")
|
a.append('entries/feature/' + article)
|
||||||
result.append(a)
|
result.append(a)
|
||||||
return result
|
return result
|
||||||
|
|
||||||
@@ -41,6 +42,14 @@ def count_lines(fname):
|
|||||||
pass
|
pass
|
||||||
return linenum
|
return linenum
|
||||||
|
|
||||||
|
def find_content(article, length, head, tail):
|
||||||
|
content = ""
|
||||||
|
with open('entries/feature/' + article) as f:
|
||||||
|
for pos, line in enumerate(f):
|
||||||
|
if pos > head and pos < length - tail:
|
||||||
|
content += line
|
||||||
|
return content
|
||||||
|
|
||||||
def snip_article(article):
|
def snip_article(article):
|
||||||
# read text in article
|
# read text in article
|
||||||
# clean 250 first characters
|
# clean 250 first characters
|
||||||
|
|||||||
Reference in New Issue
Block a user