Edgewall Software

Opened 13 years ago

Closed 12 years ago

Last modified 12 years ago

#10120 closed enhancement (fixed)

Add a `format` parameter to the RecentChanges macro — at Version 17

Reported by: Ryan J Ollos <ryano@…> Owned by: Ryan J Ollos <ryano@…>
Priority: normal Milestone: 1.0
Component: wiki system Version: 0.13dev
Severity: normal Keywords: bitesized, macro
Cc: Branch:
Release Notes:

RecentChanges can produce a simple list with group=none (default is group=date, pre-1.0 behavior of grouping by day)

API Changes:
Internal Changes:

Description

Add a format parameter to the RecentChanges macro with the following allowed values:

  • groupbydate (default) - the current display format
  • list - list each page on a separate line, a bullet ed list, same as the current display but without the date shown.

For reference, two macros accept a format parameter: WikiMacros#TitleIndex-macro and WikiMacros#TicketQuery-macro.

A patch will be provided shortly.

Change History (22)

by ryano@…, 13 years ago

Attachment: macros.r10668.patch added

First cut at a patch.

comment:1 by anonymous, 13 years ago

There is an extra whitespace in the help text that should be corrected before committing the patch. The current behavior is that any value for format other than format=groupbydate

Here are the test cases I used:

{{{
[[RecentChanges]]
}}}
[[RecentChanges]]

{{{
[[RecentChanges(,3)]]
}}}
[[RecentChanges(,3)]]

{{{
[[RecentChanges(SandBox,3)]]
}}}
[[RecentChanges(SandBox,3)]]

{{{
[[RecentChanges(SandBox)]]
}}}
[[RecentChanges(SandBox)]]

{{{
[[RecentChanges(SandBox,format=list)]]
}}}
[[RecentChanges(SandBox,format=list)]]

{{{
[[RecentChanges(format=list)]]
}}}
[[RecentChanges(format=list)]]


{{{
[[RecentChanges(, 5, format=list)]]
}}}
[[RecentChanges(, 5, format=list)]]


{{{
[[RecentChanges(SandBox, 5, format=list)]]
}}}
[[RecentChanges(SandBox, 5, format=list)]]

{{{
[[RecentChanges(SandBox, 5, format=groupbydate)]]
}}}
[[RecentChanges(SandBox, 5, format=groupbydate)]]

{{{
[[RecentChanges(SandBox, format=groupbydate)]]
}}}
[[RecentChanges(SandBox, format=groupbydate)]]

{{{
[[RecentChanges(format=groupbydate)]]
}}}
[[RecentChanges(format=groupbydate)]]

{{{
[[RecentChanges(format=groupbydate, , 3)]]
}}}
[[RecentChanges(format=groupbydate, , 3)]]

{{{
[[RecentChanges(format=groupbydate, SandBox, 3)]]
}}}
[[RecentChanges(format=groupbydate, SandBox, 3)]]

comment:2 by anonymous, 13 years ago

Submitted my previous comment before finishing what I was writing …

The current behavior is that any value for format other than format=groupbydate results in the list format. I was thinking this might be expanded on in the future to add a format=compact option.

comment:3 by Christian Boos, 13 years ago

Nice proposal, thanks!

Two remarks:

  • as this is 0.13 material, please use the x if b else y style instead of b and x or y (see #9536)
  • for format=list, I think it would be more appropriate to generate a single list; even if this will probably make the patch a bit longer, it more important to have a semantically correct output

comment:4 by Remy Blank, 13 years ago

Milestone: 0.13

in reply to:  3 ; comment:5 by anonymous, 13 years ago

Replying to cboos:

Nice proposal, thanks!

Two remarks:

  • as this is 0.13 material, please use the x if b else y style instead of b and x or y (see #9536)
  • for format=list, I think it would be more appropriate to generate a single list; even if this will probably make the patch a bit longer, it more important to have a semantically correct output

I've incorporated those changes. I'm not super happy with the list generation … perhaps someone will be more clever than I have been in coding this. However, it seems to work correctly at least.

by Ryan J Ollos <ryano@…>, 13 years ago

Attachment: macros.r10671.patch added

in reply to:  5 ; comment:6 by Christian Boos, 13 years ago

Replying to anonymous:

I've incorporated those changes.

Nice, thanks!

I'm not super happy with the list generation …

For example you could add an extra transformation step to entries_per_date and factor out the part:

tag.li(tag.a(page, href=formatter.href.wiki(name)), ' ',  ...
... for date, entries in entries_per_date

into:

items_per_date = [(date, [tag.li(...) 
                         for ...])
                  for ... in entries_per_date]

and from that produce either the (<h3>, <ul>) sequence or a single <ul>.

by Ryan J Ollos <ryano@…>, 13 years ago

Attachment: macros.r10672.patch added

in reply to:  6 comment:7 by Ryan J Ollos <ryano@…>, 13 years ago

Replying to cboos:

For example you could add an extra transformation step to entries_per_date and factor out the part: …

Thank you for the pointers! I attempted to incorporate those changes into the latest patch.

comment:8 by Ryan J Ollos <ryano@…>, 13 years ago

I've been looking closely at the syntax of the TicketQuery macro and am thinking about some ways that we can make the new arguments to this macro more like the format and group arguments of the TicketQuery macro, for consistency. I'll post some more comments about this shortly.

comment:9 by Remy Blank, 12 years ago

Milestone: 1.01.0-triage

Preparing for 1.0.

comment:10 by Christian Boos, 12 years ago

Milestone: next-stable-1.0.xnext-dev-1.1.x

Last patch looks good, I suppose it was not applied because in comment:8 you were talking about follow-up changes. But that was quite some time ago, so I suppose we can consider the patch as is for the next dev release.

comment:11 by Ryan J Ollos <ryano@…>, 12 years ago

One of many things I've unfortunately lost track of.

If I remember correctly, I was thinking the notation would be more consistent with the TicketQuery macro if we added a group option, rather than adding a format option. The default for the group option would be date (or perhaps we want to use day, to allow for grouping by week, month, etc. in the future). We could add a none option for the grouping, and in the future also allow for grouping by author, alphabetically, etc.

I'm not sure which way is the better way to go. But if anyone has suggestions, I can quickly rework the patch.

comment:12 by Christian Boos, 12 years ago

Yes, group=date|none (where date is interpreted as day, as a first step) sounds better and leaves the door opened for more grouping possibilities, as you said.

comment:13 by Ryan J Ollos <ryano@…>, 12 years ago

New patch against r11098 of the trunk:

  • option added is group=date|none.
  • added unit tests.

by Ryan J Ollos <ryano@…>, 12 years ago

Attachment: t10120-r11098-1.patch added

Patch described in comment:13.

by Ryan J Ollos <ryano@…>, 12 years ago

Attachment: t10120-r11098-2.patch added

Patch described in comment:13. Previous patch had some garbage in it.

comment:14 by Christian Boos, 12 years ago

Milestone: next-dev-1.1.x1.0
Owner: set to Christian Boos

Looks good, thanks!

comment:15 by Christian Boos, 12 years ago

Resolution: fixed
Status: newclosed

I've taken the occasion of reviewing and testing the patch to do a few more clean-ups in macros.py.

Detailed steps in repos:cboos.git:ticket10120/t10120-r11098-2.patch-review, committed as a whole in r11100 (+ there's a hidden bonus in that changeset ;-) ).

comment:16 by Christian Boos, 12 years ago

Owner: changed from Christian Boos to Ryan J Ollos <ryano@…>

comment:17 by Christian Boos, 12 years ago

Release Notes: modified (diff)
Note: See TracTickets for help on using tickets.