diff --git a/html/logic.js b/html/logic.js
index 4a2e64b..4e0dfa3 100644
--- a/html/logic.js
+++ b/html/logic.js
@@ -304,6 +304,7 @@ async function getSearchResults(f)
f.foundDocs = data["results"];
const rssurl = new URL("https://berthub.eu/tkconv/search/index.xml");
rssurl.searchParams.set("q", f.searchQuery);
+ rssurl.searchParams.set("soorten", f.soorten);
f.rssurl = rssurl.href
f.message = `${data["milliseconds"]} milliseconden`;
diff --git a/partials/search.html b/partials/search.html
index e8ba90b..ad0da5b 100644
--- a/partials/search.html
+++ b/partials/search.html
@@ -21,7 +21,7 @@
{% endblock %}
{% block extrameta %}
-
+
{% endblock %}
{% block customheader %}
diff --git a/search.cc b/search.cc
index 69d1f77..19da94c 100644
--- a/search.cc
+++ b/search.cc
@@ -1,7 +1,41 @@
#include "search.hh"
#include "support.hh"
+#include
using namespace std;
+RSSItem makeRSSItem(const SearchHelper::Result& r, const std::string& naam)
+{
+ RSSItem item;
+ item.title = r.onderwerp;
+
+ if(r.categorie == "Document") {
+ item.description = naam + " | " + r.titel + " " + r.onderwerp;
+ item.link = fmt::format("https://berthub.eu/tkconv/document.html?nummer={}", r.nummer);
+ item.guid = "tkconv_" + r.nummer;
+ } else {
+ item.description = r.onderwerp;
+ if(!r.soort.empty())
+ item.description = r.soort + " | " + item.description;
+ item.link = fmt::format("https://berthub.eu/tkconv/{}", r.relurl);
+ item.guid = "tkconv_" + r.relurl;
+ }
+ return item;
+}
+
+bool searchResultMatchesSoorten(const SearchHelper::Result& r, const std::string& soorten)
+{
+ if(soorten == "documenten")
+ return r.categorie == "Document";
+ if(soorten == "moties")
+ return r.soort == "Motie";
+ if(soorten == "vragenantwoorden") {
+ return r.soort == "Schriftelijke vragen" ||
+ r.soort == "Antwoord schriftelijke vragen" ||
+ r.soort == "Antwoord schriftelijke vragen (nader)";
+ }
+ return true;
+}
+
std::vector SearchHelper::search(const std::string& query, const std::set& categories, const std::string& cutoff, unsigned int mseclimit, unsigned int itemlimit)
{
diff --git a/search.hh b/search.hh
index a789e8f..4e7340a 100644
--- a/search.hh
+++ b/search.hh
@@ -43,4 +43,16 @@ struct SearchHelper
SQLiteWriter& d_sqw;
};
+
+struct RSSItem
+{
+ std::string title;
+ std::string description;
+ std::string link;
+ std::string guid;
+};
+RSSItem makeRSSItem(const SearchHelper::Result& r, const std::string& naam);
+
+bool searchResultMatchesSoorten(const SearchHelper::Result& r, const std::string& soorten);
+
std::set> getZakenFromDocument(const std::string& id);
diff --git a/testrunner.cc b/testrunner.cc
index cdf5c90..12ced0f 100644
--- a/testrunner.cc
+++ b/testrunner.cc
@@ -90,7 +90,90 @@ TEST_CASE("Test timestamps")
CHECK(then == 1737094027);
}
+TEST_CASE("makeRSSItem for Document 2026D10396")
+{
+ SearchHelper::Result r;
+ r.nummer = "2026D10396";
+ r.categorie = "Document";
+ r.onderwerp = "Minimum vermogensbelasting van 2% voor zeer vermogende personen";
+ r.titel = "Herziening Belastingstelsel";
+ r.soort = "Brief regering";
+
+ auto item = makeRSSItem(r, "vaste commissie voor Financiën");
+ CHECK(item.title == "Minimum vermogensbelasting van 2% voor zeer vermogende personen");
+ CHECK(item.description == "vaste commissie voor Financiën | Herziening Belastingstelsel Minimum vermogensbelasting van 2% voor zeer vermogende personen");
+ CHECK(item.link == "https://berthub.eu/tkconv/document.html?nummer=2026D10396");
+ CHECK(item.guid == "tkconv_2026D10396");
+}
+TEST_CASE("makeRSSItem for Motie 2026D05246")
+{
+ SearchHelper::Result r;
+ r.nummer = "2026D05246";
+ r.categorie = "Document";
+ r.onderwerp = "Motie van het lid Vermeer";
+ r.titel = "Wijziging van de Wet inkomstenbelasting 2001 om werkelijke inkomsten uit bezittingen en schulden in box 3 te belasten (Wet werkelijk rendement box 3)";
+ r.soort = "Motie";
+
+ auto item = makeRSSItem(r, "vaste commissie voor Financiën");
+ CHECK(item.title == "Motie van het lid Vermeer");
+ CHECK(item.description == "vaste commissie voor Financiën | Wijziging van de Wet inkomstenbelasting 2001 om werkelijke inkomsten uit bezittingen en schulden in box 3 te belasten (Wet werkelijk rendement box 3) Motie van het lid Vermeer");
+ CHECK(item.link == "https://berthub.eu/tkconv/document.html?nummer=2026D05246");
+ CHECK(item.guid == "tkconv_2026D05246");
+}
+
+TEST_CASE("makeRSSItem for Schriftelijke vragen 2026D10272")
+{
+ SearchHelper::Result r;
+ r.nummer = "2026D10272";
+ r.categorie = "Document";
+ r.onderwerp = "Het terugkrijgen van belastingrente door belastingplichtigen die te veel hebben betaald in box 3";
+ r.titel = "";
+ r.soort = "Schriftelijke vragen";
+
+ auto item = makeRSSItem(r, "");
+ CHECK(item.title == "Het terugkrijgen van belastingrente door belastingplichtigen die te veel hebben betaald in box 3");
+ CHECK(item.description == " | Het terugkrijgen van belastingrente door belastingplichtigen die te veel hebben betaald in box 3");
+ CHECK(item.link == "https://berthub.eu/tkconv/document.html?nummer=2026D10272");
+ CHECK(item.guid == "tkconv_2026D10272");
+}
+
+TEST_CASE("searchResultMatchesSoorten")
+{
+ SearchHelper::Result activiteit;
+ activiteit.categorie = "Activiteit";
+
+ SearchHelper::Result motie;
+ motie.categorie = "Document";
+ motie.soort = "Motie";
+
+ SearchHelper::Result antwoord;
+ antwoord.categorie = "Document";
+ antwoord.soort = "Antwoord schriftelijke vragen";
+
+ CHECK(searchResultMatchesSoorten(motie, "moties"));
+ CHECK_FALSE(searchResultMatchesSoorten(antwoord, "moties"));
+ CHECK(searchResultMatchesSoorten(antwoord, "vragenantwoorden"));
+ CHECK_FALSE(searchResultMatchesSoorten(activiteit, "vragenantwoorden"));
+ CHECK(searchResultMatchesSoorten(motie, "documenten"));
+ CHECK_FALSE(searchResultMatchesSoorten(activiteit, "documenten"));
+}
+
+TEST_CASE("makeRSSItem for Activiteit 2026A01281")
+{
+ SearchHelper::Result r;
+ r.nummer = "2026A01281";
+ r.categorie = "Activiteit";
+ r.relurl = "activiteit.html?nummer=2026A01281";
+ r.onderwerp = "Aanvang middagvergadering: STEMMINGEN (over de Wet werkelijk rendement box 3) en over moties ingediend bij het Tweeminutendebat Voorhang wijziging Postbesluit 2009)";
+ r.soort = "Stemmingen";
+
+ auto item = makeRSSItem(r, "");
+ CHECK(item.title == r.onderwerp);
+ CHECK(item.description == "Stemmingen | " + r.onderwerp);
+ CHECK(item.link == "https://berthub.eu/tkconv/activiteit.html?nummer=2026A01281");
+ CHECK(item.guid == "tkconv_activiteit.html?nummer=2026A01281");
+}
TEST_CASE("Send email" * doctest::skip())
{
diff --git a/tkserv.cc b/tkserv.cc
index af29fe0..c4ace02 100644
--- a/tkserv.cc
+++ b/tkserv.cc
@@ -733,12 +733,14 @@ int main(int argc, char** argv)
sws.wrapGet({}, "/search.html", [&tp](auto& cr) {
string q = cr.req.get_param_value("q");
+ string soorten = cr.req.get_param_value("soorten");
nlohmann::json data;
data["pagemeta"]["title"]="Zoek naar "+htmlEscape(q);
data["og"]["title"] = "Zoek naar "+htmlEscape(q);
data["og"]["description"] = "Zoek naar "+htmlEscape(q);
data["og"]["imageurl"] = "";
data["q"] = urlEscape(q);
+ data["soorten"] = soorten.empty() ? "alles" : urlEscape(soorten);
inja::Environment e;
e.set_html_autoescape(false); // !!
@@ -2009,13 +2011,7 @@ int main(int argc, char** argv)
auto sres = sh.search(term, categories, limit, mseclimit, 280);
nlohmann::json results = nlohmann::json::array();
for(const auto& r : sres) {
-
- if(soorten=="moties" && r.soort != "Motie")
- continue;
- else if(soorten=="vragenantwoorden" &&
- (r.soort != "Schriftelijke vragen" &&
- r.soort != "Antwoord schriftelijke vragen" &&
- r.soort != "Antwoord schriftelijke vragen (nader)"))
+ if(!searchResultMatchesSoorten(r, soorten))
continue;
results.push_back(nlohmann::json({
diff --git a/users.cc b/users.cc
index 05d522a..1cd2d5f 100644
--- a/users.cc
+++ b/users.cc
@@ -355,42 +355,53 @@ Goed inzicht in ons parlement is belangrijk, soms omdat er dingen in het nieuws
// https://berthub.eu/tkconv/search.html?q=bert+hubert&twomonths=false&soorten=alles
sws.wrapGet({}, "/search/index.xml", [](auto& cr) {
string q = convertToSQLiteFTS5(cr.req.get_param_value("q"));
- string categorie;
+ string soorten = cr.req.get_param_value("soorten");
+
+ // Backward compatibility: existing RSS URLs have no soorten parameter
+ // and historically only returned Documents. Treat absent soorten the
+ // same as the explicit "documenten" filter so new Activiteit items
+ // don't suddenly appear in existing subscribers' feeds.
+ if(soorten.empty())
+ soorten = "documenten";
SQLiteWriter own("tkindex-small.sqlite3", SQLWFlag::ReadOnly);
own.query("ATTACH database 'tk.sqlite3' as meta");
SearchHelper sh(own);
- // for now we can't do the rest, only Document XXX
- auto matches = sh.search(q, {"Document"});
+ set categories;
+ if(soorten=="activiteiten")
+ categories.insert("Activiteit");
+
+ auto matches = sh.search(q, categories);
cout<<"Have "<Fri, 13 Dec 2024 14:13:41 +0000