Howto to use beempy for posting

in FAQ/HowTo for beempy4 years ago (edited)


source

Why using an external markdown editor for writing?

There are some advantages in using an external editor:

  • Distraction free working (the browser can be closed)
  • Faster (The peakd markdown editor is slow on huge posts)
  • Better table creation
  • Be able to create different versions or even use versioning e.g. git

How to write your hive posts with a markdown editor and broadcast its content to the network?

You need three parts to be able to do this:

  1. A good markdown editor which understands advanced markdown as HTML, tables and has a decent preview
  2. A way to define parameter as tags, title and community
  3. A tool to broadcast your post to the network

Markdown editor

I can recommend two editors

I'm currently using visual studio code due to its great extensions e.g. Grammarly. Let's focus on this one.

Extensions for visual studio code

I'm using the following extensions for writing posts:

  • Grammarly
  • Markdown All in One
  • :emojisense:
  • Markdown Paste
  • Markdown Preview Enhanced
  • Markdown yaml Preamble
  • YAML


The YAML extension is not visible.

How to use visual studio code for writing posts

Open advanced site by site view:

Add your YAML header

Pasting an image

Open your command pallete (strg+shif+p) and select Markdown Paste

or press strg+alt+v
You can now change the file name. The image from clipboard is stored to your disk and a link to the stored image is pasted into your markdown document.

Pasting links

You can set new rules for smart link pasting. At the moment, only a rule for creating a screenshot for pasting youtube videos has been added:

This embeds an image when pasting a youtube link with strg+alt+v

Check your spelling and grammar

When you made a mistake, Grammarly shows it and it can be corrected by pressing strg+. The automatic correction has a time delay, so have to be patient for grammarly to react on your edits.

The following wrong sentence will be highlighted and useful hints are shown:
Sometames I has wrong grammer.

Adding emoji's

Just type : and the :emojisense: addon will show you all available emojis.

HTML embedding

It is possible to embed some html code as <center>

centered

or <div class="pull-right">:

to the right

Or <br>


line brake.
<h3> works also:

test

As you can see all HTML tags are correctly shown in the preview:

Howto use Typora for writing posts

Table editing

Table creating is not very convenient with visual studio code, it is solved better in typora. So I'm switching to typora for table editing.


You can easily add more rows or columns by right clicking and selecting table.

WYSIWYG

This is only be possible with Typora.
The WYSIWYG is solved great in Typora.
Instead of

you see directly what you will get in Typora

YAML Preamble

Title, author, community, tags... are defined in the YAML preamble. Such an preamble consists of two --- and parameter: value fields in the middle. --- must be the first chars in the markdown file.

---
title: "Howto to use beempy for posting"
author: holger80
community: hive-108365
tags: beempy,editor,howto,python
---

Possible parameters:

  • title - The post title should be set in quotes
  • author - Hive account name from the post author
  • permlink - If not set, the permlink is derived from title
  • community - Community creation account, e.g. hive-10865, when set post appears in this community
  • tags - comma separated tags, can be up to 10
  • beneficiaries - Post beneficiaries (komma separated, e.g. a:10%,b:20%) that will receive parts of the author rewards
  • reply_identifier - Should only set, when you are writing a comment, this is then the parent authorperm e.g. @author/great-post
  • percent_steem_dollars - 0 or 10000, 0 means 100% HP and 10000 means 50/50 in HIVE/HBD and HP. Default is 10000.
  • max_accepted_payout - Can be set to 0, for declining payout. Default is 1000000 HBD
  • parse_body - Can be set to false, in this case mentions, links and used images are not written into the json_metadata. Default is true.

Some examples

Receive all author rewards in HP

---
title: "My statement"
author: hiveuser
tags: hive,statement
percent_steem_dollars: 0
---

Decline payout

---
title: "My statement"
author: hiveuser
tags: hive,statement
max_accepted_payout: 0
---

Burn rewards

---
title: "My statement"
author: hiveuser
tags: hive,statement
beneficiaries: null:100%
---

Send some rewards to dao

---
title: "My statement"
author: hiveuser
tags: hive,statement
beneficiaries: steem.dao:5%
---

Edit a already published post

You can download the markdown with
beempy download -a hiveuser -e my-post.md my-statement

When you open the saved markdown, it should have a permlink parameter:

---
title: "My statement"
permlink: my-statement
author: hiveuser
tags: hive,statement
---

When broadcasting the markdown file, the already posted content is modified. Parameter as

  • community

  • beneficiaries

  • max_accepted_payout

  • percent_steem_dollars

  • reply_identifier

    will be ignored, as these parameters cannot be set when a post is already existing.

Post into a community

You need to find out the community owner account name.
If you want to post in OCD, go to the community site:
https://peakd.com/c/hive-174578
https://hive.blog/trending/hive-174578
and copy the shown account name in the URL.
hive-174578 for OCD.

---
title: "My statement"
author: hiveuser
tags: hive,statement
community: hive-174578
---

Broadcasting with beempy post

Now you have two choices: either copy everything to peakd or hive.blog or use beempy.
The advantages of beempy is that all locally stored images are automatically uploaded and the image urls are set to the new URL. Title, community, tags and all other settings in the YAML-header needs not to be copied by hand into the editing fields in peakd/hive.blog.

beempy is part of beem, a python library for hive. You need to install python (version >= 3.5) on your system and can then install beem with:

pip install beem

You may need to install same packages, which are listed in the readme at beem.
When you are using linux, you need to replace pip with pip3.

When using Windows you can install python 3.7 (3.8 does not work due to scrypt) with the Microsoft store.

and then beem by

python -m pip install beem

You will now see a warning beginning with WARNING: The script beempy.exe is installed in. Copy the path ending with Script and put it into your path environment. You can find help here in how to add path in windows.

A

beempy --version

entered in a cmd window should now work.

A good choice is also to use Anaconda/Miniconda. beempy can then installed with

conda config --add channels conda-forge
conda install beem

When you selecting that python is registered to the path, you should be able to run beempy in a terminal.

Updating beem

Please use always the newest version. Updating beem is easy with:

pip install beem -U

or

python -m pip install beem -U

(replace pip with pip3 on linux).
On anaconda/miniconda it is

conda update beem

You can check your install version with

beempy --version

Update nodes

beempy updatenodes --hive

Creating a wallet and adding your posting key

This step can be skipped and the posting key can be entered each time when broadcasting.
A new wallet is created with

beempy createwallet

and a posting key can be added with

beempy addkey

You can test if you have correctly created a wallet with

beempy walletinfo -u

After entering your wallet password, you should see that number of stored keys is greater than 0.

Posting your markdown file

When you have added the author and the title in the YAML header you can just enter:

beempy post your_great_post.md

If you are not sure if you entered everything in a correct why do a test with -d (or --no-broadcast)

beempy -d post your_great_post.md

All your embedded local images should be uploaded to the hive imageserver and you should see them on peakd/hive.blog.

Posting your markdown file directly from Visual studio code

You can create a new task for directly posting from visual studio code.
Go to Terminal/Configure Tasks.. and add the following to taks.json in the tasks array:

        {
            "label": "post",
            "type": "shell",
            "command": "beempy",
            "args": ["post", "${file}"],
            "problemMatcher": [
                "$eslint-stylish"
            ]
        }

You can now Run a task and select post
.
and you will be asks in the terminal for your wallet password or your posting wif:

Feedback

You are welcome to asks questions or provide feedback in the comments.


If you like what I do, consider casting a vote for me as witness on Hivesigner or on PeakD

Sort:  

I would love to see some simple code to 'get' things from the blockchain, such as anyone who self-votes comments. You can see where this is going?

@steemchiller has added a 'find abuse' to his masterpiece, but its never going to see the light of day on HIVE.

I tried that a few days ago and couldn't get anything to appear. But yeah, is unlikely to appear on the Hive version.

Great tutorial.
I returned to Python after a long time and I installed Visual studio code yesterday. I used to use pyzo, but the work with it isn't as comfortable.
I'll definitely try to setup Visual studio for markdown and make next post with it.
Thanks for your work on beem/beempy !

I feel like what we really need is a better way to get community identifiers from the system for a more "conversational" way to designate a posting target in the YAML. I guess it wouldn't be hard to do by building a little more framework around the beempy call where the writer has created a standalone text file of community names, separated from the hive accounts in the system does a simple search and replace before passing it on.

Overall, a good solution to an annoying problem. Typora is a really good editor.

I will work on community integration into beem/beempy and improve this.

Very good tutorial @holger80 ...thanks! 😇

Awesome! This is really a useful, interesting and clear tutorial. @gitplait needs to home something like this. Great work @holger80

Thanks for this great work. We featured this post in our 2-days GitPlait-elite publications.

amazing work! love beempy

Excellent post mate, I use vs code all the time, will give this a try for sure.

Thanks for your work Holger :)

Hallo @holger80,
ich hatte den Editor vor ein paar Tagen schon gezogen und ihn nach Deinem Post jetzt auch installiert.

Scheinbar ist Grammarly nicht mehr in den Extensions zu bekommen Link. Mal sehen, ob wir das nicht doch installiert bekommen ...

Falls Du einen Tipp hast, lass es mich bitte wissen :)
Werde schon mal Google diesbezueglich befragen ...

Danke fuer diesen interessanten Beitrag!

Das mit grammerly ist wirklich schade. Der Quellcode ist im github, damit kann man bestimmt die Extension per Hand installieren. Ich schaue mir das mal an.

Super!
Danke!!!

max_accepted_payout

Does this mean in theory, I could set it to 1 HTU and anything over is returned to reward pool?

In theory, it should work this way. It would be very interesting to try this out.

Neat gonna figure out beempy and try soon. If it works, I bet it will trick a lot of the autovoters and front ends that just have a if var = 0 skip condition. Muahahaha.

Congratulations @holger80! You received a personal badge!

Welcome Comrade!

Thank you for joining our fellow revolutionaries to promote decentralization and censorship-free speech.
Hive is your new home and you bravely chose to definitely turn your back on Steem.

Invite your friends to join our fight by sharing this post.

¡Viva la revolucion!

You can view your badges on your board and compare to others on the Ranking

Do not miss the last post from @hivebuzz:

Hive Revolution - Call for missions
Vote for us as a witness to get one more badge and upvotes from us with more power!

I have picked your post for my daily hive voting initiative, Keep it up and Hive On!!