Can't get the styles, what I'm doing wrong?

Forums » Dev.Opera » Archived Opera Unite Development Discussions

You need to be logged in to post in the forums. If you do not have an account, please sign up first.

Go to last post

12. May 2010, 19:04:44

Sicofonia

Posts: 10

Can't get the styles, what I'm doing wrong?

Hello,

I'm kind of embarrassed with myself for asking this but... the thing is that I cannot get the styles from a .css file to be displayed in my main page.

I have a file called "index.css" under the "public_html" folder: "public_html/index.css"

Then, this is my "templates/index.html"
<head>
<link href="../public_html/index.css" rel="stylesheet" type="text/css" />
<link href="index.css" rel="stylesheet" type="text/css" />
<meta charset="utf-8"/>
<title>Hello World</title>
</head>

I didn't know if I was doing the right thing by refering to href="../public_html/index.css" so I added the other link as well.


And finally, the "server.js" content:
Yusef.addSectionListener("_index", function( connection )
{

var tmpl = new Markuper( 'templates/index.html' );
var data = {
title : connection.request.path,
servicePath : opera.io.webserver.currentServicePath,
content : "Hello World",
styles : [{href: 'index.css'},{href: 'public_html/index.css'}]
}
tmpl.parse( data );
return tmpl.html();

}, {ui: true}
);


The page is displayed correctly, but the styles I had on my stylesheet are not being loaded, not matter where I place my "index.css" or the path used in the "tag".

So... what Am I doing wrong here??

Thanks in advance.

13. May 2010, 12:17:03

JeroenH

Posts: 434

styles : [{href: 'index.css'}]
is correct and should work.

Everything under /public_html/ inside your application will be mapped from / in the URI space. This means /public_html/styles/index.css will become http://[computername].[username].operaunite.com/[applicationname]/styles/index.css for example.

There's one thing that could cause these problems. If there is code listening for "_request", by doing a
opera.io.webserver.addEventListener('_request', generalhandler, false);
call, Opera will no longer automatically serve files from /public_html/. I don't know if Yusef listens for "_request" or not.

13. May 2010, 18:04:20 (edited)

Sicofonia

Posts: 10

Originally posted by JeroenH:

styles : [{href: 'index.css'}]
is correct and should work.

Everything under /public_html/ inside your application will be mapped from / in the URI space. This means /public_html/styles/index.css will become http://[computername].[username].operaunite.com/[applicationname]/styles/index.css for example.

There's one thing that could cause these problems. If there is code listening for "_request", by doing a
opera.io.webserver.addEventListener('_request', generalhandler, false);
call, Opera will no longer automatically serve files from /public_html/. I don't know if Yusef listens for "_request" or not.



Thanks for the response smile

Now, I tell you what I did in order to get the styles. I had to rewrite the "_index" listener altogether, following an example that I found in some other tutorial. So this is what I got now:

    Yusef.addSectionListener("_index", function( connection )
    {        
         var data = Yusef.getData(connection);
  	 var tmpl = new Markuper('templates/index.html', data);           

  	 tmpl.parse( data );
  			

          return {
    			title   : connection.request.path,
    			content : tmpl.select('#contentArea'),
    			styles  : [{href: 'index.css'}],
    			tabs    : Yusef.plugins.ui.generateTabs([{"title": opera.io.webserver.currentServiceName,
"section":""}], connection)
  			}; 
            
    }, {ui: true}


So that does the trick up , but I don't understand why it is not working in the first snippet of code I provided.

Regards.

Forums » Dev.Opera » Archived Opera Unite Development Discussions