Although my wiki is static, I'd still like all the editing functionality to be visible and link to the contributing guide page. I've achieved this by setting the cgiurl as the link to CONTRIBUTING on my wiki, and disabling plugins that define the Preferences action since there is no CGI for it to use.

The only problem I encountered was that the recentchanges plugin doesn't have a setup option to explicitly disable using the CGI for linking to changed pages when the cgiurl is set. Below is a patch that adds a configuration option for this:

--- a/IkiWiki/Plugin/recentchanges.pm   1970-01-01 07:30:01.000000000 +0730
+++ b/IkiWiki/Plugin/recentchanges.pm   2024-09-03 14:13:29.351231651 +0800
@@ -40,11 +39,19 @@
            safe => 1,
            rebuild => 0,
        },
+       recentchangescgi => {
+           type => "boolean",
+           example => 1,
+           description => "Enable recentchanges CGI?",
+           safe => 1,
+           rebuild => 1,
+       },
 }

 sub checkconfig () {
    $config{recentchangespage}='recentchanges' unless defined $config{recentchangespage};
    $config{recentchangesnum}=100 unless defined $config{recentchangesnum};
+   $config{recentchangescgi}=1 unless defined $config{recentchangescgi};
 }

 sub refresh ($) {
@@ -168,7 +175,7 @@
    my $has_diffurl=0;
    $change->{pages} = [
        map {
-           if (length $config{cgiurl}) {
+           if (length $config{cgiurl} && $config{recentchangescgi}) {
                $_->{link} = "<a href=\"".
                    IkiWiki::cgiurl(
                        do => "goto",
@@ -210,7 +217,7 @@
        $change->{authorurl}=$change->{user};
        $change->{user}=defined $change->{nickname} ? $change->{nickname} : $oiduser;
    }
-   elsif (length $config{cgiurl}) {
+   elsif (length $config{cgiurl} && $config{recentchangescgi}) {
        $change->{authorurl} = IkiWiki::cgiurl(
            do => "goto",
            page => IkiWiki::userpage($change->{author}),

It's probably better to add the functionality I'm looking for in the editing-related plugins like link and editpage, but I'm not that familiar with Ikiwiki internals yet. Please let me know if that's preferrable. -- awesomeadam

This feels odd to me: if you want to disable CGI (which is, effectively, what linking to CONTRIBUTING would do, no?), just disable CGI, then use the theme or something else to add a link? I have already patched ikiwiki to have recentchanges work properly without CGI, FWIW, in proper links in recentchanges without CGI, have you tried that?

see also sidebar. -- anarcat

Yes, I've disabled the CGI before this and the recentchanges page worked as expected. The reason I want to set the cgiurl to CONTRIBUTING is so that the Edit action and all the wikilinks to nonexistent pages(the ones with '?' prepended) will be shown, since they aren't shown if the CGI is disabled. It's normally better to not show them at all when the CGI is disabled, but it would be useful to link to a contribution guide page instead if there was an option for it.

I could just use the sidebar plugin instead and link to CONTRIBUTING from there, but then the missing pages on the wiki won't be visible from a glance... -- awesomeadam

(Let me preface this by first saying that presently I am not able to do any open source work, including IkiWiki, for reasons but I'm hoping that will change within the next few weeks.) Without looking at the code first (which might undermine my assumptions), I feel the cleanest way to achieve what you want would be if it were possible for a plugin to be triggered during link generation (the ? for broken links) and for that plugin to exist. I think enabling CGI in any scenario where you don't want CGI is likely to have some risky corner cases. Cleaner would be CGI off; a separate plugin handles dealing with ?-plugins; and anarcat's changes to make recentchanges work properly with CGI off. Jon, 2024-09-05

you'd need to make a copy of the link plugin, explicitly disable link and enable your copy. You'd then need to add a (renamed?) copy of htmllink from IkiWiki.pm to the copy, and call that instead, within the linkify subroutine.

Then, in the copy of htmllink, you can find the chunk of code which generates the links for missing pages (search for "<span class=\"createlink\">) and adjust it to be a static link to your CONTRIBUTING page. Jon, 2024-09-09

Thanks, here's my working modified link plugin based on your instructions. Would the functionality be accepted into ikiwiki's link plugin? I could make adjustments if necessary. awesomeadam, 2024-09-10

Nice! I think I might use this myself, too: on my site I have CGI turned on for comments, but I don't do web-based page editing. I'll do a full review once I'm back at work. For now, I'd say that this works well as an independent plugin from link.pm, so it probably makes sense to keep it that way rather than modify link.pm, but I'd like to see this as a plugin included in IkiWiki. One quick hint, I noticed after a quick scan over: rather than copy the utility functions from IkiWiki.pm, you can reference them with e.g. IkiWiki::abs2rel. This wouldn't be necessary if we included those utility functions in the list of things that IkiWiki.pm exports, so, we should review whether to add them to that list. Also, I'd rename the copy of htmllink to something unique (myhtmllink? you can probably do better than that) and reference that name in linkify, to quash a warning about redefining the existing one. Also: in the logic immediately after generating the CONTRIBUTIONS link, we could actually call the real htmllink to handle the rest, which would remove the need for some of those utility functions. Great work! Jon, 2024-09-10

Hey Adam, I'm in a position now where I could work on this. But I want to check, are you interested in trying to write this? I could either write it myself, or I'd be happy to mentor you and review you doing it instead, if you would like to make a contribution to IkiWiki. Let me know! Thanks, Jon, 2024-10-01

Sorry for the late reply, I'm still interested in you mentoring me writing this plugin. I have a question: Wouldn't calling the original htmllink to handle the rest result in some of the checks being repeated/overridden? I don't think there's a way to replace only part of a function, so some of the logic will be duplicated. awesomeadam, 2024-10-18