Skip to content
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

Add GitHub Wiki Support #42

Open
sheluchin opened this issue May 21, 2019 · 8 comments
Open

Add GitHub Wiki Support #42

sheluchin opened this issue May 21, 2019 · 8 comments

Comments

@sheluchin
Copy link

Some commands, like :GBrowse, do not work correctly when used on a wiki repo. For example, executing :GBrowse on the Home.md page takes you to https://github.com/tpope/vim-fugitive.wiki/blob/master/Home.md which doesn't exist.

@tpope tpope transferred this issue from tpope/vim-fugitive May 21, 2019
@tpope
Copy link
Owner

tpope commented May 21, 2019

I would welcome an implementation of this. Documenting what the behavior should be would also help. Is it possible to view an old revision of a page? A commit object? Are trees (directories) a thing or is it a flat namespace?

@hovsater
Copy link

I'm seeing this problem with a regular privat erepository. Running :Gbrowse takes me to https://github.com/org/repo/blob/my-branch while the proper URL is https://github.com/org/repo/tree/my-branch.

@tpope
Copy link
Owner

tpope commented Aug 24, 2019

It's not a "problem", it's a feature request that lacks enough information to implement.

Edit: what you're describing has nothing to do with wikis.

@hovsater
Copy link

@tpope you’re right, I’ve submitted a separate issue describing what I’m seeing in #49. Sorry for creating unnecessary noise in this issue.

@sheluchin
Copy link
Author

I'll answer using the Ethereum Wiki as an example, as it seems to be the most popular wiki on GitHub and has enough content to use for reference.

The URL to a wiki looks like this:

https://github.com/ethereum/wiki/wiki
                   │        │    │
                   │        │    └── standard title set by GitHub
                   │        │
                   │        └── repo title chosen by creator
                   │
                   └── owner name (org. name or username)

I'll refer to this as <base_url> for simplicity.

As editing the wiki through the web interface is very common, spaces are usually included in page titles. GitHub's web interface replaces them with hyphens.

For example, the page titled 5 strategies of contribution is accessible at:

https://github.com/ethereum/wiki/wiki/5-strategies-of-contribution

Is it possible to view an old revision of a page?

Yes, viewing a page revision is possible at:

<base_url>/page-title/<sha>

Example:

https://github.com/ethereum/wiki/wiki/5-strategies-of-contribution/b4ba41ef3a0127b338c082343c30d5d46486e8bb

Is it possible to view a commit object?

Yes, viewing a commit object is possible, but this behaviour is not documented, as far as I can tell, and looks a little bit hacky:

<base_url>/_compare/<sha>

Example:

https://github.com/ethereum/wiki/wiki/_compare/b4ba41ef3a0127b338c082343c30d5d46486e8bb

It relies on the functionality that allows revision comparison. This will compare all files across two revisions:

<base_url/_compare/<sha1-first-rev>...<sha1-second-rev>

Example:

https://github.com/ethereum/wiki/wiki/_compare/30d60370456d603fca92a79691937679c8cae89e...b4ba41ef3a0127b338c082343c30d5d46486e8bb

While comparing revisions of a specific file looks like this:

<base_url>/page-title/_compare/<sha1-first-rev>...<sha1-second-rev>

Example:

https://github.com/ethereum/wiki/wiki/5-strategies-of-contribution/_compare/30d60370456d603fca92a79691937679c8cae89e...b4ba41ef3a0127b338c082343c30d5d46486e8bb

Are trees (directories) a thing or is it a flat namespace?

Trees are kind of a thing. It's a little weird. You can create directories in the repo when you're editing the repo locally, but they get flattened by the GH web interface. For example, you might have:

$ tree
.
└── some_dir
    └── some-file.md

To access it through the web interface, you would disregard the tree and go to:

<base_url>/some-file

Trying to access it through the expected full path does not work:

<base_url>/some_dir/some-file

Other Notes

  • the entire revision history of the wiki is accessible at:

    <base_url>/_history
    

    Example:

    https://github.com/ethereum/wiki/wiki/_history
    
  • the home page of every wiki is accessible through the <base_url>, but the history of that page is only accessible at:

    <base_url>/Home/_history
    

    Example:

    https://github.com/ethereum/wiki/wiki/Home/_history
    
  • likewise, the revision history of any particular page is available at:

    <base_url>/page-title/_history
    

Hope this helps. Please let me know if there's any other info that might be useful.

@tpope
Copy link
Owner

tpope commented Oct 19, 2019

Thanks for the intel. Looks gross but I'm not really surprised.

@sheluchin
Copy link
Author

The wiki feature on GitHub looks pretty half-baked and the underscore prefixes might suggest an unstable interface, especially considering those endpoints are not documented, but it has been that way for as long as I can remember and the wiki is a fairly popular feature in some communities.

@benelan
Copy link

benelan commented Jul 31, 2024

@tpope Would you accept an initial implementation that only opens/copies the URL for the current version of markdown files the supported markup filetypes? Something along the lines of:

  • If the remote is a GitHub repo that ends in .wiki, proceed with the following logic
  • If the file does not end in .md filetype is not one of the supported markup formats, echo a warning/error and return
  • Transform the file name into the url format (e.g. spaces to hyphens)
  • Open or copy the url ignoring line number, visual selection and history

While not ideal, it seems better than the existing behavior for GitHub wikis.

Edit: the implementation should support all of the markup formats GitHub Wikis support, not just markdown.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants