Open a page from a document in a view

Some documents with web bookmarks appear in a Notes view. How do you open a bookmarked page bypassing the opening of the corresponding Notes document?
Two solutions follow: one uses Notes magic, and the other the InViewEdit event.

Notes magic

  1. Create a Dummy form, used for doing nothing (it sounds weird but works)
  2. Dummy: for preventing document creation, it should have a field [SaveOptions]=0 (text /computed for display)
  3. Dummy: for preventing form opening, it shoud have a sentence Continue = False in the QueryOpen script
  4. View: for inhibiting the default behaviour, in the FormFormula object write “Dummy”
  5. View: put the formula @UrlOpen( Bookmark ) into the QueryOpenDocument formula

now, if you double click the Bookmark document, the page (just it) appears in a new window

(revised text from my own comment 12351627 at Experts-Exchange)

InViewEdit event

Something special happens if an editable column shows a value as an icon: The SAVE_REQUEST type of the InViewEdit event is triggered as soon as the user clicks on the icon.

Sub Inviewedit(Source As NotesUIView, Requesttype As Integer, Colprogname As Variant, Columnvalue As Variant, Continue As Variant)
' This view has one editable column, which is for display of an icon.

     ' Define constants for request types
     Const SAVE_REQUEST = 3

     ' Define variables
     Dim db As NotesDatabase
     Dim doc As NotesDocument
     Dim ws As New NotesUIWorkspace
     Dim caret As String

     ' Get the CaretNoteID - exit if it does not point at a document
     caret = Source.CaretNoteID
     If caret = "0" Then Exit Sub

     ' Get the current database and document
     Set db = Source.View.Parent
     Set doc = db.GetDocumentByID( caret )

     ' Select the request type
     Select Case Requesttype

          Dim w As New NotesUIWorkspace
          w.UrlOpen doc.URL( 0 )
          Continue = False

     End Select
End Sub

(revised text from my own comment 12738085 at Experts-Exchange)

Put a web page in a string

If your server is Win32, you could use the following function to put a page in a string. It’s based upon a service of the MSXML library, which installation is an easy task (and maybe it’s a service already running)

Function GetPage( url As String ) As String
     Dim objHttp As Variant
     Set objHttp = CreateObject( "Msxml2.ServerXMLHTTP" )
     Call objHttp.Open( "GET", url, False )
     Call objHttp.Send()
     If objHttp.status <> 200 Then
          GetPage = "FAILED (status: " & objHttp.status & ")"
          Dim contentType As String
          contentType = objHttp.getResponseHeader( "Content-Type" )
          If contentType = "text/html" Then
               GetPage = objHttp.responseText
               GetPage = "Not HTML (type: " & contentType & ")"
          End If
     End If
     Set objHttp = Nothing
End Function

(revised text from my own comment 12271511 at Experts-Exchange)

Hacking WordPress (covers 2.0)

There is an issue related to how WordPress displays PREformatted html.
By default WP translates any post retrieved from the database before displaying it. It uses two filter functions: wptexturize and wpautop, both added to the same filter: the_content. It also translates any other piece of content (Title, Excerpt, …), but I don’t care now.

The function wptexturize is harmless but a bit annoying.
The concept behind WP is keep it simple, isn’t it? If I post a ” I expect a ” to be displayed, not a “ or a ”. Authors always need to see what they mean!

Until an optional setting appears for turning it off, I recommend you to turn it off now.
It’s quite easy. Just edit the file wordpress/wp-includes/default-filters.php and comment out the line that reads

add_filter('the_content', 'wptexturize');

The function wpautop is harmful, so here is a replacement.

Step 1/2
Edit the file wordpress/wp-includes/functions-formatting.php and copy and paste this function after the function wpautop.

function ae_autop( $unprocessed, $br = 1 ) {
	$processed = "<br />n";
	while( strlen( $unprocessed ) > 0 ) {
		$debugging += 1;
		preg_match( '{^([^<]*)?(</?[^>]+?>)?(.*)$}s', $unprocessed, $matches );
		$text = $matches[1]; // as much text as possible before an HTML tag
		$text = str_replace( "n", "<br />n", $text );
		$tag = $matches[2]; // an HTML tag
		$unprocessed = $matches[3]; // the rest of $unprocessed
		if( preg_match( '{<preb}i', $tag ) ) {
			preg_match( '{^(<preb.*?</pre>)?(.*)$}is', $tag . $unprocessed, $skipping );
			$tag = $skipping[1]; // a pre block
			$unprocessed = $skipping[2]; // the rest of $unprocessed
		$processed .= $text . $tag;     
	return $processed; 

Step 2/2
Last but not least, edit the file wordpress/wp-includes/default-filters.php and comment out the line that reads

add_filter('the_content', 'wpautop');

After it, add this line

add_filter('the_content', 'ae_autop');