Code Monkey home page Code Monkey logo

Comments (1)

jgru avatar jgru commented on August 19, 2024

Dummy data for testing purposes can now be automatically created using the minimal-setup.el provided in the wiki.
The relevant elisp functions are the following ones:

(setq test-org-roam-directory (make-temp-file "roam-" t))

(with-eval-after-load 'org-roam
  (defun create-org-roam-dummy-note (title body)
    "Create an org-roam note file with TITLE and content BODY."
    (let* ((slug (org-roam-node-slug (org-roam-node-create :title title)))
            (filename (concat (file-name-as-directory org-roam-directory)
                        (format "%d-%s.org"
                          (time-convert (current-time) 'integer)
                          slug)))
            (org-id-overriding-file-name filename)
            id)
      (with-temp-buffer
        filename
        (insert ":PROPERTIES:\n:ID:        \n:END:\n#+title: "
          title)
        (goto-char 25)
        (setq id (org-id-get-create))
        (goto-char (point-max))
        (newline 2)
        (insert body)
        (write-file filename)
        (org-roam-db-update-file filename))))

  (defun populate-org-roam-with-dummy-notes ()
    "Create some test notes in org-roam-directory."
    (let ((elems '("alpha" "bravo" "charlie" "delta" "echo" "foxtrot")))
      ;; Check existence of org-roam-directory
      (when (not (file-directory-p org-roam-directory))
        (make-directory org-roam-directory))
      ;; Create the single notes 
      (dolist (elt elems )
        (create-org-roam-dummy-note elt
          (concat "This is the body of a note about " elt)))))
  (populate-org-roam-with-dummy-notes))

This snippet creates notes in a uniquely named temp-directory by iterating over elems.
The resulting files have the following simplistic structure:

:PROPERTIES:
:ID:       a8b97174-48e6-453d-8f73-8e3cd1d955b0
:END:
#+title: alpha

This is the body of a note about alpha

This can be conveniently used to test consult-org-roam's functionality

from consult-org-roam.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.