Structured Text with Images -> enabled!
hi folks, I just figured out how to use images in strucured-text with syntax like "alternative text":img:image.jpg Because i never read how to do that anywhere (nor on zope.org!) i feel free to tell you that simple modification to the zope source. Goto $ZOPE/lib/python/StructurdText/ folder. You see some files that contain "WithImages" in their names. As i saw that i simply tried to tell the StructuredText.py file to use them, and not the others - and it wooorked. well now the only thing todo in StructuredText.py is: change source (around line 90 ) to: import HTMLWithImages, DocumentWithImages, ClassicDocumentClass and in line 96/97 to: Document = DocumentWithImages.DocumentWithImages() HTMLNG = HTMLWithImages.HTMLWithImages() thats it. so....am i the only human beeing who figured that out? i'm shure i'm not, but why did no one of the "big" zope freaks/programmers advised us? (im rellay _not_ into python. i can "just" read :-) and know some basic programming structures..) ....or is that the way of zope => see and try !?? ;-) (i'm rather new to zope/python...) a truthful puzzled but happy oli keller P.S.: that worked with zope 2.4.2 and 2.5.0a2 P.P.S.: i want to extend the :img syntax to accept "parameters" to adjust the alignment of the image. any advise/suggestion what syntax to use? what about just implementing :img-right and :img-center? thats probably not the way the structured text authors would go...wouldn't they?
On Thursday 08 November 2001 06:18, Oliver Keller wrote:
hi folks,
I just figured out how to use images in strucured-text with syntax like "alternative text":img:image.jpg Because i never read how to do that anywhere (nor on zope.org!)
Did you check the mail archives? I've created an external method quite a while ago: http://www.zope.org/Members/Barabbas/stx_to_html (you can also find it under "http://www.zope.org/Products")
i feel free to tell you that simple modification to the zope source.
Goto $ZOPE/lib/python/StructurdText/ folder. You see some files that contain "WithImages" in their names. As i saw that i simply tried to tell the StructuredText.py file to use them, and not the others - and it wooorked. well now the only thing todo in StructuredText.py is:
change source (around line 90 ) to: import HTMLWithImages, DocumentWithImages, ClassicDocumentClass
and in line 96/97 to: Document = DocumentWithImages.DocumentWithImages() HTMLNG = HTMLWithImages.HTMLWithImages()
thats it. so....am i the only human beeing who figured that out? i'm shure i'm not, but why did no one of the "big" zope freaks/programmers advised us? (im rellay _not_ into python. i can "just" read :-) and know some basic programming structures..)
As you'll see in the external method (there's a helper class in there), the trick is to choose the right base class(es). What if I need "structured text with images" in one folder, and "structured text without images" in another? HTMLWithImages gives you what you want, so just create a new class that inherits from HTMLWithImages - details in stx_to_html.py
....or is that the way of zope => see and try !?? ;-)
:-) In general, if you don't know what you're doing, you should leave "core" files just as they are.
(i'm rather new to zope/python...)
a truthful puzzled but happy oli keller
P.S.: that worked with zope 2.4.2 and 2.5.0a2
P.P.S.: i want to extend the :img syntax to accept "parameters" to adjust the alignment of the image. any advise/suggestion what syntax to use? what about just implementing :img-right and :img-center? thats probably not the way the structured text authors would go...wouldn't they?
Mmmh. In the class that inherited all the stuff you needed to include images, you can add new or override existing functions to provide whatever you need on top of that. Did you take a look at http://dev.zope.org/Members/jim/StructuredTextWiki ? hth, Danny
_______________________________________________ Zope maillist - Zope@zope.org http://lists.zope.org/mailman/listinfo/zope ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope-dev )
Danny William Adair wrote:
On Thursday 08 November 2001 06:18, Oliver Keller wrote:
Did you check the mail archives? I've created an external method quite a while ago: http://www.zope.org/Members/Barabbas/stx_to_html
yes! but it did not work. i got some strange errors (i mailed them to the list, related to an older structured text topic of this list, but no one answered)
thats it. so....am i the only human beeing who figured that out? i'm shure i'm not, but why did no one of the "big" zope freaks/programmers advised us? (im rellay _not_ into python. i can "just" read :-) and know some basic programming structures..)
As you'll see in the external method (there's a helper class in there), the trick is to choose the right base class(es). What if I need "structured text with images" in one folder, and "structured text without images" in another? HTMLWithImages gives you what you want, so just create a new class that inherits from HTMLWithImages - details in stx_to_html.py
hm. but the *WithImages thinges are allready inherited.(from HTML- and DocumentClass)why don't use them directly? btw. i really just know the basics of python - so inheriting would be quite advanced i think :-)
In general, if you don't know what you're doing, you should leave "core" files just as they are.
you can't say, i didn't knew what i did, in general. i've just chosen the simpliest way. but i understand what you mean. btw. before this modification to StructuredText.py i played around with the TreeTag.py to extend the dtml-tree functionality allowing to expand a single node by klicking a folder related text-link and not _only_ the +/- icons.(and added customizable +/- icons) therefore i really had to work with the corefile due to the "internal" tree-e variable restrictions.... maybe i will post this mod. in the future.(its really dirty, but hey... it works also!:-) [see left frame on www.kvstarnberg.brk.de ]
Did you take a look at http://dev.zope.org/Members/jim/StructuredTextWiki ?
oh yes. many times before.(many people suggested to look there) and i must say i really felt beeing left alone on that Wiki pages. i definitifly found nothing usefull especially about images in stx. and i don't like the Zwiki stuff itself either! thanks anyways oli
On Sunday 11 November 2001 12:51, Oliver Keller wrote:
Danny William Adair wrote:
On Thursday 08 November 2001 06:18, Oliver Keller wrote:
Did you check the mail archives? I've created an external method quite a while ago: http://www.zope.org/Members/Barabbas/stx_to_html
yes! but it did not work. i got some strange errors (i mailed them to the list, related to an older structured text topic of this list, but no one answered)
Most of the times, if a new thread starts, and it's not interesting for me, I don't follow it any further. Of course this way I miss out on some stuff. Sorry.
thats it. so....am i the only human beeing who figured that out? i'm shure i'm not, but why did no one of the "big" zope freaks/programmers advised us? (im rellay _not_ into python. i can "just" read :-) and know some basic programming structures..)
As you'll see in the external method (there's a helper class in there), the trick is to choose the right base class(es). What if I need "structured text with images" in one folder, and "structured text without images" in another? HTMLWithImages gives you what you want, so just create a new class that inherits from HTMLWithImages - details in stx_to_html.py
hm. but the *WithImages thinges are allready inherited.(from HTML- and DocumentClass)why don't use them directly? btw. i really just know the basics of python - so inheriting would be quite advanced i think :-)
See my comment in the .py-file: ------------------------------------------------------------- # Technical Note: # This function uses two helper classes to override the standard behavior # of the preinstalled ...WithImages classes of the StructuredText package. # # - The current Zope 2.4 (and 2.4.1b1) implementation has a little bug in # StructuredText.DocumentWithImages.doc_img() that prevents it from accepting # images with underscores in their URL. This has been fixed. # # - The current Zope 2.4 (and 2.4.1b1) implementation of # StructuredText.HTMLWithImages.document() will add <html> and <body> tags # to your input. I expect this to be unwanted by most users, since # StructuredText.HTMLClass.document() - the standard rendering without images - # doesn't do that. stx_to_html will only render "the inner part", nothing # that you didn't have in your stx input will be added. ------------------------------------------------------------- I'm not sure, but I think both problems have been solved by today. If that is the case: yes, you could use them directly.
In general, if you don't know what you're doing, you should leave "core" files just as they are.
you can't say, i didn't knew what i did, in general. i've just chosen the simpliest way. but i understand what you mean. btw. before this modification to StructuredText.py i played around with the TreeTag.py to extend the dtml-tree functionality allowing to expand a single node by klicking a folder related text-link and not _only_ the +/- icons.(and added customizable +/- icons) therefore i really had to work with the corefile due to the "internal" tree-e variable restrictions.... maybe i will post this mod. in the future.(its really dirty, but hey... it works also!:-) [see left frame on www.kvstarnberg.brk.de ]
There are so many patches to the tree tag (even I made one for urlparam_expr - had to) that I sometimes think this thing should be taken out of the core, and put into the Products directory as an external - though pre-installed - product (like SiteAccess). The ZMI pages rely on it, but most websites don't use the tree tag themselves. Putting it there would make it easier and clearer for people to exchange it with more current or more powerful versions. Plus they're not scared of messing with core files. Well, there's a new component structure underway, and these thoughts might become obsolete. I hope they will.
Did you take a look at http://dev.zope.org/Members/jim/StructuredTextWiki ?
oh yes. many times before.(many people suggested to look there) and i must say i really felt beeing left alone on that Wiki pages. i definitifly found nothing usefull especially about images in stx. and i don't like the Zwiki stuff itself either!
ZWiki: De gustibus non est disputandum. Love it or loath it, you won't get rid of it. Content: You didn't find anything useful? LOL Images are an extension to the classic stx (see: http://www.zope.org/Documentation/Articles/STX --- Advanced Usage) If you're off to customizing the document processor, how did you like "http://www.zope.org/Members/jim/StructuredTextWiki/CustomizingTheDocumentPro..." ? For ready-to-use recipes, I would always start in the mailing list archives. Btw, have you seen http://structuredtext.sourceforge.net, especially the "directives" and "substitution" feature? Yes, this is not (yet) Zope "out-of-the-box" stuff...
thanks anyways oli
Cheers, Danny
Danny William Adair wrote:
See my comment in the .py-file:
------------------------------------------------------------- # Technical Note: # This function uses two helper classes to override the standard behavior # of the preinstalled ...WithImages classes of the StructuredText package. # # - The current Zope 2.4 (and 2.4.1b1) implementation has a little bug in # StructuredText.DocumentWithImages.doc_img() that prevents it from accepting # images with underscores in their URL. This has been fixed. # # - The current Zope 2.4 (and 2.4.1b1) implementation of # StructuredText.HTMLWithImages.document() will add <html> and <body> tags # to your input. I expect this to be unwanted by most users, since # StructuredText.HTMLClass.document() - the standard rendering without images - # doesn't do that. stx_to_html will only render "the inner part", nothing # that you didn't have in your stx input will be added. -------------------------------------------------------------
I'm not sure, but I think both problems have been solved by today. If that is the case: yes, you could use them directly.
nope. :-) DocumentWithImages adds the great <html> <body> tag "feature" again. but i just commented it out. the underscore was no big problem either. furthermore i now added aligment feature with that syntax :img-<align>: with <align> can be on of the possible align="" prameters of an <img> tag and is "passed trough".
There are so many patches to the tree tag (even I made one for urlparam_expr - had to) that I sometimes think this thing should be taken out of the core, and put into the Products directory as an external - though pre-installed - product (like SiteAccess). The ZMI pages rely on it, but most websites don't use the tree tag themselves. Putting it there would make it easier and clearer for people to exchange it with more current or more powerful versions. Plus they're not scared of messing with core files.
i'm not scared :-) but yes, that would probably be the best solution.
Did you take a look at http://dev.zope.org/Members/jim/StructuredTextWiki ?
oh yes. many times before.(many people suggested to look there) and i must say i really felt beeing left alone on that Wiki pages. i definitifly found nothing usefull especially about images in stx. and i don't like the Zwiki stuff itself either!
ZWiki: De gustibus non est disputandum. Love it or loath it, you won't get rid of it.
well and i think i hate it.
Content: You didn't find anything useful? LOL
Images are an extension to the classic stx (see: http://www.zope.org/Documentation/Articles/STX --- Advanced Usage)
so what ? where is the info? BTW. can you give me a page where the behaviour of "qwertz":img:URL1:URL2 rendered in HTML is explained? or better for what it was for? i can't find the page again where i've read it. the html output was somthing link: <a name"qwertt"></a> <b> Figure </b> URL2 <img src="URL1"> as it made IMHO no sense, i deletet / commented out the recent lines.
If you're off to customizing the document processor, how did you like "http://www.zope.org/Members/jim/StructuredTextWiki/CustomizingTheDocumentPro..." ?
yes, i've visited that before, too. and,ok, that was quite informational, but not much more than i figured out by myself looking at the *WithImgaes files.
For ready-to-use recipes, I would always start in the mailing list archives.
Btw, have you seen http://structuredtext.sourceforge.net, especially the "directives" and "substitution" feature? Yes, this is not (yet) Zope "out-of-the-box" stuff...
oh you mean reStructuredText there ? yes, of course :-) but i had no clue how to use that with zope. as there where no examples, etc. thank you again for your suggestions, oli
either. furthermore i now added aligment feature with that syntax
:img-<align>: with <align> can be on of the possible align="" prameters
of an <img> tag and is "passed trough".
There you go. :-)
BTW. can you give me a page where the behaviour of "qwertz":img:URL1:URL2 rendered in HTML is explained? or better for what it was for? i can't find the page again where i've read it. the html output was somthing link: <a name"qwertt"></a> <b> Figure </b> URL2 <img src="URL1"> as it made IMHO no sense, i deletet / commented out the recent lines.
That's to display an image with a little description underneath. Didn't work right for me, though. With stx in general, I think Andreas Jung is "the man" (TM). He's maintaining it, and knows what all those things are good for and how they work. hth, Danny
participants (2)
-
Danny William Adair -
Oliver Keller