Beispiel #1
0
 def add_related(docs):
     docs = tuple(docs)
     index = build_index(docs)
     for doc in docs:
         tags = get(taxonomy, doc)
         related = pipe(_get_indexes(index, tags), Docs.dedupe,
                        Docs.remove_id_path(doc.id_path), tuple)
         yield put(meta_related, doc, related)
Beispiel #2
0
def autotemplate(doc):
    """
    Set template based on top-level directory in doc's id_path.

    E.g. if top-level-directory is "posts", template gets set to "posts.html".
    """
    if get(template, doc) != "":
        return doc
    else:
        return put(template, doc, _infer_template(doc))
Beispiel #3
0
def from_doc(doc):
    """
    Read stub from doc
    """
    return Stub(get(Doc.id_path, doc), get(Doc.output_path, doc),
                get(Doc.created, doc), get(Doc.modified, doc),
                get(Doc.title, doc), get(Doc.meta_summary, doc))
Beispiel #4
0
def should_template(doc):
    """
    Check if a doc should be templated. Returns a bool.
    """
    return get(Doc.template, doc) is not ""
Beispiel #5
0
def has_backlinks(doc):
    return len(get(meta_backlinks, doc)) > 0
Beispiel #6
0
def has_links(doc):
    return len(get(meta_links, doc)) > 0
Beispiel #7
0
 def summary(docs):
     for doc in docs:
         if get(Doc.meta_summary, doc):
             yield doc
         else:
             yield put(Doc.meta_summary, doc, read_summary(doc.content))
Beispiel #8
0
 def with_template_on_doc(doc):
     if get(template, doc) != "":
         return doc
     else:
         return put(template, doc, t)