Tags:
create new tag
, view all tags

Implemented: Tool Tip Topic Info on Wiki Word Links

Summary: Enhance the internal WikiWord links with a tool-tip message that shows the topic info (summary, last author, time stamp, revision) on mouse over.

In the TWikiPreferences, add this setting:

  • Show tool-tip topic info on mouse-over of WikiWord links. Setting can be on, off, or customized. An empty setting or off setting disables the tool-tips (for better performance). The setting can contain $summary to show the topic summary, $date for the last change date, $rev for the revision, $username for the login name of the last editor, $wikiname for the WikiName, $wikiusername for Main.WikiName, $topic for the topic name, and $web for the web name
    • Set LINKTOOLTIPINFO = on
    • #Set LINKTOOLTIPINFO = $username - $date - $rev: $summary

Contributors:
-- PeterThoeny - 05 Feb 2004

Discussions

FlexWiki's one line summary and last edit metadata on mouse-over is immediately useful. I could certainly become addicted to that in short order. Unfortunately it only seems to work in Internet Explorer; perhaps that could be fixed.

-- MattWilkie - 03 Feb 2004

The implementation is actually very easy, all the lego blocks are there.

The tooltip can be shown easily with the title attribute of the anchor tag, like this test link to WebNotify. This is part of HTML 4.0, but not all browsers support that.

Another option is to use a JavaScript tooltip. This could be done conditionally, falling back to the title attribute in case JavaScript is not enabled.

One concern is performance. The autolinking currently does not take much time, all that's needed is a check if a file exists. Now we'd need to read the topic info of all referened topics on a page view. This could be enhanced with a cache mechanism.

For an initial implementation I suggest to simply use the title attribute and to add a preferences setting where the tool-tip can be configured and turned on/off. Anyone interested to implement this?

-- PeterThoeny - 05 Feb 2004

This is now in TWikiAlphaRelease and at TWiki.org. It is not enabled on TWiki.org for performance reasons. You can set LINKTOOLTIPINFO in your user preferences to test this out.

Change:

*** ../../TWiki.pm      2004-02-24 01:18:31.000000000 -0800
--- TWiki.pm    2004-02-25 01:11:33.000000000 -0800
***************
*** 124,136 ****
          $webName $topicName $includingWebName $includingTopicName
        $userName $wikiName $wikiUserName $urlHost $isList @listTypes
        @listElements $debugUserTime $debugSystemTime $script
!         $newTopicFontColor $newTopicBgColor $noAutoLink
        $pageMode $readTopicPermissionFailed $cgiQuery $basicInitDone
      );

  # ===========================
  # TWiki version:
! $wikiversion      = "8 Feb 2004";

  # ===========================
  # Key Global variables, required for writeDebug
--- 124,136 ----
          $webName $topicName $includingWebName $includingTopicName
        $userName $wikiName $wikiUserName $urlHost $isList @listTypes
        @listElements $debugUserTime $debugSystemTime $script
!         $newTopicFontColor $newTopicBgColor $linkToolTipInfo $noAutoLink
        $pageMode $readTopicPermissionFailed $cgiQuery $basicInitDone
      );

  # ===========================
  # TWiki version:
! $wikiversion      = "25 Feb 2004";

  # ===========================
  # Key Global variables, required for writeDebug
***************
*** 441,446 ****
--- 441,447 ----
      # PTh: Moved from internalLink to initialize ('cause of performance)
      $newTopicBgColor   = TWiki::Prefs::getPreferencesValue("NEWTOPICBGCOLOR")   || "#FFFFCE";
      $newTopicFontColor = TWiki::Prefs::getPreferencesValue("NEWTOPICFONTCOLOR") || "#0000FF";
+     $linkToolTipInfo   = TWiki::Prefs::getPreferencesValue("LINKTOOLTIPINFO")   || "";
      # Prevent autolink of WikiWords
      $noAutoLink        = TWiki::Prefs::getPreferencesValue("NOAUTOLINK") || 0;

***************
*** 3559,3564 ****
--- 3560,3597 ----
  # =========================
  =pod

+ ---++ sub linkToolTipInfo ( $theWeb, $theTopic )
+
+ Returns =title="..."= tooltip info in case LINKTOOLTIPINFO perferences variable is set.
+ Warning: Slower performance if enabled.
+
+ =cut
+
+ sub linkToolTipInfo
+ {
+     my( $theWeb, $theTopic ) = @_;
+     return unless( $linkToolTipInfo );
+
+     my( $date, $user, $rev ) = TWiki::Store::getRevisionInfo( $theWeb, $theTopic );
+     my $text = $linkToolTipInfo;
+     $text =~ s/\$web/<nop>$theWeb/g;
+     $text =~ s/\$topic/<nop>$theTopic/g;
+     $text =~ s/\$rev/1.$rev/g;
+     $text =~ s/\$date/&formatDisplayTime( $date )/ge;
+     $text =~ s/\$username/<nop>$user/g;                                     # "jsmith"
+     $text =~ s/\$wikiname/"<nop>" . &TWiki::userToWikiName( $user, 1 )/ge;  # "JohnSmith"
+     $text =~ s/\$wikiusername/"<nop>" . &TWiki::userToWikiName( $user )/ge; # "Main.JohnSmith"
+     if( $text =~ /\$summary/ ) {
+         my $summary = &TWiki::Store::readFileHead( "$TWiki::dataDir\/$theWeb\/$theTopic.txt", 16 );
+         $summary = &TWiki::makeTopicSummary( $summary, $theTopic, $theWeb );
+         $text =~ s/\$summary/$summary/g;
+     }
+     return " title=\"$text\"";
+ }
+
+ # =========================
+ =pod
+
  ---++ sub internalLink (  $thePreamble, $theWeb, $theTopic, $theLinkText, $theAnchor, $doLink  )

  Not yet documented.
***************
*** 3610,3621 ****
      if( $exist) {
          if( $theAnchor ) {
              my $anchor = makeAnchorName( $theAnchor );
!             $text .= "<a href=\"$scriptUrlPath/view$scriptSuffix/"
!                   .  "$theWeb/$theTopic\#$anchor\">$theLinkText<\/a>";
              return $text;
          } else {
!             $text .= "<a href=\"$scriptUrlPath/view$scriptSuffix/"
!                   .  "$theWeb/$theTopic\">$theLinkText<\/a>";
              return $text;
          }

--- 3643,3656 ----
      if( $exist) {
          if( $theAnchor ) {
              my $anchor = makeAnchorName( $theAnchor );
!             $text .= "<a href=\"$scriptUrlPath/view$scriptSuffix/$theWeb/$theTopic\#$anchor\""
!                   .  &linkToolTipInfo( $theWeb, $theTopic )
!                   .  ">$theLinkText<\/a>";
              return $text;
          } else {
!             $text .= "<a href=\"$scriptUrlPath/view$scriptSuffix/$theWeb/$theTopic\""
!                   .  &linkToolTipInfo( $theWeb, $theTopic )
!                   .  ">$theLinkText<\/a>";
              return $text;
          }

-- PeterThoeny - 25 Feb 2004

Oops, forgot to update TWiki.pm on TWiki.org. Tooltip links should now work on TWiki.org if LINKTOOLTIPINFO is set.

-- PeterThoeny - 25 Feb 2004

Fixed a bug where the tooltip message was broken if there is a space-parenthesis-WikiWord pattern in the topic summary.

In makeTopicSummary of TWiki.pm, change:

    $htext =~ s/([\s\(])(?=\S)/$1<nop>/g;
to:
    $htext =~ s/([\s\(])(?=\S)/$1<nop>/g;

-- PeterThoeny - 05 Mar 2004

While trying the last TWikiAlphaRelease, the Twiki web didn't load. A quick browse in the Apache error.log file show that a void value is being used... I found out that the problem is in the following part in the TWikiDotPm file:

sub linkToolTipInfo
{
    my( $theWeb, $theTopic ) = @_;
     return unless ( $linkToolTipInfo );

to solve it, change that piece with the following:

sub linkToolTipInfo
{
    my( $theWeb, $theTopic ) = @_;
     return "" unless ( $linkToolTipInfo );

as soon as I can, I'll submit a patch (don't have the tools to do it at hand)

-- RafaelAlvarez - 06 Mar 2004

Thanks Rafael! This is now fixed in TWikiAlphaRelease and TWik.org.

-- PeterThoeny - 07 Mar 2004

I made a small enhancement: The setting can be simply on to set, or off to disable. In TWikiAlphaRelease, on TWiki.org, and all docs updated.

-- PeterThoeny - 24 Apr 2004

This feature would be even more informative if we had MoreMetaData.

Is it also possable that if there was a meta field for summary the summary fetching would be quicker? If a topic was created with it blank you could get the save script to automatically populate it the same way it is generated for searches now.

-- SamHasler - 28 Sep 2004

It would be somewhat quicker, but a real caching feature, hidden transparently in the TWiki Store would bring a better performance.

-- PeterThoeny - 29 Sep 2004

Moving away from caching the topic summary, I made a patch that sets the summary to the text at/after the #Anchor (for those links that are to a mid-page anchor) see AnchorToolTipSummary. My apologies for that name, I didn't know so much then...

-- JeffPeck - 01 Nov 2005

Edit | Attach | Watch | Print version | History: r13 < r12 < r11 < r10 < r9 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r13 - 2005-11-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-2015 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.