Action

Today in Review

Last update 11 months ago - Unlisted

Query for drafts created or modified on the current date, build a Markdown summary list of those drafts and display it in a preview.

Steps

  • script

    //
    
    // create workspace for drafts created today
    let wsCreated = new Workspace()
    let st1 = new QueryDate();
    st1.field = "created"
    st1.type = "relative"
    st1.days = 0;
    wsCreated.startDate = st1;
    // load drafts
    let createdToday = wsCreated.query("all");
    
    // create workspace for drafts modified today
    let wsModified = new Workspace()
    let st2 = new QueryDate();
    st2.field = "modified"
    st2.type = "relative"
    st2.days = 0;
    wsModified.startDate = st2;
    // load drafts
    let modifiedToday = wsModified.query("all");
    
    // remove duplicates from modified
    modifiedToday = modifiedToday.filter(function(d) {
    	return !createdToday.map(c => c.uuid).includes(d.uuid);
    });
    
    var md = [
    	"# Daily Activity",
    	""
    ];
    
    // formatting function drafts
    function summary(d) {
    	return `- **${d.displayTitle}** [[open]](${d.permalink}) ${d.content.length}c ${d.tags.join(",")}`
    }
    
    if (createdToday.length == 0 && modifiedToday.length == 0) { // none found
    	md.push(`No Activity Found for Today`);
    }
    else { // we found some drafts...
    	if (createdToday.length > 0) {
    		md.push("## Created Today");
    		md.push("");
    		for (let d of createdToday) {
    			md.push(summary(d));
    		}
    		md.push("");
    	}
    	if (modifiedToday.length > 0) {
    		md.push("## Modified Today");
    		md.push("");
    		for (let d of modifiedToday) {
    			md.push(summary(d));
    		}
    		md.push("");
    	}
    }
    
    draft.setTemplateTag("content", md.join("\n"));
  • htmlpreview

    <!DOCTYPE html>
    <html dir="auto">
    
    <head>
      <title>[[title]]</title>
      <meta name="viewport" content="width=device-width, initial-scale=1">
      <style>
        @charset "utf-8";
    
        :root {
          --main-bg-color: white;
          --main-color: black;
          --alternate-bg-color: #efefef;
          --alternate-color: #222222;
          --main-border-color: #BBBBBB;
            --link-color: #627EC9;
        }
    
        @media (prefers-color-scheme: dark) {
          :root {
            --main-bg-color: #222222;
            --main-color: #eeeeee;
            --alternate-bg-color: #444444;
            --alternate-color: #cccccc;
            --main-border-color: #AAAAAA;
              --link-color: #627EC9;
          }
        }
    
        html {
          font-size: 100%;
          font-family: -apple-system, BlinkMacSystemFont, "helvetica neue", helvetica, roboto, noto, "segoe ui", arial, sans-serif;
          line-height: 1.4;
        }
    
        body {
          margin: 0;
          padding: 1em;
          background-color: var(--main-bg-color);
          color: var(--main-color);
        }
    
        @media (max-device-width: 480px) {}
    
        @media (min-device-width: 481px) {
          body {
            margin: auto;
            max-width: 600px;
          }
        }
    
        blockquote {
          font-style: italic;
          margin: 1.5em 2em;
          padding: 1em;
          background-color: var(--alternate-bg-color);
          color: var(--alternate-color);
        }
    
        a {
          color: var(--link-color);
        }
        pre {
          display: block;
          overflow: scroll;
          width: 100%;
          background-color: var(--alternate-bg-color);
          padding: .5em 1em;
          margin: 1em 0;
        }
    
        code {
          background-color: var(--alternate-bg-color);
          color: var(--alternate-color);
          font-family: Menlo, Courier, sans-serif;
          padding: 2px 3px;
        }
    
        table {
          margin: 1.5em 0;
          border: 1px solid var(--main-border-color);
          border-collapse: collapse;
        }
    
        th {
          padding: .25em .5em;
          background: var(--alternate-bg-color);
          border: 1px solid var(--main-border-color);
        }
    
        td {
          padding: .25em .5em;
          border: 1px solid var(--main-border-color);
        }
    
        img {
          max-width: 90%;
        }
      </style>
    </head>
    
    <body>
      %%[[content]]%%
    </body>
    
    </html>
    

Options

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