Exemple #1
0
if matches:
    for m in matches:
        note_title = m.get('title')
        note_path = m.get('path')
        links = m.get('links')
        for l in links:
            url_title = l.get('url_title')
            url = l.get('url')
            subtitle = f'NOTE: {note_title} URL: {url[:30]}...'
            alf.setItem(title=url_title,
                        subtitle=subtitle,
                        arg=url,
                        quicklookurl=url)
            alf.addMod('cmd',
                       note_path,
                       'Open MD Note',
                       icon_path='icons/markdown.png',
                       icon_type='image')
            alf.addMod('alt',
                       url,
                       "Copy URL to Clipboard",
                       icon_path='icons/clipboard.png',
                       icon_type='image')
            alf.addItem()
else:
    alf.setItem(title='No Bookmarks found...',
                subtitle='try again',
                valid=False)
    alf.addItem()
alf.write()
Exemple #2
0
    # Tag Search and sort based on number of Hits
    tag_results = md.tagSearch(query, 'count', reverse=True)

wf = Items()

if bool(tag_results):
    for tag, counter in tag_results.items():
        wf.setItem(
            title=f'{tag}',
            subtitle=f"{counter} Hit(s), ({K.CMD} to paste tag into frontmost app)",
            valid=True,
            arg=f'#{tag}'
        )
        wf.setIcon('icons/hashtag.png', 'image')
        wf.addMod(
            key='cmd',
            arg=f'#{tag} ',
            subtitle='Paste Tag into frontmost app',
            icon_path='icons/paste.png',
            icon_type='image'
        )
        wf.addItem()
else:
    wf.setItem(
        title="No Tags found!",
        subtitle="No Tags matches search term",
        valid=False
    )
    wf.addItem()
wf.write()
        # use default icon in alf WF directory in case searched wf has not icon defined
        icon_path = ip if os.path.isfile(ip) else 'icon.png'
        keyword_text = kf.get_keywords_scriptfilter()
        valid = kf.has_keywords()
        subtitle = description + \
            u', Keywords: ' + \
            keyword_text if valid else description
        if len(kf.get_keyboard_shortcuts()) > 0:
            subtitle += ", Keyboard: " + ",".join(kf.get_keyboard_shortcuts())
        arg = os.path.dirname(info_plist_path) + "|" + name
        alf.setItem(title=name,
                    subtitle=subtitle,
                    arg=arg,
                    automcomplete=name,
                    valid=valid,
                    quicklookurl=quicklook_url)
        alf.setIcon(icon_path, m_type="image")
        alf.addMod('cmd',
                   subtitle='Choose Action...',
                   arg=arg,
                   icon_path='icons/start.png',
                   icon_type='image',
                   valid=True)
        alf.addItem()
else:
    alf.setItem(title='No Workflow matches the search query!',
                subtitle=f"...for query: \"{query}\"",
                valid=False)
    alf.addItem()
alf.write()
if len(search_terms) > 0:
    sorted_file_list = md_search.notes_search(search_terms, search_type)
# get full list of file in case no search was entered
else:
    sorted_file_list = md_search.getFilesListSorted()
# Write search results into WF object
for f in sorted_file_list:
    c_date = Tools.getDateStr(f['ctime'])
    m_date = Tools.getDateStr(f['mtime'])
    wf.setItem(
        title=f['title'],
        subtitle=
        f"Created: {c_date}, Modified: {m_date} ({K.CMD} Actions, {K.SHIFT} Quicklook)",
        type='file',
        arg=f['path'])
    # Mod for CMD - new action menu
    wf.addMod(key="cmd",
              arg=f"{f['path']}>{query}",
              subtitle="Enter Actions Menu for the Note...",
              icon_path="icons/action.png",
              icon_type="image")
    wf.addItem()

if len(wf.getItems(response_type="dict")['items']) == 0:
    wf.setItem(
        title="Nothing found...",
        subtitle=f'Do you want to create a new note with title "{query}"?',
        arg=query)
    wf.addItem()
wf.write()
wf = Items()
if len(todos) > 0:
    for i in todos:
        md_path = pathname2url(i['path'])
        md_title = i['title'] if i['title'] != str() else Tools.chop(i['filename'], ext)
        wf.setItem(
            title=i['todo'],
            subtitle=f"{K.ARROW_RIGHT} {md_title} (Created: {Tools.getDateStr(i['ctime'])}, Modified: {Tools.getDateStr(i['mtime'])})",
            arg=i['path'],
            valid=True,
            type='file'
        )
        wf.setIcon('icons/unchecked.png', 'image')
        # Mod for CMD - new action menu
        wf.addMod(
            key="cmd",
            arg=f"{i['path']}>{query}",
            subtitle="Actions..",
            icon_path="icons/action.png",
            icon_type="image"
        )
        wf.addItem()
else:
    wf.setItem(
        title="No todo found!",
        subtitle="No todo matches search term",
        valid=False
    )
    wf.addItem()
wf.write()