Edgewall Software
Modify

Opened 9 years ago

Closed 7 years ago

Last modified 4 years ago

#11865 closed enhancement (fixed)

Workflow macro could read files from the repository

Reported by: Ryan J Ollos Owned by: Ryan J Ollos
Priority: normal Milestone: 1.3.2
Component: ticket system Version:
Severity: normal Keywords: workflow macro bitesized
Cc: Branch:
Release Notes:

Workflow macro can render files from the repository.

API Changes:

Added method read_file_by_path to RepositoryManager, which returns the contents from the specified repository-scoped file at the specified revision, or HEAD revision if no revision is specified.

Internal Changes:

Description

The Image macro and several WikiProcessors on trac-hacks support reading a file from the repository: th:CodeExampleMacro, th:PlantUmlMacro.

Adding this capability to the Workflow macro and allowing ini files to be read from the repository would make the documentation on the TracWorkflow page could be made more maintainable.

Attachments (0)

Change History (19)

comment:1 by Ryan J Ollos, 9 years ago

Summary: Path option for WikiProcessorsWorkflow macro could read files from the repository

comment:2 by Ryan J Ollos, 9 years ago

Keywords: bitesized added

comment:3 by Ryan J Ollos, 9 years ago

Some work has been done to implement the feature in log:rjollos.git:t11865-workflow-macro. More work is needed to mock out RepositoryManager and develop a thorough set of test cases.

comment:4 by Ryan J Ollos, 9 years ago

Milestone: next-dev-1.1.xnext-dev-1.3.x

Narrowing focus for milestone:1.2. Please move ticket to milestone:1.2 if you intend to fix it.

comment:5 by Ryan J Ollos, 7 years ago

TODO Update WorkFlow/Examples to read ini files from repository after this ticket is implemented.

Version 0, edited 7 years ago by Ryan J Ollos (next)

comment:6 by Ryan J Ollos, 7 years ago

Release Notes: modified (diff)

comment:7 by Ryan J Ollos, 7 years ago

API Changes: modified (diff)
Milestone: next-dev-1.3.x1.3.2
Owner: set to Ryan J Ollos
Status: newassigned

Proposed changes in [acb2ee10/rjollos.git], with the first two changes in the branch targeted for 1.2-stable (log:rjollos.git:t11865_workflow_macro.1).

in reply to:  description comment:8 by Ryan J Ollos, 7 years ago

Replying to Ryan J Ollos:

Adding this capability to the Workflow macro and allowing ini files to be read from the repository would make the documentation on the TracWorkflow page could be made more maintainable.

This actually won't work because the TracWorkflow page is distributed with Trac, however the workflow macro with file argument can be used on the WorkFlow/Examples page.

comment:9 by Ryan J Ollos, 7 years ago

Resolution: fixed
Status: assignedclosed

Ancillary changes committed to 1.2-stable in r15856,r15857; merged to trunk in r15858,r15859.

Committed to trunk in r15860.

comment:10 by Ryan J Ollos, 7 years ago

After r15859, the following is included in the pot file:

#: trac/wiki/tests/formatter.py:127 trac/wiki/tests/formatter.py:134
#, python-format
msgid "The content: %(content)s"
msgstr ""

Is it good to use the same workaround as in tests/config.py?

  • trac/wiki/tests/formatter.py

    diff --git a/trac/wiki/tests/formatter.py b/trac/wiki/tests/formatter.py
    index 629d139fd..2c00309c3 100644
    a b class TracErrorWithUnicodeMacro(WikiMacroBase):  
    123123class MacroErrorWithFragmentMacro(WikiMacroBase):
    124124
    125125    def expand_macro(self, formatter, name, content, args=None):
    126         raise MacroError(tag_("The content: %(content)s",
    127                               content=html.code(content)))
     126        raise MacroError((tag_)("The content: %(content)s",
     127                                content=html.code(content)))
    128128
    129129
    130130class ProcessorErrorWithFragmentMacro(WikiMacroBase):
    131131
    132132    def expand_macro(self, formatter, name, content, args=None):
    133         raise ProcessorError(tag_("The content: %(content)s",
    134                                   content=html.code(content)))
     133        raise ProcessorError((tag_)("The content: %(content)s",
     134                                    content=html.code(content)))
    135135
    136136
    137137class SampleResolver(Component):

Or is there a better way?

comment:11 by Jun Omae, 7 years ago

Another way, I think we could use tgettext_noop instead of tag_ to prevent message extraction.

  • trac/wiki/tests/formatter.py

    diff --git a/trac/wiki/tests/formatter.py b/trac/wiki/tests/formatter.py
    index 629d139fd..4a571c9a9 100644
    a b import unittest  
    1616
    1717from trac.core import Component, TracError, implements
    1818from trac.util.html import genshi, html
    19 from trac.util.translation import tag_
     19from trac.util.translation import tgettext_noop
    2020from trac.wiki.api import IWikiSyntaxProvider
    2121from trac.wiki.formatter import MacroError, ProcessorError
    2222from trac.wiki.macros import WikiMacroBase
    class TracErrorWithUnicodeMacro(WikiMacroBase):  
    123123class MacroErrorWithFragmentMacro(WikiMacroBase):
    124124
    125125    def expand_macro(self, formatter, name, content, args=None):
    126         raise MacroError(tag_("The content: %(content)s",
    127                               content=html.code(content)))
     126        raise MacroError(tgettext_noop("The content: %(content)s",
     127                                       content=html.code(content)))
    128128
    129129
    130130class ProcessorErrorWithFragmentMacro(WikiMacroBase):
    131131
    132132    def expand_macro(self, formatter, name, content, args=None):
    133         raise ProcessorError(tag_("The content: %(content)s",
    134                                   content=html.code(content)))
     133        raise ProcessorError(tgettext_noop("The content: %(content)s",
     134                                           content=html.code(content)))
    135135
    136136
    137137class SampleResolver(Component):

comment:12 by Ryan J Ollos, 7 years ago

That looks useful. I was thinking, there must be a way to ignore files/directories, so did some searching. The changes in log:rjollos.git:t11865_no_extract_message ([dbb43165/rjollos.git]) seem to fix the issue. I'm considering it would be good to push changes to 1.2-stable.

in reply to:  12 ; comment:13 by Jun Omae, 7 years ago

Replying to Ryan J Ollos:

That looks useful. I was thinking, there must be a way to ignore files/directories, so did some searching. The changes in log:rjollos.git:t11865_no_extract_message ([dbb43165/rjollos.git]) seem to fix the issue.

Ignoring **/tests/** for extraction is good idea!

Also, I've added ignore = babel.messages.extract:extract_nothing line to messages-js.cfg for #12351. However, I noticed the line is not needed by your changes.

  • messages-js.cfg

    diff --git a/messages-js.cfg b/messages-js.cfg
    index 233104561..55366b3fd 100644
    a b  
    22# trac/locale/messages-js.pot (see setup.cfg)
    33[extractors]
    44javascript_script = trac.dist:extract_javascript_script
    5 ignore = babel.messages.extract:extract_nothing
    65
    76[ignore:            **/htdocs/js/jquery.js]
    87[ignore:            **/htdocs/js/jquery-ui.js]

I'm considering it would be good to push changes to 1.2-stable.

Agreed.

in reply to:  13 comment:14 by Ryan J Ollos, 7 years ago

Replying to Jun Omae:

Also, I've added ignore = babel.messages.extract:extract_nothing line to messages-js.cfg for #12351. However, I noticed the line is not needed by your changes.

Thanks, I'll include that in the changes.

comment:15 by Ryan J Ollos, 7 years ago

Proposed changes for 1.2-stable: [cdd959a1/rjollos.git].

comment:16 by Ryan J Ollos, 7 years ago

Changes committed to 1.2-stable in r15888, merged to trunk in r15890.

comment:17 by Jun Omae, 7 years ago

After [15888], extract_messages command is failing….

$ make extract
python  setup.py  extract_messages  extract_messages_js  extract_messages_tracini
running extract_messages
error: [Errno 2] No such file or directory: 'messages.cfg'
make: *** [extract] Error 1

Added messages.cfg file in [15897] using [cdd959a1/rjollos.git].

comment:18 by Ryan J Ollos, 7 years ago

Thanks for fixing - I've been overlooking the svn add lately.

comment:19 by Ryan J Ollos, 4 years ago

Reviewing code in IncludeMacro, RepositoryManager.read_file_by_path would be more useful if it returned the content type for the file.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Ryan J Ollos.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Ryan J Ollos to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.