I want to extend languages plugin to support all types of files. Because for
example images or videos can contain language specific content. As I can't add
any meta info to files like images the only way to do this is filename
parsing. So dir/en_file.ext is a resource with language: en and uuid: dir/file.ext.
Also I want this plugin to be able to sort files depending on language like
this:
content/
img/
en_pic.jpg
ru_pic.jpg
index.html
transforms into:
deploy/
en/
img/
pic.jpg
ru/
img/
pic.jpg
index.html
I have done that already, and now I want content_url('img/pic.jpg') to return
'en/img/pic.jpg' or 'ru/img/pic.jpg' or 'img/pic.jpg' depending on language of
currently processing file and presense of img/*pic.jpg files in content dir.
I looked at the code of urlcleaner plugin and I can't figure out how to get
currently processing resource from which content_url was called, is it possible?
How can I do that?
Thanks.
--
Grygoriy Fuchedzhy
> I looked at the code of urlcleaner plugin and I can't figure out how to get
> currently processing resource from which content_url was called, is it possible?
> How can I do that?
Inside content_url(), you can access self.site.content.resource_from_path().
--
Vincent Bernat ☯ http://www.luffy.cx
panic("Unable to find empty mailbox for aha1542.\n");
2.2.16 /usr/src/linux/drivers/scsi/aha1542.c
That will not help, I need to get language of currently processing file from
content_url function, I mean file that contains {{content_url('somefile')}}. I
don't know its path.
--
Grygoriy Fuchedzhy
>> Inside content_url(), you can access self.site.content.resource_from_path().
> That will not help, I need to get language of currently processing file from
> content_url function, I mean file that contains {{content_url('somefile')}}. I
> don't know its path.
Oh, OK, I misunderstood the question. Sorry, I don't know the answer.
--
Vincent Bernat ☯ http://www.luffy.cx
Use data arrays to avoid repetitive control sequences.
- The Elements of Programming Style (Kernighan & Plauger)
It seems that it is currently impossible to do so. Because
ext.templates.jinja.media_url and ext.templates.jinja.content_url calls
Site.media_url and Site.content_url functions.
I think that modifying ext.templates.jinja.*_url functions and moving media_url,
content_url functions from Site to Resource would be right thing to do as
Resource object in *_url functions may be more useful then Site object for
plugins which will decide to override them like urlcleaner plugin does.
Also it seems that its easy to do.
What do you think?
--
Grygoriy Fuchedzhy
content/
dir1/
dir2/
dir3/
index.html
photo1.jpg
photo2.jpg
It would be convenient to write something like this in index.html:
{{rel_media_url('photo1.jpg')}}
instead of
{{media_url('dir1/dir2/dir3/photo1.jpg')}}
--
Grygoriy Fuchedzhy
I think extra detailed example will explain it clearer.
dir1/
dir2/
1.html
other_page.html
dir3/
2.html
other_page.html
media/
dir1/
dir2/
pic.jpg
dir3/
pic.jpg
Both 1.html and 2.html contain rel_content_url('other_page.html') and
rel_media_url('pic.jpg') which expands to different things:
/dir1/dir2/other_page.html and /media/dir1/dir2/pic.jpg for 1.html
/dir1/dir3/other_page.html and /media/dir1/dir3/pic.jpg for 2.html
So rel_content_url(path) searches for path under current node, in this example
under /dir1/dir2/ or /dir1/dir3/. rel_media_url(path) searches for path under
corresponding node in media dir, in this example under /media/dir1/dir2/ of
/media/dir1/dir3/
On Sat, Jun 18, 2011 at 10:20:40PM -0700, Lakshmi wrote:
> Not sure if moving it to resource would solve the problem completely - what
> if you need the content url of a resource in language x.
So probably *_url functions need optional language parameter which defaults to
language of currently processing resource (resource from which *_url was
called).
However, I think moving *_url functions to resource would be useful
anyway. Because some other plugin may need currently processing resource to get
some other parameter.
--
Grygoriy Fuchedzhy
> --
> You received this message because you are subscribed to the Google Groups "Hyde" group.
> To post to this group, send email to hyde...@googlegroups.com.
> To unsubscribe from this group, send email to hyde-dev+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/hyde-dev?hl=en.
>