Re: patch to distinguish between internal and external links

View: New views
4 Messages — Rating Filter:   Alert me  

Parent Message unknown Re: patch to distinguish between internal and external links

by Bruno Postle-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

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
_______________________________________________
MKDoc-dev mailing list
MKDoc-dev@...
https://lists.webarch.co.uk/mailman/listinfo/mkdoc-dev

Re: Re: patch to distinguish between internal and external links

by Bruno Postle-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu 21-Jul-2005 at 15:19 +0100, Bruno Postle wrote:

>
> 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;
>  }

Of course you reset the default value in
$SITE_DIR/httpd/httpd-env.conf like so:

  SetEnv MKD__EXTERNAL_LINKS_OPEN_IN_NEW_WINDOW 1

This file is templated in MKDoc::Site::ConfigWriter::Httpd_Conf.  So
I would put it in the defaults, but commented out like so:

  # Uncomment if you want external links in popup windows
  # SetEnv MKD__EXTERNAL_LINKS_OPEN_IN_NEW_WINDOW 1

--
Bruno
_______________________________________________
MKDoc-dev mailing list
MKDoc-dev@...
https://lists.webarch.co.uk/mailman/listinfo/mkdoc-dev

Re: Re: patch to distinguish between internal and external links

by Chris Croome :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi

I don't know if there was a mistake in the suggestions in the last two
emails [1] or if I have made some daft mistakes in applying the patches
but I can't get this stuff to work...

I made one commit to add all the code to enable the links opening in a
new window variable to be set in the httpd.conf file here:

  https://lists.webarch.co.uk/pipermail/mkdoc-commit/2005-August/000923.html

And then a second commit to use the variable in the image template to
make images that are links to external sites open in new windows:

  https://lists.webarch.co.uk/pipermail/mkdoc-commit/2005-August/000924.html

None of this seems to work -- you still need to set the variable in
flo/Editor.pm to make external links open in new windows and where
images are links the attribute to open them in new windows isn't
appearing.

Chris


[1] https://lists.webarch.co.uk/pipermail/mkdoc-dev/2005-July/000289.html
    https://lists.webarch.co.uk/pipermail/mkdoc-dev/2005-July/000290.html

--
Chris Croome                               <chris@...>
web design                             http://www.webarchitects.co.uk/ 
web content management                               http://mkdoc.com/   
_______________________________________________
MKDoc-dev mailing list
MKDoc-dev@...
https://lists.webarch.co.uk/mailman/listinfo/mkdoc-dev

Re: patch to distinguish between internal and external links

by Bruno Postle-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon 08-Aug-2005 at 14:52 +0100, Chris Croome wrote:
>
> I don't know if there was a mistake in the suggestions in the last
> two emails [1] or if I have made some daft mistakes in applying
> the patches but I can't get this stuff to work...

It needed to be placed inside the flo::Editor->links() method itself
rather than at the top of flo::Editor:

  https://lists.webarch.co.uk/pipermail/mkdoc-commit/2005-August/000959.html

(maybe someone else can explain why)

> ... and where images are links the attribute to open them in new
> windows isn't appearing.

Works here, no need to fix.

--
Bruno
_______________________________________________
MKDoc-dev mailing list
MKDoc-dev@...
https://lists.webarch.co.uk/mailman/listinfo/mkdoc-dev