Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const alfy = require('alfy')
const utils = require('./lib/utils')
const promises = []
const items = []
// teams config
const teams = alfy.config.get('figma.teams') ? JSON.parse(alfy.config.get('figma.teams')) : []
const isAddingTeam = alfy.input.match(/^add\shttps:\/\/www\.figma\.com\/files\/team\/(\d+)\/([^\/]+)/i)
if(isAddingTeam) {
return alfy.output([{
title: isAddingTeam[2],
subtitle: `Add ${isAddingTeam[2]} team’s project files to your search results.`,
arg: JSON.stringify({id: isAddingTeam[1], name: isAddingTeam[2]}),
variables: {
action: 'add',
notification: `${isAddingTeam[2]} team’s projects and files added to search results.`
}
}])
}
Promise.all(teams.map(team => {
return Promise.resolve(items.push({
/* eslint-disable no-unused-vars */
/* eslint-disable camelcase */
const alfy = require('alfy')
const ankiConnect = require('./anki-connect')
const decks = require('./anki-decks')
const nameOfDeck = alfy.config.get('default-deck')
const note_type = Object.keys(alfy.config.get('default-model'))[0]
const logResult = {
error: [],
result: []
}
module.exports = async function (output) {
/* eslint-disable no-await-in-loop */
for (let i = 0; i < output.length; i++) {
if (output[i].Homnum) {
output[i].Headword = `${output[i].Headword}<span class="HOMNUM-title">${
output[i].Homnum.toString()}</span>`
}
delete output[i].Inflections // Can't understood the reason of error without delete
/* eslint camelcase: ["error", {properties: "never"}] */
/* eslint-parserOptions: {"ecmaVersion: 2017"} */
'use strict'
const fs = require('fs')
const alfy = require('alfy')
const jsonfile = require('jsonfile')
const pMap = require('p-map')
const {markdownIt} = require('./utils/engine')
const ankiAddCard = require('./anki/anki-add-card')
const config = require('./config').card
const modelFieldNames = require(`${process.env.alfred_workflow_data}/anki-model-fields.json`)
const modelId = alfy.config.get('default-model') ? alfy.config.get('default-model')[Object.keys(alfy.config.get('default-model'))[0]] : null
const header = jsonfile.readFileSync(config.input)
let firstField = [Object.keys(header)[0]]
if (firstField[0] === undefined) {
firstField = modelFieldNames[0]
header[firstField] = ''
}
async function main(id) {
setupDirStructure()
const cleanedInput = cleanInput(header)
const output = await processInput(cleanedInput, id)
await ankiAddCard(output)
}
const mapper = key => ({
title: `${key} ⇒ ${
Object.keys(alfy.config.get(key))[0] === undefined ? config.models['default-model'] : Object.keys(alfy.config.get(key))[0]}`,
subtitle: '↵ pick out another model...',
valid: false,
autocomplete: `!model ${key} `,
icon: {path: './icons/Model.png'}
})
const alfy = require('alfy')
const jsonfile = require('jsonfile')
const WorkflowError = require('../utils/error')
const decks = require('../anki/anki-decks')
const {errorAction} = require('../utils/error')
const config = require('../config').card
const {modelExist} = require('./anki-models')
const ankiConnect = require('./anki-connect')
const fileAnkiDecks = `${process.env.alfred_workflow_data}/anki-decks.json`
const model = alfy.config.get('default-model') ? Object.keys(alfy.config.get('default-model'))[0] : null
module.exports = async () => {
const introMessage = [{
name: 'intro',
title: alfy.config.get('default-deck') ? 'Create new card (⌘ + ↵)' : 'press ↵ or ↹ to select default deck',
subtitle: alfy.config.get('default-deck') ? `🧰 ${alfy.config.get('default-deck')} ⚒ ${model} 👤 ${alfy.config.get('default-profile')}` : '',
icon: {path: './icons/anki.png'},
autocomplete: '!deck default-deck ',
valid: false,
arg: '',
quicklookurl: `${config.mediaDir}/_preview.html`,
mods: {
alt: {
subtitle: '❌ RESET',
valid: true,
variables: {
const mapper = key => ({
title: `${key} ⇒ ${
alfy.config.get(key) === undefined ? config.defaults['default-deck'] : alfy.config.get(key)}`,
subtitle: '↵ pick out another ...',
valid: false,
autocomplete: `!deck ${key} `,
icon: {path: './icons/deck-settings.png'}
})
item.subtitle = field
item.arg = ''
item.quicklookurl = `${config.mediaDir}/_preview.html`
item.icon = alfy.config.get('fields') && alfy.config.get('fields')[modelId][field] === 'rli' ? fs.existsSync(`./icons/${field}.png`) ? `./icons/${field}_marked.png` : './icons/flag_marked.png' : fs.existsSync(`./icons/${field}.png`) ? `./icons/${field}.png` : './icons/flag.png'
item.variables = variables(field)
item.mods = mods(field)
items.push(item.getProperties())
}
const tags = new Render('Tags',
'title', 'variables', 'quicklookurl', 'subtitle', 'arg', 'icon', 'mods')
tags.title = header[modelId] && header[modelId].Tag ? header[modelId].Tag : '...'
tags.subtitle = 'Choose your tags'
tags.arg = ''
tags.quicklookurl = `${config.mediaDir}/_preview.html`
tags.icon = alfy.config.get('Tag') === 'rli' ? './icons/tag_marked.png' : './icons/tag.png'
tags.variables = {
mode: 'Tags',
action: 'work'
}
tags.mods = mods('Tag')
items.push(tags.getProperties())
return items
}
const mapper = key => ({
title: key,
subtitle: `current deck is ⇒ ${alfy.config.get('default-deck')} | ↵ choose this or pick out another`,
valid: false,
autocomplete: `!del ${key} `,
icon: {path: './icons/delete.png'}
})
case 'modelExist':
if (alfy.config.get('default-model')) {
title = `model "${Object.keys(alfy.config.get('default-model'))[0]}" was not found`
subtitle = `Pres ⇤ (tab) to pick out exist note type. Or ⇧↵ to open Anki & choose another profile which has current note type.`
text = {largetype: subtitle}
autocomplete = '!models default-model '
} else {
title = `no model selected`
subtitle = `Pres ⇤ (tab) to pick out exist note type. Or ⇧↵ to open Anki & choose another profile which has current note type.`
text = {largetype: subtitle}
autocomplete = '!models default-model '
}
break
case 'new-profile':
title = `Select model for [👤${alfy.config.get('default-profile')}] profile`
subtitle = `Pres ⇤ (tab) to pick out exist profile. Or ⇧↵ to open Anki & choose another profile which has current note type.`
text = {largetype: subtitle}
autocomplete = '!models default-model '
break
case '!deck decks':
title = null
subtitle = '⇧↵ to open Anki. | ⌘L to see the stack trace'
text = {largetype: subtitle}
autocomplete = '!deck '
break
case '!model models':
title = null
subtitle = '⇧↵ to open Anki. | ⌘L to see the stack trace'
text = {largetype: subtitle}
autocomplete = '!model '
break
const alfy = require('alfy');
function getRtf(colorList, codeBlock, bg) {
return `{\\rtf1\\ansi
{\\fonttbl\\f0\\fswiss\\fcharset0 Menlo;}
{\\colortbl;${colorList};}
\\f0\\fs24
${codeBlock}${bg}
}`;
}
module.exports = {
theme: alfy.config.get('theme') || 'github',
getRtf: getRtf,
};