notes for 20200514

last time

  1. understand req.params
  2. get and display a specified record at /airtable/:record_id

and Dani caught up:

  1. added a new element to our package.json document that specifies an executable script's path (./cli.js) and pairs it with an arbitrary word of our choosing that we'll use to launch the script:
    "bin": {
     "my-launch-word": "./cli.js"
    },
  2. we then used npm link to install your package globally while in development, making my-launch-word work from anywhere you happen to be in Terminal. Ultimately, when you publish your package to npmjs.com, other people (including future you) will run npm i -g [your_package] to get the same effect.
  3. we then played around with two other fun modules: figlet and chalk to print out a giant title for our little tool.
  4. grabbed the same code we used in our Airtable route and ran it from the command line (the sort of thing you might want to do if you wanted to periodically generate some quick text for yourself out of airtable from the command line rather than building a big website or server to do this automatically for any user).

this time

  1. start making the individual resource page look better by using specific parts of the record
  2. loops in js and ejs
  3. start to understand JS data types:
    • strings
    • numbers
    • arrays
    • objects
    • booleans
    • dates (which is just an object not its own type, but a special object we'll use a lot)

next time

  1. maybe work on styling this stuff and handling loops in the ejs
  2. maybe work on shell scripting at some point? or using child process to open up stuff in the terminal?
  3. anything else?

notes for and from 20200513

syntax for loops in js:

for (var i = 0; i < array.length; i++) {
  console.log(array[i]) 
}

syntax for loops in ejs:

<ol>
  <% for (i = 0; i < links.length; i++) { %>
    <li>
     <a href="<%- links[i].url %>" ><%- links[i].linkTitle  %></a>.<% if (links[i].externalUrl) { %>
                  (direct link <a href= <%- links[i].externalUrl %> >here</a>).
                <% } %>
        <% if (links[i].text) { %>
<span class="light-gray">
                       <%- links[i].text %>
</span>
                   <% } %>
    </li>
  <% } %>
</ol>