Find out how socket.io works in order to edit notes.
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 30/100
Hướng nghiên cứu
Bắt đầu với các lệnh socket và các ví dụ payload trong issue, sau đó kiểm tra mã nguồn được liên kết trong gist và so sánh các yêu cầu curl với các thông báo mạng của trình duyệt. Sử dụng yeast.py, msg_0 và msg_4 làm các điểm vào được tham chiếu. Công việc được hoàn tất khi CLI có thể chỉnh sửa ghi chú, bao gồm cả việc xóa văn bản, thông qua giao thức socket.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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
- Ngôn ngữ chính
- Shell
- Star
- 166
- Fork
- 39
- Merge trung bình
- 1 giờ 27 phút
- Pull request đã merge (30 ngày)
- 1
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của hedgedoc/cli
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 38/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
-
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
-
Support image uploadĐang mởenhancement help wanted
Độ khó 5/5 Hơn một tuần Mức phù hợp với người mới 25/100
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
Issue tương tự
-
CI repository variables is redĐang mởarea: build-and-ci guard-red-main S3: minor
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
manaflow-ai/cmux#65616 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
achisolomon/software-factory#300 · 1 bình luận ·
-
Độ khó 2/5 Nửa ngày Mức phù hợp với người mới 86/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
-
Bump runtime to 26.08Đang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 78/100
flathub/cc.arduino.IDE2#168 ·