wikiotics/creoleparser

Allow to use a distinct base URL for <img src>

GoogleCodeExporter opened this issue · 6 comments

Hello,

I started using creoleparser some days ago, and I needed to use a
distinct base URL for wiki page links than for images. For instance:
   <a href="/mysite/pages/apage">a page</a>
   <img src="/mysite/files/image.jpg"/>

This is often needed, because wiki pages and images require a completely
different processing:
- wiki pages are generated using the creoleparser;
- images are served statically or with binary modifications such as
 resizing.
Thus, one may want to separate their URLs in different “namespaces”, to
allow the wiki engine to run the appropriate code.

So here is a patch that implements such a distinction, by adding two
arguments wiki_files_base_url and wiki_files_path_func to
creole10_base(). For compatibility, when they are not provided they
default to wiki_links_base_url and wiki_links_path_func.

I hope this patch will be useful.

Regards,

--
Tanguy Ortolo

Original issue reported on code.google.com by stephen....@gmail.com on 14 Jun 2010 at 9:46

Attachments:

This is interesting: I've been needing something like this, but I'm not sure if 
the proposed patch is general enough for my needs.  Instead of having a 
different prefix, I'd actually like to get a suffix appended to the path.  For 
example, I'd like an image "Image.jpg" included in the wiki to map to <img 
src="wiki-path/Image.jpg&view=image"/> or <img 
src="wiki-path/Image.jpg&view=image&max_size=500x500"/>.  Maybe a more generic 
mechanism for filtering an image path would be the best way?

Original comment by j...@garrison.cc on 15 Jun 2010 at 5:23

A more generic way would be to supply a unique path_func when instantiating the 
ImageElement class. Or make the optional wiki_links_path_func aware of the type 
of link by adding a optional parameter (e.g., isimage).


Original comment by stephen....@gmail.com on 15 Jun 2010 at 11:41

What I'm thinking now is, rather than add more parameters to create_dialect(), 
to allow some existing parameters to accept a list. If a list is supplied, the 
first element would be used for links and the second for images. When a 
non-list is supplied, the behavior would be as it is now. 

Original comment by stephen....@gmail.com on 15 Jun 2010 at 1:18

Regarding comment #1, nevermind.  I looked at the patch again and realized it 
is general enough to suit my needs perfectly.

Original comment by j...@garrison.cc on 15 Jun 2010 at 4:06

I decided to implement this by overloading the existing parameters rather than 
creating new ones. This saves inventing more nomenclature and is still pretty 
intuitive imo.

Original comment by stephen....@gmail.com on 17 Jun 2010 at 4:51

  • Changed state: Fixed
http://code.google.com/p/creoleparser/source/detail?r=203

Original comment by stephen....@gmail.com on 17 Jun 2010 at 4:54