Re: [Sugar-devel] [PATCH Browse] Error page SL #3500

2012-09-25 Thread Manuel Kaufmann
On Fri, Sep 21, 2012 at 8:32 PM, Martin Langhoff
martin.langh...@gmail.com wrote:
 So just put img src=file:///path/to/file . That saves a some of
 pointless CPU cycles, some RAM.
 This old man doesn't like inefficient code, even in small details.

I agree with you in this point but I would like to mention that this
feature (reading from file:// uri) has to be enabled because it is
not enabled by default[1] and this is because it was marked as a
security issue[2].

** Message: console message:  @0: Not allowed to load local resource:
file:///home/humitos/src/browse/browse.png

What do you think? Should I go for the file:// approach anyway?

[1] 
http://webkitgtk.org/reference/webkitgtk/stable/WebKitWebSettings.html#WebKitWebSettings--enable-file-access-from-file-uris
[2] http://en.wikipedia.org/wiki/File_URI_scheme

-- 
Kaufmann Manuel
Blog: http://humitos.wordpress.com/
Porfolio: http://fotos.mkaufmann.com.ar/
PyAr: http://www.python.com.ar/
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] [PATCH Browse] Error page SL #3500

2012-09-25 Thread Daniel Narvaez
The API description is not very clear and I didn't read the code. But
I guess it would allow remote web pages (http) to access local files?
If so you don't want to enable it :)

On 25 September 2012 18:43, Manuel Kaufmann humi...@gmail.com wrote:
 On Fri, Sep 21, 2012 at 8:32 PM, Martin Langhoff
 martin.langh...@gmail.com wrote:
 So just put img src=file:///path/to/file . That saves a some of
 pointless CPU cycles, some RAM.
 This old man doesn't like inefficient code, even in small details.

 I agree with you in this point but I would like to mention that this
 feature (reading from file:// uri) has to be enabled because it is
 not enabled by default[1] and this is because it was marked as a
 security issue[2].

 ** Message: console message:  @0: Not allowed to load local resource:
 file:///home/humitos/src/browse/browse.png

 What do you think? Should I go for the file:// approach anyway?

 [1] 
 http://webkitgtk.org/reference/webkitgtk/stable/WebKitWebSettings.html#WebKitWebSettings--enable-file-access-from-file-uris
 [2] http://en.wikipedia.org/wiki/File_URI_scheme

 --
 Kaufmann Manuel
 Blog: http://humitos.wordpress.com/
 Porfolio: http://fotos.mkaufmann.com.ar/
 PyAr: http://www.python.com.ar/
 ___
 Sugar-devel mailing list
 Sugar-devel@lists.sugarlabs.org
 http://lists.sugarlabs.org/listinfo/sugar-devel



-- 
Daniel Narvaez
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] [PATCH Browse] Error page SL #3500

2012-09-25 Thread Manuel Quiñones
2012/9/25 Daniel Narvaez dwnarv...@gmail.com:
 The API description is not very clear and I didn't read the code. But
 I guess it would allow remote web pages (http) to access local files?
 If so you don't want to enable it :)

Right, is a security issue and I think is good webkit doesn't allow it.

-- 
.. manuq ..
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] [PATCH Browse] Error page SL #3500

2012-09-25 Thread Martin Langhoff
On Tue, Sep 25, 2012 at 12:43 PM, Manuel Kaufmann humi...@gmail.com wrote:
 ** Message: console message:  @0: Not allowed to load local resource:
 file:///home/humitos/src/browse/browse.png

 What do you think? Should I go for the file:// approach anyway?

Hmmm, security, tiny performance tweak, what should I choose? ;-)

Good catch. I didn' t know it had been locked down this way.



m
-- 
 martin.langh...@gmail.com
 mar...@laptop.org -- Software Architect - OLPC
 - ask interesting questions
 - don't get distracted with shiny stuff  - working code first
 - http://wiki.laptop.org/go/User:Martinlanghoff
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] [PATCH Browse] Error page SL #3500

2012-09-21 Thread Manuel Kaufmann
On Wed, Sep 19, 2012 at 10:56 PM, Martin Langhoff
martin.langh...@gmail.com wrote:
 You have the file on-disk. It is inefficient to base64-encode it.

I'm not sure to understand what you are saying here. I'm not doing
this each time the function is called. Here, I just showed what I did
to get the base64 file encoded. I mean, I did this just once and I put
the result inside the HTML file. Epiphany does the same: it has
hardcoded the image inside the html. Is that a bad idea?


-- 
Kaufmann Manuel
Blog: http://humitos.wordpress.com/
Porfolio: http://fotos.mkaufmann.com.ar/
PyAr: http://www.python.com.ar/
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] [PATCH Browse] Error page SL #3500

2012-09-21 Thread Martin Langhoff
On Fri, Sep 21, 2012 at 6:56 PM, Manuel Kaufmann humi...@gmail.com wrote:
 I'm not sure to understand what you are saying here. I'm not doing
 this each time the function is called. Here, I just showed what I did
 to get the base64 file encoded. I mean, I did this just once and I put
 the result inside the HTML file. Epiphany does the same: it has
 hardcoded the image inside the html. Is that a bad idea?

Yeah, it's a wasteful approach. Probably doesn't matter much.

You have the file on disk, correct? So you have the file path. You
know that the webkit engine can read the file, too (it's on the same
machine, in a readable directory, etc).

So just put img src=file:///path/to/file . That saves a some of
pointless CPU cycles, some RAM.

This old man doesn't like inefficient code, even in small details.
Mostly because that means that when you code some that is hot (ie: is
exercised a lot, so is a potential bottleneck or memory hog if
inefficient) you have the right instincts.

I've spent many years fixing performance issues in large systems where
people coded without much care to efficiency (or error handling). So
there's a gnome in the back of my mind that kicks me if I write
careless code...

cheers,


m
-- 
 martin.langh...@gmail.com
 mar...@laptop.org -- Software Architect - OLPC
 - ask interesting questions
 - don't get distracted with shiny stuff  - working code first
 - http://wiki.laptop.org/go/User:Martinlanghoff
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] [PATCH Browse] Error page SL #3500

2012-09-21 Thread James Cameron
It is the conversion back to binary from base64 that kicks my alarms.
This will be done by the browser.  If there was a binary encoding, use
it rather than an external file.

For small images that would require another HTTP GET over the network,
that's where this technique can certainly save time.  That's what I
wanted it for.

-- 
James Cameron
http://quozl.linux.org.au/
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] [PATCH Browse] Error page SL #3500

2012-09-19 Thread Manuel Kaufmann
On Tue, Sep 18, 2012 at 10:58 PM, James Cameron qu...@laptop.org wrote:
 Neat.  What method did you use to convert the image?

Python... It is my best friend :)

 import base64
 base64.b64encode(open('browse-logo.png', 'r').read())

See you,

-- 
Kaufmann Manuel
Blog: http://humitos.wordpress.com/
Porfolio: http://fotos.mkaufmann.com.ar/
PyAr: http://www.python.com.ar/
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] [PATCH Browse] Error page SL #3500

2012-09-19 Thread James Cameron
On Wed, Sep 19, 2012 at 07:54:01AM -0300, Manuel Kaufmann wrote:
 On Tue, Sep 18, 2012 at 10:58 PM, James Cameron qu...@laptop.org wrote:
  Neat.  What method did you use to convert the image?
 
 Python... It is my best friend :)
 
  import base64
  base64.b64encode(open('browse-logo.png', 'r').read())
 
 See you,

Thanks.  In the end I used bash and the base64 program from debian coreutils.

echo a href=\$1\$1/a a href=\$1.hex\(hex)/apimg 
src=\data:image/png;base64,$(base64 $1.png)\p  index.html


-- 
James Cameron
http://quozl.linux.org.au/
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] [PATCH Browse] Error page SL #3500

2012-09-19 Thread Manuel Kaufmann
On Wed, Sep 19, 2012 at 8:38 AM, Manuel Kaufmann humi...@gmail.com wrote:
 Added an Error page with Sugar style that informs the users about
 the the page could not be loaded for any reason.

I had to add --no-validate to the git send-email command because
this patch has a line longer than 998 chars and it's not valid due a
SMTP limitation. I'm not sure if this patch will apply properly, if
not, please download it from SugarLabs' Trac:

 * 
http://bugs.sugarlabs.org/attachment/ticket/3500/0001-Error-page-SL-3500.2.patch

Thanks,

-- 
Kaufmann Manuel
Blog: http://humitos.wordpress.com/
Porfolio: http://fotos.mkaufmann.com.ar/
PyAr: http://www.python.com.ar/
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] [PATCH Browse] Error page SL #3500

2012-09-19 Thread Martin Langhoff
On Wed, Sep 19, 2012 at 6:54 AM, Manuel Kaufmann humi...@gmail.com wrote:
 On Tue, Sep 18, 2012 at 10:58 PM, James Cameron qu...@laptop.org wrote:
 Neat.  What method did you use to convert the image?

 Python... It is my best friend :)

 import base64
 base64.b64encode(open('browse-logo.png', 'r').read())

You have the file on-disk. It is inefficient to base64-encode it. Just
say img src=file://path-to-image. Keep in mind location changes
slighly between rpm-installed activities and those in ~/Activities .

cheers,



m
-- 
 martin.langh...@gmail.com
 mar...@laptop.org -- Software Architect - OLPC
 - ask interesting questions
 - don't get distracted with shiny stuff  - working code first
 - http://wiki.laptop.org/go/User:Martinlanghoff
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] [PATCH Browse] Error page SL #3500

2012-09-18 Thread Manuel Kaufmann
On Tue, Sep 18, 2012 at 1:55 PM, Manuel Kaufmann humi...@gmail.com wrote:
 This patch contains a HTML template (error_page.tmpl) that is used to
 generate the error page with the correct language.

Please, comments and suggestions are welcomed here. I didn't find an
existent way (inside Sugar) to translate html content, so I decide to
make it by myself.

I created a file called error_page.tmpl that contains the html
structure of the page with some placeholders to put the translated
strings (those placeholders are substituted with the % operator) and a
new html file is create: error_page.html with the correct strings
and url to try again. Then, this file is used to tell WekKit to load
that file as an uri:

  self.load_uri('file://' + DEFAULT_ERROR_PAGE)

That file is generated every time that the web page can't be reached
for any reason.

See you,

-- 
Kaufmann Manuel
Blog: http://humitos.wordpress.com/
Porfolio: http://fotos.mkaufmann.com.ar/
PyAr: http://www.python.com.ar/
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] [PATCH Browse] Error page SL #3500

2012-09-18 Thread Daniel Drake
On Tue, Sep 18, 2012 at 11:00 AM, Manuel Kaufmann humi...@gmail.com wrote:
 On Tue, Sep 18, 2012 at 1:55 PM, Manuel Kaufmann humi...@gmail.com wrote:
 This patch contains a HTML template (error_page.tmpl) that is used to
 generate the error page with the correct language.

 Please, comments and suggestions are welcomed here. I didn't find an
 existent way (inside Sugar) to translate html content, so I decide to
 make it by myself.

How does epiphany handle this?

Daniel
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] [PATCH Browse] Error page SL #3500

2012-09-18 Thread Manuel Quiñones
2012/9/18 Daniel Drake d...@laptop.org:
 On Tue, Sep 18, 2012 at 11:00 AM, Manuel Kaufmann humi...@gmail.com wrote:
 On Tue, Sep 18, 2012 at 1:55 PM, Manuel Kaufmann humi...@gmail.com wrote:
 This patch contains a HTML template (error_page.tmpl) that is used to
 generate the error page with the correct language.

 Please, comments and suggestions are welcomed here. I didn't find an
 existent way (inside Sugar) to translate html content, so I decide to
 make it by myself.

 How does epiphany handle this?

http://git.gnome.org/browse/epiphany/tree/embed/ephy-web-view.c#n2487

Humitos, you can compare with your solution and take ideas from there.
 I haven't tested your patch yet.

-- 
.. manuq ..
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] [PATCH Browse] Error page SL #3500

2012-09-18 Thread Daniel Narvaez
On 18 September 2012 19:33, Manuel Quiñones ma...@laptop.org wrote:
 2012/9/18 Daniel Drake d...@laptop.org:
 On Tue, Sep 18, 2012 at 11:00 AM, Manuel Kaufmann humi...@gmail.com wrote:
 On Tue, Sep 18, 2012 at 1:55 PM, Manuel Kaufmann humi...@gmail.com wrote:
 This patch contains a HTML template (error_page.tmpl) that is used to
 generate the error page with the correct language.

 Please, comments and suggestions are welcomed here. I didn't find an
 existent way (inside Sugar) to translate html content, so I decide to
 make it by myself.

 How does epiphany handle this?

 http://git.gnome.org/browse/epiphany/tree/embed/ephy-web-view.c#n2487

 Humitos, you can compare with your solution and take ideas from there.
  I haven't tested your patch yet.

Oh cool, load_alternate_string definitely looks like the way to go.
(it doesn't break history etc).
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] [PATCH Browse] Error page SL #3500

2012-09-18 Thread Manuel Kaufmann
On Tue, Sep 18, 2012 at 2:54 PM, Daniel Narvaez dwnarv...@gmail.com wrote:
 Oh cool, load_alternate_string definitely looks like the way to go.
 (it doesn't break history etc).

Yeah!

http://webkitgtk.org/reference/webkitgtk/stable/webkitgtk-webkitwebview.html#WebKitWebView--load-status

Thanks, I will patch my patch :) , I will send it again :)

-- 
Kaufmann Manuel
Blog: http://humitos.wordpress.com/
Porfolio: http://fotos.mkaufmann.com.ar/
PyAr: http://www.python.com.ar/
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] [PATCH Browse] Error page SL #3500

2012-09-18 Thread Manuel Kaufmann
On Tue, Sep 18, 2012 at 2:21 PM, Daniel Narvaez dwnarv...@gmail.com wrote:
 Perhaps you could use the data protocol to avoid the temporary file

 http://www.ietf.org/rfc/rfc2397.txt

I used this to put the images inside the html-string.

img id=browse-logo src=data:image/png;base64,iVBO (...) /img

Thanks!

-- 
Kaufmann Manuel
Blog: http://humitos.wordpress.com/
Porfolio: http://fotos.mkaufmann.com.ar/
PyAr: http://www.python.com.ar/
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel