Tags:
create new tag
view all tags

Feature Proposals » Enhancement to WEB Variable

Summary

Current State: Developer: Reason: Date: Concerns By: Bug Tracking: Proposed For:
MergedToCore PeterThoeny AcceptedByReleaseMeeting 2016-02-17   TWikibug:Item7727 KampalaRelease

Edit Form

TopicSummary:
CurrentState:
CommittedDeveloper:
ReasonForDecision:
DateOfCommitment:   Format: YYYY-MM-DD
ConcernRaisedBy:
BugTracking:
OutstandingIssues:
RelatedTopics:
InterestedParties:
ProposedFor:
TWikiContributors:
 

Motivation

The WEB variable does not work as expected in subwebs. Instead of showing the name of the current (sub)web, it shows the full path back up to the topmost parent web. There needs to be a simple way to show just the name of the current web, or the current web and its parent, without resorting to a plugin.

Description and Documentation

Apparently, a new feature has recently been added that allows for specifying %WEB{format=current"}% to get just the current webname (last element of the path). However, this is a lot to type and not very flexible. What if I want to see, e.g., two levels?

(Use case: Our home wiki has many levels of subwebs, e.g. http://wiki.cfcl.com/Projects/Access/Utiles/DS is a subweb)

Suggestion:

Parameter: Description: Default:
number a number from 1 to the number of webs in the path "$web"
A number that is larger than the maximum actual number of webs in the path would simply return the same value that Codev returns now.

Examples

Assuming %WEB% is Engineering/TechPubs/Apps:
%WEB{1}% returns: Apps ; %WEB{2}% returns: TechPubs/Apps.

Impact

No backward compatibility issues.

Implementation

Actual implementation by PeterThoeny:

  • Supported parameter:
    Parameter: Description: Example: Default:
    "..." or
    format="..."
    Format of web name. Supported tokens:
    $web - the full web path,
    $parents - parent webs, if any,
    $current - current web without parent webs,
    $last(n) - last n webs, including current one,
    $top - top-level web only,
    $top(n) - n top-level webs,
    $item(n) - the n-th web from top
    $list - comma-space delimited list of webs
    $size - array size of webs
     
    Engineering/TechPubs/Apps/Bugs
    Engineering/TechPubs/Apps  
    Bugs for $current
    Apps/Bugs for $last(2)
    Engineering for $top
    Engineering/TechPubs for $top(2)
    TechPubs for $item(2)
    Engineering, TechPubs, Apps, Bugs
    4 for $size
    "$web"

-- Contributors: Vicki Brown - 2016-02-14

Discussion

I can see the need on reduced typing. Personally I do not favor introducing an exception to the existing format="" parameter. I think it is better to find a way to enhance it consistently. What about this:

  • WEB can be used with named parameter format="$current", or nameless parameter "$current". This works even without quotes, such as %WEB{$current}%
  • Introduce new tokens to fit your needs, such as "$last2", "$last3", etc. Or "$last(2)", "$last(3)", etc.
  • To make it orthogonal we could also introduce $top2, $top3, etc.

-- Peter Thoeny - 2016-02-15

I like Peter's way. Making the format parameter work as nameless parameter as well is clean and consistent with the current way.

For flexibility, how about introducing optional parameters to $web? $web would be able to take zero (the current behavior), one, or two parameters. The first parameter would be offset and the second would be length -- analogous to substr() of Perl.

  • $web(0,1) == $top
  • $web(-1) == $web(-1,1) == $current
  • $web(0,-1) == $parents
Assuming $web == "Engineering/TecPubs/Apps"
  • $web(-2,2) == $web(1) == "TechPubs/Apps"

-- Hideyo Imazu - 2016-02-15

I put myself down as a committed developer for this.

-- Peter Thoeny - 2016-02-18

Accepted by KampalaReleaseMeeting2016x02x18; tracked at TWikibug:Item7727

-- Peter Thoeny - 2016-02-21

I implemented this, spec is updated above

-- Peter Thoeny - 2016-03-03

Edit | Attach | Watch | Print version | History: r7 < r6 < r5 < r4 < r3 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r7 - 2016-03-03 - PeterThoeny
 
  • Learn about TWiki  
  • Download TWiki
This site is powered by the TWiki collaboration platform Powered by Perl Hosted by OICcam.com Ideas, requests, problems regarding TWiki? Send feedback. Ask community in the support forum.
Copyright © 1999-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.