-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feature: pages index. #267
Conversation
By having an index for the pages, it'd allow clients to build autocomplete's and show an index of pages making only one request (think `tldr list`). Subsequent caching of this file would prevent further requests. Included is a makefile to easily rebuild the index. It could be tailored in case the pages structure changed. In a particular case, the web client would benefit greatly from an index. It'd know exactly what folder a command is in and thus the number of requests would drop from 4 to 1.
Actually, it'd be best to have the index in JSON format. Something like this:
I.e. I'll refactor this after we get some feedback. |
I've actually been thinking about a way to allow command auto-complete or search for a long time but never got around to actually propose something. I like how you already implemented a prototype of the index file as well! I'll just state that I really like this feature and it makes sense to index on command name first like you did. I would also rather like JSON but there are two approaches here. The one written above by @leostera or something rather like:
I guess the main advantage here is an easier lookup on command name but that advantage kind of disappears when trying to do other things. Curious as to what @rprieto thinks about this! |
That's a great idea, it will probably enable some cool new ideas in different clients! The only downside I can think of is having to update this file when new commands get added. Hopefully that's not too big of a burden. My preference is for the original suggestion (array), but I don't really mind if we want to go for a hash instead (lookups are easier, but counting and filtering are typically harder...). Let's just make sure there's a top-level entry, so we can add fields later without breaking compatibility: {
"commands": [{
"name": "tar",
"platforms": ["osx", "common"]
}]
} I'd definitely keep a structure that makes sense for commands - regardless of the current folder structure. There's another issue open about potentially changing that folder structure, so the clients would have to change but the index can stay the same. We could even consider going hypermedia-like, so clients don't have to know where the files sit... but this could also be overkill. Happy to discuss. {
"commands": [{
"name": "tar",
"platforms": {
"osx": "pages/common/osx.md"
}
}]
} 👍 from me, and 👍 on the Makefile as well if we update it to produce JSON 😄 |
I wouldn't bother adding the paths firstly to avoid the footprint (the index could get very big), and secondly because they can be built with the name of the command and it's platforms. If we were to store pages elsewhere (say, S3), we'd be just fine adding a top-level tldr.js requests to: Rebuilding the index could be done with a git-hook. Propagating the hook alongside forks is a matter of adding a Anywho, I'll start working on the refactor for the JSON output. |
also removes index.md
I'm by no means a rubyist, but this does the trick. Any suggestions? |
Any thoughts here? @rubenvereecken @rprieto @waldyrious |
Sorry for the long wait, let's blow some new life into this. I'm not sure I understand the Git hook. This would be a tiny script that reruns the index builder, right? Would the symlink be preserved along forks, so the hook is shared? That does sound like a good idea then. Then reindexes should be part of commits that add pages, would be fairly clean. @rprieto we need your thoughts. |
Nice work reviving this thread - some great ideas here. I definitely like the idea of a hook, and to @rubenvereecken's point could it be a On the format, some things I'm keen to discuss:
|
I think the hypermedia will be overkill. If we had multiple sources of truth, with multiple directory structures, then it'd be a better way of defining the index – but as of right now and presumably the near future, there will be a single source of truth with a defined structure; whether it is 👍 on the keywords for searching locally. I can see |
@Ostera the As for the index, I was coming from the angle that this new index is here to enable the webapp - at least as a first client. We could take the opportunity to avoid the web client hardcoding a URL structure that might change soon (and potentially 👍 on not having hypermedia for every page, but at least a url template at the top). |
But in any case, 👍 to this index, as it will help clients discover what pages are available, and for which platforms. I'm guessing @gianasista's android client could benefit from this as well for example. |
So this is kinda stalled. Here's a to-do list that I think needs to pass before it can be merged:
Anything else that you guys can think of? @rubenvereecken @rprieto @waldyrious |
@Ostera Sounds like a great start, I'm happy to look into it tomorrow myself as I've finally found some spare time. |
@rubenvereecken, sure thing, go ahead. Just let me know your repo/branch so I can fetch, merge and push again to update this PR. |
Submitted a PR at leostera#1 |
Adds `make setup` and a pre-commit hook to rebuild index.
Looks like we're good to go 👍 |
@rprieto last change to get something in :D |
Pages index is a great idea. I have changed my client to work with the index.json from the branch. Looking forward that the request will be merged. |
Thanks for the feedback @gianasista, I bet @Ostera is proud and it helps to see that people may find this useful. Alright, the glorious moment is finally here! Just did a thorough check (and I'll let the edit to README.md slide) and everything is good to go. Some things still need to happen though (and I'm writing them down because I'm in a hurry):
EDIT: There was an actual typo in the Markdown syntax of your README.md edit 😛. |
Holy Moly! 💯 Great news! I'll start working on the index for tldr.js ASAP. Thanks everyone for letting me contribute :) |
You did a really great job :). And while you're at it, doing good jobs and all, feel free to check out #277 beacuse @hollingberry made some changes to your index script and I'd like your thoughts on it. I feel like this PR has set some things in motion, tldr has just become a lot more powerful. |
By having an index for the pages, it'd allow clients
to build autocomplete's and show an index of pages
making only one request (think
tldr list
). Subsequentcaching of this file would prevent further requests.
Includes a makefile to easily rebuild the index. It could
be tailored in case the pages structure/hierarchy changed.
In a particular case, the web client would benefit greatly
from an index. It'd know exactly what folder a command is in
and thus the number of requests would drop from 4 to 1.
Also adds tldr.js to README.