Action

omg.lol weblog

Posted by nico, Last update 5 months ago

UPDATES

5 months ago

Fixed some coding issues and modified bear archiving.

show all updates...

5 months ago

Fixed some coding issues and modified bear archiving.

about 1 year ago

fixed tags

about 1 year ago

republishing update

about 1 year ago

Added thanks to the omg.lol users @maique and @podiboq.

about 1 year ago

Added function so whatever rags you set in Drafts are retained on omg.lol

This action creates a new post on omg.lol’s weblog service, weblog.lol.

This script will take the first line of your draft and set it as title, and everything else as body. A new Draft is created in Archive with omg.lol weblog frontmatter(date, tags, title), your content is added, and the file published to omg.lol weblog. Your original is moved to Trash.

The title in Drafts will be escaped with // this makes it so you can see the title in Drafts, but omg.lol will ignore it.

You’ll need an omg.lol account, and the API key for that account. You’ll be asked for both during first run.

Steps

  • defineTemplateTag

    name
    blog
    template
    // [[title]]
    ---
    Date: [[date|%Y-%m-%d]] [[time|%H:%m]]
    Tags: [[tags]]
    Title: [[safe_title]]
    --- 
    
    # [[title]] 
    [[body]]
  • script

    // Storing the omg.lol credentials in Draft's Credential instead of the action code directly
    // Thank you podiboq: https://actions.getdrafts.com/a/2DT
    
    var credential = Credential.create("omg.lol weblog", "Store your omg.lol API key username privately");
    credential.addTextField("omg_username", "Your username");
    credential.addPasswordField("omg_api_key", "API Key");
    credential.authorize();
    
    // Get the values and store them: 
    let omg_api_key = credential.getValue("omg_api_key")
    let omg_username = credential.getValue("omg_username")
    
    var d = new Date("2015-12-01 21:15");
    
    var content = draft.processTemplate("[[blog]]");
    
    var random = Math.random().toString().substr(2, 8);
    
      var http = HTTP.create();
      var response = http.request({
    	"url": "https://api.omg.lol/address/" + omg_username + "/weblog/entry/" + random + "/",
    	"method": "POST",
    	"data": { "content": content},
    	"headers": {
    	  "Authorization": "Bearer " + omg_api_key
    	}
      });
  • createDraft

    template
    [[blog]]
    tags
    omg, blog
    folder
    archive
    flagged
    false
    openInEditor
    false
  • callbackUrl

    template
    bear://x-callback-url/create?title=[[title]]&text=[[blog]]&tags=blog
    waitForResponse
    true
    encodeTags
    true

Options

  • After Success Archive , Tags: blog
    Notification Info
    Log Level Info
Items available in the Drafts Directory are uploaded by community members. Use appropriate caution reviewing downloaded items before use.