From cba07534cce3841807ad84dec6bd0b976002ec20 Mon Sep 17 00:00:00 2001 From: PeterThoeny Date: Thu, 25 Oct 2001 02:13:01 +0000 Subject: [PATCH] none --- TWiki/FormattedSearch.mdwn | 143 +++++++++++++++++++++++++++++++++++++++++++++ TWiki/TWikiVariables.mdwn | 26 ++++++--- 2 files changed, 162 insertions(+), 7 deletions(-) create mode 100644 TWiki/FormattedSearch.mdwn diff --git a/TWiki/FormattedSearch.mdwn b/TWiki/FormattedSearch.mdwn new file mode 100644 index 0000000..6b5e479 --- /dev/null +++ b/TWiki/FormattedSearch.mdwn @@ -0,0 +1,143 @@ +**Formatted Search Using **%SEARCH\{... format="..."\}%** Variable** + +
+ +
+ +## Preface + +By default, the format for displaying a search result is fixed, e.g. a table with rows of topic name and topic summary. Use the `format="..."` parameter to specify a customized format of the search result. The string of the format parameter is typically a bullet list or table row containing variables (i.e. `%SEARCH{ "food" format="| $topic | $summary |" }%`). + +## Syntax + +Two paramters can be used to specify a customized search result: + +1. `header="..."` parameter + +Use the header paramter to specify the header of a search result. It should correspond to the format of the format parameter. This parameter is optional. I.e. `header="| *Topic:* | *Summary:* |"` + +2. `format="..."` parameter + +Use the format paramter to specify the format of one search hit. I.e. `format="| $topic | $summary |"` + +Variables that can be used in the format string: + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Name: Expands To:
$web Name of the web
$topic Topic name
$locked LOCKED flag (if any)
$date Time stamp of last topic update
$rev Number of last topic revision, i.e. 1.4
$wikiusername Wiki user name of last topic update, i.e. Main.JohnSmith
$summary Topic summary
$formfield(name) The field value of a form field, i.e. $formfield([[Main/TopicClassification]]) would get expanded to PublicFAQ. This applies only to topics that have a [[Main/TWikiForms]]
$pattern(reg-exp) A regular expression pattern to extract some text from a topic, i.e. $pattern(.*?\*.*?Email\:\s*([^\n\r]+).*) extracts the email address from a bullet of format * Email: ....
+ +**_Note:_** For `$pattern(reg-exp)`, specify a [[RegularExpression]] that scans from start to end and contains the text you want to keep in parenthesis, i.e. `$pattern(.*?(from here.*?to here).*)`. You need to make sure that the integrity of a web page is not compromised, i.e. if you include a table make sure to include everything including the table end tag. + +## Examples + +### Bullet list showing topic name and summary + +Write this: + +`%SEARCH{ "FAQ" scope="topic" nosearch="on" nototal="on" header="   * *Topic: Summary:*" format="   * [[$topic]]: $summary" }%` + +To get this: + +# TWiki Installation Error + +Incorrect format of searchformat template (missing sections? There should be 4 %SPLIT% tags) + +### Table showing form field values of topics with a form + +Write this in the Know web: + +`| *Topic:* | *OperatingSystem:* | *OsVersion:* |`
%SEARCH\{ "[T]opicClassification.\*?value=\\"[P]ublicFAQ\\"" scope="text" regex="on" nosearch="on" nototal="on" format="| \[[$topic]] | $formfield([[OperatingSystem]]) | $formfield([[OsVersion]]) |" \}% + +To get this: + + + + + + + + + + + + + + + + + +
Topic:OperatingSystem:OsVersion:
IncorrectDllVersionW32PTH10DLLOsWin 95/98
WinDoze95CrashOsWin 95
+ +### Extract some text from a topic using regular expression + +Write this: + +`%SEARCH{ "__Back to\:__ TWikiFAQ" scope="text" regex="on" nosearch="on" nototal="on" header="TWiki FAQs:" format="   * $pattern(.*?FAQ\:[\n\r]*([^\n\r]+).*) [[$topic][Answer...]]" }%` + +To get this: + +# TWiki Installation Error + +Incorrect format of searchformat template (missing sections? There should be 4 %SPLIT% tags) + +-- [[PeterThoeny]] - 24 Oct 2001
diff --git a/TWiki/TWikiVariables.mdwn b/TWiki/TWikiVariables.mdwn index a41659f..b0a70c6 100644 --- a/TWiki/TWikiVariables.mdwn +++ b/TWiki/TWikiVariables.mdwn @@ -217,7 +217,7 @@ With a couple of notable exceptions, predefined variables return set values that %GMTIME% - GM time, is 29 Jun 2010 - 15:30 + GM time, is 29 Jun 2010 - 15:31 %GMTIME{"format"}% @@ -267,15 +267,15 @@ With a couple of notable exceptions, predefined variables return set values that 2 digit year 99 - Variables can be shortened to 3 characters. Example:
%GMTIME{"$day $month, $year - $hour:$min:$sec"}% is
29 Jun, 2010 - 15:30:48 + Variables can be shortened to 3 characters. Example:
%GMTIME{"$day $month, $year - $hour:$min:$sec"}% is
29 Jun, 2010 - 15:31:15 %SERVERTIME% - Server time, is 29 Jun 2010 - 11:30 + Server time, is 29 Jun 2010 - 11:31 %SERVERTIME{"format"}% - Formatted server time.
Example: %SERVERTIME{"$hou:$min"}% is 11:30 + Formatted server time.
Example: %SERVERTIME{"$hou:$min"}% is 11:31 %HTTP_HOST% @@ -403,13 +403,23 @@ With a couple of notable exceptions, predefined variables return set values that nosummary="on" - Show topic title only + Show topic title only. [3] Show topic summary bookview="on" - [[Main/BookView]] search, e.g. show complete topic text - Show topic summary + [[Main/BookView]] search, e.g. show complete topic text. [3] + Show topic summary. + + + format="..." + Define a [[Main/FormattedSearch]], i.e.
"   * [[$topic]]: $summary". [3] + Show regular search result with topic summary + + + header="..." + Specify header of [[Main/FormattedSearch]], i.e.
"   * *Topic: Summary:*". + Show regular header nosearch="on" @@ -470,6 +480,8 @@ With a couple of notable exceptions, predefined variables return set values that > : The search form uses identical names for input fields. > > [2] **_Note_**: A web can be excluded from a `web="all"` search if you define a `NOSEARCHALL=on` variable in its [[WebPreferences]]. +> +> [3] **_Note_**: Regular search, no summary, [[BookView]] and [[FormattedSearch]] are exclusive. ## Preferences Variables -- 1.9.4