Giter VIP home page Giter VIP logo

cli's Introduction

codimd-cli

A tiny CLI to perform common operations on CodiMD (formerly known as HackMD).

For more background, see the initial discussion on the main codimd repo.

Install

Dependencies:

  • A CodiMD server running somewhere
  • curl (install via apt install curl or brew install curl on Mac)
  • wget (install via apt install wget or brew install wget on Mac)
  • jq (install via apt install jq or brew install jq on Mac)
git clone https://github.com/codimd/cli

# Add the following to your ~/.bashrc or shell profile
export PATH=/path/to/codimd-cli/bin:$PATH

# optionally add the CODIMD_SERVER environment variable to specify a server
# it defaults to 127.0.0.1:3000
export CODIMD_SERVER='https://codimd.example.com'  

# Test by creating a new note
codimd import test.md

Documentation

Create/import a new note

codimd import test.md                   # takes a markdown file
qhmNmwmxSmK1H2oJmkKBQQ                  # returns <note_id> on success

Create/import a new note with a given alias

This requires that the server has the FreeURL mode enabled.

codimd import-as note-alias test.md     # takes a markdown file
note-alias                              # returns the alias on success

Publish an existing note

codimd publish qhmNmwmxSmK1H2oJmkKBQQ   # takes a <note_id>
/s/S1ok9no3f                            # returns publish url

Export an existing note

codimd export --pdf qhmNmwmxSmK1H2oJmkKBQQ my_note.pdf
codimd export --md qhmNmwmxSmK1H2oJmkKBQQ my_note.md
codimd export --html qhmNmwmxSmK1H2oJmkKBQQ my_note.html
codimd export --slides qhmNmwmxSmK1H2oJmkKBQQ my_slides.zip

Note: you must specify the filename to export to as the second argument (with a correct extension), as the CodiMD CLI cannot determine the title of the note on its own.

Authenticate and get notes history

# optionally add the CODIMD_COOKIES_FILE environment variable to specify
# where cookies will be stored. It defaults to ~/.config/codimd-cli/key.conf
export CODIMD_COOKIES_FILE=~/.codimd-key.conf

Authenticate with email

codimd login --email [email protected] p4sW0rD  # takes an email and a password

Authenticate with LDAP

codimd login --ldap username p4sW0rD  # takes a username and a password

Get auth status, history, and logout

codimd profile
You are logged in $CODIMD_SERVER as email with id xxxx-xx[...]xxx.

codimd history
ID                      Name
0nAp3YRyTlyQ-N3N7lCk-w  Note_1
qhmNmwmxSmK1H2oJmkKBQQ  Note_2

codimd logout

API Endpoints

These server endpoints are used by this project and can be unstable and undocumented, but may be of use if you're developing your own projects that need API access to CodiMD.

  • https://<codimd_server>/login
  • https://<codimd_server>/logout
  • https://<codimd_server>/me
  • https://<codimd_server>/history (requires auth)
  • https://<codimd_server>/new
  • https://<codimd_server>/new/<alias>
  • https://<codimd_server>/<note_id>/publish
  • https://<codimd_server>/<note_id>/download
  • https://<codimd_server>/<note_id>/pdf
  • https://<codimd_server>/<note_id>/slide

Help contribute!

We'd love a PR for any one of these commands!

  • codimd edit <note_id> < new_content.md
  • codimd inviteuser <email_to_invite>
  • codimd chmod <permissions> <note_id>
  • codimd chown <user> <note_id>
  • codimd delete <note_id>
  • codimd list --all list all notes on the server by id: title
  • codimd list <user_email> list notes for a given user by id: title
  • codimd search <query> find a note ids matching a given query

Inspiration

If you want to build something with this CLI, here are some ideas that the community has requested:

Import/Export:

Permission management:

  • Support permission of invitee only: ./codimd inviteuser --permissions r <user_email> could work by first chmod and chowning the note, then sending an email invite to that note
  • Find the notes by the owner: ./codimd list <user_email> works as a rudimentary API to do this form the command line
  • Add user administration: setup a script that creates all the users & their notes from .md files on disk, chown & chmods them to their proper permissions, then invites all the users to join. Would be possible to run this on a timer to do regularly as well.

Sync backends:

cli's People

Contributors

b1sandmann avatar ccoenen avatar cdancette avatar fbartels avatar fumesover avatar pirate avatar ppjet6 avatar sisheogorath avatar

Watchers

 avatar  avatar

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.