changeset 2254:1ba1a9c6c3b2

Merged thomaswaldmann/moin-2.0 into default
author Ashutosh Singla <ashu1461@gmail.com>
date Mon, 02 Sep 2013 17:46:59 +0530
parents 46b74c363c6f (current diff) 56ca9d2dcfc9 (diff)
children 98be82eb3db8
files MoinMoin/apps/frontend/views.py MoinMoin/config/default.py wikiconfig.py
diffstat 8 files changed, 89 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/MoinMoin/apps/frontend/_tests/test_frontend.py	Mon Sep 02 17:41:54 2013 +0530
+++ b/MoinMoin/apps/frontend/_tests/test_frontend.py	Mon Sep 02 17:46:59 2013 +0530
@@ -119,6 +119,12 @@
     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'))
+
     def test_backrefs(self):
         self._test_view('frontend.backrefs', status='200 OK', viewopts=dict(item_name='DoesntExist'))
 
--- a/MoinMoin/apps/frontend/views.py	Mon Sep 02 17:41:54 2013 +0530
+++ b/MoinMoin/apps/frontend/views.py	Mon Sep 02 17:46:59 2013 +0530
@@ -103,6 +103,8 @@
 Disallow: /+similar_names/
 Disallow: /+quicklink/
 Disallow: /+subscribe/
+Disallow: /+refs/
+Disallow: /+forwardrefs/
 Disallow: /+backrefs/
 Disallow: /+wanteds/
 Disallow: /+orphans/
@@ -862,7 +864,7 @@
     """
     Returns the list of all items the current user has contributed to.
 
-    :returns: a page with all the items which link or transclude item_name
+    :returns: a page with all the items the current user has contributed to
     """
     my_changes = _mychanges(flaskg.user.itemid)
     return render_template('link_list_no_item_panel.html',
@@ -887,6 +889,60 @@
     return fq_names
 
 
+@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):
+    """
+    Returns the list of all 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 the items linked from this item
+    """
+    refs = _forwardrefs(item_name)
+    return render_template('link_list_item_panel.html',
+                           item_name=item_name,
+                           headline=_(u"Items that are referred by '%(item_name)s'", item_name=item_name),
+                           item_names=refs
+    )
+
+
+def _forwardrefs(item_name):
+    """
+    Returns a list with all names of items that get referenced from item_name
+
+    :param item_name: the name of the current item
+    :type item_name: unicode
+    :returns: the list of all items which are referenced from this item
+    """
+    q = {WIKINAME: app.cfg.interwikiname,
+         NAME_EXACT: item_name,
+        }
+    rev = flaskg.storage.document(**q)
+    if rev is None:
+        refs = []
+    else:
+        refs = rev.meta.get(ITEMLINKS, []) + rev.meta.get(ITEMTRANSCLUSIONS, [])
+    return refs
+
+
 @frontend.route('/+backrefs/<itemname:item_name>')
 def backrefs(item_name):
     """
--- a/MoinMoin/config/default.py	Mon Sep 02 17:41:54 2013 +0530
+++ b/MoinMoin/config/default.py	Mon Sep 02 17:46:59 2013 +0530
@@ -408,7 +408,7 @@
             ('frontend.rename_item', L_('Rename'), L_('Rename this item'), True, ),
             ('frontend.delete_item', L_('Delete'), L_('Delete this item'), True, ),
             ('frontend.destroy_item', L_('Destroy'), L_('Completely destroy this item'), True, ),
-            ('frontend.backrefs', L_('Referrers'), L_('What refers here?'), False, ),
+            ('frontend.refs', L_('References'), L_('Show incoming and outgoing references'), False, ),
             ('frontend.sitemap', L_('Site Map'), L_('Local Site Map of this item'), True, ),
             ('frontend.similar_names', L_('Similar'), L_('Items with similar names'), False, ),
         ], 'list of edit bar entries (list of tuples (endpoint, label))'),
--- a/MoinMoin/templates/base.html	Mon Sep 02 17:41:54 2013 +0530
+++ b/MoinMoin/templates/base.html	Mon Sep 02 17:46:59 2013 +0530
@@ -43,9 +43,13 @@
     {% block head_links %}
 
     {% block bootstrap_stylesheet %}
-    <link rel="stylesheet" href="{{ url_for('serve.files', name='bootstrap', filename='bootstrap/css/bootstrap.css') }}" />
+    <link rel="stylesheet" href="{{ url_for('serve.files', name='bootstrap', filename='css/bootstrap.css') }}" />
     {% endblock %}
 
+    {% block icons_stylesheet %}
+    <link rel="stylesheet" href="{{ url_for('serve.files', name='font_awesome', filename='css/font-awesome.css') }}" />
+    {% endblock %}
+    
     <link rel="shortcut icon" href="{{ url_for('static', filename='logos/favicon.ico') }}" />
 
     {% block theme_stylesheets %}
@@ -76,6 +80,7 @@
         <script src="{{ url_for('serve.files', name='svgweb', filename='svg.js') }}"></script>
     <![endif]-->
     <script src="{{ url_for('serve.files', name='jquery', filename='jquery.min.js') }}"></script>
+    <script src="{{ url_for('serve.files', name='bootstrap', filename='js/bootstrap.min.js') }}"></script>
     <script src="{{ url_for('frontend.template', filename='common.js') }}"></script>
     {{ scripts }}
     <!--[if lt IE 9]>
--- a/MoinMoin/templates/itemviews.html	Mon Sep 02 17:41:54 2013 +0530
+++ b/MoinMoin/templates/itemviews.html	Mon Sep 02 17:46:59 2013 +0530
@@ -5,7 +5,7 @@
             {%- if endpoint in [
                 'frontend.show_item', 'frontend.index', 'frontend.highlight_item',
                 'frontend.show_item_meta', 'frontend.download_item',
-                'frontend.history', 'frontend.backrefs', 'frontend.sitemap',
+                'frontend.history', 'frontend.refs', 'frontend.sitemap',
                 'frontend.similar_names', 'frontend.copy_item',
             ] %}
                 <li>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/MoinMoin/templates/refs.html	Mon Sep 02 17:46:59 2013 +0530
@@ -0,0 +1,15 @@
+{% 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 %}
--- a/setup.py	Mon Sep 02 17:41:54 2013 +0530
+++ b/setup.py	Mon Sep 02 17:46:59 2013 +0530
@@ -106,7 +106,8 @@
         'pdfminer',  # pdf -> text/plain conversion
         'passlib>=1.6.0',  # strong password hashing (1.6 needed for consteq)
         'XStatic>=0.0.2',  # support for static file pypi packages
-        'XStatic-Bootstrap>=2.3.2.1',
+        'XStatic-Bootstrap>=3.0.0.1',
+        'XStatic-Font-Awesome>=3.2.1.1',
         'XStatic-CKEditor>=3.6.1.2',
         'XStatic-jQuery>=1.8.2',
         'XStatic-jQuery-File-Upload>=4.4.2',
--- a/wikiconfig.py	Mon Sep 02 17:41:54 2013 +0530
+++ b/wikiconfig.py	Mon Sep 02 17:46:59 2013 +0530
@@ -65,6 +65,7 @@
         'jquery', 'jquery_file_upload',
         'json_js',
         'bootstrap',
+        'font_awesome',
         'ckeditor',
         'svgweb',
         'svgedit_moin', 'twikidraw_moin', 'anywikidraw',