Hi Duncan,
I think these patches must have got lost in the noise. I sent the
patches on 28, but to save you some trouble I am reattaching the files
again and pasting the message for reference.
Hello Duncan and Wout,
I fixed the issue where you can have ITEMS which may not be a tuple
(like in the case of web radio). So Duncan with the new patch you
should be able to use webserver without any modifications and
(hopefully) no crashes :-). Before adding child resources to twisted I
check to make sure the each item is a tuple. If you think users may
use lists, then we need to add that check as well. But I think we are
good to go for now.
As for images, I modified the code to scale images that are larger
than 800x600 to 200x200 (maintaining aspect ratio of course). Does
that answer your queries Wout? May be we can make the 800x600 value a
config variable. Or you guys decide what would be a proper value. This
change will speed up image downloads. Oh I also made sure that when
you click on the links the original image files are opened.
Yes I see that TV recordings work now. Excellent!
Regards,
Chandan
Please check and merge to svn.
Thanks
Chandan
On 12/28/06, Duncan Webb <[EMAIL PROTECTED]> wrote:
wout clymans wrote:
> Chandan Pitta wrote:
>> On 12/28/06, Duncan Webb <[EMAIL PROTECTED]> wrote:
>>
>>> Chandan Pitta wrote:
>> I think it is a good idea, but this has to be done only for
>> media=images. I will take a look at it.
>>
> If you need any help, let me know!
> Question i already have:
> do we need to resize all images or just the images that are larger than
> 800x600 (as example) and what will be the new default size?
The page with lots of small images would load nice and quickly if the
images were 200x200, these should be scaled and cached.
A full size image doesn't really need scaling but does need a max width
and max height for the browser, something in local_conf.py. Then it is
easy to keep the aspect ratio and fill either the width or height.
>>>
>>>
>>>> However I could not solve one problem, I am unable to click on
>>>> recorded TV programs from webpage. They are not active links. Is
>>>> anyone facing the same problem?
>>>>
>>> These didn't work in the original patch either.
>>>
>>>
>>
>> Hmm, one more item in my TODO list then.
>>
> This should be fixed in svn.
Works now but some of the fields in the popup window are not correct,
eg: Year and recorded time. Recorded time needs a time.localtime and a
time.strftime.
I must say the the freevo web interface is starting to look really good
now, possibly a killer feature. Many thanks to you both for this.
Duncan
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Freevo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-devel
Index: src/www/htdocs/library.rpy
===================================================================
--- src/www/htdocs/library.rpy (revision 8853)
+++ src/www/htdocs/library.rpy (working copy)
@@ -71,13 +71,27 @@
return FALSE
def convert_dir(self, dir_str):
+ '''
+ Converts a direct file location to a link that twisted can display.
+ If the file exists in one of the child resources of twisted, then
+ this method converts the file to a proper child resource link that
+ twiseted knows about.
+ If above case fails, the original file link will be returned.
+ '''
print 'convert_dir(self, dir_str=%r)' % (dir_str)
- for i in range(len(self.allowed_dirs)):
- val = self.allowed_dirs[i][1]
- if dir_str.startswith(val):
- return val.replace("/", "_") + dir_str[len(val):]
- return dir_str
+ child_res = ""
+ ### if the file starts with FREEVO_CACHEDIR return converted file
+ if dir_str.startswith(config.FREEVO_CACHEDIR):
+ child_res = config.FREEVO_CACHEDIR
+ else:
+ for i in range(len(self.allowed_dirs)):
+ val = self.allowed_dirs[i][1]
+ if dir_str.startswith(val):
+ child_res = val
+ break
+ return child_res.replace("/", "_") + dir_str[len(child_res):]
+
def get_suffixes (self, media):
print 'get_suffixes (self, media=\"%s\")' % (media)
suffixes = []
@@ -452,11 +466,11 @@
status = 'favorite'
### show image
if action_mediatype == "images":
+ size = (info['width'], info['height'])
+ (scaled_image, new_size) =
self.get_scaled_image_and_size(filepath, size)
image_link = self.convert_dir(filepath)
- size = (info['width'], info['height'])
- new_size = self.resize_image(image_link, size)
fv.tableCell('<a
href="javascript:openfoto(\''+image_link+'\','+str(size[0])+','+str(size[1])+')">'\
- +'<img src="'+image_link+'"
height="'+str(new_size[1])+'px" width="'+str(new_size[0])+'px" />'\
+ +'<img src="'+scaled_image+'"
height="'+str(new_size[1])+'px" width="'+str(new_size[0])+'px" />'\
+'<br />'+Unicode(title)+'</a>',
'class="'+status+'" colspan="1"')
### show movie
elif action_mediatype == "movies" or action_mediatype ==
"rectv":
@@ -593,8 +607,8 @@
new_height = 200
return [int(new_width), int(new_height + 0.5)]
- def resize_image_to_square(self, image, size):
- print 'resize_image_to_square(self, image=%s, size=%s)' % (image, size)
+ def get_fit_to_square_size(self, size):
+ print 'get_fit_to_square_size(self, size=%s)' % str(size)
### if aspect ratio > 1 then scale width to 200
new_size = [200, 200]
try:
@@ -609,6 +623,27 @@
pass
return new_size
+ def get_scaled_image_and_size(self, filepath, size):
+ '''
+ Returns the location of a scaled image and size of the scaled image
+ as a 2-tuple. Eg. ("/var/cache/freevo/test.jpg", [200, 150]).
+ The image will be scaled only if it larger than a certain prefixed
+ size. May be in future the prefixed image size could be a config
+ variable.
+ '''
+ threshold_size = [800, 600]
+ new_size = self.get_fit_to_square_size(size)
+ scaled_image_path = self.cache_dir + filepath.replace("/",
"_").replace(".", "_") + ".jpg"
+ if not os.path.exists(scaled_image_path):
+ if size[0] > threshold_size[0] or size[1] > threshold_size[1]:
+ image = imlib2.open(filepath)
+ new_image = image.scale(new_size)
+ new_image.save(scaled_image_path)
+ else:
+ scaled_image_path = filepath
+ scaled_image_path = self.convert_dir(scaled_image_path)
+ return (scaled_image_path, new_size)
+
def get_fxd_title(self, fxd_file):
fxd_info = ""
parser = util.fxdparser.FXD(fxd_file)
Index: src/helpers/webserver.py
===================================================================
--- src/helpers/webserver.py (revision 8853)
+++ src/helpers/webserver.py (working copy)
@@ -92,14 +92,21 @@
root = static.File(docRoot)
root.processors = { '.rpy': script.ResourceScript, }
- for (item, dir_str) in config.VIDEO_ITEMS:
- root.putChild(dir_str.replace("/", "_"), static.File(dir_str))
- for (item, dir_str) in config.AUDIO_ITEMS:
- root.putChild(dir_str.replace("/", "_"), static.File(dir_str))
- for (item, dir_str) in config.IMAGE_ITEMS:
- root.putChild(dir_str.replace("/", "_"), static.File(dir_str))
+ for item in config.VIDEO_ITEMS:
+ if isinstance(item, tuple) and len(item) == 2:
+ dir_str = item[1]
+ root.putChild(dir_str.replace("/", "_"), static.File(dir_str))
+ for item in config.AUDIO_ITEMS:
+ if isinstance(item, tuple) and len(item) == 2:
+ dir_str = item[1]
+ root.putChild(dir_str.replace("/", "_"), static.File(dir_str))
+ for item in config.IMAGE_ITEMS:
+ if isinstance(item, tuple) and len(item) == 2:
+ dir_str = item[1]
+ root.putChild(dir_str.replace("/", "_"), static.File(dir_str))
root.putChild(config.TV_RECORD_DIR.replace("/", "_"),
static.File(config.TV_RECORD_DIR))
-
+ root.putChild(config.FREEVO_CACHEDIR.replace("/", "_"),
static.File(config.FREEVO_CACHEDIR))
+
root.putChild('vhost', vhost.VHostMonsterResource())
rewriter = rewrite.RewriterResource(root, helpimagesrewrite)
if (config.DEBUG == 0):
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Freevo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freevo-devel