Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

do not show USERPROFILES ns within a list of selectable namespaces #60 #1832

Merged
merged 1 commit into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions src/moin/apps/admin/templates/user/index_user.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,9 @@ <h2>{{ _("Reports") }}</h2>
<h2>{{ _("Namespaces") }}</h2>
<ul class="moin-namespaces">
<li><a href="{{ url_for('frontend.global_views') }}">{{ _("all") }}</a></li>
{% for namespace, root in theme_supp.get_namespaces()|sort -%}
{% for namespace, root in theme_supp.get_namespaces() -%}
<li>
{% if namespace == NAMESPACE_USERPROFILES %}
{{ namespace }}
{% else %}
<a href="{{ url_for('frontend.show_item', item_name=root) }}">{{ namespace }}</a>
{% endif %}
<a href="{{ url_for('frontend.show_item', item_name=root) }}">{{ namespace }}</a>
</li>
{%- endfor %}
</ul>
Expand Down
10 changes: 3 additions & 7 deletions src/moin/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -160,15 +160,11 @@ <h1>{{ title }}</h1>
<p> {{ _("Click home icon to view namespace home page or click name to view namespace index.") }} </p>
<ul class="moin-namespaces">
<li><i class="fa fa-home"></i> <a href="{{ url_for('frontend.index', item_name='all') }}">{{ _("all") }}</a></li>
{% for namespace, root in theme_supp.get_namespaces()|sort -%}
{% for namespace, root in theme_supp.get_namespaces() -%}
{% set index = '%s/%s' % ('+index', root.namespace) %}
<li>
{% if namespace == NAMESPACE_USERPROFILES %}
<i class="fa fa-home"></i> {{ namespace }}
{% else %}
<a href="{{ url_for('frontend.show_item', item_name=root) }}"><i class="fa fa-home"></i></a>
<a href="{{ url_for('frontend.show_item', item_name=index) }}">{{ namespace }}</a>
{% endif %}
<a href="{{ url_for('frontend.show_item', item_name=root) }}"><i class="fa fa-home"></i></a>
<a href="{{ url_for('frontend.show_item', item_name=index) }}">{{ namespace }}</a>
</li>
{%- endfor %}
</ul>
Expand Down
21 changes: 11 additions & 10 deletions src/moin/themes/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from moin.constants.keys import USERID, ADDRESS, HOSTNAME, REVID, ITEMID, NAME_EXACT, ASSIGNED_TO, NAME, NAMESPACE
from moin.constants.contenttypes import CONTENTTYPES_MAP, CONTENTTYPE_MARKUP, CONTENTTYPE_TEXT, CONTENTTYPE_MOIN_19
from moin.constants.misc import VALID_ITEMLINK_VIEWS, FLASH_REPEAT
from moin.constants.namespaces import NAMESPACE_DEFAULT, NAMESPACE_USERS, NAMESPACE_ALL
from moin.constants.namespaces import NAMESPACE_DEFAULT, NAMESPACE_USERS, NAMESPACE_USERPROFILES, NAMESPACE_ALL
from moin.constants.rights import SUPERUSER
from moin.search import SearchForm
from moin.utils.interwiki import (
Expand Down Expand Up @@ -524,20 +524,21 @@ def login_url(self):
url = url or url_for("frontend.login")
return url

def get_namespaces(self, ns=None):
def get_namespaces(self):
"""
Return the list of tuples (composite name, namespace) referring to namespaces other
than the current namespace.
Return a sorted list of tuples (namespace name, fq name of ns home item).

The special userprofiles NS is omitted because it can never be selected
by a wiki user.
"""
if ns is not None and ns.value == "~":
ns = ""
namespace_root_mapping = []
for namespace, _unused in app.cfg.namespace_mapping:
if namespace == NAMESPACE_USERPROFILES:
continue
namespace = namespace.rstrip("/")
if ns is None or namespace != ns:
fq_namespace = CompositeName(namespace, NAME_EXACT, "")
namespace_root_mapping.append((namespace or "~", fq_namespace.get_root_fqname()))
return namespace_root_mapping
fq_namespace = CompositeName(namespace, NAME_EXACT, "")
namespace_root_mapping.append((namespace or "~", fq_namespace.get_root_fqname()))
return sorted(namespace_root_mapping)

def item_exists(self, itemname):
"""
Expand Down
Loading