Kodi Community Forum

Full Version: Maraschino (formerly HTPC Frontend) - a summary web interface for your XBMC HTPC
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
gugahoi Wrote:Fair enough. It worked with no problems for me.

MrK, sorry but Im gonna have to trouble you again with some Q's...

Which files need to be modified to add a new module? I've been reading around the code and thought it seemed simple but I've had no luck getting my new module showing up properly.

Is there a chance you could explain the saving process for the settings?

Cheers!

Sure. It varies depending on what you want the module to do, but the basic process is the same. These instructions are for a generic module like SABnzbd+.

First, you need to add the default settings for the module to AVAILABLE_MODULES in modules.py, as described here.

If you want to add extra settings (in the case on SABnzbd we have the SABnzbd API url) then add them in extra_settings - plenty of examples in module.py.

Then you need to create a .py file which contains all of the module's functions, mostly XHR views which render templates. See sabnzbd.py for a good example which you can base your module on.

To access the value of any extra settings that you've specified in modules.py, use:

Code:
get_setting_value('setting_name')

There is already code in place to handle the creation of extra settings, so it is done automatically, as is the 'edit settings' for each module.

Next, you need to create a template with the same name as 'AVAILABLE_MODULES[yourmodule].name' - so if in AVAILABLE_MODULES you set the name of your module to be "loldongs", the template should be loldongs.html.

The HTML for the module goes in this template. Again, check out sabnzbd.html for an example. You'll see that the module only appears if SABnzbd is downloading something, otherwise a placeholder is rendered instead. The placeholder is important because it provides styling hooks when in settings mode so that you can still see the module; also because the placeholder gets replaced with the actual module when it is determined that it should be displayed (in that case, when SABnzbd is actually downloading something). Make sure that you add an HTML5 data attribute (data-module) with the module "name" as this is used for the aforementioned hook.

You'll notice that all modules use the same basic styling (class of module, h2 for the title, etc.) so you can whip up a new module with consistent styling pretty easily.

You don't need to worry about JavaScript unless you're doing something more complex - the JS to show/hide/load/poll modules is already in place, and if you implement the module as described above then it will automatically pick it up and handle everything.

I think that's everything, but shoot if you have any questions.
DejaVu Wrote:Just made a Git Pull from the latest changes made from Gugahoi's pull request.

The drop down is empty for me.
Does it have a fault or am I missing something?

Hmm - works for me when testing locally using the dev server, doesn't work when on my Apache installation. I'll look into it.

Edit: I've just pushed a fix. It's not perfect, but it does the job (searches sys.path for a "maraschino" entry and prepends this to the directory location if it exists, so that Apache knows the full path).
My maraschino install is in /home/xbmc/.maraschino using cherrypy, which up to this was working perfectly btw! Smile

Not sure if that makes a difference with the paths to the images - but it's still not working from the latest commit.
DejaVu Wrote:My maraschino install is in /home/xbmc/.maraschino using cherrypy, which up to this was working perfectly btw! Smile

Not sure if that makes a difference with the paths to the images - but it's still not working from the latest commit.

Heh, guess it only fixed it for Apache Smile

Just pushed another fix (at least I hope so) - how about now?

Edit: Broken for me now in Apache... I'm rubbish... should really test better!
Okay, how about now? I just pushed something which works for me on my local dev server, my local CherryPy installation, and my HTPC's Apache installation.
Man, when I first saw this thread in it's infancy, I was immediately floored by the screen shots...

But, the way it has exploded--super cool. Thank you guys for all the hard work.

Now that the MFP guys are here (MFP is great btw, thanks for that work as well)....

Any chance that you can use your knowledge to bring some of the features of MFP over to this project, such as NZBMatrix searching, Sickbeard coming episodes, utorrent/jdownloader widgets, etc...

I know it is early to be asking for such specific things--I was just curious if you guys who worked on MFP had any plans, however subconscious, to bring this project up to MFP's level of comprehensiveness.
branlr Wrote:Man, when I first saw this thread in it's infancy, I was immediately floored by the screen shots...

But, the way it has exploded--super cool. Thank you guys for all the hard work.

Now that the MFP guys are here (MFP is great btw, thanks for that work as well)....

Any chance that you can use your knowledge to bring some of the features of MFP over to this project, such as NZBMatrix searching, Sickbeard coming episodes, utorrent/jdownloader widgets, etc...

I know it is early to be asking for such specific things--I was just curious if you guys who worked on MFP had any plans, however subconscious, to bring this project up to MFP's level of comprehensiveness.

There's a few of us that are 'learning' this to potentially make some of MFP migrate over, including some of the widgets mentioned. If you read the posts above you'll notice that guga and deja have altered/added modules and are still working on other things as well... Later today/tomorrow I'm going to attempt a few little things that I hope pan out, but no idea yet.
mrkipling Wrote:Okay, how about now? I just pushed something which works for me on my local dev server, my local CherryPy installation, and my HTPC's Apache installation.

Still a no go on this.
It seems as though Python does not recognise it's 'working directory' and is defaulting to the root directory searching for the images.

Is this what the problem is or am I way off base?
DejaVu Wrote:Still a no go on this.
It seems as though Python does not recognise it's 'working directory' and is defaulting to the root directory searching for the images.

Is this what the problem is or am I way off base?

I read a little bit about the path functions in python. It's possible it's a os compatibility problem? Are you running on windows?
mrkipling Wrote:Sure. It varies depending on what you want the module to do, but the basic process is the same. These instructions are for a generic module like SABnzbd+.

First, you need to add the default settings for the module to AVAILABLE_MODULES in modules.py, as described here.

If you want to add extra settings (in the case on SABnzbd we have the SABnzbd API url) then add them in extra_settings - plenty of examples in module.py.

Then you need to create a .py file which contains all of the module's functions, mostly XHR views which render templates. See sabnzbd.py for a good example which you can base your module on.

To access the value of any extra settings that you've specified in modules.py, use:

Code:
get_setting_value('setting_name')

There is already code in place to handle the creation of extra settings, so it is done automatically, as is the 'edit settings' for each module.

Next, you need to create a template with the same name as 'AVAILABLE_MODULES[yourmodule].name' - so if in AVAILABLE_MODULES you set the name of your module to be "loldongs", the template should be loldongs.html.

The HTML for the module goes in this template. Again, check out sabnzbd.html for an example. You'll see that the module only appears if SABnzbd is downloading something, otherwise a placeholder is rendered instead. The placeholder is important because it provides styling hooks when in settings mode so that you can still see the module; also because the placeholder gets replaced with the actual module when it is determined that it should be displayed (in that case, when SABnzbd is actually downloading something). Make sure that you add an HTML5 data attribute (data-module) with the module "name" as this is used for the aforementioned hook.

You'll notice that all modules use the same basic styling (class of module, h2 for the title, etc.) so you can whip up a new module with consistent styling pretty easily.

You don't need to worry about JavaScript unless you're doing something more complex - the JS to show/hide/load/poll modules is already in place, and if you implement the module as described above then it will automatically pick it up and handle everything.

I think that's everything, but shoot if you have any questions.

Awesome, it's exactly as I thought it was. I only overlooked the hook.

One thing I noticed tho is that all the py files end up having a pyc file except for the module I created. It does show up in the page fine however.

Another quick question I have: how do you debug some of the code? As in, variables for example. How do you check the content of a variable? Can I just print it to the console or would I have to pass it to the template and use some special printing there?
gugahoi Wrote:I read a little bit about the path functions in python. It's possible it's a os compatibility problem? Are you running on windows?

Nope. Ubuntu 10.04 LTS (XBMCLive updated to Pre-Eden).

My installation directory is @ /home/xbmc/.maraschino
DejaVu Wrote:Nope. Ubuntu 10.04 LTS (XBMCLive updated to Pre-Eden).

My installation directory is @ /home/xbmc/.maraschino

I'll try and find a solution tomorrow. Gotta study for my last exam ...

On another note. I managed to get a pause/resume functionality for the sabnzbd widget. Just like we had on mfp. One thing that does not seem to happen is the auto-refresh of the widget tho.... I'm not sure why since I thought ajax handled that despite whatever else was happening...? I'll put up this little mod on my repo soon and make the pull request. If MrK likes it, he can add it to his repo and probably polish the code too...
Good luck with your exam G. Smile
Is the refresh set when you 'Add Application' under 'Poll Frequency (Seconds)'? Cant say I checked TBH.

Got a bit bored with a 'Saturday Night in!'

So tweaked the CSS for my Drive Widget a tad.
I love the way everything can still be editted with simple Web Knowledge BTW!

Only really wanna quick glance at see the state of the disks, not to bothered about the decimal places either, but could not get my head around rounding it up...

Percentage follows the bar -

Image
DejaVu Wrote:Good luck with your exam G. Smile
Is the refresh set when you 'Add Application' under 'Poll Frequency (Seconds)'? Cant say I checked TBH.

Got a bit bored with a 'Saturday Night in!'

So tweaked the CSS for my Drive Widget a tad.
I love the way everything can still be editted with simple Web Knowledge BTW!

Only really wanna quick glance at see the state of the disks, not to bothered about the decimal places either, but could not get my head around rounding it up...

Percentage follows the bar -

Image

If you don't want the decimals then somewhere around line 102

free = float(st.f_bavail * st.f_frsize) / 1073741824
total = float(st.f_blocks * st.f_frsize) / 1073741824
used = float((st.f_blocks - st.f_bfree) * st.f_frsize) / 1073741824

These shouldn't be floating numbers.
DejaVu Wrote:Still a no go on this.
It seems as though Python does not recognise it's 'working directory' and is defaulting to the root directory searching for the images.

Is this what the problem is or am I way off base?

Yep, I think that different servers have different ideas of what it should be using as the working directory.

Anyway, I've pushed another change. It starts with the current working directory; it then attempts to prepend the path from sys.path (which works in Apache); then it tries to get the icons. If successful it displays them using a dropdown, otherwise it falls back to using an input text box. There's probably a super-easy, super-nice way of doing this, but I don't know it and don't have the time to figure it out right now unfortunately, and at least this shouldn't break anything Smile