ForkKILLET / TerminalXbqg

Read novel from xbqg in your terminal easily. Awesome features: bookcase, update watching, interactive mode, pagewarner, etc.
17 stars 2 forks source link

Patch #13

Open ForkKILLET opened 3 years ago

ForkKILLET commented 3 years ago

We need patches!
We should be able to manually manage the prev and next pointers of a chapter.


All of the xbqg sites storage novels as a linked list.
Suppose there's a book with 3 chapters:

           +-----+ next +-----+ next +-----+
           |     |----->|     |----->|     |-----> null
           |  1  |      |  2  |      |  3  |
null <-----|     |<-----|     |<-----|     |
           +-----+ prev +-----+ prev +-----+

And the 2nd chapter needs fixing, for example, it's an anti-theft one, or garbled, or improperly typeset.
After we get the correct chapter, it should be stored in $XBQG_DATA so that it won't lost when we want to read it again or share it.

           +-----+ next +-----+ next +-----+
           |     |--/-->|     |--/-->|     |-----> null
           |  1  |      |  2  |      |  3  |
null <-----|     |<--/--|     |<--/--|     |
           +-----+ prev +-----+ prev +-----+
              |         +-----+         ^
              |    prev |     | next    |
              +-------->|  2$ |---------+
                        |     |
                        +-----+

Considering the other coming commands for advanced book operation, the directory strcuture will have a breaking change. See below.

books
├── 5_5244              # book id
│   ├── index.json      # will be used by `index_*` commands.
│   └── pages           # will be used by `cache_*` and `patch_*` commands.
│       ├── 5533019
│       ├── 5533022
│       ├── 5533022$    # a patch chapter ends with `$`.
│       └── 5533026
└── marks.json          # `books.json` will be here.

When fetch_{prev,next} commands is called, it first checks if the patch file exists. This progress will be a built-in hook.


Estimated completion time: undefined.