add list of services on main page
This commit is contained in:
		
							parent
							
								
									789762dd51
								
							
						
					
					
						commit
						471a49a80f
					
				
					 7 changed files with 64 additions and 6 deletions
				
			
		|  | @ -32,6 +32,8 @@ ADMINS = [ | |||
| [LENTICULAR_CLOUD_SERVICES.jabber] | ||||
| app_token = true | ||||
| # client_cert= true | ||||
| icon = "https://seafile.milliways.info/media/favicons/favicon.png" | ||||
| href = "https://seafile.milliways.info" | ||||
| 
 | ||||
| 
 | ||||
| [LENTICULAR_CLOUD_SERVICES.mail-cardav] | ||||
|  |  | |||
|  | @ -1,11 +1,12 @@ | |||
| from flask import Flask | ||||
| from .model import Service | ||||
| import logging | ||||
| 
 | ||||
| from .model import Service | ||||
| 
 | ||||
| logger = logging.getLogger(__name__) | ||||
| 
 | ||||
| 
 | ||||
| class LenticularServices(dict): | ||||
| class LenticularServices(dict[str, Service]): | ||||
| 
 | ||||
|     def init_app(self, app: Flask) -> None: | ||||
|         for service_name, service_config in app.config['LENTICULAR_CLOUD_SERVICES'].items(): | ||||
|  |  | |||
|  | @ -58,6 +58,9 @@ class Service(object): | |||
|     def __init__(self, name: str): | ||||
|         self._name = name | ||||
|         self._app_token = False | ||||
|         self._icon: Optional[str] = None | ||||
|         self._href: Optional[str] = None | ||||
| 
 | ||||
|         self._client_cert = False | ||||
|         self._pki_config = { | ||||
|                     'cn': '{username}', | ||||
|  | @ -66,8 +69,6 @@ class Service(object): | |||
| 
 | ||||
|     @staticmethod | ||||
|     def from_config(name, config) -> 'Service': | ||||
|         """ | ||||
|         """ | ||||
|         service = Service(name) | ||||
|         if 'app_token' in config: | ||||
|             service._app_token = bool(config['app_token']) | ||||
|  | @ -75,6 +76,10 @@ class Service(object): | |||
|             service._client_cert = bool(config['client_cert']) | ||||
|         if 'pki_config' in config: | ||||
|             service._pki_config.update(config['pki_config']) | ||||
|         if 'icon' in config: | ||||
|             service._icon = str(config['icon']) | ||||
|         if 'href' in config: | ||||
|             service._href = str(config['href']) | ||||
| 
 | ||||
|         return service | ||||
| 
 | ||||
|  | @ -96,6 +101,14 @@ class Service(object): | |||
|             raise Exception('invalid call') | ||||
|         return self._pki_config | ||||
| 
 | ||||
|     @property | ||||
|     def icon(self) -> Optional[str]: | ||||
|         return self._icon | ||||
| 
 | ||||
|     @property | ||||
|     def href(self) -> Optional[str]: | ||||
|         return self._href | ||||
| 
 | ||||
| 
 | ||||
| class Certificate(object): | ||||
| 
 | ||||
|  |  | |||
|  | @ -1,2 +1,19 @@ | |||
| 
 | ||||
| {% extends 'frontend/base.html.j2' %} | ||||
| 
 | ||||
| 
 | ||||
| {% block content %} | ||||
| <div class="users"> | ||||
| 	<h1>Available Services</h1> | ||||
| 
 | ||||
|     <div class="row"> | ||||
|     {% for service_name, service in lenticular_services.items() %} | ||||
|         <div class="col-md-3 col-sm-6"> | ||||
|             <a href="{{ service.href }}"> | ||||
|                 <img class="img-thumbnail" style="width: 100%;" alt="{{ service_name }}"  src="{{ service.icon }}"/> | ||||
|             </a> | ||||
|         </div> | ||||
|     {% endfor %} | ||||
|     </div> | ||||
| </div> | ||||
| {% endblock %} | ||||
|  |  | |||
|  | @ -76,7 +76,10 @@ def index() -> ResponseReturnValue: | |||
|         next_url = session['next_url'] | ||||
|         del session['next_url'] | ||||
|         return redirect(next_url) | ||||
|     return render_template('frontend/index.html.j2') | ||||
|     return render_template( | ||||
|         'frontend/index.html.j2', | ||||
|         lenticular_services=lenticular_services, | ||||
|     ) | ||||
| 
 | ||||
| 
 | ||||
| @frontend_views.route('/client_cert') | ||||
|  |  | |||
							
								
								
									
										22
									
								
								module.nix
									
										
									
									
									
								
							
							
						
						
									
										22
									
								
								module.nix
									
										
									
									
									
								
							|  | @ -69,6 +69,28 @@ in | |||
|               type = types.str; | ||||
|               default = "https://${config.services.ory-hydra.public_domain}"; | ||||
|             }; | ||||
|             LENTICULAR_CLOUD_SERVICES = mkOption { | ||||
|               type = types.attrsOf (types.submodule { | ||||
|                 options = { | ||||
|                   app_token = mkOption { | ||||
|                     type = types.bool; | ||||
|                     default = false; | ||||
|                     description = "enables the app token function for this service"; | ||||
|                   }; | ||||
|                   href = mkOption { | ||||
|                     type = types.str; | ||||
|                     example = "https://service.example.com"; | ||||
|                     description = "Link to the hosted service"; | ||||
|                   }; | ||||
|                   icon = mkOption { | ||||
|                     type = types.str; | ||||
|                     example = "https://service.example.com/favicon.png"; | ||||
|                     description = "Link to an icon of the service"; | ||||
|                   }; | ||||
|                 }; | ||||
|               }); | ||||
|               default = {}; | ||||
|             }; | ||||
|           }; | ||||
|         }; | ||||
|       }; | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue