Action

omg.lol weblog

Posted by tekeous, Last update 8 months ago

UPDATES

8 months ago

fixed tags

show all updates...

8 months ago

fixed tags

8 months ago

republishing update

8 months ago

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

8 months 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
    weblog
    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("[[weblog]]");
    
    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
    [[weblog]]
    tags
    omg, weblog
    folder
    archive
    flagged
    false
    openInEditor
    false

Options

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