Giter VIP home page Giter VIP logo

cli's Introduction

HedgeDoc Logo

#HedgeDoc on matrix.org version POEditor Mastodon Twitter REUSE Compliance Check Nest.JS CI codecov

HedgeDoc lets you create real-time collaborative markdown notes.

Getting Started

State of the project

HedgeDoc 1.x is stable and used around the world, but the codebase has grown over time, making it hard to add new features.
We are currently working on HedgeDoc 2, a complete rewrite of HedgeDoc. Please note the following:

  • This branch contains the latest development code and does not implement all features yet. If you are looking for the 1.x source code, have a look at the master branch.
  • The 1.x release is maintenance-only. We do not accept feature requests or PRs for this release anymore and may choose to close non-critical bug reports, if the bug will be non-existent in 2.0.
  • HedgeDoc 2 will be split in two components. The backend and the frontend. Both are present in this repository.

Development

Information for setting up a local development environment can be found in the developer documentation

HedgeDoc 2 Alpha

Curious about the new look and feel of HedgeDoc 2? We provide a demo of the alpha on hedgedoc.dev.

If you want to try it out on your own devices, visit the HedgeDoc 2 docs. But be aware that these may change over time.

Contributions

We welcome contributions!
Have a look at our contribution docs to find out how you can help. If you want to contribute to HedgeDoc 2, please join our development chat.

License

Licensed under AGPLv3. For our list of contributors, see AUTHORS.

The license does not include the HedgeDoc logo, whose terms of usage can be found in the github repository.

cli's People

Contributors

b1sandmann avatar ccoenen avatar cdancette avatar davidmehren avatar fbartels avatar fumesover avatar hugopeixoto avatar inducer avatar lawri-van-buel avatar mrdrogdrog avatar peschmae avatar pirate avatar ppjet6 avatar sisheogorath avatar spasche avatar xldrkp avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cli's Issues

`export` does not work

The import functions works nicely! But the export doesn't. I tried all combinations.

$ env CODIMD_SERVER='https://demo.codimd.org' ./codimd import /tmp/out.md
Found. Redirecting to https://demo.codimd.org/BEy9CA7aTr2blBPAoAXDmg

$ env CODIMD_SERVER='https://demo.codimd.org' ./codimd export --slides BEy9CA7aTr2blBPAoAXDmg out.zip
Cannot specify both -k or --convert-file-only and -O if multiple URLs are given, or in combination
with -p or -r. See the manual for details.

$ env CODIMD_SERVER='https://demo.codimd.org' ./codimd export --html BEy9CA7aTr2blBPAoAXDmg out.html
--2018-09-26 17:01:58--  https://demo.codimd.org/Found.%20Redirecting%20to%20https://demo.codimd.org/s/Bkn2szKYX
Loaded CA certificate '/etc/ssl/certs/ca-certificates.crt'
Resolving demo.codimd.org (demo.codimd.org)... 2606:4700:30::681b:92b6, 2606:4700:30::681b:93b6, 104.27.147.182, ...
Connecting to demo.codimd.org (demo.codimd.org)|2606:4700:30::681b:92b6|:443... connected.
HTTP request sent, awaiting response... 404 Not Found
2018-09-26 17:01:58 ERROR 404: Not Found.

Converted links in 0 files in 0 seconds.

There's a typo in codimd:38, it should be ..."$CODIMD_SERVER/$publish_url" right? With the slash? And I removed the -O "$3" option of the wget to make it "work".

improve support for export to stdout

When passing - as output file, it mostly works: Both curl and wget treats that as a redirection to stdout.

Unfortunately the shell script does not expect this (which is a common pattern in POSIX-like tools):

a) An annoying trailing line containing the lone dash is appended.
b) Exporting as slides does not support this.

For both cases, dash should here be captured and an appropriate action (either nothing or a graceful error message emitted to stderr) should be taken instead.

does this work with hackmd site

this looks super useful but it's unclear if it can be used with the main existing hackmd install, which only supports OAUTH logins.

403 when attempting to import a note

Hi!

I am currently trying to import a local note to my own HedgeDoc instance. After a successful login, I get the following output from hedgedoc profile:

$ hedgedoc profile                                 
You are logged in to a HedgeDoc server.

HEDGEDOC_SERVER=https://my.hedgedoc.instance
HEDGEDOC_COOKIES_FILE=/home/me/.config/hedgedoc/key.conf

USER_NAME=me
USER_ID=some-uuid
USER_PHOTO=https://cdn.libravatar.org/avatar/myavatar

(I hid my info but it the same as what is set server-side)
Immediately after running this, if I try to hedgedoc import a file with any existing or non-existing note_id, I get the following output:

$ hedgedoc import File.md note_id
https://my.hedgedoc.instance/new/note_id
Failed with a 403 status.
Hint: You may need to run 'hedgedoc login' to authenticate first.

But if I try without defining a note_id:

$ hedgedoc import File.md                       
https://my.hedgedoc.instance/new

(I should mention that if I try to hedgedoc profile right after these, it still shows that I'm correctly logged in)

Maybe I did something wrong when I configured my hedgedoc server, but everything seems to work well from my browser. Do you have any idea of why it's doing this?

Thank you very much!

Stablize Releases

Since the CLI is now already existing for quite a while and working great for most people, we might want to start to tag releases.

Background: In order to package it for any regular distro, we would need to provide versions. I don't plan do package it, but it's required to enable people to do that and iirc there is an AUR package already existing.

Also: It makes it easier to announce new features and, given we ever have to introduce breaking changes on CodiMD-side, we can tell which CLI version works with what CodiMD version.

I'll leave it to you if you want to use 0.x.x versions (i.e. unstable) or if you want to switch to 1.0.0 for a first version. As I don't think it makes a lot of sense to use anything else than SemVer in here.

Cookie doesn't authenticate with Oauth2

Hi, I'm struggling with authentication. I'm using a self-hosted OIDC/OAuth2 provider called Authentik to login into HedgeDoc. This works great with just the press of a button.

What I've done/tried:

  1. Extract the cookie, isolated connect.sid line
  2. Changed docs.domain.com to http://127.0.0.1:3000 in the key.conf
  3. All defaults apply to me, so no setting of env settings.

image

Add CLI support for /history endpoint to list all note titles and IDs

I am sadly very inexperienced in web development, and I don't even see what CodiMD does when I search for something or filter by tag, so I have no clue how to get that info.

Nonetheless, it would be an amazing feature for this project, and I'd love to experiment with it, but I don't even know where to start.

Any ideas?

is that "/" chars not supported in export ?

I can not export a note from codimd if I use chinese chars in export file name.

update: chinese file name were supported , but not spaces.
update again: after some try and error , the problem is char "/" . is there anyway to escape those special chars ?

2019-09-09 14:49:11 [changch@hqdc034 ~]$ codimd export --md BUFqXnrKSYKRl0Qk39tHpw "LAB 機器規格&&售價 2019/09/09.md"
LAB 機器規格&&售價 2019/09/09.md: 沒有此一檔案或目錄 <-- means "no such file or directory"
2019-09-09 14:50:00 [changch@hqdc034 ~]$ codimd export --md BUFqXnrKSYKRl0Qk39tHpw "LAB 機器規格售價 2019/09/09.md"
LAB 機器規格售價 2019/09/09.md: 沒有此一檔案或目錄 <-- means "no such file or directory"
2019-09-09 14:50:04 [changch@hqdc034 ~]$ codimd export --md BUFqXnrKSYKRl0Qk39tHpw my.md
--2019-09-09 14:50:15--  http://192.168.11.34:3000/BUFqXnrKSYKRl0Qk39tHpw/download
正在連接 192.168.11.34:3000... 連上了。
已送出 HTTP 要求,正在等候回應... 200 OK
長度: 1074 (1.0K) [text/markdown]
Saving to: ‘my.md’

my.md                            100%[========================================================>]   1.05K  --.-KB/s    in 0.004s  

2019-09-09 14:50:15 (298 KB/s) - ‘my.md’ saved [1074/1074]

2019-09-09 14:50:15 [changch@hqdc034 ~]$ ls

Import all Markdown files in a directory

This should work:

codimd import /path/to/markdown/files

Workaround

[davidak@X230:~/code/cli/bin]$ for file in ~/Downloads/hackmd/*.md; do xdg-open $(CODIMD_SERVER='https://pad.nixnet.services' ./codimd import "$file" | awk '{print $4}'); done

(You have to open the imported note for it to appear in the history.)

Output just URL of imported note

According to the unix philosophy, you should be able to pipe the output of a tool into another. With the output of this script, it is not possible.

The actual output of ./codimd import test.md is

Found. Redirecting to https://pad.nixnet.services/gNvbypueQ6awH73V3nx_jw

(don't forget to update usage information when this is changed)

Workaround

Use awk to manipulate the text:

./codimd import test.md | awk '{print $4}'
https://pad.nixnet.services/zKOoDxhQTuaT4dnJAybrfw

DCO and contributing file from CodiMD?

We use a DCO in the CodiMD repo to simplify the legal status of code.

We could apply this here as well, it doesn't hurt, is easy to adapt and we could also link the CONTRIBUTING.md in the README.

As I'll focus on CodiMD when it comes to development, I don't want to tell you how you should develop your code, so I will leave the decision to the developers and users of this repository.

Where is the API documentation for CodiMD?

I'd love to add some more options to this tool but I can't seem to find any docs on the API.

Could you maybe add that info in the README.md? So it's easier for a potential contributor to see what's doable.

Codimd-cli required re-authenticating again a day after initial login

I logged in with my account yesterday. Then i imported notes today. I noticed that i was not able to edit permissions. I didn't own the notes! So it seems i was not logged in anymore. (that might also be related to the fact that i deleted my account multiple times)

Please document if you have to login after some time again.

Make `import-as` display an explicit error message when the given note id conflicts with an existing note

Hello and thanks for the work thus far!

In our collective, we use the same pad for our weekly meeting. It's quite handy to have the same URL. After the meeting is over, the moderator is tasked with copying the minutes to the website and resetting the minutes template. I thought import-as could be used to help automate this process by uploading the template to the existing pad.

Initial note creation 👍

$ codimd import newnote
Found. Redirecting to https://codi.kanthaus.online/zCaOffwOSgGQRRpnaeJM0A

First template import 👍

$ codimd import-as zCaOffwOSgGQRRpnaeJM0A exampleTemplate.md
Found. Redirecting to https://codi.kanthaus.online/zCaOffwOSgGQRRpnaeJM0A

Second template import 👎

$ codimd import-as zCaOffwOSgGQRRpnaeJM0A exampleTemplate.md
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">

...

            <h1>500 Internal Error <small>wtf.</small></h1>

I get that this could be an issue with how we set our instance up (and I'll ask our 'sysadmins') but if it could be something with codimd(-cli) I thought I'd let you know.

How to authenticate CLI if using an auth provider?

When I created my hedgedoc account at the demo server, I used GitHub to authenticate.

Now I'd like to use the CLI, but both the --email and --ldap options require a username and password. As far as I know, I never set up a specific password for hedgedoc because authentication is happening via GitHub.

So, I'm confused at how I can use this CLI when my user account lacks a password.

CURL-generated cookies.txt file not working to authenticate wget downloads

Description

I am not sure if it is just a usage error or if it is actually an issue.
After logging in with valid credentials the script prints a success message.
When i then try to download a pad the download results in a html file prompting to login to access the pad.
While testing i noticed that the download only works when the pad is visible for guests which makes me belive that the login functionality is not working correctly or the login state is not tracked.

Executed commands:

env CODIMD_SERVER="{our codimd server}" codimd login --ldap {username} {password}
$ Logged in {our codimd server} as {username} successfully.
env CODIMD_SERVER="{our codimd server}" codimd export --md {pad id} file.md
(file is downloaded but contains html)

Desired state:

The Login Information is carried over to the download function which then downloads the correct data.

Current state:

The Login Information doesn't seem to be carried over and a download (of a restricted pad) results in html.

Steps to Reproduce:

see Executed Commands

Add pass support

The UNIX passwordstore called pass is a very handy unix tool that allows to have GPG encrypted passwords stored in a git repository and being used as a password safe.

CodiMD CLI could integrate with pass by checking for its existence and reading login (i.e. pass show demo.codimd.org/myuser) data from there.

In order to make it easy to integrate, we should provide a function that abstracts provided password. Means check if a password is supplied by CLi parameter, check if passwordstore is there and if so, check for a password. When non of the above provides a password, show a prompt.

Just my rough idea, feel free to extend/change/improve.

Also download images when using export

So I was wondering if there already exists an option to also download the images that are added to the notes.

In that case, one might need to change the url of those images in the document as they are not referring back to the server anymore.

It would have the advantage that the export is actually standalone and offline accessible (might not be relevant if running on localhost)

If something like this does not exist yet, is there any reason why I shouldn't give it a try?

Just asking so that I am not doing something that won't be needed after all.

Cheers 🍻

Support URL ending with /

[davidak@X230:~/code/cli/bin]$ CODIMD_SERVER='https://pad.nixnet.services/' ./codimd login --email *****@*****.de **********
parse error: Invalid numeric literal at line 1, column 10
Failed to login at https://pad.nixnet.services/.

It works when i remove the / like in the example.

Example:
    $ env CODIMD_SERVER='https://codimd.example.com' codimd import /path/to/your/content.md

Please support such URLs for better UX.

Update links and content to new CodiMD repository

Since we moved to an own organization now, it would be great to update the links in the README.

Most of the links in the lower part point to the old repository and should be replaced. If you wonder about the background of this whole change, there is a vision for the future that tries to explains how things went and what we plan to do in the future 🙂

Also since most of those issues have no equivalent in the new repository, feel free to create new issues for them 👍 Time to get things rolling!

Found. Redirected when using codimd import

If the following environment variables are set

CMD_ALLOW_ANONYMOUS=false
CMD_ALLOW_EMAIL_REGISTER=false

import with cli is not possible. Found. Redirected is output.

If environment variable are set to true import is possible but ownership of imported note is not the user who logged in before by cli.

'download' fetches last revision, not current state

A collective I'm part of use CodiMD for meeting minutes. I was using a script to transfer the pad to our website using curl URL/download. As far as I know, this used to capture the current state of the pad, but recently (perhaps an admin updated the instance?) it captures the last revision. This is unfortunate, since there is no way for a user to generate a revision, meaning they must sit patiently if they wish to use the API, or just do it manually.

Thanks in advance!

Find out how socket.io works in order to edit notes.

I'm trying to figure out how to edit a note directly from the command line, unfortunately I can't delete text successfully.
So I leave here what I found, and if someone can make it work, it would be a great addition to this client.

First of all, let's authentificate cf #9. (Idk if it's necessary)

codimd login --email [email protected] password

Then, connecting to the socket.

NOTEID=3_jUrZCYRTOtcEAJG6Oywg

# The socket url
URL=$CODIMD_SERVER/socket.io/?noteId=$NOTEID\&EIO=3\&transport=polling

# get the 'io' token
curl -c /tmp/codimd-cookies.txt \
    -b /tmp/codimd-cookies.txt \
    $URL\&t=$(python yeast.py) \
    &> /dev/null

Then, all messages must be passed to $SERVER/socket.io/?noteId=$NOTEID&EIO=3&transport=polling&t=$(python yeast.py)&sid\=$TOKEN, TOKEN is the token we just picked up.

To do so:

TOKEN=$(cat /tmp/codimd-cookies.txt | grep io | awk '{print $7}')

curl -b /tmp/codimd-cookies.txt \
    $URL\&t\=$(python yeast.py)\&sid\=$TOKEN \
    -H "Content-Type: text/plain;charset=UTF-8" \
    -d @msg_0

This will send the data from the file msg_0 to the socket.

As an example, on a fresh new note:

#!/bin/bash

SERVER=https://xxxxxxxxxxxxxx
NOTEID=xxxxxxxxxxxxxxxxxxxxxx

URL=$SERVER/socket.io/?noteId=$NOTEID\&EIO=3\&transport=polling

curl -c /tmp/codimd-cookies.txt \
    -b /tmp/codimd-cookies.txt \
    $URL\&t=$(python yeast.py) \
    &> /dev/null

TOKEN=$(cat /tmp/codimd-cookies.txt | grep io | awk '{print $7}')

curl -b /tmp/codimd-cookies.txt \
    $URL\&t\=$(python yeast.py)\&sid\=$TOKEN \
    -H "Content-Type: text/plain;charset=UTF-8" \
    -d @msg_4 

With msg_4 containing 61:42["operation",0,["test"],{"ranges":[{"anchor":4,"head":4}]}]

Then, by analyzing the different possible messages I think the format is as follows:

$1:42["operation",$2,["$3",$4],{"ranges":[{"anchor":$5,"head":$5}]}]

  • $1 is the len of the message after :
  • $2 is the number of the operation (starts at 0, then must be increased by one at each request)
  • $3 is the text that you want to add (optional)
  • $4 is the number of chars to remove (optional)
  • $5 is the location of the modification

For example:

  • Add test to the note
    • 61:42["operation",0,["test"],{"ranges":[{"anchor":4,"head":4}]}]
  • Remove test and replace it by 01234
    • 65:42["operation",0,["01234",-4],{"ranges":[{"anchor":5,"head":5}]}]
  • Remove the last char
    • 59:42["operation",0,[4,-1],{"ranges":[{"anchor":4,"head":4}]}]

This payloads are working when I'm inspecting the network on my browser, but I can't reproduce it (text deletion) by using curl. Even if the socket returns ok to me every time.

I hope I can help, if someone can figure out how to do it.
This is the last thing before being able to edit notes from codimd-cli.

PS: here you can find the source file

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.