Work Journal — a static daily activity log generated from revision history

I wanted a journal in SilverBullet, but not primarily as a place for writing daily notes.

What I was looking for was a chronological history of my work in the space: which pages were created, modified, renamed or deleted on each day.

I previously used a similar workflow in Zim Wiki and found it very useful when trying to remember when I worked on something.

The built-in SilverBullet Journal is designed mainly for manually written daily entries. Work Journal complements it by generating daily activity pages from the space revision history.

What it does

Work Journal reads the local revision history using:

space.getSpaceLog()

It creates static Markdown pages for completed historical days using this structure:

Journal/
└── 2026/
    └── 2026-10/
        ├── 2026-10-05
        └── 2026-10-06

A generated page looks like this:

---
tags:
  - journal
journalDate: "2026-10-05"
journalGeneratedAt: "2026-10-06 08:15:00 +0200"
pageDecoration:
  icon: calendar
---

## Activity

### Created pages

- [[Projects/Home|Projects/Home]] — 19:16, User

### Modified pages

- [[Dashboard|Dashboard]] — 21:06, User
- [[Projects/Home/Home Assistant|Projects/Home/Home Assistant]] — 21:44, User

### Renamed pages

_No matching pages._

### Deleted pages

- [[Projects/Test|Projects/Test]] — 16:34, User

## Notes

-

Main properties

  • Reads the existing Managed revision history.
  • Does not require an external Git repository.
  • Generates ordinary static Markdown files.
  • Generates only completed historical days, not the current day.
  • Creates only missing journal pages.
  • Never overwrites an existing daily journal page.
  • Keeps a section for manually written notes.
  • Deduplicates pages changed multiple times during the same day.
  • Distinguishes added, modified, renamed and deleted changes.
  • Can include the time and revision author.
  • Excludes technical pages and the Journal itself.
  • Can be run manually using a command.
  • Does not send any data outside SilverBullet.

The command provided by the script is:

Journal: Fill History

Running it scans the available revision history and generates all missing historical daily pages.

Why generate static pages?

I deliberately chose generated Markdown pages instead of a dynamic query.

A page modified today and again next week should remain recorded in today’s journal. A query based only on the current lastModified value cannot preserve that history.

Static pages also remain readable:

  • outside SilverBullet;
  • in ordinary Markdown editors;
  • directly on the filesystem;
  • after exporting or backing up the space.

How page activity is merged

Revisions are processed from oldest to newest.

If a page is saved multiple times during one day, it appears only once. The latest time and author are displayed.

The final daily status is merged using these rules:

  • added followed by modified remains added;
  • renamed followed by modified remains renamed;
  • deleted results in deleted;
  • repeated modifications result in a single modified entry.

Template

The page layout is stored separately in:

Templates/journal

The generator replaces these placeholders:

__JOURNAL_DATE__
__GENERATED_AT__
<!-- JOURNAL_ADDED -->
<!-- JOURNAL_MODIFIED -->
<!-- JOURNAL_RENAMED -->
<!-- JOURNAL_DELETED -->

This keeps presentation separate from the generation logic.

Installation

The implementation consists of two pages:

Scripts/Journal
Templates/journal

1. Create Templates/journal

Create a page named:

Templates/journal

and use the following content:

---
tags:
  - meta/template/page
frontmatter:
  tags:
    - journal
  journalDate: "__JOURNAL_DATE__"
  journalGeneratedAt: "__GENERATED_AT__"
  pageDecoration:
    icon: calendar
---

## Activity

### Created pages

<!-- JOURNAL_ADDED -->

### Modified pages

<!-- JOURNAL_MODIFIED -->

### Renamed pages

<!-- JOURNAL_RENAMED -->

### Deleted pages

<!-- JOURNAL_DELETED -->

## Notes

-

The frontmatter section in this template is converted into the actual frontmatter of every generated journal page.

The template page itself remains a meta page because it carries the meta/template/page tag.

2. Create Scripts/Journal

Create a page named:

Scripts/Journal

and use the following content:

---
tags:
  - meta
---

```space-lua
workJournal = workJournal or {}

function workJournal.loadAllRevisions()
  local revisions = {}
  local before = nil
  local previousBefore = nil

  while true do
    local batch = space.getSpaceLog(before)

    if not batch then
      error("Unable to load the space revision history.")
    end

    local commits = batch.commits or {}

    for _, revision in ipairs(commits) do
      table.insert(revisions, revision)
    end

    if not batch.more or #commits == 0 then
      break
    end

    local oldestRevision = commits[#commits]
    local nextBefore = oldestRevision
      and oldestRevision.rev
      or nil

    if not nextBefore then
      error(
        "The oldest revision has no revision identifier."
      )
    end

    if nextBefore == previousBefore then
      error("Revision history pagination did not advance.")
    end

    before = nextBefore
    previousBefore = nextBefore
  end

  return revisions
end

function workJournal.isContentPage(path)
  if type(path) ~= "string" then
    return false
  end

  if not string.endsWith(path, ".md") then
    return false
  end

  if path == "CONFIG.md"
    or string.startsWith(path, "Journal/")
    or string.startsWith(path, "Library/")
    or string.startsWith(path, "Scripts/")
    or string.startsWith(path, "Templates/")
    or string.startsWith(path, "Diagnostics/") then
    return false
  end

  return true
end

function workJournal.mergeStatus(
  previousStatus,
  newStatus
)
  if newStatus == "deleted" then
    return "deleted"
  end

  if newStatus == "added" then
    return "added"
  end

  if newStatus == "renamed" then
    return "renamed"
  end

  if newStatus == "modified" then
    if previousStatus == "added"
      or previousStatus == "renamed" then
      return previousStatus
    end

    return "modified"
  end

  return previousStatus or newStatus
end

function workJournal.getDayActivity(targetDate)
  local pages = {}
  local revisions = workJournal.loadAllRevisions()

  -- Process revisions from oldest to newest.
  for revisionIndex = #revisions, 1, -1 do
    local revision = revisions[revisionIndex]

    if revision and revision.timestamp then
      local revisionDate = os.date(
        "%Y-%m-%d",
        math.floor(revision.timestamp / 1000)
      )

      if revisionDate == targetDate then
        local files = revision.files or {}

        for _, fileChange in ipairs(files) do
          local path = fileChange.path

          if workJournal.isContentPage(path) then
            local page = pages[path] or {
              path = path
            }

            page.status = workJournal.mergeStatus(
              page.status,
              fileChange.status
            )

            page.time = os.date(
              "%H:%M",
              math.floor(revision.timestamp / 1000)
            )

            page.author = revision.author
            pages[path] = page
          end
        end
      end
    end
  end

  local statusLabels = {
    added = "created",
    modified = "modified",
    renamed = "renamed",
    deleted = "deleted"
  }

  local result = {}

  for _, page in pairs(pages) do
    table.insert(result, {
      page = string.sub(
        page.path,
        1,
        #page.path - 3
      ),
      status = page.status,
      statusLabel = statusLabels[page.status]
        or page.status,
      time = page.time,
      author = page.author
    })
  end

  table.sort(result, function(first, second)
    return first.page < second.page
  end)

  return result
end

function workJournal.renderActivityList(
  status,
  activities
)
  local lines = {}

  for _, activity in ipairs(activities) do
    if activity.status == status then
      local details = {}

      if activity.time then
        table.insert(details, activity.time)
      end

      if activity.author then
        table.insert(details, activity.author)
      end

      local suffix = ""

      if #details > 0 then
        suffix = " — " .. table.concat(
          details,
          ", "
        )
      end

      table.insert(
        lines,
        "- [[" .. activity.page .. "|"
          .. activity.page .. "]]"
          .. suffix
      )
    end
  end

  if #lines == 0 then
    return "_No matching pages._"
  end

  return table.concat(lines, "\n")
end

function workJournal.replaceTemplateMarker(
  text,
  marker,
  replacement
)
  local startPosition, endPosition = string.find(
    text,
    marker,
    1,
    true
  )

  if not startPosition then
    error(
      "The journal template is missing marker: "
        .. marker
    )
  end

  return string.sub(
    text,
    1,
    startPosition - 1
  )
    .. replacement
    .. string.sub(text, endPosition + 1)
end

function workJournal.preparePageTemplate(
  templateText
)
  templateText = string.gsub(
    templateText,
    "\r\n",
    "\n"
  )

  local sourceLines = string.split(
    templateText,
    "\n"
  )

  if string.trim(sourceLines[1] or "") ~= "---" then
    error(
      "The journal template has no valid frontmatter."
    )
  end

  local frontmatterEnd = nil

  for lineIndex = 2, #sourceLines do
    if string.trim(sourceLines[lineIndex]) == "---" then
      frontmatterEnd = lineIndex
      break
    end
  end

  if not frontmatterEnd then
    error(
      "The journal template frontmatter is not closed."
    )
  end

  local outputFrontmatterStart = nil

  for lineIndex = 2, frontmatterEnd - 1 do
    if sourceLines[lineIndex] == "frontmatter:" then
      outputFrontmatterStart = lineIndex + 1
      break
    end
  end

  if not outputFrontmatterStart then
    error(
      "The journal template has no frontmatter section."
    )
  end

  local resultLines = {
    "---"
  }

  for lineIndex = outputFrontmatterStart,
    frontmatterEnd - 1 do
    local line = sourceLines[lineIndex]

    if line == "" then
      table.insert(resultLines, "")
    elseif string.startsWith(line, "  ") then
      table.insert(
        resultLines,
        string.sub(line, 3)
      )
    else
      error(
        "Invalid indentation in the journal template "
          .. "frontmatter section."
      )
    end
  end

  table.insert(resultLines, "---")

  for lineIndex = frontmatterEnd + 1,
    #sourceLines do
    table.insert(
      resultLines,
      sourceLines[lineIndex]
    )
  end

  return table.concat(resultLines, "\n")
end

function workJournal.renderDay(targetDate)
  local pageTemplate = space.readPage(
    "Templates/journal"
  )

  if not pageTemplate then
    error(
      "Unable to load the Templates/journal template."
    )
  end

  local activities = workJournal.getDayActivity(
    targetDate
  )

  local result = workJournal.preparePageTemplate(
    pageTemplate
  )

  result = workJournal.replaceTemplateMarker(
    result,
    "__JOURNAL_DATE__",
    targetDate
  )

  result = workJournal.replaceTemplateMarker(
    result,
    "__GENERATED_AT__",
    os.date("%Y-%m-%d %H:%M:%S %z")
  )

  result = workJournal.replaceTemplateMarker(
    result,
    "<!-- JOURNAL_ADDED -->",
    workJournal.renderActivityList(
      "added",
      activities
    )
  )

  result = workJournal.replaceTemplateMarker(
    result,
    "<!-- JOURNAL_MODIFIED -->",
    workJournal.renderActivityList(
      "modified",
      activities
    )
  )

  result = workJournal.replaceTemplateMarker(
    result,
    "<!-- JOURNAL_RENAMED -->",
    workJournal.renderActivityList(
      "renamed",
      activities
    )
  )

  result = workJournal.replaceTemplateMarker(
    result,
    "<!-- JOURNAL_DELETED -->",
    workJournal.renderActivityList(
      "deleted",
      activities
    )
  )

  return result
end

function workJournal.getHistoricalDates()
  local dates = {}
  local today = os.date("%Y-%m-%d")

  for _, revision in ipairs(
    workJournal.loadAllRevisions()
  ) do
    if revision and revision.timestamp then
      local revisionDate = os.date(
        "%Y-%m-%d",
        math.floor(revision.timestamp / 1000)
      )

      if revisionDate < today then
        for _, fileChange in ipairs(
          revision.files or {}
        ) do
          if workJournal.isContentPage(
            fileChange.path
          ) then
            dates[revisionDate] = true
            break
          end
        end
      end
    end
  end

  local result = {}

  for revisionDate in pairs(dates) do
    table.insert(result, revisionDate)
  end

  table.sort(result)

  return result
end

function workJournal.getPageName(targetDate)
  local year = string.sub(targetDate, 1, 4)
  local month = string.sub(targetDate, 1, 7)

  return "Journal/"
    .. year
    .. "/"
    .. month
    .. "/"
    .. targetDate
end

function workJournal.getMissingJournalPages()
  local result = {}

  for _, targetDate in ipairs(
    workJournal.getHistoricalDates()
  ) do
    local pageName = workJournal.getPageName(
      targetDate
    )

    if not space.pageExists(pageName) then
      table.insert(result, {
        date = targetDate,
        page = pageName
      })
    end
  end

  return result
end

function workJournal.generateMissingPages()
  local createdPages = {}

  for _, missingPage in ipairs(
    workJournal.getMissingJournalPages()
  ) do
    -- Check again immediately before writing.
    if not space.pageExists(missingPage.page) then
      local content = workJournal.renderDay(
        missingPage.date
      )

      space.writePage(
        missingPage.page,
        content
      )

      table.insert(
        createdPages,
        missingPage.page
      )
    end
  end

  return createdPages
end

command.define {
  name = "Journal: Fill History",

  run = function()
    local success, result = pcall(
      workJournal.generateMissingPages
    )

    if not success then
      editor.flashNotification(
        "Journal generation failed: "
          .. tostring(result),
        "error"
      )
      return
    end

    if #result == 0 then
      editor.flashNotification(
        "The journal is up to date. "
          .. "No pages were created."
      )
      return
    end

    editor.flashNotification(
      "Journal updated. Pages created: "
        .. #result
    )
  end
}
```

3. Generate the missing pages

After saving both pages, run:

Journal: Fill History

If the command does not appear immediately, reload the SilverBullet browser tab normally.

The command creates journal pages only for completed days that:

  • contain at least one relevant content-page revision;
  • do not already have a generated journal page.

Excluded pages

The following pages and branches are excluded by default:

CONFIG.md
Journal/
Library/
Scripts/
Templates/
Diagnostics/

This prevents technical changes from polluting the activity log and prevents the generator from recording its own generated journal pages.

You can adjust the exclusions in:

function workJournal.isContentPage(path)

For example, to exclude another branch:

or string.startsWith(path, "Archive/")

Requirements

This version has been tested with:

SilverBullet 2.11.1
Revision mode: Managed

It relies on the revision data returned by:

space.getSpaceLog()

No external Git repository or remote synchronization is required.

Current limitations

  • The available history depends on the revisions retained by the space.
  • Existing journal pages are intentionally not regenerated or updated.
  • Changes made after a historical page has been generated are not added automatically to that existing page.
  • Rename information depends on the paths and statuses returned by the revision log.
  • Dates and times use the client’s local time zone.
  • The revision author is written into the generated journal page.
  • I have currently tested it only with Managed revisions.
  • It is currently a pair of user pages rather than a packaged SilverBullet library.

Possible future improvements

Some ideas I am considering:

  • configurable journal path and date format;
  • configurable excluded page branches;
  • optional author and time display;
  • preview before generating pages;
  • an option to regenerate only the automatic activity sections while preserving manual notes;
  • packaging the solution as an installable SilverBullet library.

I would be interested to know whether other people use their journal as a history of work rather than primarily as a daily diary, and whether this would be useful as a reusable library.

This looks great! I use my journal as a daily stream of notes and tasks but I also try to manually record * Created [[ProjectX]] and * Worked on [[ProjectX]] activity to build out the relationships between pages.