gallery blueimp
This commit is contained in:
17
utils.py
17
utils.py
@@ -5,6 +5,8 @@ import os
|
||||
import re
|
||||
from os.path import isfile, abspath
|
||||
|
||||
from collections import namedtuple
|
||||
LinkElement=namedtuple("LinkElement", ["title", "url","desc"])
|
||||
|
||||
def pjoin2 (pth):
|
||||
if (not type(pth) is list):
|
||||
@@ -32,3 +34,18 @@ def path_depth(path):
|
||||
if p_split[-1]=='index' or p_split[-1]=='index.json' :
|
||||
cc=cc-1
|
||||
return cc
|
||||
|
||||
def page_to_link(pages, url_for_method):
|
||||
"page to url"
|
||||
for p in pages:
|
||||
yield LinkElement(title=p.meta.get("title",p.path),
|
||||
url=url_for_method(name=p.path),
|
||||
desc='/'.join(p.path.split('/')[-2:-1])
|
||||
)
|
||||
def file_to_link(files, url_for_method):
|
||||
"file to url"
|
||||
for p in files:
|
||||
yield LinkElement(title=p,
|
||||
url=url_for_method(name=p),
|
||||
desc=""
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user