MFlow  Create and maintain dynamic Web applications as easy and fast as console applications
Thou shall not write request handlers
 This release: 11/06/2014.  agocorona@gmail.com (@agocorona) <>< . issues & bugs .  Mflow Source code,     source code of this site




Kinds of Links

You may see different kinds of links in MFlow:

wlink's

An wlink get a value, a rendering for the link and return this value when clicked, to the procedure where it belongs. 

wlink :: (Typeable a, Show a, MonadIO m, FormInput view) => a -> view -> View view m a

It is safe by definition, That means that it can not be broken.

An wlink follow the path of the prevous wlinks That means that if in the navigation the path of the page is:

/a/b/c/d

then 

wlink "e" << "hi" 

in this page will render this

<a href="/a/b/c/d/e">hi </a>

The same happens for monadic widgets in the same page. the second wlink in a sequence append its path to the previous one.

absLink's

absLink Creates an absolute link. It has the same signature and meaning than wlink:

absLink :: (Typeable a, Show a, MonadIO m, FormInput view) => a -> view -> View view m a

While a wlink path is relative and depend on the page where it is located and
 ever points to the code of the page that had it inserted, an absLink point to the first page in the flow that inserted it. It is useful for creating a backtracking point in combination with `retry`

      page $ absLink "here" << p << "here link"
   page $ p << "second page" ++> wlink () << p << "click here"
   page $ p << "third page" ++> retry (absLink "here" << p << "will go back")
   page $ p << "fourth page" ++> wlink () << p << "will not reach here"

After navigating to the third page, when clicking in the link, will backtrack to the first, and will validate the first link as if the click
where done in the first page. Then the second page would be displayed.

Really, retry is not necessary in the last version of MFlow, since the REST navigation has been inproved. But it is there for compatibility purposes

In monadic widgets, it also backtrack to the statement where the absLink is located without the need of retry:

    page $ do
      absLink "here" << p << "here link"
      p << "second statement" ++> wlink () << p << "click here"
      p << "third statement" ++>  absLink "here" << p << "will present the first statement alone"
      p << "fourth statement" ++> wlink () << p << "will not reach here"


Ordinary links

They are freely made with the formatting chosen. Normally, blaze-html. They point to whatever internal or external URL. They are not verified at compilation time

page $  (a ! href "http://whathever/link $ "this link is not verified") 
     ++> wlink () << "this link is verified, and return ()"

This page shows two links . The first is not verified. The second is .

of course, if the ordinary link is internal, it will provoke a tracking to the page serving the URL, like in the case of th absLinks.


Runtime template links

 I´m writing this content over a runtime template. The one of the wiki. I can insert a link here that does not appear int he code of the application. it is just a piece of static HTML stored in a file that is read and cached by the template engine. See home of the wilki to see the code of the wiki pages.

comments powered by Disqus