Tags:
archive_me1Add my vote for this tag create new tag
, view all tags
Currently in Twiki every link needs to be a proper WikiWord. This can get to be a real pain. Sometimes it is nice to have a topic that is not a WikiWord but is a well known shortcut for a given topic. An acronym comes to mind.

In the WikiClone Tiki they use the standard WikiNotation, but also let you force a word to become a new topic by enclosing it with '' and '.

So TLA becomes a link for your project with a ThreeLetterAcronym

Here is an example of Tiki: http://www.todo.org/cgi-bin/en/tiki.cgi?c=v&p=WelcomeVisitors

-- WayneScott - 07 Sep 2000


I like this idea. The '' and '' rule is in line with other TWiki rules of enclosing words with a pair of characters, i.e. the rule to make words *bold* or _italic_ . Shall we go ahead with this syntax? Opinions?

Related, this could be combined with WikiWordswithSpaces.

BTW, until available in the TWiki distribution, you could easily implement this as an extended rule in file wikicfg.pm , sub extendGetRenderedVersionOutsidePRE :

s/([\*\s][\(\-\*\s]*)\[\[([A-Z]+[a-z]+(?:[A-Z]+[a-zA-Z0-9]*))\]\]/&internalLink($webName,$2,$2,$1,1)/geo;

Beware, I just typed it here, this code is not tested!

-- PeterThoeny - 07 Sep 2000

Your code works, but still enforces WikiNotation. I used this code:

	 # FlexibleWikiWords : allow internet links to be created with non-WikiNames by enclosing the
	 # link with '[[' and ']]'
	 s/([\*\s][\(\-\*\s]*)\[\[(\w+)\]\]/&internalLink($webName,$2,$2,$1,1)/geo;
It seems to work fine and the indexing and searching pages don't seem to have any problems yet. I have several programs that are all lowercase with underscores that I wanted to make links.

What explains the beginning of the regular expression?

-- WayneScott - 08 Sep 2000

Note this change causes the Ref-By link at the bottom of the view page to not work as well as it used to. It helps to add 'casesensive=on' to the search string, but we still get false hits. You want to search for '\%TOPIC\%' but that would ONLY work for the new links.

-- WayneScott - 08 Sep 2000


I tried that but:

  • It doesn't do spaces
  • It doesn't work for Ref-By (as you've since mentioned)
  • It doesn't seem to work on Search either

I tried to fix the spaces by using:

s/([\*\s][\(\-\*\s]*)\[\[([\w\s]+)\]\]/&internalLink($webName,$2,$2,$1,1)/geo;


Update That should be:
s/(^|[\*\s][\(\-\*\s]*)\[\[([\w\s]+)\]\]/&internalLink($webName,$2,$2,$1,1)/geo;
All the other ones should be like that too (notice the ^| at the beginning). Without this, all of these rules fail to recognize words at the start of a line! -- AlWilliams - 17 Sep 2000

That worked, but for some reason, rendering was turning the first space (and only the first space) into an underbar. Didn't have time to chase it any further.

-- AlWilliams - 08 Sep 2000


Sorry, I kept the WikiNotation by mistake. Taking WikiWordswithSpaces into account, I propose that spaced words within the square brackets get rendered as is, but point to a topic with removed spaces, i.e. [[Dim Sum]] gets rendered as Dim Sum and points to the topic DimSum . The regex:

s/([\*\s][\(\-\*\s]*)\[\[([a-zA-Z\s]*)\]\]/&internalLink($webName,$2,$2,$1,1)/geo;

sub internalLink needs to be tweaked as well to remove spaces for the link.

Ref-By needs to be adapted as well, it should search for ( regular Wiki word | spaced Wiki word )

Using above example, the Ref-By search string current is DimSum[^A-Za-z] . It should be altered to do something like ((DimSum[^A-Za-z])|(\[\[D\s*i\s*m\s*S\s*u\s*m[^A-Za-z]]\])) (again, not tested). The idea is to insert an optional space between every character to catch every possible spacing of words. That way we catch also [[Dim Sum]] , which is what we want. Opinions?

> What explains the beginning of the regular expression?

The idea is to restrict Wiki links, e.g. build a link only if the word is preceeded by a space, '(' , '-' or '*' . This will prevent unwanted links, for example as in <img src="WikiWord.gif"> .

-- PeterThoeny - 08 Sep 2000


That means it would be possible to have multiple words pointing to the same topic? For example Big Topic BigTopic and B i g T o p i c would all be the same under your proposal. Hmmmm.... Not sure if that is good or bad.

-- AlWilliams - 09 Sep 2000


Yes, that is the idea. What are the disadvantages? In case we go for that we need to create a new %SPACEDTOPIC% variable that inserts a \s* between each character of the topic name.

(BTW, I fixed some of the broken Wiki links above. Yesterday I upgraded this TWiki installation to the latest Beta.)

-- PeterThoeny - 09 Sep 2000


> _sub internalLink needs to be tweaked as well to remove spaces for the link._

just before the topicExists if( $doPluralToSingular.... call, add this -- ManpreetSingh - 17 Sep 2000

	 $page =~ s/^\s*//;
	 $page =~ s/\s*$//;
	 $page =~ s/^(.)/\U$1/;
	 $page =~ s/\s([a-zA-Z0-9])/\U$1/g;

BTW, What does

$page =~ s/\s/_/;
do in there? I had to comment that out to make a funky link Another funky Link Still Another Funky link work.

-- ManpreetSingh - 15 Sep 2000

That must be where my initial underscore was coming from. Peter, I suspect this was an attempt to replace spaces with _ but it should have been /\s/_/g ?? is that true? (This is obsolete, don't know why it is in there -- PeterThoeny)

-- AlWilliams - 15 Sep 2000


%SPACEDTOPIC% implementation

The following code basically uses \s* separated characters and regexp search.

In wiki.pm just after $text =~ s/%TOPIC%/$topic/go;

	 my $spacedtopic = lc($topic);
	 $spacedtopic = join("%5Cs*" , split("", $spacedtopic));  # %5Cs* is \s*
	 $text =~ s/%SPACEDTOPIC%/$spacedtopic/go;

I am using a modified view.tmpl with Ref-by link as

<a href="%SCRIPTURLPATH%/search%SCRIPTSUFFIX%/%WEB%/?scope=text&amp;web=all&amp;order=topic&amp;search=%SPACEDTOPIC%&amp;regex=on&amp;limit=all">Ref-By</A>

Thje only problem I found is that web=all is not working but that is not working anyway in my almost unhacked copy of TWiki. Is this a bug?

-- ManpreetSingh - 15 Sep 2000

I committed the forced internal links (flexible wiki words) to CVS (TWiki Alpha) with a few changes:

  • sub internalLink does Wikify links (i.e. text [[some word]] links to topic "SomeWord"), but only if there is a space in the text. This is to avoid changing a single words from lowercase to uppercase (i.e. text [[sushi]] links to topic "sushi")
  • Forced internal links may point to another web, i.e. write [[TWiki.text formatting FAQ]] to get the link TWiki.text formatting FAQ that points to topic TextFormattingFAQ in the TWiki.TWiki web.
  • %SPACEDTOPIC% inserts space only between [A-Z] and [a-z0-9]

Regarding web=all search, this is working in TWiki Beta and Alpha.

-- PeterThoeny - 19 Sep 2000

Haven't looked at the code yet but [[sushi]] could point to Sushi and still render as sushi. Right? Why should we restrict it to WikiWordswithSpacesOnly?

Another thought: Now that we are highlighting the as yet undefined WikiWord (and degrading it with color in case of a LesserBrowser ), can we not make, the whole word, a link to create new word instead of just the question mark at the end?

-- ManpreetSingh - 19 Sep 2000

I prefer to keep the question mark link for non existing topics, this is more visible.

You are right, it is more consistent if non spaced words are also capitalized. Writing [[sushi]] points now to Sushi and renders as sushi.

I commited the change to CVS. See also WikiWordswithSpaces for more changes.

-- PeterThoeny - 19 Sep 2000

I want to be able to make a topic not using WikiWord. Is it possible to just bracket around the word like [not!a!wiki!word] I saw it possible in PhpWiki. If you see what happen may arise, please advice me before I set up such wiki.

-- KorakotChaovavanich - 04 Dec 2000

Moved discussion to ArbitraryTextForWikiWordLinks.

-- PeterThoeny - 10 Feb 2001

TopicClassification:
FeatureDone
Edit | Attach | Watch | Print version | History: r20 < r19 < r18 < r17 < r16 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r20 - 2001-02-10 - 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-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.