|
|
@ -18,14 +18,21 @@ def get_recent(limit=config.recent_pastes):
|
|
|
|
recent_pastes = []
|
|
|
|
recent_pastes = []
|
|
|
|
i = 0
|
|
|
|
i = 0
|
|
|
|
while i < limit and i < len(paths):
|
|
|
|
while i < limit and i < len(paths):
|
|
|
|
|
|
|
|
if paths[i].is_file():
|
|
|
|
with open(paths[i]) as fp:
|
|
|
|
with open(paths[i]) as fp:
|
|
|
|
|
|
|
|
try:
|
|
|
|
paste = json.loads(fp.read())
|
|
|
|
paste = json.loads(fp.read())
|
|
|
|
|
|
|
|
except json.JSONDecodeError:
|
|
|
|
|
|
|
|
i += 1
|
|
|
|
|
|
|
|
continue
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Set extra metadata
|
|
|
|
basename = path.basename(paths[i])
|
|
|
|
basename = path.basename(paths[i])
|
|
|
|
paste['unique_id'] = basename[:-8] if basename.endswith(".expires") else basename
|
|
|
|
paste['unique_id'] = basename[:-8] if basename.endswith(".expires") else basename
|
|
|
|
paste['content'] = '\n'.join(paste['content'].splitlines()[0:10])
|
|
|
|
paste['content'] = '\n'.join(paste['content'].splitlines()[0:10])
|
|
|
|
paste['icon'] = common.get_icon(paste['language'])
|
|
|
|
paste['icon'] = common.get_icon(paste['language'])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Replace preview if encrypted
|
|
|
|
if paste['encrypted']:
|
|
|
|
if paste['encrypted']:
|
|
|
|
paste['content'] = "[Encrypted]"
|
|
|
|
paste['content'] = "[Encrypted]"
|
|
|
|
|
|
|
|
|
|
|
@ -40,7 +47,10 @@ def get_paste(unique_id, key=""):
|
|
|
|
|
|
|
|
|
|
|
|
if file_path is not None:
|
|
|
|
if file_path is not None:
|
|
|
|
with open(file_path, "r") as fp:
|
|
|
|
with open(file_path, "r") as fp:
|
|
|
|
|
|
|
|
try:
|
|
|
|
paste = json.loads(fp.read())
|
|
|
|
paste = json.loads(fp.read())
|
|
|
|
|
|
|
|
except json.JSONDecodeError:
|
|
|
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
|
|
# Check if paste is expired
|
|
|
|
# Check if paste is expired
|
|
|
|
if common.is_expired(paste):
|
|
|
|
if common.is_expired(paste):
|
|
|
|