|
|
@ -1,13 +1,13 @@
|
|
|
|
import datetime, os, re
|
|
|
|
import datetime, os, re
|
|
|
|
from bottle import error, response, route, run, static_file, template, TEMPLATE_PATH
|
|
|
|
from bottle import error, response, route, run, static_file, template, TEMPLATE_PATH
|
|
|
|
|
|
|
|
|
|
|
|
# List up to 3 recommended articles for current article
|
|
|
|
|
|
|
|
def list_rec(page):
|
|
|
|
def list_rec(page):
|
|
|
|
loc = 'diary/entries/'
|
|
|
|
loc = 'diary/entries/'
|
|
|
|
result = []
|
|
|
|
result = []
|
|
|
|
rec = []
|
|
|
|
rec = []
|
|
|
|
comment = ""
|
|
|
|
comment = ""
|
|
|
|
if isinstance(page, int):
|
|
|
|
if isinstance(page, int):
|
|
|
|
|
|
|
|
# Collect recommended articles from comment line
|
|
|
|
with open('diary/entries/' + str(page)) as f:
|
|
|
|
with open('diary/entries/' + str(page)) as f:
|
|
|
|
comment = f.readline()
|
|
|
|
comment = f.readline()
|
|
|
|
comment = comment.replace('<!--','')
|
|
|
|
comment = comment.replace('<!--','')
|
|
|
@ -15,14 +15,18 @@ def list_rec(page):
|
|
|
|
comment = comment.replace(' ','')
|
|
|
|
comment = comment.replace(' ','')
|
|
|
|
comment = clean(comment)
|
|
|
|
comment = clean(comment)
|
|
|
|
rec = comment.split(',')
|
|
|
|
rec = comment.split(',')
|
|
|
|
|
|
|
|
# Convert into array for template to display
|
|
|
|
for article in rec:
|
|
|
|
for article in rec:
|
|
|
|
path = loc + article
|
|
|
|
path = loc + article
|
|
|
|
data = []
|
|
|
|
data = []
|
|
|
|
with open(path) as f:
|
|
|
|
try:
|
|
|
|
f.readline()
|
|
|
|
with open(path) as f:
|
|
|
|
data.append(clean(f.readline().replace('<br>','')))
|
|
|
|
f.readline()
|
|
|
|
data.append(path)
|
|
|
|
data.append(clean(f.readline().replace('<br>','')))
|
|
|
|
result.append(data)
|
|
|
|
data.append(path)
|
|
|
|
|
|
|
|
result.append(data)
|
|
|
|
|
|
|
|
except EnvironmentError:
|
|
|
|
|
|
|
|
print("No article @ " + path)
|
|
|
|
return result
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
|
|
|
# List latest 5 articles as headline links
|
|
|
|
# List latest 5 articles as headline links
|
|
|
|