Skip to content
Snippets Groups Projects
c-tim's avatar
c-tim authored
chore(nix): Switch to nix flake from shell

See merge request !2
5cf5907e
History

pad-Initiator

Script to initialize a set of HedgeDoc pads from markdown files

Installation

To install this script poetry is used. Run poetry install to install it.

When you are using nix you can also use nix-shell (which will use the shell.nix) or install the script as a derivation from the default.nix.

Usage

To use the script either enter poetry shell and run pad_initiator or run poetry run pad_initiator. When using nix you can simply run pad_initiator from anywhere.

usage: pad_initiator [-h] [--server url] [--connectsid csid] [--humanreadablelinks file] files [files ...]

Initialize a set of HedgeDoc pads from markdown files

positional arguments:
  files                 The markdown files to be uploaded to HedgeDoc for the new pads.

optional arguments:
  -h, --help            show this help message and exit
  --server url, -s url  The hedgeDoc server to use. Can also be specified via the environment variable PI_SERVER
  --connectsid csid, -c csid
                        The connection sid to use. This is required to authenticate the user. If not set the pads are created by the system. Can also be
                        specified via the environment variable PI_CONNECT_SID
  --humanreadablelinks file, -l file
                        A file containing a mapping from markdown file to human readable links. If this is not set or no mapping exists for a file, the link
                        will be random. Can also be specified via the environment variable PI_HUMAN_READBLE_LINKS

Dotenv

To set the environment variables a .env file can be used. See python-dotenv.

Human readable links file

If the resulting pads should have human readble links a map file must be passed. It contains a mapping from filename (as given to the tool) to the link (only the path) the pad should have. Each line represents one mapping. It should start with the filename followed by a colon (:) and the link. All whitespace is ignored. If a filename appears more then once in the file, the last occurence is used.

Example line: README.md : my_reamde This will result in the link to the pad being my.server.com/my_readme

Obtaining the connectsid

To obtain the connectsid login to your HedgeDoc Server using your browser, open the Developer Tools, select the Network Tab and then open some note in HedgeDoc. In the first line you will see a request to the url of that note. Examine that request and look for the request header Cookie. In there should be a cookie named connect.sid.

Example: The Cookie header may be indent_type=space; space_units=4; keymap=sublime; loginstate=true; connect.sid=YdOW-dUl6Y9KyABKVy/Qi06aAMuh6.upJahu_EYpm8%3BtteD0HTBWya1-ceIA835UGs1GmyRk%3ApN.Vu; userid=853be112-34f8-4731-8ecd-811737b5e075 Then the connectsid is YdOW-dUl6Y9KyABKVy/Qi06aAMuh6.upJahu_EYpm8%3BtteD0HTBWya1-ceIA835UGs1GmyRk%3ApN.Vu.