-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
201f319
commit e0c7d2c
Showing
1 changed file
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
from xsbs.http.jsonapi import JsonAdminSite | ||
from xsbs.settings import pluginNames, pluginSections, sectionOptions, setOption | ||
|
||
try: | ||
import json | ||
except ImportError: | ||
import simplejson as json | ||
|
||
class ConfigPluginSite(JsonAdminSite): | ||
def __init__(self, plugin_name): | ||
self.plugin_name = plugin_name | ||
def render_admin_JSON(self, request): | ||
return json.dumps({ | ||
'plugin': self.plugin_name, | ||
'sections': pluginSections(self.plugin_name) | ||
}) | ||
|
||
class ConfigSectionSite(JsonAdminSite): | ||
def __init__(self, plugin_name, section_name): | ||
self.plugin_name = plugin_name | ||
self.section_name = section_name | ||
def render_admin_JSON(self, request): | ||
return json.dumps({ | ||
'plugin': self.plugin_name, | ||
'section': self.section_name, | ||
'options': sectionOptions(self.plugin_name, self.section_name) | ||
}) | ||
|
||
def init(site): | ||
configSite = JsonAdminSite() | ||
for name in pluginNames(): | ||
pluginConfigSite = ConfigPluginSite(name) | ||
for section in pluginSections(name): | ||
pluginConfigSite.putChild(section, ConfigSectionSite(name, section)) | ||
configSite.putChild(name, pluginConfigSite) | ||
site.putChild('config', configSite) | ||
|