Contents
- Setup
- Check draft format
- Wrap draft
- Upload draft
- Look at draft data
- Wrap and upload draft assets
- Look at draft assets data
- Delete draft
Setup
Create a work directory: "new_articles"
Inside the work directory, create these subdirectories:
- "keys"
- "drafts"
Inside the keys directory, create these subdirectories:
- "private_keys"
- "public_keys"
Copy your secondary private key into the "private_keys" directory.
Example private key filename:
stjohn_piano_2_private_key.txt
Explanation: We use a secondary author_name e.g. "stjohn_piano_2" instead of "stjohn_piano". This means that your secondary identity key will be used when signing the wrapped version of the draft. This is for convenience, as usually the secondary key will kept on an online computer (while the primary will be kept on an offline one).
Copy the secondary public key of Edgecase Datafeed into the "public_keys" directory.
Download link:
edgecase_datafeed_2_public_key.txt
Browse to:
github.com/sj-piano/edgecase_article
Check that you have the requirements listed in the README.
Open a shell, and change directory into the work directory.
Clone the edgecase_article repo:
git clone --recurse-submodules git@github.com:sj-piano/edgecase_article.git
Change to the "edgecase_article" directory.
You'll need to know your Edgecase longUserID, which is stored inside your authentication cookie (and was sent to you in an email when you initially subscribed).
Example longUserID:
771820140041095689280498743232786848
In the shell, set your longUserID and authorName:
LONG_USER_ID=771820140041095689280498743232786848
AUTHOR_NAME=stjohn_piano
AUTHOR_NAME=stjohn_piano
^ Note: This time, use your primary author name e.g. "stjohn_piano". There's only one author account, although this account can have multiple keys.
Check draft format
Prerequisite: Read How to write an article. This page describes the format of an Edgecase article.
Copy the draft article into "drafts".
Important: Change the author name within the draft to your secondary key name. E.g. change it from "stjohn_piano" to "stjohn_piano_2". This is because in this procedure you will sign the draft with your secondary key. The author name within the draft will be used to look up this public key and verify the signature.
Set a variable containing the draft article file name. Example:
DRAFT_FILE_NAME=2021-01-05_stjohn_piano_blockchain_companies.txt
Open a shell and change directory into the work directory.
Check the format:
python3 edgecase_article/cli.py --task verify --logLevel info --verifyContent --articleFile drafts/$DRAFT_FILE_NAME
^ Note: We aren't checking the format of the article file name. It could be called anything e.g. "foo.txt".
Example output:
stjohn@judgement:new_articles$ python3 edgecase_article/cli.py --task verify --logLevel info --verifyContent --articleFile drafts/$DRAFT_FILE_NAME
INFO [edgecase_article.code.verify: 91 (verify)] File drafts/2021-01-05_stjohn_piano_blockchain_companies.txt contains a valid Element.
INFO [edgecase_article.code.verify: 101 (verify)] Element name: article
INFO [edgecase_article.code.verify: 171 (verify)] Content element: All descendant elements have permitted names.
INFO [edgecase_article.code.verify: 193 (verify)] Content element: All descendant elements have been checked against the list of permitted tree structures.
INFO [cli: 380 (verify)] Article file drafts/2021-01-05_stjohn_piano_blockchain_companies.txt loaded and verified.
Wrap draft
Explanation: A "wrapped" file is:
1) Signed by the private key of the sender.
2) Encrypted to the public key of the receiver.
This mechanically guarantees its author in a way that is only visible to the receiver.
Change directory to the work directory.
In the shell, set the wrapped draft file name.
DRAFT_FILE_NAME_WRAPPED=$DRAFT_FILE_NAME.wrapped
Wrap the draft:
python3 edgecase_article/edgecase_article/submodules/stateless_gpg/cli.py --logLevel=error --task wrap --privateKeyFile keys/private_keys/stjohn_piano_2_private_key.txt --publicKeyFile keys/public_keys/edgecase_datafeed_2_public_key.txt --dataFile drafts/$DRAFT_FILE_NAME > drafts/$DRAFT_FILE_NAME_WRAPPED
Upload the draft
Upload the wrapped draft:
curl --include --cookie "edgecase_long_user_id=$LONG_USER_ID" --request POST --header "Content-Type: multipart/form-data" --form "data=@drafts/$DRAFT_FILE_NAME_WRAPPED" edgecase.pro/api/v1/authors/$AUTHOR_NAME/upload/draft
Example output:
stjohn@judgement:new_articles$ curl --include --cookie "edgecase_long_user_id=$LONG_USER_ID" --request POST --header "Content-Type: multipart/form-data" --form "data=@drafts/$DRAFT_FILE_NAME_WRAPPED" edgecase.pro/api/v1/authors/$AUTHOR_NAME/upload/draft
HTTP/1.1 100 Continue
HTTP/1.1 200 OK
Server: nginx/1.18.0 (Ubuntu)
Date: Sun, 19 Dec 2021 16:13:51 GMT
Content-Type: text/plain
Transfer-Encoding: chunked
Connection: keep-alive
{
"links": {
"self": "http://edgecase.pro/api/v1/authors/stjohn_piano/upload/draft",
"path": "authors/stjohn_piano/upload/draft"
},
"data": [
{
"result": "success",
"links": {
"draft": "http://edgecase.pro/api/v1/authors/stjohn_piano/drafts/blockchain_companies"
}
}
]
}
^ Looking at the output, we can see that the title value within the draft has been stripped down into a URI article title. In this case, it is: "blockchain_companies"
Set this value in the shell:
DRAFT_URI_TITLE=blockchain_companies
Look at draft data
Test: Get draft metadata.
curl --cookie "edgecase_long_user_id=$LONG_USER_ID" edgecase.pro/api/v1/authors/stjohn_piano/drafts/$DRAFT_URI_TITLE
Example output:
stjohn@judgement:new_articles$ curl --cookie "edgecase_long_user_id=$LONG_USER_ID" edgecase.pro/api/v1/authors/stjohn_piano/drafts/$DRAFT_URI_TITLE
{
"links": {
"self": "http://edgecase.pro/api/v1/authors/stjohn_piano/drafts/blockchain_companies",
"path": "authors/stjohn_piano/drafts/blockchain_companies"
},
"data": [
{
"type": "draft",
"name": "blockchain_companies",
"attributes": {
"author_name": "stjohn_piano_2",
"date": "2021-01-05",
"word_count": "1726",
"page_count": "8",
"minutes": "10",
"size_bytes": "11608",
"uri_title": "blockchain_companies",
"title": "Blockchain_Companies"
},
"links": {
"self": "http://edgecase.pro/api/v1/authors/stjohn_piano/drafts/blockchain_companies",
"data": "http://edgecase.pro/api/v1/authors/stjohn_piano/drafts/blockchain_companies/data"
}
}
]
}
Test: Get draft data:
curl --cookie "edgecase_long_user_id=$LONG_USER_ID" edgecase.pro/api/v1/authors/stjohn_piano/drafts/$DRAFT_URI_TITLE/data
Look at how the draft gets rendered.
- Browse to edgecase.pro. Need to be logged in.
-- Note: You can log in by visiting this link in the browser:
edgecase.pro/cookies/create/<long_user_id>
- Go to Navigation / Account / Drafts, and click the link to the draft article. (This will be its title.)
Wrap and upload draft assets
Copy the draft assets directory to the "drafts" directory.
In the shell, set a value for the draft assets directory name:
DRAFT_ASSETS_DIR_NAME=article_7_assets
Set some derived values:
DRAFT_ASSETS_DIR=drafts/$DRAFT_ASSETS_DIR_NAME
DRAFT_ASSETS_DIR_WRAPPED=$DRAFT_ASSETS_DIR.tar.gz.base64.wrapped
DRAFT_ASSETS_DIR_WRAPPED=$DRAFT_ASSETS_DIR.tar.gz.base64.wrapped
Archive the assets directory, and then encode it into base64:
tar --create --gzip --file=$DRAFT_ASSETS_DIR.tar.gz --directory=$DRAFT_ASSETS_DIR .
cat $DRAFT_ASSETS_DIR.tar.gz | base64 > $DRAFT_ASSETS_DIR.tar.gz.base64
cat $DRAFT_ASSETS_DIR.tar.gz | base64 > $DRAFT_ASSETS_DIR.tar.gz.base64
Wrap the result:
python3 edgecase_article/edgecase_article/submodules/stateless_gpg/cli.py --logLevel=info --task wrap --privateKeyFile keys/private_keys/stjohn_piano_2_private_key.txt --publicKeyFile keys/public_keys/edgecase_datafeed_2_public_key.txt --dataFile $DRAFT_ASSETS_DIR.tar.gz.base64 > $DRAFT_ASSETS_DIR_WRAPPED
Upload draft assets:
curl --cookie "edgecase_long_user_id=$LONG_USER_ID" --request POST --header "Content-Type: multipart/form-data" --form "data=@$DRAFT_ASSETS_DIR_WRAPPED" edgecase.pro/api/v1/authors/$AUTHOR_NAME/upload/draft/$DRAFT_URI_TITLE/assets
Look at draft assets data
Test: Get draft assets metadata:
curl --cookie "edgecase_long_user_id=$LONG_USER_ID" edgecase.pro/api/v1/authors/stjohn_piano/drafts/$DRAFT_URI_TITLE/assets
Example output:
stjohn@judgement:new_articles$ curl --cookie "edgecase_long_user_id=$LONG_USER_ID" edgecase.pro/api/v1/authors/stjohn_piano/drafts/$DRAFT_URI_TITLE/assets
{
"links": {
"self": "http://edgecase.pro/api/v1/authors/stjohn_piano/drafts/blockchain_companies/assets",
"path": "authors/stjohn_piano/drafts/blockchain_companies/assets"
},
"data": [
{
"file_name": "20170812_stjohn_piano_jordan_peterson_on_speech_truth_thinking_and_attention_raw_transcript.txt",
"size_bytes": 8221
}
]
}
^ We can get the asset name from the output above.
Set this in the shell:
DRAFT_ASSET_NAME=20170812_stjohn_piano_jordan_peterson_on_speech_truth_thinking_and_attention_raw_transcript.txt
Test: Get draft asset metadata:
curl --cookie "edgecase_long_user_id=$LONG_USER_ID" edgecase.pro/api/v1/authors/stjohn_piano/drafts/$DRAFT_URI_TITLE/assets/$DRAFT_ASSET_NAME
Test: Get draft asset data:
curl --cookie "edgecase_long_user_id=$LONG_USER_ID" edgecase.pro/api/v1/authors/stjohn_piano/drafts/$DRAFT_URI_TITLE/assets/$DRAFT_ASSET_NAME/data
Delete the draft
Delete the wrapped draft file:
rm drafts/$DRAFT_FILE_NAME_WRAPPED
Delete the wrapped draft asset directory, if it exists:
rm $DRAFT_ASSETS_DIR_WRAPPED
Delete the draft on Edgecase:
- Note: This will also delete any draft assets.
curl --cookie "edgecase_long_user_id=$LONG_USER_ID" edgecase.pro/api/v1/authors/stjohn_piano/delete/draft/$DRAFT_URI_TITLE
Example output:
stjohn@judgement:new_articles$ curl --cookie "edgecase_long_user_id=$LONG_USER_Ie.pro/api/v1/authors/stjohn_piano/delete/draft/$DRAFT_URI_TITLE
{
"links": {
"self": "http://edgecase.pro/api/v1/authors/stjohn_piano/delete/draft/blockchain_companies",
"path": "authors/stjohn_piano/delete/draft/blockchain_companies"
},
"data": [
{
"status": "200 OK",
"result": "success"
}
]
}