+ added theme api
+ added switcher from dark and light theme - deleted profiles directory for now + added theme config option * added boilerplate to circle picker and useridenticons
This commit is contained in:
parent
578a238f2e
commit
7e9fe03235
18 changed files with 171 additions and 44 deletions
|
@ -20,6 +20,8 @@
|
|||
import os
|
||||
from httpapi import security, friendsapi, profilesapi, configapi, insertblock, miscclientapi, onionrsitesapi, apiutils
|
||||
from httpapi import directconnections
|
||||
from httpapi import themeapi
|
||||
|
||||
def register_private_blueprints(private_api, app):
|
||||
app.register_blueprint(security.client.ClientAPISecurity(private_api).client_api_security_bp)
|
||||
app.register_blueprint(friendsapi.friends)
|
||||
|
@ -32,4 +34,5 @@ def register_private_blueprints(private_api, app):
|
|||
app.register_blueprint(apiutils.shutdown.shutdown_bp)
|
||||
app.register_blueprint(miscclientapi.staticfiles.static_files_bp)
|
||||
app.register_blueprint(directconnections.DirectConnectionManagement(private_api).direct_conn_management_bp)
|
||||
app.register_blueprint(themeapi.theme_blueprint)
|
||||
return app
|
|
@ -24,7 +24,7 @@ from . import pluginwhitelist
|
|||
|
||||
# Be extremely mindful of this. These are endpoints available without a password
|
||||
whitelist_endpoints = ['www', 'staticfiles.homedata', 'staticfiles.sharedContent',
|
||||
'staticfiles.friends', 'staticfiles.friendsindex', 'siteapi.site', 'staticfiles.onionrhome']
|
||||
'staticfiles.friends', 'staticfiles.friendsindex', 'siteapi.site', 'staticfiles.onionrhome', 'themes.getTheme']
|
||||
|
||||
class ClientAPISecurity:
|
||||
def __init__(self, client_api):
|
||||
|
|
46
onionr/httpapi/themeapi/__init__.py
Normal file
46
onionr/httpapi/themeapi/__init__.py
Normal file
|
@ -0,0 +1,46 @@
|
|||
"""
|
||||
Onionr - Private P2P Communication
|
||||
|
||||
API to get current CSS theme for the client web UI
|
||||
"""
|
||||
"""
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
"""
|
||||
from flask import Blueprint, Response
|
||||
|
||||
import config
|
||||
from utils import readstatic
|
||||
|
||||
theme_blueprint = Blueprint('themes', __name__)
|
||||
|
||||
LIGHT_THEME_FILES = ['bulma-light.min.css', 'styles-light.css']
|
||||
DARK_THEME_FILES = ['bulma-dark.min.css', 'styles-dark.css']
|
||||
|
||||
def _load_from_files(file_list: list)->str:
|
||||
"""Loads multiple static dir files and returns them in combined string format (non-binary)"""
|
||||
combo_data = ''
|
||||
for f in file_list:
|
||||
combo_data += readstatic.read_static('www/shared/main/themes/' + f)
|
||||
return combo_data
|
||||
|
||||
@theme_blueprint.route('/gettheme', endpoint='getTheme')
|
||||
def get_theme_file()->Response:
|
||||
"""Returns the css theme data"""
|
||||
css: str
|
||||
theme = config.get('ui.theme', 'dark').lower()
|
||||
if theme == 'dark':
|
||||
css = _load_from_files(DARK_THEME_FILES)
|
||||
elif theme == 'light':
|
||||
css = _load_from_files(LIGHT_THEME_FILES)
|
||||
return Response(css, mimetype='text/css')
|
Loading…
Add table
Add a link
Reference in a new issue