Skip to content

Commit efc5ccb

Browse files
authored
Merge pull request #1832 from RogerHaase/60-search-options
do not show USERPROFILES ns within a list of selectable namespaces #60
2 parents 769c38d + fa0cdb7 commit efc5ccb

File tree

3 files changed

+16
-23
lines changed

3 files changed

+16
-23
lines changed

src/moin/apps/admin/templates/user/index_user.html

+2-6
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,9 @@ <h2>{{ _("Reports") }}</h2>
2525
<h2>{{ _("Namespaces") }}</h2>
2626
<ul class="moin-namespaces">
2727
<li><a href="{{ url_for('frontend.global_views') }}">{{ _("all") }}</a></li>
28-
{% for namespace, root in theme_supp.get_namespaces()|sort -%}
28+
{% for namespace, root in theme_supp.get_namespaces() -%}
2929
<li>
30-
{% if namespace == NAMESPACE_USERPROFILES %}
31-
{{ namespace }}
32-
{% else %}
33-
<a href="{{ url_for('frontend.show_item', item_name=root) }}">{{ namespace }}</a>
34-
{% endif %}
30+
<a href="{{ url_for('frontend.show_item', item_name=root) }}">{{ namespace }}</a>
3531
</li>
3632
{%- endfor %}
3733
</ul>

src/moin/templates/index.html

+3-7
Original file line numberDiff line numberDiff line change
@@ -160,15 +160,11 @@ <h1>{{ title }}</h1>
160160
<p> {{ _("Click home icon to view namespace home page or click name to view namespace index.") }} </p>
161161
<ul class="moin-namespaces">
162162
<li><i class="fa fa-home"></i> <a href="{{ url_for('frontend.index', item_name='all') }}">{{ _("all") }}</a></li>
163-
{% for namespace, root in theme_supp.get_namespaces()|sort -%}
163+
{% for namespace, root in theme_supp.get_namespaces() -%}
164164
{% set index = '%s/%s' % ('+index', root.namespace) %}
165165
<li>
166-
{% if namespace == NAMESPACE_USERPROFILES %}
167-
<i class="fa fa-home"></i> {{ namespace }}
168-
{% else %}
169-
<a href="{{ url_for('frontend.show_item', item_name=root) }}"><i class="fa fa-home"></i></a>
170-
<a href="{{ url_for('frontend.show_item', item_name=index) }}">{{ namespace }}</a>
171-
{% endif %}
166+
<a href="{{ url_for('frontend.show_item', item_name=root) }}"><i class="fa fa-home"></i></a>
167+
<a href="{{ url_for('frontend.show_item', item_name=index) }}">{{ namespace }}</a>
172168
</li>
173169
{%- endfor %}
174170
</ul>

src/moin/themes/__init__.py

+11-10
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
from moin.constants.keys import USERID, ADDRESS, HOSTNAME, REVID, ITEMID, NAME_EXACT, ASSIGNED_TO, NAME, NAMESPACE
2828
from moin.constants.contenttypes import CONTENTTYPES_MAP, CONTENTTYPE_MARKUP, CONTENTTYPE_TEXT, CONTENTTYPE_MOIN_19
2929
from moin.constants.misc import VALID_ITEMLINK_VIEWS, FLASH_REPEAT
30-
from moin.constants.namespaces import NAMESPACE_DEFAULT, NAMESPACE_USERS, NAMESPACE_ALL
30+
from moin.constants.namespaces import NAMESPACE_DEFAULT, NAMESPACE_USERS, NAMESPACE_USERPROFILES, NAMESPACE_ALL
3131
from moin.constants.rights import SUPERUSER
3232
from moin.search import SearchForm
3333
from moin.utils.interwiki import (
@@ -524,20 +524,21 @@ def login_url(self):
524524
url = url or url_for("frontend.login")
525525
return url
526526

527-
def get_namespaces(self, ns=None):
527+
def get_namespaces(self):
528528
"""
529-
Return the list of tuples (composite name, namespace) referring to namespaces other
530-
than the current namespace.
529+
Return a sorted list of tuples (namespace name, fq name of ns home item).
530+
531+
The special userprofiles NS is omitted because it can never be selected
532+
by a wiki user.
531533
"""
532-
if ns is not None and ns.value == "~":
533-
ns = ""
534534
namespace_root_mapping = []
535535
for namespace, _unused in app.cfg.namespace_mapping:
536+
if namespace == NAMESPACE_USERPROFILES:
537+
continue
536538
namespace = namespace.rstrip("/")
537-
if ns is None or namespace != ns:
538-
fq_namespace = CompositeName(namespace, NAME_EXACT, "")
539-
namespace_root_mapping.append((namespace or "~", fq_namespace.get_root_fqname()))
540-
return namespace_root_mapping
539+
fq_namespace = CompositeName(namespace, NAME_EXACT, "")
540+
namespace_root_mapping.append((namespace or "~", fq_namespace.get_root_fqname()))
541+
return sorted(namespace_root_mapping)
541542

542543
def item_exists(self, itemname):
543544
"""

0 commit comments

Comments
 (0)