subtitle = 'NOTE: {0} URL: {1}...'.format(note_title, 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()
Esempio n. 2
0
items.addMod(
    arg=u"{0}||paste".format(query),
    icon_path="icons/new_from_clipboard.png",
    icon_type="image",
    key="alt",
    subtitle=u"\"{0}\" ({1})".format(query, zettel_action),
)
items.addMod(
    arg=u"{0}||paste".format(query_alt),
    icon_path="icons/new_from_clipboard.png",
    icon_type="image",
    key="cmd+alt",
    subtitle=u"\"{0}\"".format(query_alt),
)
items.setIcon('icons/new.png', 'image')
items.addItem()

templates_list = search.templates()

if len(templates_list) > 0:
    for file in templates_list:
        items.setItem(
            arg=u"{0}|{1}|".format(query, file['path']),
            subtitle=u"\"{0}\" ({1}, {2}. {3})".format(query, zettel_action,
                                                       paste_action,
                                                       quicklook_action),
            title=u"Create note from template: {0}".format(file['filename']),
            type='file',
            quicklookurl=file['path'],
        )
        items.addMod(
Esempio n. 3
0
def get_json_from_file(file):
    return json.load(codecs.open(file, 'r', 'utf-8-sig'))['roots']


wf = Items()
query = Tools.getArgv(1) if Tools.getArgv(1) is not None else str()
bookmarks_file = path_to_bookmarks()

if bookmarks_file is not None:
    bm_json = get_json_from_file(bookmarks_file)
    bookmarks = get_all_urls(bm_json)
    for bm in bookmarks:
        name = bm.get('name')
        url = bm.get('url')
        if query == str() or query.lower() in name.lower():
            wf.setItem(title=name, subtitle=url, arg=url, quicklookurl=url)
            wf.addItem()

    if wf.getItemsLengths() == 0:
        wf.setItem(title='No Bookmark found!',
                   subtitle='Search \"%s\" in Google...' % query,
                   arg='https://www.google.com/search?q=%s' % query)
        wf.addItem()
else:
    wf.setItem(title="Bookmark File not found!",
               subtitle='Ensure Brave is installed',
               valid=False)
    wf.addItem()

wf.write()