From 2cbafc754d5e14811c808f65ce9e60b4d4bf7df5 Mon Sep 17 00:00:00 2001 From: Bryce Kwon Date: Sun, 19 Jul 2026 15:54:22 -1000 Subject: Add a help page with common workflows --- source/ui-help.c | 93 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) create mode 100644 source/ui-help.c (limited to 'source/ui-help.c') diff --git a/source/ui-help.c b/source/ui-help.c new file mode 100644 index 0000000..981733d --- /dev/null +++ b/source/ui-help.c @@ -0,0 +1,93 @@ +/* ui-help.c: built-in guide to the cgit interface + * + * Copyright (C) 2006-2018 cgit Development Team + * + * Licensed under GNU General Public License v2 + * (see LICENSE.txt for full license text) + */ + +#include "cgit.h" +#include "ui-help.h" +#include "html.h" +#include "ui-shared.h" + +static void print_workflow(const char *title, const char *intro, + const char *pattern, const char *example) +{ + html("

"); + html_txt(title); + html("

\n

"); + html_txt(intro); + html("

\n"); + if (pattern) { + html("
");
+		html_txt(pattern);
+		if (example) {
+			html("\n");
+			html_txt(example);
+		}
+		html("
\n"); + } +} + +void cgit_print_help(void) +{ + cgit_print_layout_start(); + html("
\n"); + + html("

Every page on this site has a stable address, so anything " + "you can see can also be linked, scripted or fetched. The " + "patterns below cover the common workflows. Angle brackets " + "mark the parts you replace.

\n"); + + print_workflow("Browse a repository", + "Each repository has a summary page, and the tabs on it lead " + "to the branch and tag list, the commit history and the file " + "tree.", + "// //refs/ //log/ //tree/", + NULL); + + print_workflow("Pin what you are looking at", + "Add h= to select a branch, or id= to select any commit, tag " + "or object hash. They work on nearly every page, so a pinned " + "URL always shows the same content.", + "//tree/?h= //tree/?id=", + "/linux/tree/?h=stable /linux/tree/?id=v6.1"); + + print_workflow("View a file", + "Append a path to the tree page for the rendered view, use " + "plain for the raw bytes, and blame to see which commit last " + "touched each line.", + "//tree/ //plain/ //blame/", + "/linux/tree/kernel/fork.c?h=v6.1"); + + print_workflow("Compare two points in history", + "The diff page compares id2, the older point, with id, the " + "newer one. Both accept tags, branches and commit hashes. " + "Use rawdiff for the plain patch text.", + "//diff/?id=&id2=", + "/linux/diff/?id=v6.2&id2=v6.1"); + + print_workflow("Follow the history of a path", + "The log page takes a path to limit history to it. The " + "search box above the log searches the message, author or " + "committer, and the range type accepts any revision range.", + "//log/ //log/?qt=range&q=..", + "/linux/log/?qt=range&q=v6.1..v6.2"); + + print_workflow("Download a release or a patch", + "Snapshots are archives of a tag or commit, named after the " + "repository and version. The patch page emits a single " + "commit as an emailable patch.", + "//snapshot/-.tar.gz //patch/?id=", + "/linux/snapshot/linux-v6.1.tar.gz"); + + print_workflow("Subscribe to changes", + "Every repository serves an Atom feed of its history, and " + "h= scopes it to a branch.", + "//atom/ //atom/?h=", + NULL); + + html("
\n"); + cgit_print_layout_end(); +} -- cgit v2.8.0