Commits

Ashutosh Singla committed ec92e2d Draft

Added multiple and fqname support to misc views.

Comments (0)

Files changed (3)

MoinMoin/apps/misc/templates/misc/sitemap.xml

 <?xml version="1.0" encoding="UTF-8"?>
 <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
-{% for item_name, lastmod, changefreq, priority in sitemap -%}
+{% for fq_name, lastmod, changefreq, priority in sitemap -%}
 <url>
-<loc>{{ url_for('frontend.show_item', item_name=item_name, _external=True)|e }}</loc>
+<loc>{{ url_for('frontend.show_item', item_name=fq_name, _external=True)|e }}</loc>
 <lastmod>{{ lastmod }}</lastmod>
 <changefreq>{{ changefreq }}</changefreq>
 <priority>{{ priority }}</priority>

MoinMoin/apps/misc/templates/misc/urls_names.txt

-{% for item_name in item_names -%}
-{{ url_for('frontend.show_item', item_name=item_name, _external=True) }} {{ item_name }}
+{% for fq_name in fq_names|sort(attribute='value') -%}
+{{ url_for('frontend.show_item', item_name=fq_name, _external=True) }} {{ fq_name.value }}
 {% endfor %}

MoinMoin/apps/misc/views.py

 
     sitemap = []
     for rev in flaskg.storage.documents(wikiname=app.cfg.interwikiname):
-        name = rev.name
+        fqnames = rev.fqnames
         mtime = rev.meta[MTIME]
         # these are the content items:
         changefreq = "daily"
         priority = "0.5"
-        sitemap.append((name, format_timestamp(mtime), changefreq, priority))
-    # add an entry for root url
-    root_mapping = app.cfg.root_mapping
-    query = Or([And([Term(NAME_EXACT, root_mapping[namespace]), Term(NAMESPACE, namespace)]) for namespace in root_mapping.keys()])
+        sitemap += [((fqname, format_timestamp(mtime), changefreq, priority)) for fqname in fqnames]
+    # add entries for root urls
+    root_mapping = [(namespace, app.cfg.root_mapping.get(namespace, app.cfg.default_root)) for namespace, _ in app.cfg.namespace_mapping]
+    query = Or([And([Term(NAME_EXACT, root), Term(NAMESPACE, namespace)]) for namespace, root in root_mapping])
     for rev in flaskg.storage.search(q=query):
         mtime = rev.meta[MTIME]
         sitemap.append((rev.meta[NAMESPACE], format_timestamp(mtime), "hourly", "1.0"))
     See: http://usemod.com/cgi-bin/mb.pl?SisterSitesImplementationGuide
     """
     # XXX we currently also get deleted items, fix this
-    item_names = sorted([rev.name for rev in flaskg.storage.documents(wikiname=app.cfg.interwikiname)])
-    content = render_template('misc/urls_names.txt', item_names=item_names)
+    fq_names = []
+    for rev in flaskg.storage.documents(wikiname=app.cfg.interwikiname):
+        fq_names += [fqname for fqname in rev.fqnames]
+    content = render_template('misc/urls_names.txt', fq_names=fq_names)
     return Response(content, mimetype='text/plain')