Custom Portal - Development

1. Very impressed with progress.
2. The Humax logo is the wrong one! compare it with the boot logo or the one on the front of the box, you'll see what I mean :)
3. I guess that (for instance) xbmc developed addons for the various OD channels is a completely different beast to this one. I have them all (inc. 4OD) on my raspbmc setup though I'm no expert. 4OD is a bit rubbish though as its mainly old stuff (perhaps this is the only stuff you can do on these machines).
 
1. Very impressed with progress.
2. The Humax logo is the wrong one! compare it with the boot logo or the one on the front of the box, you'll see what I mean :)
3. I guess that (for instance) xbmc developed addons for the various OD channels is a completely different beast to this one. I have them all (inc. 4OD) on my raspbmc setup though I'm no expert. 4OD is a bit rubbish though as its mainly old stuff (perhaps this is the only stuff you can do on these machines).

Cheers!

You are hardly expecting official logos for an unofficial portal now ;-)

The plan is to implement the exact same beast as the XBMC on demand players! AFAIK the 4OD player on xbmc is no longer working either since C4 changed the feed source away from ps3.channel4.com..

If that is not the case and some solution is found then I will look into that too! My priority is the Irish OD players as that is what I will be watching ;-)

The rest will follow, providing I get the Irish ones working..
 
@ChrisDaniels/af123

A quick question lads please..

I had been back looking at this new portal today and decided to include a section to maintain Favourite Apps. Anyway, I had it working well on the laptop using a SQLite DB and I was able to add/remove etc. apps from the main lists of apps to a Favourites database.

Anyway, having put the code onto the HDR T2 it wouldn't work, blank app list so it must be throwing an error. I then stuck it on the TV Emulator and the problem is the Opera TV Browser doesn't support SQLite databases.. :mad:

It doesn't like:
Code:
var db = openDatabase("FavouriteApps", "1.0", "Favourite Apps", 200000);

Anyway, I see you guys are able to query databases using JIM. I don't know anything about jim and have never come across it.

Can I call a JIM script from within javascript or any other way I could add a DB to the Opera TV Browser?

Cheers,
mcquaim
 
You could call a CGI script on the local webserver to perform the database operations on your behalf. The best language to write it in would be Jim (and I'd be happy to help you with that) but from the Javascript perspective you can just do an Ajax call to the CGI script and get it to return data in XML or JSON.
 
Thanks for that.. I'm afraid I don't know zip about CGI either :(

Can you look at the attached file please, this is my javascript for the DB stuff. How would I convert this to a CGI script? I could manage the Ajax query but the other stuff I'd have to have a look at an example first. Could you draw up something quickly and I will take a look?

Sorry if this puts you out....

In my document.ready function I call the initDatabase so I would do something similar if possible?
 

Attachments

  • DB_Queries.txt
    4.6 KB · Views: 11
A lot of the functionality that you have in Javascript there would move to the Jim script on the local server. You're using JQuery so that makes the Javascript side easier.

Code:
function insertRecord(uri, name, img)
{
  $.post('http://localhost/path/to/script.jim', { 'action': 'insert', 'uri': uri, 'name': name, 'img': img });
}
 
function showRecords()
{
    $("#apps-favouritelist").html("<!-- Empty List -->");
    $.getJSON('http://localhost/path/to/script.jim?action=fetch', function(data, status, xhr) {
        //console.log("Status: %s", status);
          //console.dir(data);
      $.each(data, function() {... TBD ...});
    });
}

and on the server side, script.jim would look something like. I haven't tested this but it should be fairly close.

Code:
#!/mod/bin/jimsh
 
package require cgi
package require sqlite3
source /mod/webif/lib/setup
 
httpheader "application/json"
 
set action [cgi_get action fetch]
set uri [cgi_get uri]
set name [cgi_get name]
set img [cgi_get img]
set id [cgi_get id]
 
set db [sqlite3.open /mod/etc/portal.db]
 
$db query {
        create table if not exists favourites (
                id integer primary key autoincrement,
                uri text,
                name text,
                img text)
}
 
switch $action {
    insert {
        $db query {
            insert into favourites(uri, name, img) values('%s','%s','%s')
        } $uri $name $img
    }
    update {
        $db query {
                update favourites set uri = '%s', name = '%s', img = '%s'
                where id = '%s'
        } $uri $name $img $id
    }
    delete {
        $db query { delete from favourites where id = '%s' } $id
    }
    fetch {
        set flag 0
        puts "["
        foreach rec [$db query { select * from from favourites order by id }] {
                if {$flag} { puts "," }
                puts " {"
                set iflag 0
                while {[llength $rec] > 1} {
                        set rec [lassign $rec key val]
                        if {$iflag} { puts "," }
                        puts -nonewline "\"$key\":\"$val\""
                        set iflag 1
                }
                puts -nonewline "\n }"
                set flag 1
        }
        puts "\n]"
    }
}
 
@af123

I put in your code this morning but I have a small issue, I hope..

I created a new folder called "jim" within the "portal" folder and added your script.jim file there. Then in my javascript I included the code above with the path as follows:
Code:
$.getJSON('http://localhost/portal/jim/script.jim?action=fetch', function(data, status, xhr) {

It is throwing an error in the mongoose error log saying that the file or directory doesn't exist. Is my path above wrong?
 
For that URL the script should be at /mod/webif/html/portal/jim/script.jim

I wrote the script when away from my box so haven't had a chance to run it - I doubt it will run first time but hopefully it's fairly close. I'll have a chance to test/fix it this evening if you have problems.
 
Yeah, that is where I have the script alright...

This is the error being thrown:
Code:
[1383211354] [error] [client 127.0.0.1] GET /portal/jim/script.jim: spawn_process: execle(script.jim): No such file or directory
[1383211354] [error] [client 127.0.0.1] GET /portal/jim/script.jim: Error 500: Internal Server Error

Any ideas?
 
Have you just tried putting this instead?
Code:
$.getJSON('http://localhost/mod/webif/html/portal/jim/script.jim?action=fetch', function(data, status, xhr) {
 
Changing that throws a different error!
Code:
[1383216906] [error] [client 127.0.0.1] GET /mod/webif/html/portal/jim/script.jim: Error 404: Not Found
[1383216916] [error] [client 127.0.0.1] POST /mod/webif/html/portal/jim/script.jim: Error 404: Not Found

It's looks like my original path may have been correct but I might have a script error..
 
Yes, the root for the webserver is already in /mod/webif/html so it is wrong to include as I suggested. Sorry about that!
You are probably right that you have a script error.
 
the jquery call shoudn't include the /mod/webif/html/ directories.
They are the server directories before the webservers folder. Jquery is client side so doesn't have access to that.
Assuming the jim files are in /mod/webif/html/portal/jim/ the jquery call should be to /portal/jim/script.jim.

The errors:
[1383211354] [error] [client 127.0.0.1] GET /portal/jim/script.jim: spawn_process: execle(script.jim): No such file or directory
[1383211354] [error] [client 127.0.0.1] GET /portal/jim/script.jim: Error 500: Internal Server Error

might not be saying the files dont exist, but possibly one of the files script.jim is looking for doesn't exist.Maybe /mod/etc/portal.db?
 
"500: Internal Server Error" means there's a problem with the Jim script.

Try running it from the command line:

Code:
humax# /mod/webif/html/portal/jim/script.jim
 
Saying it's not found when I try running it from the console but if I look at the contents of the directory it exists...
Code:
Humax HDR-Fox T2 (humax) 1.03.06/2.19
 
humax# /mod/webif/html/portal/jim/script.jim
-/bin/sh: /mod/webif/html/portal/jim/script.jim: not found
humax# cd /mod/webif/html/portal/jim
humax# ls
script.jim

Something funny going on here?
 
Windows/DOS line endings in the script file I'd imagine.

Try:

Code:
humax# cd /mod/webif/html/portal/jim
humax# cp script.jim script.jim~
humax# dos2unix < script.jim~ > script.jim
humax# chmod 755 script.jim
 
Windows/DOS line endings in the script file I'd imagine.

Try:

Code:
humax# cd /mod/webif/html/portal/jim
humax# cp script.jim script.jim~
humax# dos2unix < script.jim~ > script.jim
humax# chmod 755 script.jim

Should have thought of this, looks like this was the issue as no more mongoose errors.. Not getting data back from saving/reading but I'm sure that is my code!

Thanks for the help!
 
Back
Top