You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by br...@apache.org on 2016/12/12 21:07:08 UTC

[1/3] allura git commit: Minor fixups for nbhd home page from wiki content

Repository: allura
Updated Branches:
  refs/heads/master d5b26edea -> 59719404a


Minor fixups for nbhd home page from wiki content


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/59719404
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/59719404
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/59719404

Branch: refs/heads/master
Commit: 59719404a72dcd9a5e0b6b58c99a49725850e9fc
Parents: e9bedee
Author: Kenton Taylor <kt...@slashdotmedia.com>
Authored: Mon Dec 12 19:19:03 2016 +0000
Committer: Dave Brondsema <da...@brondsema.net>
Committed: Mon Dec 12 15:56:38 2016 -0500

----------------------------------------------------------------------
 Allura/allura/controllers/project.py | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/59719404/Allura/allura/controllers/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/project.py b/Allura/allura/controllers/project.py
index 05ef643..685519c 100644
--- a/Allura/allura/controllers/project.py
+++ b/Allura/allura/controllers/project.py
@@ -98,7 +98,7 @@ class NeighborhoodController(object):
         if self.neighborhood.use_wiki_page_as_root:
             default_wiki_page = get_default_wiki_page()
             if default_wiki_page:
-                text = g.markdown_wiki.convert('[[include ref=Home]]')
+                text = default_wiki_page.html_text
         elif self.neighborhood.redirect:
             redirect(self.neighborhood.redirect)
         elif not self.neighborhood.has_home_tool:
@@ -1031,6 +1031,5 @@ def get_default_wiki_page():
     wiki_page = None
     wiki_app = c.project.app_instance('wiki')
     if wiki_app:
-        wiki_app.config._id
         wiki_page = WM.Page.query.get(app_config_id=wiki_app.config._id, title='Home')
         return wiki_page


[2/3] allura git commit: Ensures there is a default wiki home for use with neighborhood landing pages

Posted by br...@apache.org.
Ensures there is a default wiki home for use with neighborhood landing pages


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/e9bedee5
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/e9bedee5
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/e9bedee5

Branch: refs/heads/master
Commit: e9bedee532ae15ceb51cba772c6ed11dde656bae
Parents: 8c4a787
Author: Kenton Taylor <kt...@slashdotmedia.com>
Authored: Mon Dec 12 16:29:00 2016 +0000
Committer: Dave Brondsema <da...@brondsema.net>
Committed: Mon Dec 12 15:56:38 2016 -0500

----------------------------------------------------------------------
 Allura/allura/controllers/project.py            | 23 ++++++++++++++++++--
 .../templates/neighborhood_admin_overview.html  |  2 +-
 .../widgets/neighborhood_overview_form.html     | 10 ++++++++-
 3 files changed, 31 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/e9bedee5/Allura/allura/controllers/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/project.py b/Allura/allura/controllers/project.py
index 0cd083b..05ef643 100644
--- a/Allura/allura/controllers/project.py
+++ b/Allura/allura/controllers/project.py
@@ -96,7 +96,9 @@ class NeighborhoodController(object):
     def index(self, sort='alpha', limit=25, page=0, **kw):
         text = None
         if self.neighborhood.use_wiki_page_as_root:
-            text = g.markdown_wiki.convert('[[include ref=Home]]')
+            default_wiki_page = get_default_wiki_page()
+            if default_wiki_page:
+                text = g.markdown_wiki.convert('[[include ref=Home]]')
         elif self.neighborhood.redirect:
             redirect(self.neighborhood.redirect)
         elif not self.neighborhood.has_home_tool:
@@ -545,9 +547,12 @@ class NeighborhoodAdminController(object):
         set_nav(self.neighborhood)
         c.overview_form = W.neighborhood_overview_form
         allow_undelete = asbool(config.get('allow_project_undelete', True))
+        allow_wiki_as_root = True if get_default_wiki_page() else False
+
         return dict(
             neighborhood=self.neighborhood,
-            allow_project_undelete=allow_undelete)
+            allow_project_undelete=allow_undelete,
+            allow_wiki_as_root=allow_wiki_as_root)
 
     @without_trailing_slash
     @expose('jinja:allura:templates/neighborhood_admin_permissions.html')
@@ -1015,3 +1020,17 @@ class ProjectImporterController(object):
             return ep.load()(self.neighborhood), rest
 
         raise exc.HTTPNotFound
+
+
+def get_default_wiki_page():
+    """
+    Gets the default home page from the default Wiki setup.
+    """
+
+    from forgewiki import model as WM
+    wiki_page = None
+    wiki_app = c.project.app_instance('wiki')
+    if wiki_app:
+        wiki_app.config._id
+        wiki_page = WM.Page.query.get(app_config_id=wiki_app.config._id, title='Home')
+        return wiki_page

http://git-wip-us.apache.org/repos/asf/allura/blob/e9bedee5/Allura/allura/templates/neighborhood_admin_overview.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/neighborhood_admin_overview.html b/Allura/allura/templates/neighborhood_admin_overview.html
index 8944b22..da2be53 100644
--- a/Allura/allura/templates/neighborhood_admin_overview.html
+++ b/Allura/allura/templates/neighborhood_admin_overview.html
@@ -31,7 +31,7 @@
 {% endblock %}
 
 {% block content %}
-    {{c.overview_form.display(value=neighborhood, neighborhood=neighborhood)}}
+    {{c.overview_form.display(value=neighborhood, neighborhood=neighborhood, allow_wiki_as_root=allow_wiki_as_root)}}
 {% endblock %}
 
 {% block extra_css %}

http://git-wip-us.apache.org/repos/asf/allura/blob/e9bedee5/Allura/allura/templates/widgets/neighborhood_overview_form.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/widgets/neighborhood_overview_form.html b/Allura/allura/templates/widgets/neighborhood_overview_form.html
index 86e2221..7ba2a88 100644
--- a/Allura/allura/templates/widgets/neighborhood_overview_form.html
+++ b/Allura/allura/templates/widgets/neighborhood_overview_form.html
@@ -31,8 +31,16 @@
   {% endif %}
     <label class="grid-4">Show Title</label>
     <div class="grid-14">{{widget.display_field(widget.fields.show_title)}}</div>
+
     <label class="grid-4">"Home" Wiki as Root</label>
-    <div class="grid-14">{{widget.display_field(widget.fields.use_wiki_page_as_root)}}</div>
+    <div class="grid-14">
+        {%if not allow_wiki_as_root %}
+        This feature is disabled because there is no "Home" page in the default Wiki.
+        {% else %}
+        {{widget.display_field(widget.fields.use_wiki_page_as_root)}}
+        {% endif %}
+    </div>
+
   {% if neighborhood.allow_custom_css %}
     <label class="grid-4">Custom CSS</label>
     <div class="grid-14">{{widget.display_field(widget.fields.css)}}</div>


[3/3] allura git commit: Adds ability for neighborhood home to use Wiki home content

Posted by br...@apache.org.
Adds ability for neighborhood home to use Wiki home content


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/8c4a787c
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/8c4a787c
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/8c4a787c

Branch: refs/heads/master
Commit: 8c4a787c7f59e5bfbf202f3319732070ff2b7733
Parents: d5b26ed
Author: Kenton Taylor <kt...@slashdotmedia.com>
Authored: Wed Dec 7 19:37:00 2016 +0000
Committer: Dave Brondsema <da...@brondsema.net>
Committed: Mon Dec 12 15:56:38 2016 -0500

----------------------------------------------------------------------
 Allura/allura/controllers/project.py               | 17 +++++++++++++----
 Allura/allura/lib/widgets/forms.py                 |  1 +
 Allura/allura/model/neighborhood.py                |  1 +
 .../templates/neighborhood_project_list.html       |  3 +++
 .../widgets/neighborhood_overview_form.html        |  2 ++
 .../allura/tests/functional/test_neighborhood.py   |  7 ++++++-
 6 files changed, 26 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/8c4a787c/Allura/allura/controllers/project.py
----------------------------------------------------------------------
diff --git a/Allura/allura/controllers/project.py b/Allura/allura/controllers/project.py
index 5f956d9..0cd083b 100644
--- a/Allura/allura/controllers/project.py
+++ b/Allura/allura/controllers/project.py
@@ -94,9 +94,12 @@ class NeighborhoodController(object):
     @expose('jinja:allura:templates/neighborhood_project_list.html')
     @with_trailing_slash
     def index(self, sort='alpha', limit=25, page=0, **kw):
-        if self.neighborhood.redirect:
+        text = None
+        if self.neighborhood.use_wiki_page_as_root:
+            text = g.markdown_wiki.convert('[[include ref=Home]]')
+        elif self.neighborhood.redirect:
             redirect(self.neighborhood.redirect)
-        if not self.neighborhood.has_home_tool:
+        elif not self.neighborhood.has_home_tool:
             mount = c.project.ordered_mounts()[0]
             if mount is not None:
                 if 'ac' in mount:
@@ -105,6 +108,10 @@ class NeighborhoodController(object):
                     redirect(mount['sub'].url())
             else:
                 redirect(c.project.app_configs[0].options.mount_point + '/')
+        else:
+            text=g.markdown.cached_convert(
+                self.neighborhood, 'homepage'),
+
         c.project_summary = W.project_summary
         c.page_list = W.page_list
         limit, page, start = g.handle_paging(limit, page)
@@ -134,8 +141,7 @@ class NeighborhoodController(object):
         ]
         return dict(neighborhood=self.neighborhood,
                     title="Welcome to " + self.neighborhood.name,
-                    text=g.markdown.cached_convert(
-                        self.neighborhood, 'homepage'),
+                    text=text,
                     projects=projects,
                     sort=sort,
                     limit=limit, page=page, count=count)
@@ -615,6 +621,9 @@ class NeighborhoodAdminController(object):
         show_title = kw.get('show_title', False)
         h.log_if_changed(nbhd, 'show_title', show_title,
                          'change neighborhood show title to %s' % show_title)
+        use_wiki_page_as_root = kw.get('use_wiki_page_as_root', False)
+        h.log_if_changed(nbhd, 'use_wiki_page_as_root', use_wiki_page_as_root,
+                         'change use wiki page as root to %s' % use_wiki_page_as_root)
         project_list_url = kw.get('project_list_url', '')
         h.log_if_changed(nbhd, 'project_list_url', project_list_url,
                          'change neighborhood project list url to %s'

http://git-wip-us.apache.org/repos/asf/allura/blob/8c4a787c/Allura/allura/lib/widgets/forms.py
----------------------------------------------------------------------
diff --git a/Allura/allura/lib/widgets/forms.py b/Allura/allura/lib/widgets/forms.py
index 7bb982a..bf2da98 100644
--- a/Allura/allura/lib/widgets/forms.py
+++ b/Allura/allura/lib/widgets/forms.py
@@ -801,6 +801,7 @@ class NeighborhoodOverviewForm(ForgeForm):
         homepage = ffw.AutoResizeTextarea()
         allow_browse = ew.Checkbox(label='')
         show_title = ew.Checkbox(label='')
+        use_wiki_page_as_root = ew.Checkbox(label='')
         css = ffw.AutoResizeTextarea()
         project_template = ffw.AutoResizeTextarea(
             validator=V.JsonValidator(if_empty=''))

http://git-wip-us.apache.org/repos/asf/allura/blob/8c4a787c/Allura/allura/model/neighborhood.py
----------------------------------------------------------------------
diff --git a/Allura/allura/model/neighborhood.py b/Allura/allura/model/neighborhood.py
index 5695fd1..b27be4d 100644
--- a/Allura/allura/model/neighborhood.py
+++ b/Allura/allura/model/neighborhood.py
@@ -90,6 +90,7 @@ class Neighborhood(MappedClass):
         google_analytics=bool))
     anchored_tools = FieldProperty(str, if_missing='')
     prohibited_tools = FieldProperty(str, if_missing='')
+    use_wiki_page_as_root = FieldProperty(bool, if_missing=False)
 
     def parent_security_context(self):
         return None

http://git-wip-us.apache.org/repos/asf/allura/blob/8c4a787c/Allura/allura/templates/neighborhood_project_list.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/neighborhood_project_list.html b/Allura/allura/templates/neighborhood_project_list.html
index b747af0..ea4d3c5 100644
--- a/Allura/allura/templates/neighborhood_project_list.html
+++ b/Allura/allura/templates/neighborhood_project_list.html
@@ -49,6 +49,9 @@
 {% block header_classes %} colored{% endblock %}
 
 {% block content %}
+    {% if neighborhood.use_wiki_page_as_root and text %}
+      {{ text }}
+    {% endif %}
     {% if neighborhood.homepage %}
       {{neighborhood.homepage|safe}}
     {% endif %}

http://git-wip-us.apache.org/repos/asf/allura/blob/8c4a787c/Allura/allura/templates/widgets/neighborhood_overview_form.html
----------------------------------------------------------------------
diff --git a/Allura/allura/templates/widgets/neighborhood_overview_form.html b/Allura/allura/templates/widgets/neighborhood_overview_form.html
index c555a4d..86e2221 100644
--- a/Allura/allura/templates/widgets/neighborhood_overview_form.html
+++ b/Allura/allura/templates/widgets/neighborhood_overview_form.html
@@ -31,6 +31,8 @@
   {% endif %}
     <label class="grid-4">Show Title</label>
     <div class="grid-14">{{widget.display_field(widget.fields.show_title)}}</div>
+    <label class="grid-4">"Home" Wiki as Root</label>
+    <div class="grid-14">{{widget.display_field(widget.fields.use_wiki_page_as_root)}}</div>
   {% if neighborhood.allow_custom_css %}
     <label class="grid-4">Custom CSS</label>
     <div class="grid-14">{{widget.display_field(widget.fields.css)}}</div>

http://git-wip-us.apache.org/repos/asf/allura/blob/8c4a787c/Allura/allura/tests/functional/test_neighborhood.py
----------------------------------------------------------------------
diff --git a/Allura/allura/tests/functional/test_neighborhood.py b/Allura/allura/tests/functional/test_neighborhood.py
index e11dbac..81f2aee 100644
--- a/Allura/allura/tests/functional/test_neighborhood.py
+++ b/Allura/allura/tests/functional/test_neighborhood.py
@@ -40,7 +40,7 @@ from alluratest.controller import setup_trove_categories
 
 class TestNeighborhood(TestController):
     def test_home_project(self):
-        r = self.app.get('/adobe/wiki/')
+        r = self.app.get('/adobe/wiki/', status=302)
         assert r.location.endswith('/adobe/wiki/Home/')
         r = r.follow()
         assert 'This is the "Adobe" neighborhood' in str(r), str(r)
@@ -55,6 +55,11 @@ class TestNeighborhood(TestController):
         r = self.app.get('/adobe/')
         assert r.location.endswith('/adobe/wiki/Home/')
 
+    @patch('allura.model.neighborhood.Neighborhood.use_wiki_page_as_root', True)
+    def test_wiki_as_home(self):
+        r = self.app.get('/adobe/', status=200)
+        assert 'This is the "Adobe" neighborhood' in str(r), str(r)
+
     def test_admin(self):
         r = self.app.get('/adobe/_admin/', extra_environ=dict(username='root'))
         r = self.app.get('/adobe/_admin/overview',