[xwiki-devs] Replace words with links
Hi all, hi Caleb! Clearly I'm not the only one thinking about replacing words with links! :-) I've found the Replace Words With Links Snippet (http://tinyurl.com/37f79qu) and would like to know if it is worth to get it adapted to a different bunch of requirements, if it could be generalized or if I'm thinking about a different thing that requires/deserves a different solution. Having its origin in what I now consider wrong data model design (http://ftp.ebiotic.net/onPdr/pescaderiasDataModel.png), I now get pages including an object of User class (representing a given provider), and pages containing an object of Species class (representing a product offered by one of several providers). Doc1.User.species contents a text string like 'species 01, species 04, species 05' Doc2.Species.galicianName contents, for instance, 'species 04' What I need to do is to replace 'species 04' when rendering Doc1.User.species with a link to Doc2. And the same with the other strings if it exist a document with a Doc2.Species.galicianName matching one of the strings in Doc1.User.species. I've not a clear idea yet about what must be the right implementation to "assign items to providers, but I've to deal with what I have for now. Please, is it worth to adapt the Replace Words With Links Snippet to this use case? Could it be done in some other simpler way? Could you point me to any other example that could apply to this case? Thanks! I'm new to Velocity, to Groovy and in most of the senses to XWiki as well! By the way: the replacement of strings with links must be done on the fly. Doing it any other way will complicate the way users create new pages. It could be not the most efficient and cheap way, but I'm forced to do it this way until we time and resources to modify the whole model. Thank you so much for your help! Ricardo -- Ricardo Rodríguez CTO eBioTIC. Life Sciences, Data Modeling and Information Management Systems
Hi Ricardo, The correct way to do that would be by implementing a rendering transformation. Transformations are called to modify the XDOM (document content in a Java object based model) before rendering it. See http://code.xwiki.org/xwiki/bin/view/Modules/RenderingModule#HAddinganewTran... The only problem is that there is one limitation currently: when you edit the a page with the WYSIWYG and save, the modified XDOM will be saved. We need http://jira.xwiki.org/jira/browse/XWIKI-3260 to fully support any possible modification to the XDOM (I'm currently working on it but it's a big work). Hope it helps. On Thu, Sep 30, 2010 at 15:23, [Ricardo Rodriguez] eBioTIC. <[email protected]> wrote:
Hi all, hi Caleb!
Clearly I'm not the only one thinking about replacing words with links! :-) I've found the Replace Words With Links Snippet (http://tinyurl.com/37f79qu) and would like to know if it is worth to get it adapted to a different bunch of requirements, if it could be generalized or if I'm thinking about a different thing that requires/deserves a different solution.
Having its origin in what I now consider wrong data model design (http://ftp.ebiotic.net/onPdr/pescaderiasDataModel.png), I now get pages including an object of User class (representing a given provider), and pages containing an object of Species class (representing a product offered by one of several providers).
Doc1.User.species contents a text string like 'species 01, species 04, species 05'
Doc2.Species.galicianName contents, for instance, 'species 04'
What I need to do is to replace 'species 04' when rendering Doc1.User.species with a link to Doc2. And the same with the other strings if it exist a document with a Doc2.Species.galicianName matching one of the strings in Doc1.User.species.
I've not a clear idea yet about what must be the right implementation to "assign items to providers, but I've to deal with what I have for now.
Please, is it worth to adapt the Replace Words With Links Snippet to this use case? Could it be done in some other simpler way? Could you point me to any other example that could apply to this case? Thanks!
I'm new to Velocity, to Groovy and in most of the senses to XWiki as well!
By the way: the replacement of strings with links must be done on the fly. Doing it any other way will complicate the way users create new pages. It could be not the most efficient and cheap way, but I'm forced to do it this way until we time and resources to modify the whole model.
Thank you so much for your help!
Ricardo
-- Ricardo Rodríguez CTO eBioTIC. Life Sciences, Data Modeling and Information Management Systems
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Thomas Mortagne
Hi Thomas, Thomas Mortagne wrote:
Hi Ricardo,
The correct way to do that would be by implementing a rendering transformation. Transformations are called to modify the XDOM (document content in a Java object based model) before rendering it.
See http://code.xwiki.org/xwiki/bin/view/Modules/RenderingModule#HAddinganewTran...
I think I can, more intuitively that with real knowledge, understand what you are talking about.
The only problem is that there is one limitation currently: when you edit the a page with the WYSIWYG and save, the modified XDOM will be saved. We need http://jira.xwiki.org/jira/browse/XWIKI-3260 to fully support any possible modification to the XDOM (I'm currently working on it but it's a big work).
We don't use the WYSIWYG editor in concerned wiki: I'm working in a 1.3.x plain old wiki. It is currently being migrated to a 2.4.1 new farm. But even in this case I think I'm far from being able to implement this solution here. I see that we have not available information yet about "Adding a new Transformation". The only solution that I currently see is replacing the strings stored in thar property to sore XWiki links there. Automatically or manually. Any other idea will be really welcome! Thanks! -- Ricardo Rodríguez CTO eBioTIC. Life Sciences, Data Modeling and Information Management Systems
On Thu, Sep 30, 2010 at 23:14, [Ricardo Rodriguez] eBioTIC. <[email protected]> wrote:
Hi Thomas,
Thomas Mortagne wrote:
Hi Ricardo,
The correct way to do that would be by implementing a rendering transformation. Transformations are called to modify the XDOM (document content in a Java object based model) before rendering it.
See http://code.xwiki.org/xwiki/bin/view/Modules/RenderingModule#HAddinganewTran...
I think I can, more intuitively that with real knowledge, understand what you are talking about.
The only problem is that there is one limitation currently: when you edit the a page with the WYSIWYG and save, the modified XDOM will be saved. We need http://jira.xwiki.org/jira/browse/XWIKI-3260 to fully support any possible modification to the XDOM (I'm currently working on it but it's a big work).
We don't use the WYSIWYG editor in concerned wiki: I'm working in a 1.3.x plain old wiki. It is currently being migrated to a 2.4.1 new farm. But even in this case I think I'm far from being able to implement this solution here. I see that we have not available information yet about "Adding a new Transformation".
Sorry i did not seen there was nothing in the section actually (I just took the link from the toc). Anyway adding a transformation just mean implementing the component interface org.xwiki.rendering.transformation.Transformation either in java or groovy. You can look at http://platform.xwiki.org/xwiki/bin/view/DevGuide/RenderingMacroTutorial to see how to implement a simple component.
The only solution that I currently see is replacing the strings stored in thar property to sore XWiki links there. Automatically or manually.
Any other idea will be really welcome!
Thanks!
-- Ricardo Rodríguez CTO eBioTIC. Life Sciences, Data Modeling and Information Management Systems
_______________________________________________ devs mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/devs
-- Thomas Mortagne
On Oct 1, 2010, at 9:39 AM, Thomas Mortagne wrote:
On Thu, Sep 30, 2010 at 23:14, [Ricardo Rodriguez] eBioTIC. <[email protected]> wrote:
Hi Thomas,
Thomas Mortagne wrote:
Hi Ricardo,
The correct way to do that would be by implementing a rendering transformation. Transformations are called to modify the XDOM (document content in a Java object based model) before rendering it.
See http://code.xwiki.org/xwiki/bin/view/Modules/RenderingModule#HAddinganewTran...
I think I can, more intuitively that with real knowledge, understand what you are talking about.
The only problem is that there is one limitation currently: when you edit the a page with the WYSIWYG and save, the modified XDOM will be saved. We need http://jira.xwiki.org/jira/browse/XWIKI-3260 to fully support any possible modification to the XDOM (I'm currently working on it but it's a big work).
We don't use the WYSIWYG editor in concerned wiki: I'm working in a 1.3.x plain old wiki. It is currently being migrated to a 2.4.1 new farm. But even in this case I think I'm far from being able to implement this solution here. I see that we have not available information yet about "Adding a new Transformation".
Sorry i did not seen there was nothing in the section actually (I just took the link from the toc). Anyway adding a transformation just mean implementing the component interface org.xwiki.rendering.transformation.Transformation either in java or groovy.
You can look at http://platform.xwiki.org/xwiki/bin/view/DevGuide/RenderingMacroTutorial to see how to implement a simple component.
And here's a tutorial for it + the code Ricardo was looking for: http://code.xwiki.org/xwiki/bin/view/Modules/RenderingModule#HAddinganewTran... Enjoy! -Vincent
The only solution that I currently see is replacing the strings stored in thar property to sore XWiki links there. Automatically or manually.
Any other idea will be really welcome!
Thanks!
Vincent, Thomas, all, exciting! Vincent Massol wrote:
You can look at http://platform.xwiki.org/xwiki/bin/view/DevGuide/RenderingMacroTutorial to see how to implement a simple component.
And here's a tutorial for it + the code Ricardo was looking for: http://code.xwiki.org/xwiki/bin/view/Modules/RenderingModule#HAddinganewTran...
I bit far from my skills yet, but exciting! To the best of my understanding the transformation apply to any word being rendered independently of where it is stored, being in a property of XWiki class, being in the body of an XWiki document. Is that correct? What I don't understand is how do you set the scope of the transformation: will be it "applied" to all and every rendered "page"? Another doubt: in the General Architecture graphic, what is the relation between Other Transformations and Macro Transformations? What does this doted line mean? It's more than sure than I'm missing some obvious response! Sorry about that! I've had to solve the problem that initiated this thread in a 1.3.x installation by using a MySQL to do a "raw replace" of words in a XWiki class property. It was not an elegant solution, but it worked and allow me to use the result as a kind of "proof of concept" for the use case. Thanks for your work and your help! Ricardo -- Ricardo Rodríguez CTO eBioTIC. Life Sciences, Data Modeling and Information Management Systems
participants (3)
-
[Ricardo Rodriguez] eBioTIC. -
Thomas Mortagne -
Vincent Massol