Re: [xwiki-users] Images in links
Hi Lewis, On Mar 14, 2009, at 9:18 AM, Lewis Denizen wrote: Thanks Vincent (and sorry for the late reply!) - inlined my reply: On Sun, Mar 1, 2009 at 4:41 AM, Vincent Massol vinc...@massol.net wrote: Same here, the image syntax doesn't support relative paths. I guess we could improve the link and image syntax to support paths starting with / and then consider them as paths relative to the context root. However it wouldn't work for relative paths such as ../../some/path. Right now we could easily add a XWiki API to get an absolute URL from a relative one. Note that you can still use the old syntax using the {{velocity}} {{html}}a href=..{{/html}}{{/velocity}} but that's not very nice and it would be nice if it could be written using the new syntax but was made to avoid using HTML... :) Would recognizing references starting with / a good solution for you? What do others think? I guess checking for / at the beginning would work, or maybe some way of flagging it as a relative path would be even better (maybe something like [[image:img.png||relative=true]]). Not sure how feasible this is, or if it would make sense to do so... See the vote I've sent on this: http://tinyurl.com/c737ve This won't be in 1.8 final but will be in 1.9M1. This is not correct. The html macro must contain HTML. This is not the case in your example. You need this: {{velocity}} * this works - [[image: http://localhost:8080/$xwiki.getSkinFile('icons/black-file.pnghttp://localhost:8080/$xwiki.getSkinFile%28%27icons/black-file.png ') ]] * this doesn't work - {{html}}img src=$xwiki.getSkinFile('icons/ black-file.png')/{{/html}} {{/velocity}} It seems that the HTML Macro's final filter parses this last test case as 1 BulletedListBlock and 1 XMLBlock, but I'm not sure if this the expected behavior. If this is the expected behavior, the more need to get the [[image:]] tag working... Thanks again for the great job! Hm... kind of makes sense but, what does the wiki=true flag do, then...? It means that HTML element content can contain wiki syntax as in: elementtext with wiki syntax here/element It's also a bit problematic for me since I have the following (posting everything, since this might be useful for others as well): -- {{velocity}}#set($serverClassFullName = Server.ServerClass){{/ velocity}} {{velocity}}#set($serverDocumentSQL = select distinct doc from Document as doc, doc.object(${serverClassFullName}) as obj where obj.name '${serverClassFullName}Template'){{/velocity}} {{velocity}}#set($serverDocuments = $xwiki.queryManager.xwql($serverDocumentSQL).execute()){{/velocity}} There are currently {{velocity}}**${serverDocuments.size()}**{{/ velocity}} document(s) containing Server objects. {{velocity}} Why do you repeat the velocity macro several times? You can wrap all the macros into one single velocity macro. {{html}} This one can also be in the top level velocity macro. table id=serverList class=grid sortable filterable doOddEven tr class=sortHeader th class=selectFilterSpace/th thClass/th thServer/th th class=unsortable noFilterLink/th /tr Note that in the future we've planned to add filterable/sortable tables in the new table syntax directly. #foreach($serverDocument in $serverDocuments) #set($serverObjectSQL = select obj.hostname, obj.prettyName, obj.urlRoot, obj.hostName from Document as doc, doc.object(${serverClassFullName}) as obj where doc.id = ${serverDocument.id}) #set($serverObjects = $xwiki.queryManager.xwql($serverObjectSQL).execute()) tr td${serverDocument.space}/td td${serverDocument.name}/td td #foreach($serverObject in $serverObjects) #set($server = $listtool.get($serverObject, 0)) #set($serverPrettyName = $listtool.get($serverObject , 1)) #set($serverURLRoot = $listtool.get($serverObject, 2)) #set($serverHostName = $listtool.get($serverObject , 3)) * ${serverPrettyName} - a href=${serverURLRoot}img src=$xwiki.getSkinFile('icons/black-file.png') alt=Root URL title=Root URL //a a href=${serverHostName}img src=$xwiki.getSkinFile('icons/black-rss-mini.png') alt=Host Name title=Host Name //a #end /td td[[${serverDocument.name}${serverDocument}]]/td /tr #end /table {{/html}} {{/velocity}} This looks good. -- This will list out all the properties of Server.ServerClass for all documents that contain a Server.ServerClass object in it. I got this to work by replacing the XWiki list syntax with: td ul #foreach($serverObject in $serverObjects) #set($server = $listtool.get($serverObject, 0)) #set($serverPrettyName = $listtool.get($serverObject , 1)) #set($serverURLRoot = $listtool.get($serverObject, 2))
[xwiki-users] Images in links
Hi xwiki-users, In XWiki Syntax 1.0, I was able to do something like this: a href=${documentURLRoot}img src=$xwiki.getSkinFile('icons/black-file.png') alt=Root URL title=Root URL //a This would render an icon from the current skin as a link. I understand that in XWiki Syntax 2.0, there's a new form of this available: [[image:space.w...@picture.png${documentURLRoot}]] This works if the image exists in your document as an attachment, but doesn't work when the image link is relative to your web context: [[image:$xwiki.getSkinFile('icons/black-file.png')${documentURLRoot}]] This renders as the following: a href=http://www.google.com/; img alt=/xwiki/skins/albatross/icons/black%2Dfile.png class=wikimodel-freestanding src=/xwiki/bin/download/XWiki/WebHome/%2Fxwiki%2Fskins%2Falbatross%2Ficons%2Fblack%252Dfile.png/ /a which is not what I expected... One workaround is to put an explicit http://server-name:port/; before the $xwiki.getSkin() call, but that ties the wiki to the server's address/port. One other interesting thing I found out was that: {{velocity}} {{html wiki=true}} * this works - [[image: http://localhost:8080/$xwiki.getSkinFile('icons/black-file.png')]] * this doesn't work - img src=$xwiki.getSkinFile('icons/black-file.png') {{/html}} {{/velocity}} It seems that the HTML Macro's final filter parses this last test case as 1 BulletedListBlock and 1 XMLBlock, but I'm not sure if this the expected behavior. If this is the expected behavior, the more need to get the [[image:]] tag working... Thanks again for the great job! ___ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
Re: [xwiki-users] Images in links
Hi Lewis, On Feb 28, 2009, at 7:14 PM, Lewis Denizen wrote: Hi xwiki-users, In XWiki Syntax 1.0, I was able to do something like this: a href=${documentURLRoot}img src=$xwiki.getSkinFile('icons/black-file.png') alt=Root URL title=Root URL //a This would render an icon from the current skin as a link. I understand that in XWiki Syntax 2.0, there's a new form of this available: [[image:space.w...@picture.png${documentURLRoot}]] Since $documentURLRoot is velocity syntax you'd need to wrap it in {{velocity}} macro but indeed it'll still not work for the moment since the link syntax supports either absolute URL or document references but not relative paths. So right now you'd need to make documentURLRoot absolute. There are some xwiki api to do so. This works if the image exists in your document as an attachment, but doesn't work when the image link is relative to your web context: [[image:$xwiki.getSkinFile('icons/black-file.png')$ {documentURLRoot}]] Same here, the image syntax doesn't support relative paths. I guess we could improve the link and image syntax to support paths starting with / and then consider them as paths relative to the context root. However it wouldn't work for relative paths such as ../../some/path. Right now we could easily add a XWiki API to get an absolute URL from a relative one. Note that you can still use the old syntax using the {{velocity}} {{html}}a href=..{{/html}}{{/velocity}} but that's not very nice and it would be nice if it could be written using the new syntax but was made to avoid using HTML... :) Would recognizing references starting with / a good solution for you? What do others think? This renders as the following: a href=http://www.google.com/; img alt=/xwiki/skins/albatross/icons/black%2Dfile.png class=wikimodel-freestanding src=/xwiki/bin/download/XWiki/WebHome/%2Fxwiki%2Fskins%2Falbatross %2Ficons%2Fblack%252Dfile.png/ /a which is not what I expected... One workaround is to put an explicit http://server-name:port/; before the $xwiki.getSkin() call, but that ties the wiki to the server's address/port. One other interesting thing I found out was that: {{velocity}} {{html wiki=true}} BTW this is the default I think so no need to specify wiki=true AFAIR. * this works - [[image: http://localhost:8080/$xwiki.getSkinFile('icons/black-file.png')]] * this doesn't work - img src=$xwiki.getSkinFile('icons/black-file.png') {{/html}} {{/velocity}} This is not correct. The html macro must contain HTML. This is not the case in your example. You need this: {{velocity}} * this works - [[image:http://localhost:8080/$xwiki.getSkinFile('icons/black-file.png') ]] * this doesn't work - {{html}}img src=$xwiki.getSkinFile('icons/ black-file.png')/{{/html}} {{/velocity}} It seems that the HTML Macro's final filter parses this last test case as 1 BulletedListBlock and 1 XMLBlock, but I'm not sure if this the expected behavior. If this is the expected behavior, the more need to get the [[image:]] tag working... Thanks again for the great job! Thanks -Vincent http://xwiki.com http://xwiki.org http://massol.net ___ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users