Jump to content

jmeischner

Member
  • Posts

    6
  • Joined

  • Last visited

Posts posted by jmeischner

  1. Hej Gordon,

     

    happy to hear that you're using/used the workflow.

     

    I can not test it on apple silicon but on Big Sur it's actually working for me. But the text you're getting in your note is exactly the text in one of the Alfred workflow steps (image) which should normally get executed instead of just passed as argument to the next step. So I would assume it's somehow a problem with Alfred and it's workflow execution 🙈

     

    From February onwards I'll hopefully be able to test it on a M1 chip, but in the meantime I can not reproduce it and therefore have no idea how to help 😓

     

    Sorry 🥺,

    Jan

    Bildschirmfoto 2020-12-10 um 09.32.40.png

  2. Alfred Bear Workflow

    This workflow should help to use templates in combination with the bear app.

     

    I created one once, which is far less customizable. Now I moved to a node version of this workflow where templates can use placeholders whose values can come from node scripts. 

     

    Link to GitHub Repo.

    Installation

    npm install --global alfred-bear

    Usage

    While creating note templates with static content can be useful, having the possibility to use dynamic placeholder from any source I want is really great. That's why I built this workflow.

    To get an idea how this should work, take a look at an example: the Jira Ticket

    The idea is that there is a index.yml which contains a list of your templates and some optional variables to configure the template behavior.

    The Index

    the index.yml has the following form

    templates:
      - title: "Weekly Review"
        file: "weekly-review/template.md"
        script: "weekly-review/script.js"
        newWindow: true
        var:
          myFirstVar: "Hello "
          mySecond: "World!"
        question: "Any Subtitle?"
    
      - title: "Jira Ticket"
        ...

    title

    The title is shown in the template list to choose from. Alfred Template Title

    file

    Path to the template markdown file. This file can contain 2 different styles of placeholder.

    1. Normal Alfred Dynamic Placeholder
    2. Placeholders with double curly braces {{myPlaceholder}} which follow the Handlebars syntax. These Placeholders could come from the script, var or question option.

    First the handlebars placeholders are replaced in the template and in the second step the dynamic placeholders from alfred.

    script [optional]

    Path to a node.js module file. This module has to export an [optional async] function which returns an object, whose properties are placeholder keys.

    To use other npm modules in this script, the script has to be a node module by itself. This means that templates can easily be shared as npm packages or repositories.

    // script.js
    const rp = require('request-promise');
    
    /**
     * [Async] function which gets the static variables
     * from the var option and the answer from 
     * the optional question.
     */
    async function greet(variables) {
      const data = await rp(variables.myRestApiEndpoint);
      return {
        myText: data.body
      }
    }
    
    module.exports = greet;

    newWindow [optional]

    Should the new note opened in a separate window?

    var [optional]

    List of static placeholders for the template (e.g. APIToken, BaseUrl for REST Call etc.)

    question [optional]

    Sets a question to the workflow which asks for an additional placeholder value. To use the answer of this question in the template or script the placeholder key is {{answer}}. Alfred Template Question

    The Template Directory

    There is a bear template directoy [default: ~/.bear-templates] -- which can be synced e.g. with a .dotfiles repository, Dropbox, etc. This directory should contain a template index [default: index.yml] and all the necessary files for your templates.

    These paths are handled by the bearTemplateIndex workflow variable which can be changed in the workflow settings.

    A possible template directory can have the following form

    - ~/.bear-templates
    '-- index.yml
    '-- weekly-review
      '-- template.md
      '-- script.js
    '-- jira-ticket
      '-- ticket.md
      '-- ticket.js
      '-- package.json
      '-- node_modules
    '-- diary.md
    ' ...
    

    Examples

    If someone built a nice basis for a template, feel free to add it to this list and make a PR.

    •  
  3. On 10/10/2019 at 7:30 PM, deanishe said:

     

    The default is actually ~ because you set bearTemplateDirectory to "Don't export", which means it's empty…

     

    @RobinB You need to go into the workflow's settings (the weird [𝑥] icon) and set bearTemplateDirectory to .bear-templates

     

    Thank you deanishe. I will reexport and upload the workflow and hopefully export the bearTemplateDirectory this time 😓

     

    Sorry for the inconvenience,

    Jan

  4. Alfred Bear Templates Workflow

    Workflow to create a bear note from a given template. These templates follow bear snippet syntax and can contain default alfred variables (e.g. {datetime}).

    The Templates live in the bearTemplateDirectory which is by default '~/.bear-templates' but can be changed by giving another path starting at the users home directory.

    Usage

    By default just type bt and then start to type. The Workflow suggests all template names it found in the bearTemplateDirectory. To get the snippet variables translated it pushes the template text to the clipboard. So after using the workflow the template is in Bear and also in your clipboard.

    Alfred Workflow.png

    Download

    You can download the workflow from Packal

×
×
  • Create New...