Package: hatena-cli
hatena-cliCommand line utility for Hatena Blog.hatena-cliis designed for Hatena Blog enthusiasts who perfer to keep their files stored locally on their machines.Here's whyhatena-cliis better than the traditional copy-paste approach:No body length limits.You know how Hatena Blog's web editor puts a cap on how much you can write? Withhatena-cli, that's a thing of the past! You can upload massive Markdown files without any hassle.Say goodbye to manual image uploads.With the--with-imagesoption,hatena-cliautomatically sniffs out the local images referenced in your Markdown file and uploads them to your Hatena Fotolife storage. It even updates the image paths in the generated HTML file!Currently,hatena-clionly supports Markdown files. But no worries, we're thinking about adding support for other file formats soon.To get started, make sure you havepandocandhatena-cliinstalled. You can install them by running these commands:~$brewinstallpandoc
...
~$python-mpipinstallhatena-cli
...
~$pandoc--version
pandoc3.1.3
Features:+server+lua
Scriptingengine:Lua5.4
Userdatadirectory:/Users/taichimaeda/.local/share/pandoc
Copyright(C)2006-2023JohnMacFarlane.Web:https://pandoc.org
Thisisfreesoftware;seethesourceforcopyingconditions.Thereisno
warranty,notevenformerchantabilityorfitnessforaparticularpurpose.
~$hatena--version
HatenaBlogCLIVersion:0.1.0Before you can dive into the functionality ofhatena-cli, you need do a bit of setup.First, follow this tutorial to obtain your API key and secret:https://developer.hatena.ne.jp/ja/documents/auth/apis/oauth/consumerThen submit the details withhatena config init, after which you are ready to go!:~$hatenaconfiginit
hatenaconfiginit
auth:api_key:<api_key>
auth:api_secret:<api_secret>
blog:username:<user_id>
blog:domain:<user_id>.hatenablog.comIf you need more configurations, try these commands:~$hatenaconfiglist
Listofconfig:
auth:api_key:<api_key>
auth:api_secret:<api_secret>
auth:access_token:auth:access_secret:auth:expires:2023-07-0212:00:00.000000
blog:username:<user_name>
blog:domain:<user_name>.hatenablog.com
image:pattern:src="(.+\.(?:jpg|png))"image:replace:src="\1"path:template:<home_dir>/Library/ApplicationSupport/hatena-cli/template.html
path:pandoc:/opt/homebrew/bin/pandoc
~$hatenaconfigsetpandoc:path/usr/local/pandoc
path:pandoc:/usr/local/pandoc
~$hatenaconfiggetpandoc:path
path:pandoc:/usr/local/pandocNow, let's seehatena-cliin action! Check out these examples:~$hatenaupload--with-images'My First Blog'~/Documents/first-blog.md
...
~$hatenaupdate--with-images'My First Blog 2'~/Documents/first-blog2.md820878482946714696...
~$hatenadelete--with-images820878482946714696...hatena uploadandhatena deleterequire the blog ID of your entry on Hatena Blog.To find this blog ID, take a look at the URL of Hatena Blog's web editor. It's the<blog_id>part in this format:https://blog.hatena.ne.jp/<user>/<domain>/edit?entry=<blog_id>On a first launch, you will be redirected to your web browser for authentication. Copy the code displayed and enter it when prompted.Remember, when you use the--with-imagesoption withhatena update, it deletes all previously referenced images and uploads the new ones from your local Markdown file. It can take some time, so use it wisely. It might be quicker to use the web editor if the changes are small.Happy blogging!