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?
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 theEdit
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 disablelink
and enable your copy. You'd then need to add a (renamed?) copy ofhtmllink
fromIkiWiki.pm
to the copy, and call that instead, within thelinkify
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 yourCONTRIBUTING
page. — Jon, 2024-09-09Thanks, 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 modifylink.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 fromIkiWiki.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 thatIkiWiki.pm
exports, so, we should review whether to add them to that list. Also, I'd rename the copy ofhtmllink
to something unique (myhtmllink
? you can probably do better than that) and reference that name inlinkify
, to quash a warning about redefining the existing one. Also: in the logic immediately after generating the CONTRIBUTIONS link, we could actually call the realhtmllink
to handle the rest, which would remove the need for some of those utility functions. Great work! — Jon, 2024-09-10