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

Added option to honour the main page revision when using included pages #217

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

ruud12
Copy link

@ruud12 ruud12 commented Oct 8, 2017

I have added the option to honour the main page revision: if a revision of a page is viewed, any included pages will also be shown with the closest (but older) revision with respect to the revision date of the viewed page. The 'closest' revision is the first revision equal to or older than the viewed page revision timestamp.

  • If the latest draft/revision of a page is shown, the included pages will also show the latest version.
  • If no older revision of the included page is present, the oldest (first) revision is used
  • If the approve plugin (https://www.dokuwiki.org/plugin:approve) is used, the last approved version will also be honoured. This should perhaps be made optional
  • Added the 'honourmainrevision' option to the configuration options of the plugin, to enable or disable the added functionality

I hope I have made myself clear. I'm using the dokuwiki software for manuals and documentation, and whilst the include plugin features great functionality, I needed the option to go back in time to view an older version of a manual and the include plugin did not feature this option yet.

Please comment on my work, as I'm only a hobby programmer and my code can probably be improved. Thanks for the great include plugin anyway!

Copy link
Member

@michitux michitux left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apart from the changes requested in the individual comments, this looks fine. Would you mind having a look at #131 and possibly try integrate this with the changes proposed here? In particular, support for $DATE_AT would be nice. The additional helper class is not necessary anymore. There are also a couple of interesting points in #131, like a) adapting links to the included pages and b) not including a page if it did not exist at the requested time.

I am also wondering about the support for the approval plugin. For full support, I assume, this would also need to possibly get older revisions if the current page is the most recent revision, but the included page's most recent revision hasn't been approved, right? If this is the case, this will interfere with caching and requires changes to the caching logic. Further, for which approval plugin is this?

$first_revision = '';

$m = p_get_metadata($id); // get metadata for current page
$sum = $m['last_change']['sum']; // get last change summary
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two lines seems to be unused.

if ($this->getConf('honourmainrevision')) {

// initialize variables with empty string
$wanted_revision = '';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$wanted_revision should be initialized to null, outside this if statement.

Comment on lines +146 to +147
$revision_before_main_revision = '';
$first_revision = '';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These two variables are only used inside the if-statement and should thus be initialized there.

}
}
} else {
$wanted_revision = null;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If $wanted_revision is initialized to null, this line can be removed.

$first_revision = $rev;
}

if ($wanted_revision == '') { // no suitable revision found with approval
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If $wanted_revision is initialized to null, this needs to be adapted.

Comment on lines +153 to +154
$changelog = new PageChangeLog($id); // initiate changelog
$chs = $changelog->getRevisions(0, 10000); // load changes list
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this limit to 10000 revisions? Wouldn't it make more sense to load revisions dynamically in batches? I.e., use two nested loops below, where the outer loop gets revisions in batches of, e.g., 100 revisions and the inner loop then iterates over the current batch. Further, these two lines should be inside the if statement below. Otherwise, they are also executed when the current revision is used. Further, $changelog->getLastRevisionAt() could be used unless the approval plugin is installed, and even then there are functions for getting a number of revisions around that date.

// add configuration option to honour top page revision or not
// if (not configuration_option_honour_revision) {
// $wanted_revision = null;
// }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please remove this comment as it has been addressed above.

@@ -136,6 +138,55 @@ function render($format, Doku_Renderer $renderer, $data) {
if (in_array($id, $page_stack)) continue;
array_push($page_stack, $id);

// check if the include plugin should honour the main page revision
if ($this->getConf('honourmainrevision')) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This if statement could also directly check $REV (as all code below should be moved as explained there).

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

Successfully merging this pull request may close these issues.

2 participants