예제 #1
0
파일: __init__.py 프로젝트: drivet/yawt
    def on_files_changed(self, changed):
        changed = changed.content_changes().normalize()
        for repofile in changed.deleted + changed.modified:
            name = fullname(repofile)
            if name:
                self.unvisit(name)

        for a in g.site.fetch_articles_by_repofiles(changed.modified + changed.added):
            self.on_visit_article(a)

        self.on_post_walk()
예제 #2
0
파일: autotags.py 프로젝트: drivet/yawt
def _add_tags_for_indexed_article(indexed_file, edit):
    root_dir = current_app.yawt_root_dir
    if not indexed_file.startswith(content_folder()):
        print("file must be in content folder")
        return

    searcher = _whoosh().searcher
    docnums = searcher.document_numbers(fullname=fullname(indexed_file))
    keywords = [keyword for keyword, _
                in searcher.key_terms(docnums, "content", numterms=3)]
    keyword_str = ",".join(keywords)
    print("Tags: "+keyword_str)
    if edit:
        abs_article_file = os.path.join(root_dir, indexed_file)
        post = frontmatter.load(abs_article_file)
        post['tags'] = keyword_str
        save_file(abs_article_file, frontmatter.dumps(post))
예제 #3
0
파일: notify.py 프로젝트: drivet/yawt
def _notify_message(file_added):
    base_url = cfg('YAWT_NOTIFY_BASE_URL')
    name = fullname(file_added)
    link = os.path.join(base_url, name)
    return (link, link)