Dusko Pijetlovic

My personal notes where I store things I find interesting or might need in the future.

How to Create and Use Notes in Gitea

04 Feb 2024 » howto, git, versioncontrol, sysadmin, cli, notebook, diary, journal, plaintext, text, terminal, shell, knowledge, projectmanagement, unix, graph, diagram, visualization, wiki, technicalwriting, documentation, writing, tex, latex, pdf, markdown, web, webbrowser, webdevelopment, software, coding, programming, opensource, reference

Assumption: Using Gitea as your Git server. It’s installed on and hosted by https://example.com:3000/.

Log in to Gitea.

Create a new repository; for example, name it duskosnotes.

Install Git on the Client Machine

For example, on FreeBSD:

$ sudo pkg install git 

Cloning and Updating (Pushing) the Repository

$ git clone https://example.com:3000/dusko/duskosnotes.git
$ ls -Alh duskosnotes/
total 9
drwxr-xr-x  7 dusko  dusko    10B Feb  3 18:15 .git
$ cd duskosnotes
$ printf %s\\n "# Book of Documentation" > index.md
$ printf %s\\n >> index.md
$ printf %s\\n "## Infrastructure" >> index.md
$ pwd
/usr/home/dusko/duskosnotes
$ git add .
$ git commit -a
---- snip ----
$ git push
---- snip ----
$ git status
On branch main
Your branch is up to date with 'origin/main'.
 
nothing to commit, working tree clean

Installing MDwiki and Serving Notes Locally with Python HTTP Server

About MDwiki - from MDwiki’s own site:

“MDwiki is a CMS/Wiki completely built in HTML5/Javascript and runs 100% on the client. No special software installation or server side processing is required. Just upload the mdwiki.html shipped with MDwiki into the same directory as your markdown files and you are good to go!

Note: The website you are currently viewing is realized with MDwiki and hosted on GitHub pages. http://mdwiki.info redirects here.”

While still in /usr/home/dusko/duskosnotes:

$ fetch https://dynalon.github.io/mdwiki/mdwiki-latest-debug.html
$ mv mdwiki-latest-debug.html index.html
$ ls -lh
total 205
-rw-r--r--  1 dusko  dusko   405K Oct 25  2018 index.html
-rw-r--r--  1 dusko  dusko    44B Feb  3 18:15 index.md
$ command -v python3
/usr/local/bin/python3

Run a Local Web Server

Navigate to the directory with your notes.

$ cd ~/duskosnotes

Start the Python HTTP Server.

$ python3 -m http.server 8000 &
$ netstat -an | grep 8000
tcp46     0     0 *.8000             *.*                LISTEN

With your Web browser, open http://localhost:8000.

Displaying notes from gitea with python http server

When you are ready to stop the Python HTTP server:

$ ps auxw | grep -v grep | grep 29891
dusko  29891  0.0  0.0  47104  21384  0  S  18:15    0:00.07 python3 -m http.server 8000 (python3.9)
$ kill 29891
[1]    Terminated                python3 -m http.server 8000

Adding a Navigation

$ fetch https://raw.githubusercontent.com/Dynalon/mdwiki-seed/gh-pages/navigation.md
$ vi navigation.md
$ cat navigation.md
# My Notes

[Home](index.md)

Another example of navigation.md: From mdwiki-seed project
https://github.com/exalted/mdwiki-seed/blob/gh-pages/ll_CC/navigation.md

Configuration

Configuration options are kept in a config.json file. For a list of availabe options in config.json, refer to MDwiki Documentation - Customizing, under Configuration heading:

http://dynalon.github.io/mdwiki/#!customizing.md#Configuration

$ fetch https://raw.githubusercontent.com/Dynalon/mdwiki-seed/gh-pages/config.json
$ cat config.json 
{
    "useSideNav": "true"
}

Create 404 Error Page

$ vi 404.md
$ cat 404.md
# Page not found
 
Try going to [homepage](index.md)

Run a Local Web Server

Start the Python HTTP Server from within the directory where your notes are located.

$ cd ~/duskosnotes
$ python3 -m http.server 8000 &

With your Web browser, open http://localhost:8000.

When you are ready to stop the Python HTTP server:

$ ps auxw | grep -v grep | grep python 
dusko   8712   0.0  0.1   46848  20088  7  S+   15:17      0:00.13 python3 -m http.server 8000 (python3.9) 
$ kill 8712

References

(Retrieved on Feb 3, 2024)


MDwiki Structure

From mdwiki-seed: README - Structure:

All file references here are relative to their respective language folder.

NameTypeDescription
index.mdFileStarting point (a.k.a. “home page”) for your wiki. Note this is not the index.html, but index.md!
navigation.mdFileVarious settings of your wiki (e.g., name of your wiki, items in the navigation bar at the top, etc.)
config.jsonFileIf you don’t know what this is for, don’t touch it.
pagesFolderIdeally, inside this folder, you create one *.md file for every page inside your wiki (e.g., foo.md, much-longer-names-are-also-okay.md, etc.) You can also create as many subfolders as you need, just remember to link them accordingly.
uploadsFolderAn example folder structure where you could put other files. Although it is best to host your files somewhere else, like Dropbox, or a CDN, etc.

Creating a new repository on the command line

$ touch README.md
$ git init
$ git checkout -b main
$ git add README.md
$ git commit -m "first commit"
$ git remote add origin git@example.com:dusko/duskosnotes.git
$ git push -u origin main

Pushing an existing repository from the command line

$ git remote add origin git@example.com:dusko/duskosnotes.git
$ git push -u origin main