From e55308f50abb3d717208602d455199adf10a5c3b Mon Sep 17 00:00:00 2001 From: Starbeamrainbowlabs Date: Mon, 25 May 2020 21:15:19 +0100 Subject: [PATCH] Display basic similar page suggestions. They are w=even appearing in the right pace! Next up, we need to write the CSS to make it look pretty :D --- modules/feature-similarpages.php | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/modules/feature-similarpages.php b/modules/feature-similarpages.php index 4173f0c..96825b0 100644 --- a/modules/feature-similarpages.php +++ b/modules/feature-similarpages.php @@ -68,6 +68,23 @@ register_module([ break; } }); + + page_renderer::register_part_preprocessor(function(&$parts) { + global $env; + + $html = "

Other pages to explore

\n\t\t\n\t\t\n"; + + $parts["{extra}"] = $html . $parts["{extra}"]; + }); } ]); @@ -95,7 +112,6 @@ function similar_suggest(string $pagename, string $content, bool $limit_output = $max_count = -1; $i = 0; foreach($index as $term => $data) { - error_log("[similar_suggest] checking $term | {$data["freq"]}"); // Only search the top 20% most common words // Stop words are skipped automagically // if($i > $max_count * 0.2) break; @@ -112,8 +128,6 @@ function similar_suggest(string $pagename, string $content, bool $limit_output = // Check is it's present just in case (todo figure out if it's necessary) if(!search::invindex_term_exists($term)) continue; - error_log("ok"); - $otherpages = search::invindex_term_getpageids($term); foreach($otherpages as $pageid) { if($pageid == $our_pageid) continue; @@ -133,7 +147,7 @@ function similar_suggest(string $pagename, string $content, bool $limit_output = $result = []; $i = 0; foreach($pages as $pageid => $count) { - if($limit_output && $i > $settings->similarpages_count) break; + if($limit_output && $i >= $settings->similarpages_count) break; $result[ids::getpagename($pageid)] = $count; $i++; }