You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by ke...@apache.org on 2021/05/21 17:34:05 UTC

[allura] branch master updated (9d1956a -> 8694800)

This is an automated email from the ASF dual-hosted git repository.

kentontaylor pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git.


    from 9d1956a  Change the exec call used by paster script cmd, to preserve the filename (helps when running coverage.py on a paster script cmd)
     new 0c5b8f5  [#8388] fix image references, make youtube embed https
     new ada8262  [#8388] consolidate markdown_syntax and markdown_syntax_dialog URLs
     new c2bc5be  [#8388] rename and comments about static vs newforge
     new 8694800  [#8388] tidy up per-tool details on ticket search_help; mark as nofollow/noindex so not duplicate content for search engines

The 4 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 .../allura/controllers/{static.py => newforge.py}  | 15 ++++++-
 Allura/allura/controllers/project.py               |  6 +--
 Allura/allura/controllers/repository.py            |  5 ---
 Allura/allura/controllers/root.py                  |  2 +-
 Allura/allura/templates/jinja_master/lib.html      | 25 ++++++-----
 Allura/allura/templates/markdown_syntax.html       |  6 ++-
 .../allura/templates/markdown_syntax_dialog.html   |  2 +
 Allura/allura/templates/widgets/markdown_edit.html |  2 +-
 Allura/allura/tests/functional/test_newforge.py    | 52 ++++++++++++++++++++++
 Allura/allura/tests/functional/test_root.py        | 15 -------
 Allura/allura/tests/functional/test_static.py      |  7 ++-
 Allura/docs/getting_started/using.rst              |  2 +-
 ForgeBlog/forgeblog/main.py                        |  6 ---
 .../forgediscussion/controllers/root.py            | 13 ++----
 ForgeDiscussion/forgediscussion/forum_main.py      |  2 +-
 .../forgediscussion/tests/functional/test_forum.py |  8 +---
 .../forgegit/tests/functional/test_controllers.py  |  4 --
 .../forgetracker/templates/tracker/bin.html        |  2 +
 .../forgetracker/templates/tracker/search.html     |  1 +
 .../templates/tracker/search_help.html             | 21 ++++-----
 .../forgetracker/tests/functional/test_root.py     |  4 --
 ForgeTracker/forgetracker/tracker_main.py          | 19 +++-----
 ForgeWiki/forgewiki/tests/functional/test_root.py  |  4 +-
 ForgeWiki/forgewiki/wiki_main.py                   | 24 ++--------
 24 files changed, 124 insertions(+), 123 deletions(-)
 rename Allura/allura/controllers/{static.py => newforge.py} (78%)
 create mode 100644 Allura/allura/tests/functional/test_newforge.py

[allura] 04/04: [#8388] tidy up per-tool details on ticket search_help; mark as nofollow/noindex so not duplicate content for search engines

Posted by ke...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kentontaylor pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git

commit 8694800c3c8ccfda6b1eb060683a110b3cb84232
Author: Dave Brondsema <db...@slashdotmedia.com>
AuthorDate: Thu May 20 11:51:24 2021 -0400

    [#8388] tidy up per-tool details on ticket search_help; mark as nofollow/noindex so not duplicate content for search engines
---
 .../forgetracker/templates/tracker/bin.html         |  2 ++
 .../forgetracker/templates/tracker/search.html      |  1 +
 .../forgetracker/templates/tracker/search_help.html | 21 ++++++++-------------
 ForgeTracker/forgetracker/tracker_main.py           |  4 +++-
 4 files changed, 14 insertions(+), 14 deletions(-)

diff --git a/ForgeTracker/forgetracker/templates/tracker/bin.html b/ForgeTracker/forgetracker/templates/tracker/bin.html
index d919ee6..b3838d1 100644
--- a/ForgeTracker/forgetracker/templates/tracker/bin.html
+++ b/ForgeTracker/forgetracker/templates/tracker/bin.html
@@ -55,6 +55,7 @@
                       show_title=True,
                       target='_blank',
                       href=tg.url(app.url + 'search_help/'),
+                      rel='nofollow',
                       extra_css='btn search_help_modal') }}
                 {% if bin.error %}<br/><span style="color:red">{{bin.error}}</span>{% endif %}
             </td>
@@ -80,6 +81,7 @@
                   show_title=True,
                   target='_blank',
                   href=tg.url(app.url + 'search_help/'),
+                  rel='nofollow',
                   extra_css='btn search_help_modal') }}
             {% if new_bin and new_bin.error %}<br/><span class="err" style="color:red">{{new_bin.error}}</span>{% endif %}
           </td>
diff --git a/ForgeTracker/forgetracker/templates/tracker/search.html b/ForgeTracker/forgetracker/templates/tracker/search.html
index 823773b..8e34d31 100644
--- a/ForgeTracker/forgetracker/templates/tracker/search.html
+++ b/ForgeTracker/forgetracker/templates/tracker/search.html
@@ -82,6 +82,7 @@
     show_title=True,
     target='_blank',
     href=tg.url(c.app.url + 'search_help/'),
+    rel='nofollow',
     extra_css='btn search_help_modal') }}
 
 </div>
diff --git a/ForgeTracker/forgetracker/templates/tracker/search_help.html b/ForgeTracker/forgetracker/templates/tracker/search_help.html
index 9b0c6a6..571de1f 100644
--- a/ForgeTracker/forgetracker/templates/tracker/search_help.html
+++ b/ForgeTracker/forgetracker/templates/tracker/search_help.html
@@ -22,8 +22,7 @@
 {% do g.register_app_css('css/tracker.css') %}
 
 {% block head %}
-  <link rel="alternate" type="application/rss+xml" title="RSS" href="feed.rss"/>
-  <link rel="alternate" type="application/atom+xml" title="Atom" href="feed.atom"/>
+  <meta name="robots" content="noindex">
 {% endblock %}
 
 {% block title %}{{c.project.name}} / {{c.app.config.options.mount_label}} / Search help{% endblock %}
@@ -49,13 +48,11 @@
     <li>Votes up/down of the ticket - votes_up/votes_down (if enabled in tool options)</li>
     <li>Votes total of the ticket - votes_total</li>
     <li>Imported legacy id - import_id</li>
-    {% if c.app.globals.custom_fields %}
+    {% if custom_fields %}
     <li>Custom fields:
         <ul>
-        {% for field in c.app.globals.custom_fields or [] %}
-            {% if field.name != '_milestone' %}
-                <li>{{field.name}}</li>
-            {% endif %}
+        {% for field in custom_fields %}
+            <li>{{field.name}}</li>
         {% endfor %}
         </ul>
     </li>
@@ -92,18 +89,16 @@
     <li>Title of the ticket - snippet_s</li>
     <li>Private ticket - private_b</li>
     <li>Discussion disabled ticket - discussion_disabled_b</li>
-    {% if c.app.globals.custom_fields %}
+    {% if custom_fields %}
     <li>Custom fields:
         <ul>
-        {% for field in c.app.globals.custom_fields or [] %}
-            {% if field.name != '_milestone' %}
-                <li>{{field.name}}</li>
-            {% endif %}
+        {% for field in custom_fields %}
+            <li>{{field.name}}</li>
         {% endfor %}
         </ul>
     </li>
     {% endif %}
     </ul>
     <p>You can use these properties by appending them to the url (only one sort allowed at a time) like this:</p>
-    <div class="codehilite"><pre>/p/yourproject/tickets/search/?q=_milestone:1.0&amp;sort=snippet_s+asc</pre></div></div>
+    <div class="codehilite"><pre>{{ h.absurl(c.app.url) }}search/?q=_milestone:1.0&amp;sort=snippet_s+asc</pre></div></div>
 {% endblock %}
diff --git a/ForgeTracker/forgetracker/tracker_main.py b/ForgeTracker/forgetracker/tracker_main.py
index 71073fa..689c47f 100644
--- a/ForgeTracker/forgetracker/tracker_main.py
+++ b/ForgeTracker/forgetracker/tracker_main.py
@@ -889,7 +889,9 @@ class RootController(BaseController, FeedController):
     @expose('jinja:forgetracker:templates/tracker/search_help.html')
     def search_help(self, **kw):
         'Static page with search help'
-        return dict()
+        return dict(
+            custom_fields=[fld for fld in (c.app.globals.custom_fields or []) if fld.name != '_milestone'],
+        )
 
     @with_trailing_slash
     @expose('jinja:forgetracker:templates/tracker/new_ticket.html')

[allura] 01/04: [#8388] fix image references, make youtube embed https

Posted by ke...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kentontaylor pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git

commit 0c5b8f5cb9b36c566c56cda733b90e90319a3d50
Author: Dave Brondsema <db...@slashdotmedia.com>
AuthorDate: Wed May 19 16:36:09 2021 -0400

    [#8388] fix image references, make youtube embed https
---
 Allura/allura/templates/jinja_master/lib.html | 22 ++++++++++++----------
 1 file changed, 12 insertions(+), 10 deletions(-)

diff --git a/Allura/allura/templates/jinja_master/lib.html b/Allura/allura/templates/jinja_master/lib.html
index ee70c53..f879def 100644
--- a/Allura/allura/templates/jinja_master/lib.html
+++ b/Allura/allura/templates/jinja_master/lib.html
@@ -445,7 +445,7 @@ paragraph.""")}}
 Markdown doing anything to it, just indent every line by at least 4
 spaces (or 1 tab).  As an alternative to indenting, you can make a code block use 3 or
 more tildes (~) or backticks (`) on a line before and after the text
-(<a href="https://pythonhosted.org/Markdown/extensions/fenced_code_blocks.html">syntax details</a>). See examples in the
+(<a href="https://python-markdown.github.io/extensions/fenced_code_blocks/">syntax details</a>). See examples in the
 <a href="#md_ex_code">Code Highlighting section</a>.
 </p>
 <div class="codehilite"><pre>
@@ -620,41 +620,43 @@ you will get a header
 <h2 id="md_ex_img{{id}}">Images</h2>
 <p>To include an image, just put a "!" in front of a text link:</p>
 <div class="codehilite"><pre>
-![alternate text](https://{{config.domain}}/images/icon_linux.gif)
+![alternate text]({{g.forge_static('images/up.png')}})
 </pre></div>
 
 <p>Output:</p>
-{{g.markdown.convert('''![alternate text](http://'''+config.domain+'''/images/icon_linux.gif)''')}}
+{{g.markdown.convert('''![alternate text]('''+g.forge_static('images/up.png') + ''')''')}}
 
 <p>The "alternate text" will show up if the browser can't load the
 image.</p>
 <p>You can also use a title if you want, like this:</p>
 <div class="codehilite"><pre>
-![tiny arrow](https://{{config.domain}}/images/icon_linux.gif "tiny arrow")
+![small up arrow]({{g.forge_static('images/up.png')}} "small up arrow")
 </pre></div>
 
 <p>Output:</p>
-{{g.markdown.convert('''![tiny arrow](http://'''+config.domain+'''/images/icon_linux.gif "tiny arrow")''')}}
+{{g.markdown.convert('''![small up arrow]('''+g.forge_static('images/up.png')+''' "small up arrow")''')}}
 
 <p>To reference an attached image, just use the img macro.  You can add more attributes:</p>
 <div class="codehilite"><pre>
 [[img src=attached-image.jpg alt=foobar]]
 </pre></div>
 
+{#  no output, since this standalone example page doesn't have attachments
 <p>Output:</p>
 {{g.markdown.convert('''[[img src=attached-image.jpg alt=foobar]]''')}}
+ #}
 </div>
 
 
 <div class="markdown_syntax_section hidden_in_modal md_ex_video{{id}}">
 <h2 id="md_ex_video{{id}}">Videos</h2>
-<p>To embed a YouTube video, use the `embed` macro (only YouTube is supported at this time):</p>
+<p>To embed a YouTube video, use the <code>embed</code> macro (only YouTube is supported at this time):</p>
 <div class="codehilite"><pre>
-[[embed url=http://www.youtube.com/watch?v=6YbBmqUnoQM]]
+[[embed url=https://www.youtube.com/watch?v=6YbBmqUnoQM]]
 </pre></div>
 
 <p>Output:</p>
-{{g.markdown.convert('''[[embed url=http://www.youtube.com/watch?v=6YbBmqUnoQM]]''')}}
+{{g.markdown.convert('''[[embed url=https://www.youtube.com/watch?v=6YbBmqUnoQM]]''')}}
 </div>
 
 
@@ -739,7 +741,7 @@ allowed, permitting basic styling and layout: &lt;div markdown style="float:left
 
 <div class="markdown_syntax_section hidden_in_modal md_ex_code{{id}}">
 <h2 id="md_ex_code{{id}}">Code Highlighting</h2>
-<p>The code highlighting syntax uses <a href="http://pythonhosted.org/Markdown/extensions/code_hilite.html">CodeHilite</a> and is colored with <a href="http://pygments.org/">Pygments</a>. It follows the same syntax as regular Markdown <a href="#md_ex_pre">code blocks</a>, with ways to tell the highlighter what language to use for the code block.</p>
+<p>The code highlighting syntax uses <a href="https://python-markdown.github.io/extensions/code_hilite/">CodeHilite</a> and is colored with <a href="https://pygments.org/">Pygments</a>. It follows the same syntax as regular Markdown <a href="#md_ex_pre">code blocks</a>, with ways to tell the highlighter what language to use for the code block.</p>
 
 <p>The language will be detected automatically, if possible.  Or you can specify it on the first line with 3 colons and the language name.</p>
 
@@ -788,7 +790,7 @@ then that shebang line will be omitted from output.
 <a href="#">My code</a>
 ```''')}}
 
-<p>Many languages are supported.  See all the "short names" listed in the <a href="http://pygments.org/docs/lexers/">Pygments docs</a>.</p>
+<p>Many languages are supported.  See all the "short names" listed in the <a href="https://pygments.org/docs/lexers/">Pygments docs</a>.</p>
 </div>
 
 

[allura] 02/04: [#8388] consolidate markdown_syntax and markdown_syntax_dialog URLs

Posted by ke...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kentontaylor pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git

commit ada826293489bc5fe68398439e1626bb666bfe15
Author: Dave Brondsema <db...@slashdotmedia.com>
AuthorDate: Wed May 19 18:04:14 2021 -0400

    [#8388] consolidate markdown_syntax and markdown_syntax_dialog URLs
---
 Allura/allura/controllers/repository.py            |  5 ---
 Allura/allura/controllers/static.py                | 12 ++++-
 Allura/allura/templates/jinja_master/lib.html      |  3 +-
 Allura/allura/templates/markdown_syntax.html       |  6 ++-
 .../allura/templates/markdown_syntax_dialog.html   |  2 +
 Allura/allura/templates/widgets/markdown_edit.html |  2 +-
 Allura/allura/tests/functional/test_newforge.py    | 52 ++++++++++++++++++++++
 Allura/allura/tests/functional/test_root.py        | 15 -------
 Allura/docs/getting_started/using.rst              |  2 +-
 ForgeBlog/forgeblog/main.py                        |  6 ---
 .../forgediscussion/controllers/root.py            | 13 ++----
 ForgeDiscussion/forgediscussion/forum_main.py      |  2 +-
 .../forgediscussion/tests/functional/test_forum.py |  8 +---
 .../forgegit/tests/functional/test_controllers.py  |  4 --
 .../forgetracker/tests/functional/test_root.py     |  4 --
 ForgeTracker/forgetracker/tracker_main.py          | 15 ++-----
 ForgeWiki/forgewiki/tests/functional/test_root.py  |  4 +-
 ForgeWiki/forgewiki/wiki_main.py                   | 24 ++--------
 18 files changed, 87 insertions(+), 92 deletions(-)

diff --git a/Allura/allura/controllers/repository.py b/Allura/allura/controllers/repository.py
index 2b34847..54b762e 100644
--- a/Allura/allura/controllers/repository.py
+++ b/Allura/allura/controllers/repository.py
@@ -86,11 +86,6 @@ class RepoRootController(BaseController, FeedController):
     def _check_security(self):
         require_access(c.app, 'read')
 
-    @expose('jinja:allura:templates/markdown_syntax_dialog.html')
-    def markdown_syntax_dialog(self, **kw):
-        """Static page explaining markdown."""
-        return dict()
-
     @with_trailing_slash
     @expose()
     def index(self, offset=0, branch=None, **kw):
diff --git a/Allura/allura/controllers/static.py b/Allura/allura/controllers/static.py
index 720ef77..fa0148b 100644
--- a/Allura/allura/controllers/static.py
+++ b/Allura/allura/controllers/static.py
@@ -21,7 +21,7 @@ from io import BytesIO
 
 import six
 from tg import expose
-from tg.decorators import without_trailing_slash
+from tg.decorators import without_trailing_slash, with_trailing_slash
 from webob import exc
 
 from tg import app_globals as g
@@ -57,3 +57,13 @@ class NewForgeController(object):
         css, md5 = g.tool_icon_css
         return utils.serve_file(
             BytesIO(six.ensure_binary(css)), 'tool_icon_css', 'text/css', etag=md5)
+
+    @expose('jinja:allura:templates/markdown_syntax.html')
+    def markdown_syntax(self, **kw):
+        'Static page explaining markdown.'
+        return dict()
+
+    @expose('jinja:allura:templates/markdown_syntax_dialog.html')
+    def markdown_syntax_dialog(self, **kw):
+        'Static dialog page about how to use markdown.'
+        return dict()
diff --git a/Allura/allura/templates/jinja_master/lib.html b/Allura/allura/templates/jinja_master/lib.html
index f879def..d69d8a6 100644
--- a/Allura/allura/templates/jinja_master/lib.html
+++ b/Allura/allura/templates/jinja_master/lib.html
@@ -230,10 +230,9 @@
 
 {% macro markdown_syntax(id='') %}
 <a class="markdown_syntax_toc_crumb" href="#md_ex_toc{{id}}">Back</a>
-<h1>Markdown Syntax Guide</h1>
 
 <div class="markdown_syntax_section md_ex_toc{{id}}">
-<p>{{config.site_name}} uses markdown syntax everywhere to allow you to create rich<br>text markup, and extends markdown in several ways to allow for quick linking<br>to other artifacts in your project. </p>
+<p>{{config.site_name}} uses markdown syntax everywhere to allow you to create rich text markup, and extends markdown in several ways to allow for quick linking to other artifacts in your project. </p>
 <p>Markdown was created to be easy to read, easy to write, and still readable in plain text format.</p>
 
 <ul class="markdown_syntax_toc">
diff --git a/Allura/allura/templates/markdown_syntax.html b/Allura/allura/templates/markdown_syntax.html
index ffba5aa..d974b01 100644
--- a/Allura/allura/templates/markdown_syntax.html
+++ b/Allura/allura/templates/markdown_syntax.html
@@ -18,9 +18,11 @@
 -#}
 {% extends g.theme.master %}
 
-{% block title %}{{c.project.name}} / {{c.app.config.options.mount_label}} / Markdown Syntax{% endblock %}
+{% block title %}{{config['site_name']}} Markdown Syntax{% endblock %}
 
-{% block header %}Markdown Syntax{% endblock %}
+{% block header %}Markdown Syntax Guide{% endblock %}
+
+{% set hide_left_bar = True %}
 
 {% block content %}
 {{lib.markdown_syntax()}}
diff --git a/Allura/allura/templates/markdown_syntax_dialog.html b/Allura/allura/templates/markdown_syntax_dialog.html
index 9675a53..7c49e76 100644
--- a/Allura/allura/templates/markdown_syntax_dialog.html
+++ b/Allura/allura/templates/markdown_syntax_dialog.html
@@ -18,4 +18,6 @@
 -#}
 <!DOCTYPE html>
 {% import 'allura:templates/jinja_master/lib.html' as lib with context %}
+<h1>Markdown Syntax Guide</h1>
+<hr>
 {{lib.markdown_syntax()}}
diff --git a/Allura/allura/templates/widgets/markdown_edit.html b/Allura/allura/templates/widgets/markdown_edit.html
index 1af3df9..48b1806 100644
--- a/Allura/allura/templates/widgets/markdown_edit.html
+++ b/Allura/allura/templates/widgets/markdown_edit.html
@@ -21,7 +21,7 @@
   <textarea id="{{id or rendered_name}}" name="{{rendered_name}}" class="{{widget.css_class}}" {{widget.j2_attrs(attrs)}}>{{value or ''}}</textarea>
   <div class="modal lightmodal markdown_help" style="display:none">
     {{ g.icons['close'].render(extra_css='close') }}
-    <div class="markdown_help_contents" data-url="{{c.app.url}}markdown_syntax_dialog"></div>
+    <div class="markdown_help_contents" data-url="/nf/markdown_syntax_dialog"></div>
   </div>
   <input type="hidden" class="markdown_project" value="{{c.project.shortname}}">
   <input type="hidden" class="markdown_neighborhood" value="{{c.project.neighborhood._id}}">
diff --git a/Allura/allura/tests/functional/test_newforge.py b/Allura/allura/tests/functional/test_newforge.py
new file mode 100644
index 0000000..cb4a20f
--- /dev/null
+++ b/Allura/allura/tests/functional/test_newforge.py
@@ -0,0 +1,52 @@
+#       Licensed to the Apache Software Foundation (ASF) under one
+#       or more contributor license agreements.  See the NOTICE file
+#       distributed with this work for additional information
+#       regarding copyright ownership.  The ASF licenses this file
+#       to you under the Apache License, Version 2.0 (the
+#       "License"); you may not use this file except in compliance
+#       with the License.  You may obtain a copy of the License at
+#
+#         http://www.apache.org/licenses/LICENSE-2.0
+#
+#       Unless required by applicable law or agreed to in writing,
+#       software distributed under the License is distributed on an
+#       "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+#       KIND, either express or implied.  See the License for the
+#       specific language governing permissions and limitations
+#       under the License.
+
+from __future__ import unicode_literals
+from __future__ import absolute_import
+
+from six.moves.urllib.parse import quote
+
+from allura.tests import TestController
+from allura.tests import decorators as td
+from allura import model as M
+
+
+class TestNewForgeController(TestController):
+
+    @td.with_wiki
+    def test_markdown_to_html(self):
+        n = M.Neighborhood.query.get(name='Projects')
+        r = self.app.get(
+            '/nf/markdown_to_html?markdown=*aaa*bb[wiki:Home]&project=test&app=bugs&neighborhood=%s' % n._id, validate_chunk=True)
+        assert '<p><em>aaa</em>bb<a class="alink" href="/p/test/wiki/Home/">[wiki:Home]</a></p>' in r, r
+
+        # this happens to trigger an error
+        bad_markdown = '<foo {bar}>'
+        r = self.app.get('/nf/markdown_to_html?markdown=%s&project=test&app=bugs&neighborhood=%s' %
+                         (quote(bad_markdown), n._id))
+        r.mustcontain('The markdown supplied could not be parsed correctly.')
+        r.mustcontain('<pre>&lt;foo {bar}&gt;</pre>')
+
+    def test_markdown_syntax(self):
+        r = self.app.get('/nf/markdown_syntax')
+        r.mustcontain('Markdown Syntax')
+        r.mustcontain('href="http://someurl"')
+
+    def test_markdown_syntax_dialog(self):
+        r = self.app.get('/nf/markdown_syntax_dialog')
+        r.mustcontain('<h1>Markdown Syntax Guide</h1>')
+        r.mustcontain('href="http://someurl"')
diff --git a/Allura/allura/tests/functional/test_root.py b/Allura/allura/tests/functional/test_root.py
index beb49de..3caf217 100644
--- a/Allura/allura/tests/functional/test_root.py
+++ b/Allura/allura/tests/functional/test_root.py
@@ -33,7 +33,6 @@ from __future__ import absolute_import
 import os
 
 import six
-from six.moves.urllib.parse import quote
 
 from tg import tmpl_context as c
 from alluratest.tools import assert_equal, assert_in
@@ -174,20 +173,6 @@ class TestRootController(TestController):
         assert len(
             response.html.findAll('a', {'href': '/adobe/adobe-2/'})) == 1
 
-    @td.with_wiki
-    def test_markdown_to_html(self):
-        n = M.Neighborhood.query.get(name='Projects')
-        r = self.app.get(
-            '/nf/markdown_to_html?markdown=*aaa*bb[wiki:Home]&project=test&app=bugs&neighborhood=%s' % n._id, validate_chunk=True)
-        assert '<p><em>aaa</em>bb<a class="alink" href="/p/test/wiki/Home/">[wiki:Home]</a></p>' in r, r
-
-        # this happens to trigger an error
-        bad_markdown = '<foo {bar}>'
-        r = self.app.get('/nf/markdown_to_html?markdown=%s&project=test&app=bugs&neighborhood=%s' %
-                         (quote(bad_markdown), n._id))
-        r.mustcontain('The markdown supplied could not be parsed correctly.')
-        r.mustcontain('<pre>&lt;foo {bar}&gt;</pre>')
-
     def test_slash_redirect(self):
         self.app.get('/p', status=301)
         self.app.get('/p/', status=302)
diff --git a/Allura/docs/getting_started/using.rst b/Allura/docs/getting_started/using.rst
index b8fb6f3..c77c01c 100644
--- a/Allura/docs/getting_started/using.rst
+++ b/Allura/docs/getting_started/using.rst
@@ -160,4 +160,4 @@ Using markdown syntax
 
 Everything in Allura uses Markdown formatting, with several customizations and macros
 specifically for Allura.  There are "Formatting Help" buttons throughout Allura for
-easy reference to the Markdown syntax.  One such page is https://forge-allura.apache.org/p/allura/wiki/markdown_syntax/
+easy reference to the Markdown syntax.  One such page is https://forge-allura.apache.org/nf/markdown_syntax
diff --git a/ForgeBlog/forgeblog/main.py b/ForgeBlog/forgeblog/main.py
index 2d86e2f..ced04ba 100644
--- a/ForgeBlog/forgeblog/main.py
+++ b/ForgeBlog/forgeblog/main.py
@@ -324,12 +324,6 @@ class RootController(BaseController, FeedController):
         notification_tasks.send_usermentions_notification.post(post.index_id(), kw['text'])
         redirect(h.urlquote(h.really_unicode(post.url())))
 
-    @with_trailing_slash
-    @expose('jinja:allura:templates/markdown_syntax_dialog.html')
-    def markdown_syntax_dialog(self, **kw):
-        'Static dialog page about how to use markdown.'
-        return dict()
-
     @expose()
     def _lookup(self, year=None, month=None, name=None, *rest):
         if year is None or month is None or name is None:
diff --git a/ForgeDiscussion/forgediscussion/controllers/root.py b/ForgeDiscussion/forgediscussion/controllers/root.py
index b636f7c..29266fc 100644
--- a/ForgeDiscussion/forgediscussion/controllers/root.py
+++ b/ForgeDiscussion/forgediscussion/controllers/root.py
@@ -39,7 +39,7 @@ from allura.lib.security import require_access, has_access, require_authenticate
 from allura.lib.search import search_app
 from allura.lib import helpers as h
 from allura.lib import validators as v
-from allura.lib.utils import AntiSpam
+from allura.lib.utils import AntiSpam, permanent_redirect
 from allura.lib.decorators import require_post, memorable_forget
 from allura.controllers import BaseController, DispatchIndex
 from allura.controllers.rest import AppRestControllerMixin
@@ -175,16 +175,9 @@ class RootController(BaseController, DispatchIndex, FeedController):
         d['search_comments_disable'] = True
         return d
 
-    @expose('jinja:allura:templates/markdown_syntax.html')
+    @expose()
     def markdown_syntax(self, **kw):
-        'Static page explaining markdown.'
-        return dict()
-
-    @with_trailing_slash
-    @expose('jinja:allura:templates/markdown_syntax_dialog.html')
-    def markdown_syntax_dialog(self, **kw):
-        'Static dialog page about how to use markdown.'
-        return dict()
+        permanent_redirect('/nf/markdown_syntax')
 
     @expose()
     def _lookup(self, id=None, *remainder):
diff --git a/ForgeDiscussion/forgediscussion/forum_main.py b/ForgeDiscussion/forgediscussion/forum_main.py
index d48919f..0bf6043 100644
--- a/ForgeDiscussion/forgediscussion/forum_main.py
+++ b/ForgeDiscussion/forgediscussion/forum_main.py
@@ -197,7 +197,7 @@ class ForgeDiscussionApp(Application):
                 l = l + forum_links
             l.append(SitemapEntry('Help'))
             l.append(
-                SitemapEntry('Formatting Help', c.app.url + 'markdown_syntax'))
+                SitemapEntry('Formatting Help', '/nf/markdown_syntax', extra_html_attrs={'target': '_blank'}))
             return l
         except Exception:  # pragma no cover
             log.exception('sidebar_menu')
diff --git a/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py b/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
index 3788a7f..2fe9ccf 100644
--- a/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
+++ b/ForgeDiscussion/forgediscussion/tests/functional/test_forum.py
@@ -379,10 +379,6 @@ class TestForum(TestController):
         self.app.get('/discussion/search')
         self.app.get('/discussion/search', params=dict(q='foo'))
 
-    def test_render_markdown_syntax(self):
-        r = self.app.get('/discussion/markdown_syntax')
-        assert 'Markdown Syntax' in r
-
     def test_forum_index(self):
         self.app.get('/discussion/testforum/')
         self.app.get('/discussion/testforum/childforum/')
@@ -927,7 +923,7 @@ class TestForum(TestController):
         assert_in("/p/test/discussion/create_topic/", sidebar_links)
         assert_in("/p/test/discussion/new_forum", sidebar_links)
         assert_in('<h3 class="">Help</h3>', sidebar_menu)
-        assert_in("/p/test/discussion/markdown_syntax", sidebar_links)
+        assert_in("/nf/markdown_syntax", sidebar_links)
         assert_not_in("flag_as_spam", sidebar_links)
         r = self.app.get('/discussion/create_topic/')
         f = r.html.find('form', {'action': '/p/test/discussion/save_new_topic'})
@@ -951,7 +947,7 @@ class TestForum(TestController):
         assert_in("/p/test/discussion/create_topic/", sidebar_links)
         assert_in("/p/test/discussion/new_forum", sidebar_links)
         assert_in('<h3 class="">Help</h3>', sidebar_menu)
-        assert_in("/p/test/discussion/markdown_syntax", sidebar_links)
+        assert_in("/nf/markdown_syntax", sidebar_links)
         assert_not_in("flag_as_spam", sidebar_menu)
         r = self.app.get('/discussion/create_topic/')
         f = r.html.find('form', {'action': '/p/test/discussion/save_new_topic'})
diff --git a/ForgeGit/forgegit/tests/functional/test_controllers.py b/ForgeGit/forgegit/tests/functional/test_controllers.py
index d8680c2..3a5a474 100644
--- a/ForgeGit/forgegit/tests/functional/test_controllers.py
+++ b/ForgeGit/forgegit/tests/functional/test_controllers.py
@@ -547,10 +547,6 @@ class TestRootController(_TestCase):
         assert_equal(app_config.options['external_checkout_url'], 'http://foo.bar/baz')
         assert_equal(app_config.options['merge_disabled'], True)
 
-    def test_markdown_syntax_dialog(self):
-        r = self.app.get('/p/test/src-git/markdown_syntax_dialog')
-        assert_in('<h1>Markdown Syntax Guide</h1>', r)
-
     def test_refresh(self):
         r = self.app.get('/p/test/src-git/refresh')
         assert_in('refresh queued', r)
diff --git a/ForgeTracker/forgetracker/tests/functional/test_root.py b/ForgeTracker/forgetracker/tests/functional/test_root.py
index d403d59..d4b325a 100644
--- a/ForgeTracker/forgetracker/tests/functional/test_root.py
+++ b/ForgeTracker/forgetracker/tests/functional/test_root.py
@@ -798,10 +798,6 @@ class TestFunctionalController(TrackerTestController):
         create_button = r.html.find('a', attrs={'href': '/p/test/bugs/new/'})
         assert_equal(create_button['class'], ['icon', 'sidebar-disabled'])
 
-    def test_render_markdown_syntax(self):
-        r = self.app.get('/bugs/markdown_syntax')
-        assert_true('Markdown Syntax' in r)
-
     @patch.dict('allura.lib.app_globals.config', markdown_cache_threshold='0')
     def test_cached_convert(self):
         from allura.model.session import artifact_orm_session
diff --git a/ForgeTracker/forgetracker/tracker_main.py b/ForgeTracker/forgetracker/tracker_main.py
index 0604cd5..71073fa 100644
--- a/ForgeTracker/forgetracker/tracker_main.py
+++ b/ForgeTracker/forgetracker/tracker_main.py
@@ -20,14 +20,12 @@ from __future__ import absolute_import
 import logging
 import re
 from datetime import datetime, timedelta
-from functools import partial
 from six.moves.urllib.parse import urlencode, unquote
 from webob import exc
 import json
 import os
 
 # Non-stdlib imports
-import pkg_resources
 from tg import expose, validate, redirect, flash, url, jsonify
 from tg.decorators import with_trailing_slash, without_trailing_slash
 from paste.deploy.converters import aslist
@@ -64,6 +62,7 @@ from allura.lib.security import (require_access, has_access, require,
                                  require_authenticated)
 from allura.lib import widgets as w
 from allura.lib import validators as V
+from allura.lib.utils import permanent_redirect
 from allura.lib.widgets import form_fields as ffw
 from allura.lib.widgets.subscriptions import SubscribeForm
 from allura.lib.plugin import ImportIdConverter
@@ -380,7 +379,7 @@ class ForgeTrackerApp(Application):
             links = links + search_bins
         links.append(SitemapEntry('Help'))
         links.append(
-            SitemapEntry('Formatting Help', self.config.url() + 'markdown_syntax'))
+            SitemapEntry('Formatting Help', '/nf/markdown_syntax', extra_html_attrs={'target': '_blank'}))
         return links
 
     def sidebar_menu_js(self):
@@ -905,15 +904,9 @@ class RootController(BaseController, FeedController):
                     subscribed_to_tool=M.Mailbox.subscribed(),
                     )
 
-    @expose('jinja:allura:templates/markdown_syntax.html')
+    @expose()
     def markdown_syntax(self, **kw):
-        """Static page explaining markdown."""
-        return dict()
-
-    @expose('jinja:allura:templates/markdown_syntax_dialog.html')
-    def markdown_syntax_dialog(self, **kw):
-        """Static page explaining markdown."""
-        return dict()
+        permanent_redirect('/nf/markdown_syntax')
 
     @memorable_forget()
     @expose()
diff --git a/ForgeWiki/forgewiki/tests/functional/test_root.py b/ForgeWiki/forgewiki/tests/functional/test_root.py
index 4c4f284..5b98fbc 100644
--- a/ForgeWiki/forgewiki/tests/functional/test_root.py
+++ b/ForgeWiki/forgewiki/tests/functional/test_root.py
@@ -73,8 +73,8 @@ class TestRootController(TestController):
         assert 'Create page' in r.text
 
     def test_root_markdown_syntax(self):
-        response = self.app.get('/wiki/markdown_syntax/')
-        assert 'Markdown Syntax' in response
+        response = self.app.get('/wiki/markdown_syntax/', status=301)
+        assert response.location.endswith('/nf/markdown_syntax')
 
     def test_root_browse_tags(self):
         response = self.app.get('/wiki/browse_tags/')
diff --git a/ForgeWiki/forgewiki/wiki_main.py b/ForgeWiki/forgewiki/wiki_main.py
index 4d47311..3b8af16 100644
--- a/ForgeWiki/forgewiki/wiki_main.py
+++ b/ForgeWiki/forgewiki/wiki_main.py
@@ -278,7 +278,7 @@ The wiki uses [Markdown](%s) syntax.
             links.append(SitemapEntry(subscribe_title, subscribe_url, ui_icon=g.icons['mail']))
         if not admin_menu:
             links += [SitemapEntry(''),
-                      SitemapEntry('Formatting Help', self.url + 'markdown_syntax/')]
+                      SitemapEntry('Formatting Help', '/nf/markdown_syntax', extra_html_attrs={'target': '_blank'})]
         return links
 
     def admin_menu(self, skip_common_menu=False):
@@ -519,17 +519,9 @@ class RootController(BaseController, DispatchIndex, FeedController):
     def create_wiki_page(self, **kw):
         return {}
 
-    @with_trailing_slash
-    @expose('jinja:allura:templates/markdown_syntax.html')
+    @expose()
     def markdown_syntax(self, **kw):
-        'Display a page about how to use markdown.'
-        return dict(example=MARKDOWN_EXAMPLE)
-
-    @with_trailing_slash
-    @expose('jinja:allura:templates/markdown_syntax_dialog.html')
-    def markdown_syntax_dialog(self, **kw):
-        'Display a page about how to use markdown.'
-        return dict(example=MARKDOWN_EXAMPLE)
+        permanent_redirect('/nf/markdown_syntax')
 
     @expose()
     @require_post()
@@ -839,16 +831,6 @@ class WikiAttachmentsController(ac.AttachmentsController):
     AttachmentControllerClass = WikiAttachmentController
 
 
-MARKDOWN_EXAMPLE = '''
-# First-level heading
-
-Some *emphasized* and **strong** text
-
-#### Fourth-level heading
-
-'''
-
-
 class RootRestController(BaseController, AppRestControllerMixin):
 
     def __init__(self):

[allura] 03/04: [#8388] rename and comments about static vs newforge

Posted by ke...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

kentontaylor pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/allura.git

commit c2bc5be1673ca2b7fee1e438e05fa7abe8054727
Author: Dave Brondsema <db...@slashdotmedia.com>
AuthorDate: Wed May 19 18:18:31 2021 -0400

    [#8388] rename and comments about static vs newforge
---
 Allura/allura/controllers/{static.py => newforge.py} | 3 +++
 Allura/allura/controllers/project.py                 | 6 +-----
 Allura/allura/controllers/root.py                    | 2 +-
 Allura/allura/tests/functional/test_static.py        | 7 ++++++-
 4 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/Allura/allura/controllers/static.py b/Allura/allura/controllers/newforge.py
similarity index 94%
rename from Allura/allura/controllers/static.py
rename to Allura/allura/controllers/newforge.py
index fa0148b..0060f35 100644
--- a/Allura/allura/controllers/static.py
+++ b/Allura/allura/controllers/newforge.py
@@ -31,6 +31,9 @@ from allura.lib import utils
 
 class NewForgeController(object):
 
+    # /nf/_static_/... (or whatever static.script_name is set to) is handled by StaticFilesMiddleware
+    # /nf/admin/... is handled by SiteAdminController
+
     @expose()
     @without_trailing_slash
     def markdown_to_html(self, markdown, neighborhood=None, project=None, app=None):
diff --git a/Allura/allura/controllers/project.py b/Allura/allura/controllers/project.py
index 0260d7b..9d01eae 100644
--- a/Allura/allura/controllers/project.py
+++ b/Allura/allura/controllers/project.py
@@ -37,12 +37,10 @@ from ming.utils import LazyProperty
 
 from allura import model as M
 from allura.app import SitemapEntry
-from allura.lib.base import WsgiDispatchController
 from allura.lib import helpers as h
 from allura.lib.helpers import iter_entry_points
 from allura.lib import utils
 from allura.lib.decorators import require_post
-from allura.controllers.error import ErrorController
 from allura.controllers.feed import FeedArgs, FeedController
 from allura.controllers.rest import nbhd_lookup_first_path
 from allura.lib.security import require_access
@@ -51,9 +49,7 @@ from allura.lib.widgets import forms as ff
 from allura.lib.widgets import form_fields as ffw
 from allura.lib.widgets import project_list as plw
 from allura.lib import plugin, exceptions
-from .auth import AuthController
-from .search import SearchController, ProjectBrowseController
-from .static import NewForgeController
+from .search import ProjectBrowseController
 
 log = logging.getLogger(__name__)
 
diff --git a/Allura/allura/controllers/root.py b/Allura/allura/controllers/root.py
index 885383e..c9092b3 100644
--- a/Allura/allura/controllers/root.py
+++ b/Allura/allura/controllers/root.py
@@ -41,7 +41,7 @@ from allura.ext.personal_dashboard.dashboard_main import DashboardController
 from .auth import AuthController
 from .trovecategories import TroveCategoryController
 from .search import SearchController, ProjectBrowseController
-from .static import NewForgeController
+from .newforge import NewForgeController
 from .site_admin import SiteAdminController
 from .rest import RestController
 
diff --git a/Allura/allura/tests/functional/test_static.py b/Allura/allura/tests/functional/test_static.py
index 0e3eb58..5f54ccc9 100644
--- a/Allura/allura/tests/functional/test_static.py
+++ b/Allura/allura/tests/functional/test_static.py
@@ -17,10 +17,15 @@
 
 from __future__ import unicode_literals
 from __future__ import absolute_import
+
 from allura.tests import TestController
 
 
-class TestStatic(TestController):
+class TestStaticFilesMiddleware(TestController):
+
+    # this tests StaticFilesMiddleware
+    # the URLs are /nf/_static_/... because test.ini has:
+    #   static.script_name = /nf/_static_/
 
     def test_static_controller(self):
         # package directory