styxit / HTPC-Manager

A fully responsive interface to manage all your favorite software on your Htpc.
http://htpc.io
MIT License
529 stars 183 forks source link

Modules should be isolated to their own folder #91

Open fenduru opened 10 years ago

fenduru commented 10 years ago

Currently, "modules" aren't really modular, since they have files all over the place. For instance, the couchpotato module has a file in

And is also hardcoded into dash.html, dash.js, Htpc.py, and settings.html

Having files and references scattered like this makes it hard to improve existing modules or write new ones. I think reorganizing the module setup would greatly improve the community around this application. 3rd party modules could be installed simply by copying a folder, and removed just as easily.

I envision a file structure looking something like:

/modules/couchpotato
    __init__.py
    setup.py
    html/
        index.html
    css/
        styles.css
    js/
        main.js

Then something like:

for folder in os.listdir('modules/'):
    importlib.import_module(folder)

Then we wouldn't have to worry about hardcoding anything, we could just iterate over the list of loaded modules.

If this issue is accepted and someone wants to brainstorm the details with me I'd be able to implement this.

styxit commented 10 years ago

This would definitely improve the code structure. I like this!

qgerome commented 10 years ago

Wow, I totally agree with you on this !

mbw2001 commented 10 years ago

I considered this when I reorganized all the files.

However one reason i didnt go for it was because of the way CherryPy handles static files. You define the folder holding the static files. So you would need to specify all the css folders all the js folders and so on in the code. Which i found was ineffective.

styxit commented 10 years ago

@mbw2001 You are right, i forgot. You need to declare the static files-folder in cherryPy config. Maybe we can construct the static-files object for cherryPy dynamicly based on the loaded modules?