Return-Path: X-Original-To: apmail-incubator-allura-commits-archive@minotaur.apache.org Delivered-To: apmail-incubator-allura-commits-archive@minotaur.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8F17B102B2 for ; Thu, 23 Jan 2014 17:30:16 +0000 (UTC) Received: (qmail 27754 invoked by uid 500); 23 Jan 2014 17:29:52 -0000 Delivered-To: apmail-incubator-allura-commits-archive@incubator.apache.org Received: (qmail 27610 invoked by uid 500); 23 Jan 2014 17:29:50 -0000 Mailing-List: contact allura-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: allura-dev@incubator.apache.org Delivered-To: mailing list allura-commits@incubator.apache.org Received: (qmail 27180 invoked by uid 99); 23 Jan 2014 17:29:44 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 23 Jan 2014 17:29:44 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 0CF6A8BD285; Thu, 23 Jan 2014 17:29:44 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: johnsca@apache.org To: allura-commits@incubator.apache.org Date: Thu, 23 Jan 2014 17:29:58 -0000 Message-Id: <66d718c098f046f8b4fd19272a33b414@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [16/28] git commit: [#6393] Cleanup [#6393] Cleanup * Removed download button test * Changed show_download_button macro default to False * Added docs for extending Allura with macros Signed-off-by: Tim Van Steenburgh Project: http://git-wip-us.apache.org/repos/asf/incubator-allura/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-allura/commit/586eb2c1 Tree: http://git-wip-us.apache.org/repos/asf/incubator-allura/tree/586eb2c1 Diff: http://git-wip-us.apache.org/repos/asf/incubator-allura/diff/586eb2c1 Branch: refs/heads/cj/4257 Commit: 586eb2c1931754e69eab10c0b8a07d76b864dd12 Parents: bc594e1 Author: Tim Van Steenburgh Authored: Thu Jan 16 13:11:51 2014 +0000 Committer: Dave Brondsema Committed: Wed Jan 22 19:35:54 2014 +0000 ---------------------------------------------------------------------- Allura/allura/lib/app_globals.py | 2 + Allura/allura/lib/macro.py | 6 +-- Allura/allura/templates/neighborhood_help.html | 2 +- Allura/allura/tests/test_globals.py | 8 ---- Allura/docs/extending.rst | 41 +++++++++++++++++++++ 5 files changed, 47 insertions(+), 12 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/586eb2c1/Allura/allura/lib/app_globals.py ---------------------------------------------------------------------- diff --git a/Allura/allura/lib/app_globals.py b/Allura/allura/lib/app_globals.py index f53776d..d4f1b06 100644 --- a/Allura/allura/lib/app_globals.py +++ b/Allura/allura/lib/app_globals.py @@ -254,6 +254,8 @@ class Globals(object): stats=_cache_eps('allura.stats'), site_stats=_cache_eps('allura.site_stats'), admin=_cache_eps('allura.admin'), + # macro eps are used solely for ensuring that external macros are + # imported (after load, the ep itself is not used) macros=_cache_eps('allura.macros'), ) http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/586eb2c1/Allura/allura/lib/macro.py ---------------------------------------------------------------------- diff --git a/Allura/allura/lib/macro.py b/Allura/allura/lib/macro.py index 957fcb8..efb1433 100644 --- a/Allura/allura/lib/macro.py +++ b/Allura/allura/lib/macro.py @@ -164,7 +164,7 @@ def project_blog_posts(max_number=5, sort='timestamp', summary=False, mount_poin def get_projects_for_macro( category=None, display_mode='grid', sort='last_updated', show_total=False, limit=100, labels='', award='', private=False, - columns=1, show_proj_icon=True, show_download_button=True, show_awards_banner=True, + columns=1, show_proj_icon=True, show_download_button=False, show_awards_banner=True, grid_view_tools='', initial_q={}): from allura.lib.widgets.project_list import ProjectList @@ -267,7 +267,7 @@ def get_projects_for_macro( @macro('neighborhood-wiki') def projects(category=None, display_mode='grid', sort='last_updated', show_total=False, limit=100, labels='', award='', private=False, - columns=1, show_proj_icon=True, show_download_button=True, show_awards_banner=True, + columns=1, show_proj_icon=True, show_download_button=False, show_awards_banner=True, grid_view_tools=''): initial_q = dict(neighborhood_id=c.project.neighborhood_id) return get_projects_for_macro( @@ -281,7 +281,7 @@ def projects(category=None, display_mode='grid', sort='last_updated', @macro('userproject-wiki') def my_projects(category=None, display_mode='grid', sort='last_updated', show_total=False, limit=100, labels='', award='', private=False, - columns=1, show_proj_icon=True, show_download_button=True, show_awards_banner=True, + columns=1, show_proj_icon=True, show_download_button=False, show_awards_banner=True, grid_view_tools=''): myproj_user = c.project.user_project_of http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/586eb2c1/Allura/allura/templates/neighborhood_help.html ---------------------------------------------------------------------- diff --git a/Allura/allura/templates/neighborhood_help.html b/Allura/allura/templates/neighborhood_help.html index ed57b53..5c5d27a 100644 --- a/Allura/allura/templates/neighborhood_help.html +++ b/Allura/allura/templates/neighborhood_help.html @@ -45,7 +45,7 @@
  • display_mode = grid/list. Default is 'grid'
  • show_proj_icon = yes/no. Default 'yes'
  • grid_view_tools = git,hg,svn,tickets,wiki... Limit the tools shown in project list. Multivalue option (example grid_view_tools=git,wiki). Default ''
  • -
  • show_download_button = yes/no. Default 'yes'
  • +
  • show_download_button = yes/no. Default 'no'
  • show_awards_banner = yes/no. Default 'yes'
  • sort = last_updated/alpha/random/last_registered. Default 'last_updated'
  • show_total = yes/no. Adds a sentence with a total count of how many projects are listed. Default 'no'
  • http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/586eb2c1/Allura/allura/tests/test_globals.py ---------------------------------------------------------------------- diff --git a/Allura/allura/tests/test_globals.py b/Allura/allura/tests/test_globals.py index 1910e89..c8553a1 100644 --- a/Allura/allura/tests/test_globals.py +++ b/Allura/allura/tests/test_globals.py @@ -499,14 +499,6 @@ def test_projects_macro(): r = g.markdown_wiki.convert('[[projects display_mode=list columns=3]]') assert two_column_style not in r - # test project download button - r = g.markdown_wiki.convert( - '[[projects display_mode=list show_download_button=True]]') - assert 'download-button' in r - r = g.markdown_wiki.convert( - '[[projects display_mode=list show_download_button=False]]') - assert 'download-button' not in r - @td.with_wiki def test_limit_tools_macro(): http://git-wip-us.apache.org/repos/asf/incubator-allura/blob/586eb2c1/Allura/docs/extending.rst ---------------------------------------------------------------------- diff --git a/Allura/docs/extending.rst b/Allura/docs/extending.rst index 7fb46da..c39d572 100644 --- a/Allura/docs/extending.rst +++ b/Allura/docs/extending.rst @@ -64,3 +64,44 @@ The events that allura publishes are: * repo_cloned * repo_refreshed * repo_clone_task_failed + + +Markdown Macros +=============== + +Most text inputs in Allura accept Markdown text which is parsed and turned into +HTML before being rendered. The Markdown text may contain "macros" - custom +commands which extend the Markdown language. Here's an example of a macro +that comes with Allura:: + + [[project_admins]] + +Include this macro in a wiki page or other Markdown content, and when rendered +it will be replaced by an actual list of the project's admin users. + +Extending Allura with your own macros is simple, requiring two basic steps: + +1. Decide on a name for your macro, then create a function with that name, and + decorate it with the `macro()` decorator from Allura. The function can + accept keyword arguments, and must return text or HTML. For example:: + + from allura.lib.macro import macro + + @macro() + def hello(name='World'): + return "

    Hello {}!

    ".format(name) + +2. Add an entry point for your macro to the `setup.py` for your package:: + + [allura.macros] + hello_macro = mypkg.mymodule:hello + +Note that the key name (`hello_macro` in this case) doesn't matter - the macro +is named after the function name. Our example macro could be used in a couple +ways:: + + [[hello]] + [[hello name=Universe]] + +For more help with macros, consult the source code for the macros that ship +with Allura. You can find them in the `allura.lib.macro` package.