summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2023-04-07 18:25:21 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2023-04-07 18:27:28 +0100
commit200ce040b05e76f2d0fd3eaa77bd35a7d00a4b79 (patch)
tree06c32d7f55340938dbe1000bf1f19d4c71c8c35c
parentDump XML documents for analysis, not just HTML docs (diff)
downloadgentoobrowse-200ce040b05e76f2d0fd3eaa77bd35a7d00a4b79.tar.bz2
gentoobrowse-200ce040b05e76f2d0fd3eaa77bd35a7d00a4b79.tar.xz
gentoobrowse-200ce040b05e76f2d0fd3eaa77bd35a7d00a4b79.zip
Simplified/faster sitemap generationgentoobrowse-2.1.9
-rw-r--r--gentoobrowse/src/mash.ice14
-rw-r--r--gentoobrowse/src/search.cpp19
-rw-r--r--gentoobrowse/xslt/sitemap.xslt7
3 files changed, 10 insertions, 30 deletions
diff --git a/gentoobrowse/src/mash.ice b/gentoobrowse/src/mash.ice
index 0ed9f76..abdcec1 100644
--- a/gentoobrowse/src/mash.ice
+++ b/gentoobrowse/src/mash.ice
@@ -24,15 +24,6 @@ module GentooBrowse {
["slicer:key:timestamp","slicer:value:categories","slicer:item:sync"]
dictionary<string, Categories> Syncs;
-
- struct SiteMapCategory {
- ["slicer:name:detail"]
- Gentoo::OverviewCategory category;
- Gentoo::Packages packages;
- };
-
- ["slicer:element:category"]
- sequence<SiteMapCategory> SiteMapCategories;
};
["slicer:root:gentoo"]
@@ -57,11 +48,6 @@ module GentooBrowse {
};
["slicer:root:gentoo"]
- class Sitemap extends PageBase {
- Wrappers::SiteMapCategories categories;
- };
-
- ["slicer:root:gentoo"]
class Search extends PageBase {
Gentoo::Categories categories;
Gentoo::SearchResultPackages packages;
diff --git a/gentoobrowse/src/search.cpp b/gentoobrowse/src/search.cpp
index 52a5846..93ce80f 100644
--- a/gentoobrowse/src/search.cpp
+++ b/gentoobrowse/src/search.cpp
@@ -36,20 +36,13 @@ namespace GentooBrowse {
{
auto _ar_categories = prx0->getAllOverviewCategoriesAsync(request->getContext());
auto _ar_packages = prx0->getAllPackagesAsync(request->getContext());
- ::GentooBrowse::SitemapPtr _responseModel = std::make_shared<::GentooBrowse::Sitemap>();
+ auto _responseModel = std::make_shared<CategoriesAndPackages>();
auto categories = _ar_categories.get();
- auto packages = _ar_packages.get();
- for (const auto & super : categories) {
- std::transform(super.second.begin(), super.second.end(),
- std::inserter(_responseModel->categories, _responseModel->categories.begin()),
- [&packages](auto c) {
- Gentoo::Packages ps;
- std::copy_if(packages.begin(), packages.end(), std::inserter(ps, ps.begin()), [&c](auto p) {
- return p->categoryid == c->categoryid;
- });
- return GentooBrowse::Wrappers::SiteMapCategory({c, ps});
- });
- }
+ std::for_each(categories.begin(), categories.end(),
+ [ins = std::back_inserter(_responseModel->categories)](auto && oc) {
+ std::move(oc.second.begin(), oc.second.end(), ins);
+ });
+ _responseModel->packages = _ar_packages.get();
request->response(this, _responseModel);
}
diff --git a/gentoobrowse/xslt/sitemap.xslt b/gentoobrowse/xslt/sitemap.xslt
index 055b48d..40fa765 100644
--- a/gentoobrowse/xslt/sitemap.xslt
+++ b/gentoobrowse/xslt/sitemap.xslt
@@ -2,6 +2,7 @@
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:date="http://exslt.org/dates-and-times" version="1.0" exclude-result-prefixes="date">
<xsl:output encoding="utf-8" method="xml" media-type="text/xml" indent="yes"/>
<xsl:variable name="base">https://gentoobrowse.randomdan.homeip.net/</xsl:variable>
+ <xsl:key name="packages" match="/gentoo/packages/package" use="categoryid"/>
<xsl:template match="/gentoo">
<urlset>
<url>
@@ -17,8 +18,8 @@
<changefreq>weekly</changefreq>
</url>
<xsl:for-each select="categories/category">
- <xsl:sort select="detail/name"/>
- <xsl:variable name="category" select="detail"/>
+ <xsl:sort select="name"/>
+ <xsl:variable name="category" select="."/>
<url>
<loc><xsl:value-of select="$base"/>packages/<xsl:value-of select="$category/name"/></loc>
<lastmod>
@@ -26,7 +27,7 @@
</lastmod>
<changefreq>daily</changefreq>
</url>
- <xsl:for-each select="packages/package">
+ <xsl:for-each select="key('packages', $category/categoryid)">
<xsl:sort select="name"/>
<url>
<loc><xsl:value-of select="$base"/>packages/<xsl:value-of select="$category/name"/>/<xsl:value-of select="name"/></loc>