Monday, November 12, 2012

Content management in MFlow


I Just added some templating/content management to MFlow that IMHO is more flexible and simple than proper templating or content management approaches.

tFieldEd key html

is a widget that display the content of  html as is, But if logged as administrator, it permits to edit this chunk of html in place. So the editor could see the real appearance of what he write in the page while editing. When the administrator double click in the paragraph, the content is saved and identified by the key. Then, from now on the users will see the content of the saved paragraph, not the original one in the code.

The content is saved in a file by default ("texts" in this versions), but there is a configurable version (tFieldGen). The html content and his formating is cached in memory, so the display is very fast.

In case that the content has been fiixed and it don´t need further editions, 

 tField key

just read and present the edited content. tFieldEd is not longer needed.


There are also multilingual content management primitives mField and mFieldEd 


This demo shows in four steps how a typical process of content edition would work.

textEdit= do
    setHeader $ \html -> thehtml << body << html


    let first=  p << italics << 

                   (thespan << "this is a page with"
                   +++ bold << " two " +++ thespan << "paragraphs") 
                   
        second= p << italics << "This is the original text. This is the second paragraph"
         
        pageEditable =  (tFieldEd "first"  first)
                    **> (tFieldEd "second" second)
        
    ask $   first
        ++> second
        ++> wlink () (p << "click here to edit it")
    
    setAdminUser "admin" "admin"
    
    ask $ p << "Please login with admin/admin to edit it"
            ++> userWidget (Just "admin") userLogin
    
    ask $   p << "now you can click the field and edit them"
        ++> p << bold << "to save the edited field, double click on it"
        ++> pageEditable
        **> wlink () (p << "click here to see it as a normal user")
        
    logout
    
    ask $   p << "the user sees the edited content. He can not edit it"
        ++> pageEditable   
        **> wlink () (p << "click to continue")
      
    ask $   p << "When text are fixed,the edit facility and the original texts can be removed. The content is indexed by the field key"
        ++> tField "first" 
        **> tField "second" 
        **> p << "End of edit field demo" ++> wlink () (p << "click here to go to menu")


        


This example uses the last version of MFlow at https://github.com/agocorona/MFlow.
It uses the last version of  Workflow  https://github.com/agocorona/Workflow


Post a Comment