[MKDoc-dev] Re: patch to distinguish between internal and external links

Bruno Postle bruno at mkdoc.com
Thu Jul 21 15:19:04 BST 2005


On Sun 10-Jul-2005 at 19:52 -0400, Sam Tregar wrote:

Sorry, just catching up on all this now (CC'ing to mkdoc-dev since 
this is relevant there).

>   - Whether links open in a new window or not is controlled via a
>     configuration variable in flo/Editor.pm:
>
>	# Set this to true and external links (as determined by
>	# MKDoc::Util::LinkParser) will open in a new window.
>	our $EXTERNAL_LINKS_OPEN_IN_NEW_WINDOW = 1;
>
>     If this is the way we want to go then I should move this into a
>     configuration file.  Any pointers on the right way to do that would
>     be appreciated - I haven't added a new configuration variable in
>     MKDoc so far.

These kinds of global configuration options are handled by 
MKDoc::Config.  Basically you create a method that returns a value 
from the environment or a sensible default:

  package MKDoc::Config;
  ...
  sub EXTERNAL_LINKS_OPEN_IN_NEW_WINDOW
  {
      my $class = shift;
      return get_env ('MKD__EXTERNAL_LINKS_OPEN_IN_NEW_WINDOW') || 0;
  }

..and you access it like so:

  use MKDoc::Config;
  ...
  our $EXTERNAL_LINKS_OPEN_IN_NEW_WINDOW
      = MKDoc::Config->EXTERNAL_LINKS_OPEN_IN_NEW_WINDOW();

In principle, these globals are accessible to the template writer.  
So you can put this in a template:

  <html
    petal:define="popups config:EXTERNAL_LINKS_OPEN_IN_NEW_WINDOW;">
  ...
  <p petal:condition="true: popups"><blink>Warning this page fails
    the principle of least surprise</blink></p>
  ...
  </html>


There is another entire configuration system that resembles a 
hierarchical 'registry' (also implemented in MKDoc::Config).  This 
is used to set the sizes of thumbnail images and the number of items 
in a search results page and not much else.

It seems that the idea was to store configuration options in files, 
though in reality there is just a single hash ($::MKD_CONFIG), it is 
implemented here:

  MKDoc::Config::new()
  MKDoc::Config::get()
  MKDoc::Config::keys()
  MKDoc::Config::hash()

This extra system was completely broken under mod_perl, I hacked a 
fix for it this January to get the search results and thumbnailing 
working:

  https://lists.webarch.co.uk/pipermail/mkdoc-commit/2005-January/000643.html

-- 
Bruno


More information about the MKDoc-dev mailing list