tistory-helper


Nametistory-helper JSON
Version 0.0.4 PyPI version JSON
download
home_pagehttps://github.com/choikangjae/local-first-tistory
SummaryTistory Helper to upload markdown and images
upload_time2023-06-20 06:51:27
maintainer
docs_urlNone
authorKangjae Choi
requires_python
licenseMIT
keywords tistory terminal markdown image
VCS
bugtrack_url
requirements Markdown python-dotenv Requests mdx_truly_sane_lists markdown_link_attr_modifier click
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Local First Tistory

Do not be afraid of shutting down blog server.
It will help you organize the posts in `local-first, server-last` rules.

## Why Use This?

If you've ever been in trouble when the blog server were shut down,
(especially the one is big-tech and never expecting abnormal!) this script just
for you.

You will hold all the data in the local and the script will manage all the things
to communicate with the server. You can read the data when you
(or the server 😂) are offline or migrate to the other platforms.

## Table of Contents

- [Installation](#installation)
- [Usage](#usage)

### Installation

- Python >= 3.9
- To install Python dependencies:

    ```bash
    pip3 install -r requirements.txt
    ```

### Usage

There are 3 scripts: `main.py`, `image.py` and `init.py`.
You have to run each script  manually when you need it.
(since it sends HTTP requests every time, I don't want to be burden.)

- `main.py`: It detects created or modified files on `./markdowns/`
and sends requests, save the metadata of it. You can `crontab` this,
it won't send any HTTP requests it hasn't been changed
but it might consume some computing power to hash the `markdown` files.

- `image.py`: It traverses on `./images/` and sends requests,
save the `url` of it at `./.images.toml`. It will skip the already saved images.
- `init.py`: It will generate `access token` and
retrieve `category` from your blog and make subdirectories in `./markdowns/`.

#### Retrieve Access Token

Briefly, `App ID` and `redirect uri` will be used to get `Authentication code`
(or just `code`); `App ID`, `redirect uri` and `Authentication code`
will be used to get `Access token`.

To start off, run:

```bash
python3 init.py
```

You will see prompts and please follow the instructions.

To get `App ID` and `Secret Key`:

1. Go to `https://www.tistory.com/guide/api/manage/register`

1. Fill out your form.

    Please be aware of `CallBack` column to `{blog_name}.tistory.com`,
    not `http://{blog_name}.tistory.com`, `https://~` nor `https://www.~`.

    ![retrieve_app_id_and_secret_key](https://github.com/choikangjae/local-first-tistory/assets/99468424/4859388a-6670-4b0b-a2ed-6a4111a03ad1)

1. Now you get `App ID` and `Secret Key`. You can check `CallBack` column
and if it doesn't follow the `{blog_name}.tistory.com`, you can modify it here.
    ![result_app_id_and_secret_key](https://github.com/choikangjae/local-first-tistory/assets/99468424/204c4c0e-cccb-455f-940d-f6b3632ba2c2)

1. Enter `App ID` and `Secret key` while following the prompts.

1. All the data you input will be stored at `./.env`. If anything went wrong,
you can modify the data manually.

#### Category

By running `init.py`, categories will be retrieved from your blog and
subdirectories is generated by your blog categories.
You just put `markdown` files by your `category`.
The script will detect your directory and send a request from it.

e.g.

1. Put `example.md` in `markdowns/category1/category2/example.md`.
1. `category1/category2` will be your category like: `category : category1/category2`.

#### Write Markdown

Put the meta data on very top of the `markdown` file like:

```md
---
title or t or 제목: your_title [Mandatory]
visibility or vis or v or 공개: [Optional]
published: TIMESTAMP (default: current_time) [Optional]
tag or tags or 태그: tag1,tag2,tag3 (default: '') [Optional]
acceptComment or ac or comment or 댓글: [Optional]
---
```

- `visibility` (default: `private`):
  - `public`: `public` or `3` or `공개`
  - `protected`: `protected` or `1` or `보호`
  - `private`: `private` or `0` or `비공개`
- `acceptComment` (default: `yes`):
  - To accept: `yes` or `y` or `true` or `t` or `허용` or `1`
  - To deny: `no` or `n` or `false` or `f` or `거부` or `0`

You will notice that only title is mandatory and not the others. This is the example:

```md
# markdowns/category/example.md

---
t: This is my first article!
v: public
ac: 허용
tag: my article,first issue
---

And here it is article content!
```

For more information, go to [official API](https://tistory.github.io/document-tistory-apis/apis/v1/post/write.html).

#### Upload Markdown Files

- Put your `.md` files in `./markdowns/`.

    Subdirectories might be auto-generated from your blog categories.

    ```bash
    markdowns/markdown.md
    markdowns/category1/markdown1.md
    markdowns/category1/markdown2.md
    markdowns/category1/category2/markdown3.md
    ```

- Run:

    ```bash
    python3 main.py
    ```

- Modified or created files will be detected using `SHA1` checksum
at `./.metadata.toml` and it will send requests to modify for modified files
and to create for created files respectively.

#### Upload Images

- Put your `image` binaries in `./images/`.
  - It can have depth like `./markdowns/`

- Make sure images extension end with `.png`, `.jpg`, `.jpeg` or `.gif`.

- Run:

    ```bash
    python3 image.py
    ```

- Uploaded image url will be stored at `./.images.toml`
and you can use `url` when writing markdown.

- Recommend to upload images first before writing your markdowns
since you need `url` in `![images](url)`.

#### TODO

- Change it to `watchdog` to monitor directories?

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/choikangjae/local-first-tistory",
    "name": "tistory-helper",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "tistory terminal markdown image",
    "author": "Kangjae Choi",
    "author_email": "choikj33@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/6a/94/ad2b039d4c34fc3b9c7d9cc548dbff2d1d3fb4776b9eb511fbd0205819cc/tistory-helper-0.0.4.tar.gz",
    "platform": null,
    "description": "# Local First Tistory\n\nDo not be afraid of shutting down blog server.\nIt will help you organize the posts in `local-first, server-last` rules.\n\n## Why Use This?\n\nIf you've ever been in trouble when the blog server were shut down,\n(especially the one is big-tech and never expecting abnormal!) this script just\nfor you.\n\nYou will hold all the data in the local and the script will manage all the things\nto communicate with the server. You can read the data when you\n(or the server \ud83d\ude02) are offline or migrate to the other platforms.\n\n## Table of Contents\n\n- [Installation](#installation)\n- [Usage](#usage)\n\n### Installation\n\n- Python >= 3.9\n- To install Python dependencies:\n\n    ```bash\n    pip3 install -r requirements.txt\n    ```\n\n### Usage\n\nThere are 3 scripts: `main.py`, `image.py` and `init.py`.\nYou have to run each script  manually when you need it.\n(since it sends HTTP requests every time, I don't want to be burden.)\n\n- `main.py`: It detects created or modified files on `./markdowns/`\nand sends requests, save the metadata of it. You can `crontab` this,\nit won't send any HTTP requests it hasn't been changed\nbut it might consume some computing power to hash the `markdown` files.\n\n- `image.py`: It traverses on `./images/` and sends requests,\nsave the `url` of it at `./.images.toml`. It will skip the already saved images.\n- `init.py`: It will generate `access token` and\nretrieve `category` from your blog and make subdirectories in `./markdowns/`.\n\n#### Retrieve Access Token\n\nBriefly, `App ID` and `redirect uri` will be used to get `Authentication code`\n(or just `code`); `App ID`, `redirect uri` and `Authentication code`\nwill be used to get `Access token`.\n\nTo start off, run:\n\n```bash\npython3 init.py\n```\n\nYou will see prompts and please follow the instructions.\n\nTo get `App ID` and `Secret Key`:\n\n1. Go to `https://www.tistory.com/guide/api/manage/register`\n\n1. Fill out your form.\n\n    Please be aware of `CallBack` column to `{blog_name}.tistory.com`,\n    not `http://{blog_name}.tistory.com`, `https://~` nor `https://www.~`.\n\n    ![retrieve_app_id_and_secret_key](https://github.com/choikangjae/local-first-tistory/assets/99468424/4859388a-6670-4b0b-a2ed-6a4111a03ad1)\n\n1. Now you get `App ID` and `Secret Key`. You can check `CallBack` column\nand if it doesn't follow the `{blog_name}.tistory.com`, you can modify it here.\n    ![result_app_id_and_secret_key](https://github.com/choikangjae/local-first-tistory/assets/99468424/204c4c0e-cccb-455f-940d-f6b3632ba2c2)\n\n1. Enter `App ID` and `Secret key` while following the prompts.\n\n1. All the data you input will be stored at `./.env`. If anything went wrong,\nyou can modify the data manually.\n\n#### Category\n\nBy running `init.py`, categories will be retrieved from your blog and\nsubdirectories is generated by your blog categories.\nYou just put `markdown` files by your `category`.\nThe script will detect your directory and send a request from it.\n\ne.g.\n\n1. Put `example.md` in `markdowns/category1/category2/example.md`.\n1. `category1/category2` will be your category like: `category : category1/category2`.\n\n#### Write Markdown\n\nPut the meta data on very top of the `markdown` file like:\n\n```md\n---\ntitle or t or \uc81c\ubaa9: your_title [Mandatory]\nvisibility or vis or v or \uacf5\uac1c: [Optional]\npublished: TIMESTAMP (default: current_time) [Optional]\ntag or tags or \ud0dc\uadf8: tag1,tag2,tag3 (default: '') [Optional]\nacceptComment or ac or comment or \ub313\uae00: [Optional]\n---\n```\n\n- `visibility` (default: `private`):\n  - `public`: `public` or `3` or `\uacf5\uac1c`\n  - `protected`: `protected` or `1` or `\ubcf4\ud638`\n  - `private`: `private` or `0` or `\ube44\uacf5\uac1c`\n- `acceptComment` (default: `yes`):\n  - To accept: `yes` or `y` or `true` or `t` or `\ud5c8\uc6a9` or `1`\n  - To deny: `no` or `n` or `false` or `f` or `\uac70\ubd80` or `0`\n\nYou will notice that only title is mandatory and not the others. This is the example:\n\n```md\n# markdowns/category/example.md\n\n---\nt: This is my first article!\nv: public\nac: \ud5c8\uc6a9\ntag: my article,first issue\n---\n\nAnd here it is article content!\n```\n\nFor more information, go to [official API](https://tistory.github.io/document-tistory-apis/apis/v1/post/write.html).\n\n#### Upload Markdown Files\n\n- Put your `.md` files in `./markdowns/`.\n\n    Subdirectories might be auto-generated from your blog categories.\n\n    ```bash\n    markdowns/markdown.md\n    markdowns/category1/markdown1.md\n    markdowns/category1/markdown2.md\n    markdowns/category1/category2/markdown3.md\n    ```\n\n- Run:\n\n    ```bash\n    python3 main.py\n    ```\n\n- Modified or created files will be detected using `SHA1` checksum\nat `./.metadata.toml` and it will send requests to modify for modified files\nand to create for created files respectively.\n\n#### Upload Images\n\n- Put your `image` binaries in `./images/`.\n  - It can have depth like `./markdowns/`\n\n- Make sure images extension end with `.png`, `.jpg`, `.jpeg` or `.gif`.\n\n- Run:\n\n    ```bash\n    python3 image.py\n    ```\n\n- Uploaded image url will be stored at `./.images.toml`\nand you can use `url` when writing markdown.\n\n- Recommend to upload images first before writing your markdowns\nsince you need `url` in `![images](url)`.\n\n#### TODO\n\n- Change it to `watchdog` to monitor directories?\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Tistory Helper to upload markdown and images",
    "version": "0.0.4",
    "project_urls": {
        "Homepage": "https://github.com/choikangjae/local-first-tistory"
    },
    "split_keywords": [
        "tistory",
        "terminal",
        "markdown",
        "image"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "da8adf6042c2d786c0f4d4c03303e84ea0a483889557d22b58dd6af9b2b9993b",
                "md5": "8d496537353239e7b7b4e654b1bf7dff",
                "sha256": "6a761fbbc7c6b0314f10f057b25042b1da45e4e23bf557138c0954babf066749"
            },
            "downloads": -1,
            "filename": "tistory_helper-0.0.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8d496537353239e7b7b4e654b1bf7dff",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 10816,
            "upload_time": "2023-06-20T06:51:25",
            "upload_time_iso_8601": "2023-06-20T06:51:25.948497Z",
            "url": "https://files.pythonhosted.org/packages/da/8a/df6042c2d786c0f4d4c03303e84ea0a483889557d22b58dd6af9b2b9993b/tistory_helper-0.0.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "6a94ad2b039d4c34fc3b9c7d9cc548dbff2d1d3fb4776b9eb511fbd0205819cc",
                "md5": "936290202f6a8b1b85679c4d76ddade4",
                "sha256": "2c137fb6756ed5f8bd7ec21e3d07e2717e7b8b7792cf87b691e021a01905ac30"
            },
            "downloads": -1,
            "filename": "tistory-helper-0.0.4.tar.gz",
            "has_sig": false,
            "md5_digest": "936290202f6a8b1b85679c4d76ddade4",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 11046,
            "upload_time": "2023-06-20T06:51:27",
            "upload_time_iso_8601": "2023-06-20T06:51:27.588785Z",
            "url": "https://files.pythonhosted.org/packages/6a/94/ad2b039d4c34fc3b9c7d9cc548dbff2d1d3fb4776b9eb511fbd0205819cc/tistory-helper-0.0.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-06-20 06:51:27",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "choikangjae",
    "github_project": "local-first-tistory",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "Markdown",
            "specs": []
        },
        {
            "name": "python-dotenv",
            "specs": []
        },
        {
            "name": "Requests",
            "specs": []
        },
        {
            "name": "mdx_truly_sane_lists",
            "specs": []
        },
        {
            "name": "markdown_link_attr_modifier",
            "specs": []
        },
        {
            "name": "click",
            "specs": []
        }
    ],
    "lcname": "tistory-helper"
}
        
Elapsed time: 0.08195s