6

I'm writing an app that uses the GitLab API, and I'd like to list the pages in the wiki. I can do something like http://gitlab/username/project/wikis/home.md to get the source of an individual file, and see all pages with http://gitlab/username/project/wikis/pages, but I can't do http://gitlab/username/project/wikis/pages.md due to a 500 error.

Is there a way I can retrieve the list of files in the wiki?

Grayda
  • 1,870
  • 2
  • 25
  • 43

3 Answers3

2

Note; if this list is to facilitate a TOC (Table of content) for navigation purpose, you now have GitLab 13.5 (October 2020), which comes with:

Deep-level wiki navigation

In GitLab 13.5, along with the release of group wikis, we have another huge improvement in how to view and navigate the file structure of a wiki.

Currently, it’s very difficult to see where you are or understand the structure of a wiki if you have multiple folder levels. This makes it difficult to navigate, find pages, and mentally map your information.

With this release, we’ve introduced wiki deep nesting in the sidebar so you can see all of your pages and navigate accordingly.

https://about.gitlab.com/images/13_5/cdybenko-wiki-deep-nesting.png -- Deep-level wiki navigation

See Documentation and Issue.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
1

So there's now a GitLab Wiki API available which does everything I need:

https://docs.gitlab.com/ce/api/wikis.html

It can be used something like this:

https://gitlab.example.com/api/v4/projects/:project_id/wikis?with_content=1&private_token=yourtokenhere

Grayda
  • 1,870
  • 2
  • 25
  • 43
  • But you would have to add your token in the wiki and everyone could have it. I don't believe this is a good practice – Matias Bertani Jul 27 '23 at 20:42
  • @MatiasBertani not necessarily. The call could be made server-side (e.g. on another server you run) and the URL constructed at run-time, or the app could require you to register your own token and use that in a locally-run app (e.g. a desktop app). Also, the token isn't actually stored on the wiki pages themselves. – Grayda Jul 27 '23 at 22:31
0

Possibly not what you wanted (and a bit late) but if you have modified your Sidebar (i.e. _sidebar) you can make a copy of it and then delete it.

You could also add link:pages[List all pages]

to your home page. That might avoid, somehow, the 500 you get from pages.md

tristram
  • 141
  • 4
  • 10