diff --git a/source/assets/js/section.js b/source/assets/js/section.js index 96c67dc..aec1e71 100644 --- a/source/assets/js/section.js +++ b/source/assets/js/section.js @@ -2,16 +2,34 @@ function nav_hotkey(e) { var action_for_key = function(e) { switch (e.keyCode) { case 74: // 'j' + if ((window.innerHeight + window.scrollY) < document.body.scrollHeight) { + return 'down'; + } + return ''; + case 75: // 'k' + if (window.scrollY > document.body.scrollTop) { + return 'up'; + } + return ''; + case 76: // 'l' case 78: // 'n' return 'next'; - case 75: // 'k' + case 72: // 'h' case 80: // 'p' return 'prev'; } } + + const scrollStep = 50; var action = action_for_key(e); if (action == 'next' || action == 'prev') { var link = $('link[rel="'+action+'"]'); window.location.href = link[0].href; + } else if (action == 'up'){ + window.scrollTo(document.body.scrollLeft, + window.scrollY - scrollStep); + } else if (action == 'down'){ + window.scrollTo(document.body.scrollLeft, + window.scrollY + scrollStep); } } diff --git a/source/halp.html.erb b/source/halp.html.erb index c1cc43f..ceaa32e 100644 --- a/source/halp.html.erb +++ b/source/halp.html.erb @@ -12,7 +12,7 @@ title: HALP!

Figure out where you are right now

-

I'm going to assume you're on a branch. You can confirm this by typing git status in your repo. The very first line should say "On branch master" (or "On branch very-important-branch" or whatever the name of the branch you're on is). If not, please make a backup of your directory before proceeding and try to get some expert help! I can't cover all the possibilities in a document like this, and I'd hate to lead you further astray at this point.

+

I'm going to assume you're on a branch. You can confirm this by typing git status in your repo. The very first line should say "On branch main" (or "On branch very-important-branch" or whatever the name of the branch you're on is). If not, please make a backup of your directory before proceeding and try to get some expert help! I can't cover all the possibilities in a document like this, and I'd hate to lead you further astray at this point.

If the second line doesn't say "nothing to commit (working directory clean)", you have some unsaved changes. You might be able to save them by using 'git stash', or you might want to copy some files out somewhere else if you're really paranoid. Or, you just may not care...

@@ -24,9 +24,9 @@ title: HALP!

Finding your lost commit

-

Whatever branch you're on, here's the good news: Git keeps track of every commit that that branch has ever pointed to. It does this in what's called the 'reflog' (that's short for "reference log") for your branch, which lives in the following plain-text file: [repository-root]/.git/logs/refs/heads/[branch-name]. The reflog for the master branch is in .git/logs/refs/heads/master, and the reflog for very-important-branch is in .git/logs/refs/heads/very-important-branch, and so on.

+

Whatever branch you're on, here's the good news: Git keeps track of every commit that that branch has ever pointed to. It does this in what's called the 'reflog' (that's short for "reference log") for your branch, which lives in the following plain-text file: [repository-root]/.git/logs/refs/heads/[branch-name]. The reflog for the main branch is in .git/logs/refs/heads/main, and the reflog for very-important-branch is in .git/logs/refs/heads/very-important-branch, and so on.

-

So. Take a deep breath, go to the root of your repository at the command line, and type this: cat .git/logs/refs/heads/master

+

So. Take a deep breath, go to the root of your repository at the command line, and type this: cat .git/logs/refs/heads/main

You should see a bunch of lines of the form:

diff --git a/source/layouts/layout.erb b/source/layouts/layout.erb index eefa484..98bc7ab 100644 --- a/source/layouts/layout.erb +++ b/source/layouts/layout.erb @@ -95,7 +95,7 @@

Creative Commons License
- Think Like (a) Git copyright © 2011-2017 Sam Livingston-Gray is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License. + Think Like (a) Git copyright © 2011-2021 Sam Livingston-Gray is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License.


Original template © 2011 · Vectors Community Theme · All Rights Reserved

<%= clearer %> diff --git a/source/sections/about-this-site.html.erb b/source/sections/about-this-site.html.erb index 539aa97..1596e59 100644 --- a/source/sections/about-this-site.html.erb +++ b/source/sections/about-this-site.html.erb @@ -7,6 +7,6 @@ layout: section

Each page has links at the bottom to the previous and next section, so you can read through the site from beginning to end. If you find that you're already familiar with some of the concepts in a given section, you can use the sidebar navigation to skip to specific pages.

-

Keyboard junkies, you can also navigate between sections using the "N" and "P" keys, for (N)ext and (P)revious. Vim users may be pleased to know that "J" and "K" also work as they expect.

+

Keyboard junkies, you can also navigate between sections using the "N" and "P" keys, for (N)ext and (P)revious. Vim users may be pleased to know that "J" and "K" keys work as up and down within page, and "H" and "L" keys move to previous and next page respectively.

(I used to have an "EPIC MODE" page that put almost all the content on one big long page, but I haven't been able to figure out how to replicate this using Middleman. Feel free to contact me if you know how to do this.)

diff --git a/source/sections/graphs-and-git/visualizing-your-git-repository.html.erb b/source/sections/graphs-and-git/visualizing-your-git-repository.html.erb index e81e4fc..ebd18bf 100644 --- a/source/sections/graphs-and-git/visualizing-your-git-repository.html.erb +++ b/source/sections/graphs-and-git/visualizing-your-git-repository.html.erb @@ -43,7 +43,7 @@ layout: section git log --oneline --abbrev-commit --all --graph --decorate --color -

And, in fact, I have a shell alias in my dotfiles repository that does all of this:

+

And, in fact, I have a shell alias in my dotfiles repository that does all of this:

alias gg='git log --oneline --abbrev-commit --all --graph --decorate --color' diff --git a/source/sections/testing-out-merges/the-savepoint-pattern.html.erb b/source/sections/testing-out-merges/the-savepoint-pattern.html.erb index 9b83eb2..1ddac82 100644 --- a/source/sections/testing-out-merges/the-savepoint-pattern.html.erb +++ b/source/sections/testing-out-merges/the-savepoint-pattern.html.erb @@ -23,7 +23,7 @@ layout: section

The long version

-

You're on the master branch and you want the changes from the spiffy_new_feature branch to be incorporated into master. You're reasonably confident that you'll want to keep the changes, but you want to be able to abort it if, for example, this feature has unintended side effects.

+

You're on the main branch and you want the changes from the spiffy_new_feature branch to be incorporated into main. You're reasonably confident that you'll want to keep the changes, but you want to be able to abort it if, for example, this feature has unintended side effects.

  1. @@ -31,7 +31,7 @@ layout: section
  2. Whatever visualizer you're using, figure out how it shows you where your current branch is. Or, at the command line, type git status and you should see something like this: - # On branch master
    + # On branch main
    nothing to commit (working directory clean)
  3. @@ -40,7 +40,7 @@ layout: section Create a new branch to use as a savepoint, but don't switch to it. @@ -60,8 +60,8 @@ layout: section For example:
    1. After a merge, you should see a new commit.
    2. -
    3. The new commit should have a message like "Merge branch 'spiffy_new_feature' into master".
    4. -
    5. Your master branch label should have moved to this new commit, while the spiffy_new_feature branch label should still be in the same place.
    6. +
    7. The new commit should have a message like "Merge branch 'spiffy_new_feature' into main".
    8. +
    9. Your main branch label should have moved to this new commit, while the spiffy_new_feature branch label should still be in the same place.
    diff --git a/source/sections/testing-out-merges/the-scout-pattern.html.erb b/source/sections/testing-out-merges/the-scout-pattern.html.erb index 3d4a5d3..e4e4063 100644 --- a/source/sections/testing-out-merges/the-scout-pattern.html.erb +++ b/source/sections/testing-out-merges/the-scout-pattern.html.erb @@ -23,7 +23,7 @@ layout: section

    The long version

    -

    You're on the master branch and you want the changes from the spiffy_new_feature branch to be incorporated into master. You're not sure if this will be a good idea, so you want to try out the merge, but be able to abort it if things don't go smoothly.

    +

    You're on the main branch and you want the changes from the spiffy_new_feature branch to be incorporated into main. You're not sure if this will be a good idea, so you want to try out the merge, but be able to abort it if things don't go smoothly.

    1. @@ -32,7 +32,7 @@ layout: section
    2. Whatever visualizer you're using, figure out how it shows you where your current branch is. Or, at the command line, type git status and you should see something like this: - # On branch master
      + # On branch main
      nothing to commit (working directory clean)
    3. @@ -63,7 +63,7 @@ layout: section
      1. After a merge, you should see a new commit.
      2. The new commit should have a message like "Merge branch 'spiffy_new_feature' into test_merge".
      3. -
      4. Your test_merge branch label should have moved to this new commit, while the master and spiffy_new_feature branch labels should still be in the same place.
      5. +
      6. Your test_merge branch label should have moved to this new commit, while the main and spiffy_new_feature branch labels should still be in the same place.
      @@ -75,12 +75,12 @@ layout: section Are you happy with the result?