Monday, 9 November 2009

Java Code to Convert TWiki URLs to HTML Links

Few days ago I was looking for some code or tool with the ability to convert TWiki URLs to equivalent HTML URLs. (For the uninitiated, TWiki supports wide variety of URL formats in addition to the standard HTML format.). I spent almost 3 hours searching the web and trying out different code, Java classes etc., But at the end, none of the things that I found elsewhere seems to have the ability to convert almost all the TWiki URL formats that I'm trying to convert [to HTML]. So, I gave up looking for some readymade code and quickly wrote some Java code to resolve the issue that I'm trying to solve.



Now that I have the code, thought publishing it in my blog would help other people who are looking for something similar to this. So here it is. Download the source code from the following location.



        TwikiToHTML.java



The code assumes that the TWiki system is deployed on http://www.mandalika.com (a fake web site), and is capable of handling the following TWiki URL formats:





[[http://twiki.etclabs.com/pub/MDE/IsveSeeameRomanIvanovMeraJanuaryTechEval/MeraJanuaryScoping.pdf][MeraJanuaryScoping]]

[[Main.JNetX#April_22nd_2008_Whats_new_at_Sun][report]]

[[Main.RomanIvanovLDomsCheatSheet][Executiontrackingpage]]

[[MDE.IsveBravoJeffTaylorProgressApamaSolarisx64Pott][Link]]

[[IsveSeeameOrgadKimchiIGTvLabProcedures][docs]]

[[http://scweb.france.com/~fparient/pub/europa08solaris.odp][solarisprezo]]<br>[[http://scweb.france.com/~fparient/pub/europa08fx.pdf][fxbenchmark]]

[[OmalleyDataProject]]

[[http://twiki.etclabs.com/bin/view/Main/MySQL64NvPlan][Plan]],[[http://twiki.etclabs.com/bin/view/Main/IntegrateSFW][Detail]]

MDE.IsveAlphaBogdanVasiliuSynopsysVCSPerformanceOptimization

http://sidc.israel.com/~mk147459/Reports/ana.html

SofCheck

<a href="http://twiki.org">twiki</a>





Sample inputs and outputs:





% java TwikiToHTML



TWiki URL: NotSoPl@inY0uKnow

HTTP equivalent:



TWiki URL: ItIsJustplain

HTTP equivalent: <a href="http://www.mandalika.com/bin/view/Downloads/ItIsJustplain" target="_new">ItIsJustplain</a>



TWiki URL: GiriK@lyanaChakravarth!

HTTP equivalent:



TWiki URL: &ersand

HTTP equivalent:



TWiki URL: Harisha

HTTP equivalent:



TWiki URL: Janaki Lakshmi

HTTP equivalent:



TWiki URL: JanakiLakshmi

HTTP equivalent:



TWiki URL: [[OmalleyDataProject]]

HTTP equivalent: <a href="http://www.mandalika.com/bin/view/Downloads/OmalleyDataProject" target="_new">OmalleyDataProject</a>



TWiki URL: [[Giri][Mandalika]]

HTTP equivalent: <a href="http://www.mandalika.com/bin/view/Downloads/Giri" target="_new">Mandalika</a>



TWiki URL: [[Giri][Mandalika]], [[Kalyana][Chakravarthy]]

HTTP equivalent: <a href="http://www.mandalika.com/bin/view/Downloads/Giri" target="_new">Mandalika</a><BR><a href="http://www.mandalika.com/bin/view/Downloads/Kalyana" target="_new">Chakravarthy</a>



TWiki URL: [[Giri][Mandalika]], [[Kalyana][Chakravarthy]], [[IsveSeeameOrgadKimchiIGTvLabProcedures][docs]]

HTTP equivalent: <a href="http://www.mandalika.com/bin/view/Downloads/Giri" target="_new">Mandalika</a><BR><a href="http://www.mandalika.com/bin/view/Downloads/Kalyana" target="_new">Chakravarthy</a><BR><a href="http://www.mandalika.com/bin/view/Downloads/IsveSeeameOrgadKimchiIGTvLabProcedures" target="_new">docs</a>



TWiki URL: [[Giri][Mandalika]], [[Kalyana][Chakravarthy]], [[IsveSeeameOrgadKimchiIGTvLabProcedures][docs]], [[OmalleyDataProject][Omalley]]

HTTP equivalent: <a href="http://www.mandalika.com/bin/view/Downloads/Giri" target="_new">Mandalika</a><BR><a href="http://www.mandalika.com/bin/view/Downloads/Kalyana" target="_new">Chakravarthy</a><BR><a href="http://www.mandalika.com/bin/view/Downloads/IsveSeeameOrgadKimchiIGTvLabProcedures" target="_new">docs</a><BR><a href="http://www.mandalika.com/bin/view/Downloads/OmalleyDataProject" target="_new">Omalley</a>



TWiki URL: http://sidc.israel.etclabs.com/~mk147459/Reports/ana.html

HTTP equivalent: <a href="http://sidc.israel.etclabs.com/~mk147459/Reports/ana.html" target="_new">ana.html</a>



TWiki URL: http://sidc.israel.etclabs.com/~mk147459/Reports/ana.html,http://technopark02.blogspot.com

HTTP equivalent: <a href="http://sidc.israel.etclabs.com/~mk147459/Reports/ana.html" target="_new">ana.html</a><BR><a href="http://technopark02.blogspot.com" target="_new">technopark02.blogspot.com</a>



TWiki URL: [[http://www.mandalika.com/pub/MDE/IsveSeeameRomanIvanovMeraJanuaryTechEval/MeraJanuaryScoping.pdf][MeraJanuaryScoping]]

HTTP equivalent: <a href="http://www.mandalika.com/pub/MDE/IsveSeeameRomanIvanovMeraJanuaryTechEval/MeraJanuaryScoping.pdf" target="_new">MeraJanuaryScoping</a>



TWiki URL: [[http://www.mandalika.com/bin/view/Main/RomanIvanovRStyleSoftlabRSBankV6][execution details]] <BR> [[http://www.mandalika.com/bin/view/Main/OracleRAConLDom][OracleRAConLDom]]

HTTP equivalent: <a href="http://www.mandalika.com/bin/view/Main/RomanIvanovRStyleSoftlabRSBankV6" target="_new">execution details</a><BR><a href="http://www.mandalika.com/bin/view/Main/OracleRAConLDom" target="_new">OracleRAConLDom</a>



TWiki URL: [[http://www.mandalika.com/pub/ISVeProjects/ISVeProject20080213161851/Project20080213161851scoping.odt][scoping document]] , [[http://www.mandalika.com/pub/MDE/IsveSeeameRomanIvanovMeraJanuaryTechEval/MeraJanuaryScoping.pdf][MeraJanuaryScoping]] <BR> [[http://sidc.israel.etclabs.com/~ok134283/techeval/snooggie.html][techeval]] , [[http://sidc.israel.etclabs.com/~ok134283/techeval/servision.html][techeval]]

HTTP equivalent: <a href="http://www.mandalika.com/pub/ISVeProjects/ISVeProject20080213161851/Project20080213161851scoping.odt" target="_new">scoping document</a><BR><a href="http://www.mandalika.com/pub/MDE/IsveSeeameRomanIvanovMeraJanuaryTechEval/MeraJanuaryScoping.pdf" target="_new">MeraJanuaryScoping</a><BR><a href="http://sidc.israel.etclabs.com/~ok134283/techeval/snooggie.html" target="_new">techeval</a><BR><a href="http://sidc.israel.etclabs.com/~ok134283/techeval/servision.html" target="_new">techeval</a>



TWiki URL: [[Main.RomanIvanovLDomsCheatSheet][Execution tracking page]]

HTTP equivalent: <a href="http://www.mandalika.com/bin/view/Main/RomanIvanovLDomsCheatSheet" target="_new">Execution tracking page</a>



TWiki URL: [[MDE.IsveBravoJeffTaylorProgressApamaSolarisx64Pott][Link]]

HTTP equivalent: <a href="http://www.mandalika.com/bin/view/MDE/IsveBravoJeffTaylorProgressApamaSolarisx64Pott" target="_new">Link</a>



TWiki URL: [[Main.JNetX#April_22nd_2008_Whats_new_at_Sun][report]]

HTTP equivalent: <a href="http://www.mandalika.com/bin/view/Main/JNetX#April_22nd_2008_Whats_new_at_Sun" target="_new">report</a>



TWiki URL: [[Main.RomanIvanovLDomsCheatSheet][Execution tracking page]], [[MDE.IsveBravoJeffTaylorProgressApamaSolarisx64Pott][Link]] <BR> [[Main.JNetX#April_22nd_2008_Whats_new_at_Sun][report]]

HTTP equivalent: <a href="http://www.mandalika.com/bin/view/Main/RomanIvanovLDomsCheatSheet" target="_new">Execution tracking page</a><BR><a href="http://www.mandalika.com/bin/view/MDE/IsveBravoJeffTaylorProgressApamaSolarisx64Pott" target="_new">Link</a><BR><a href="http://www.mandalika.com/bin/view/Main/JNetX#April_22nd_2008_Whats_new_at_Sun" target="_new">report</a>



TWiki URL: [[http://www.mandalika.com/bin/view/MDE/IsveKylinPDSChinaVolumeISVWorldonline][World-Online]]

HTTP equivalent: <a href="http://www.mandalika.com/bin/view/MDE/IsveKylinPDSChinaVolumeISVWorldonline" target="_new">World-Online</a>



TWiki URL: [[ISVeProjects.IsveIndividualSummaryCarylTakvorian][Caryl Takvorian]] Tom Duell

HTTP equivalent: <a href="http://www.mandalika.com/bin/view/ISVeProjects/IsveIndividualSummaryCarylTakvorian" target="_new">Caryl Takvorian</a>



TWiki URL: [[http://www.mandalika.com/bin/view/MDE/IsveGANEIndividualSummaryAndrewWalton][Andrew Walton]]

HTTP equivalent: <a href="http://www.mandalika.com/bin/view/MDE/IsveGANEIndividualSummaryAndrewWalton" target="_new">Andrew Walton</a>



TWiki URL: [[http://etclabswebcollab.east.etclabs.com/gm/folder-1.11.1890618][Project Folder]]

HTTP equivalent: <a href="http://etclabswebcollab.east.etclabs.com/gm/folder-1.11.1890618" target="_new">Project Folder</a>



TWiki URL: [[http://etclabswebcollab.east.etclabs.com/gm/document-1.9.3262994/SUN%25E4%25B8%25BB%25E6%259C%25BAOCS%25E6%2580%25A7%25E8%2583%25BD%25E6%25B5%258B%25E8%25AF%2595%25E6%258A%25A5%25E5%2591%258A.doc][Cust. Report]], [[http://etclabswebcollab.east.etclabs.com/gm/document-1.9.3270163/ocs_perftune_t2000.odt][ISVE Report]]

HTTP equivalent: <a href="http://etclabswebcollab.east.etclabs.com/gm/document-1.9.3262994/SUN%25E4%25B8%25BB%25E6%259C%25BAOCS%25E6%2580%25A7%25E8%2583%25BD%25E6%25B5%258B%25E8%25AF%2595%25E6%258A%25A5%25E5%2591%258A.doc" target="_new">Cust. Report</a><BR><a href="http://etclabswebcollab.east.etclabs.com/gm/document-1.9.3270163/ocs_perftune_t2000.odt" target="_new">ISVE Report</a>



TWiki URL: MDE.IsveAlphaBogdanVasiliuSynopsysVCSPerformanceOptimization

HTTP equivalent: <a href="http://www.mandalika.com/bin/view/MDE/IsveAlphaBogdanVasiliuSynopsysVCSPerformanceOptimization" target="_new">IsveAlphaBogdanVasiliuSynopsysVCSPerformanceOptimization</a>



TWiki URL: [[Main.RomanIvanovLDomsCheatSheet]]

HTTP equivalent: <a href="http://www.mandalika.com/bin/view/Main/RomanIvanovLDomsCheatSheet" target="_new">RomanIvanovLDomsCheatSheet</a>



TWiki URL: MDE.PostgreSQLAutoTune <BR> [[Main.RomanIvanovLDomsCheatSheet]] , MDE.IsveAlphaBogdanVasiliuSynopsysVCSPerformanceOptimization

HTTP equivalent: <a href="http://www.mandalika.com/bin/view/Main/RomanIvanovLDomsCheatSheet" target="_new">RomanIvanovLDomsCheatSheet</a><BR><a href="http://www.mandalika.com/bin/view/MDE/PostgreSQLAutoTune" target="_new">PostgreSQLAutoTune</a><BR><a href="http://www.mandalika.com/bin/view/MDE/IsveAlphaBogdanVasiliuSynopsysVCSPerformanceOptimization" target="_new">IsveAlphaBogdanVasiliuSynopsysVCSPerformanceOptimization</a>



TWiki URL: [[http://www.mandalika.com/bin/view/ISVeProjects/IsveIndividualSummaryMohammedYousuf][Mohammed Yousuf]], Thiagarajan Chandrasekaran

HTTP equivalent: <a href="http://www.mandalika.com/bin/view/ISVeProjects/IsveIndividualSummaryMohammedYousuf" target="_new">Mohammed Yousuf</a>



TWiki URL: MDE.IsveDabuboirProsDamienCookeMyStaffMyStaffPostgreSQLAdoption [[http://twiki.etclabs/pub/MDE/IsveDabuboirProsDamienCookeMyStaffMyStaffPostgreSQLAdoption/MyStaff.html][Project Status]]

HTTP equivalent: <a href="http://twiki.etclabs/pub/MDE/IsveDabuboirProsDamienCookeMyStaffMyStaffPostgreSQLAdoption/MyStaff.html" target="_new">Project Status</a><BR><a href="http://www.mandalika.com/bin/view/MDE/IsveDabuboirProsDamienCookeMyStaffMyStaffPostgreSQLAdoption" target="_new">IsveDabuboirProsDamienCookeMyStaffMyStaffPostgreSQLAdoption</a>



TWiki URL: [[http://www.xxx.yyy]], <a href="http://www.xyz.com">xyz</a>, http://www.yahoo.com , <a href="www.giril.com">giri</a> , [[http://www.harisha.com][harisha]], <a href="www.etclabs.com">etclabs</a>

HTTP equivalent: <a href="http://www.xyz.com">xyz</a><BR><a href="www.giril.com">giri</a><BR><a href="www.etclabs.com">etclabs</a><BR><a href="http://www.xxx.yyy" target="_new">www.xxx.yyy<BR><a href="http://www.harisha.com" target="_new">harisha</a><BR><a href="http://www.yahoo.com" target="_new">www.yahoo.com</a>



TWiki URL: New link YousufCertificationofOracleRAConSolaris10u6Containers , old link http://blogs.etclabs.com/rac

HTTP equivalent: <a href="http://blogs.etclabs.com/rac" target="_new">rac</a>



TWiki URL: attached email.

HTTP equivalent:



TWiki URL: [[http://www.mandalika.com/bin/view/MDE/Caucho Caucho]] [[http://www.mandalika.com/bin/view/MDE/ISVeProject20070812164315 20070812164315]]

HTTP equivalent: <a href="http://www.mandalika.com/bin/view/MDE/Caucho" target="_new">Caucho</a><BR><a href="http://www.mandalika.com/bin/view/MDE/ISVeProject20070812164315" target="_new">20070812164315</a>



TWiki URL: http://download.sap.com/download.epd?context=40E2D9D5E00EEF7CB82813BD3F95797BAEB80527B36EC026E03386D659E4DE48

HTTP equivalent: <a href="http://download.sap.com/download.epd?context=40E2D9D5E00EEF7CB82813BD3F95797BAEB80527B36EC026E03386D659E4DE48" target="_new">download.epd?context=40E2D9D5E00E ... BAEB80527B36EC026E03386D659E4DE48</a>







Disclaimer:

This code is poorly documented, not perfect and most importantly may not even meet the minimum Java coding standards. However it does the intended job with minor modifications. Feel free to use, modify, reproduce or redistribute - but please do not come back complaining. I have no intention of fixing or improving this code.

No comments:

Post a Comment