Commits

Thomas Waldmann committed be0a90c

new +refs view that combines forwardrefs and backrefs

  • Participants
  • Parent commits 9d4dad9

Comments (0)

Files changed (3)

File MoinMoin/apps/frontend/_tests/test_frontend.py

     def test_index(self):
         self._test_view('frontend.index', status='200 OK', viewopts=dict(item_name='DoesntExist'))
 
+    def test_refs(self):
+        self._test_view('frontend.refs', status='200 OK', viewopts=dict(item_name='DoesntExist'))
+
     def test_forwardrefs(self):
         self._test_view('frontend.forwardrefs', status='200 OK', viewopts=dict(item_name='DoesntExist'))
 

File MoinMoin/apps/frontend/views.py

 Disallow: /+similar_names/
 Disallow: /+quicklink/
 Disallow: /+subscribe/
+Disallow: /+refs/
 Disallow: /+forwardrefs/
 Disallow: /+backrefs/
 Disallow: /+wanteds/
     return [rev.name for rev in revs]
 
 
+@frontend.route('/+refs/<itemname:item_name>')
+def refs(item_name):
+    """
+    Returns the list of all incoming/outgoing links or transclusions of item item_name
+
+    :param item_name: the name of the current item
+    :type item_name: unicode
+    :returns: a page with all incoming/outgoing item links of this item
+    """
+    refs = _forwardrefs(item_name)
+    backrefs = _backrefs(item_name)
+    return render_template('refs.html',
+                           item_name=item_name,
+                           refs=refs,
+                           backrefs=backrefs
+    )
+
+
 @frontend.route('/+forwardrefs/<itemname:item_name>')
 def forwardrefs(item_name):
     """

File MoinMoin/templates/refs.html

+{% extends theme("show.html") %}
+{% block content %}
+<h1>{{ _('Outgoing Item References') }}</h1>
+<ul>
+    {% for item_name in refs|sort %}
+    <li><a href="{{ url_for('frontend.show_item', item_name=item_name) }}">{{ item_name }}</a></li>
+    {% endfor %}
+</ul>
+<h1>{{ _('Incoming Item References') }}</h1>
+<ul>
+    {% for item_name in backrefs|sort %}
+    <li><a href="{{ url_for('frontend.show_item', item_name=item_name) }}">{{ item_name }}</a></li>
+    {% endfor %}
+</ul>
+{% endblock %}