mirror of
				https://github.com/kevinveenbirkenbach/computer-playbook.git
				synced 2025-11-03 19:58:14 +00:00 
			
		
		
		
	Different optimations and bugs
This commit is contained in:
		@@ -41,6 +41,3 @@
 | 
				
			|||||||
  changed_when:   (docker_ps.stdout | trim) == ""
 | 
					  changed_when:   (docker_ps.stdout | trim) == ""
 | 
				
			||||||
  notify:         docker compose up
 | 
					  notify:         docker compose up
 | 
				
			||||||
  when:           not (docker_compose_template.changed or env_template.changed)
 | 
					  when:           not (docker_compose_template.changed or env_template.changed)
 | 
				
			||||||
 | 
					 | 
				
			||||||
- name:           flush docker compose up
 | 
					 | 
				
			||||||
  meta:           flush_handlers
 | 
					 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										58
									
								
								roles/docker-portfolio/filter_plugins/simpleicons_source.py
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										58
									
								
								roles/docker-portfolio/filter_plugins/simpleicons_source.py
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,58 @@
 | 
				
			|||||||
 | 
					from __future__ import absolute_import, division, print_function
 | 
				
			||||||
 | 
					__metaclass__ = type
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					import requests
 | 
				
			||||||
 | 
					import re
 | 
				
			||||||
 | 
					from ansible.errors import AnsibleFilterError
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def slugify(name):
 | 
				
			||||||
 | 
					    """Convert a display name to a simple-icons slug format."""
 | 
				
			||||||
 | 
					    # Replace spaces and uppercase letters
 | 
				
			||||||
 | 
					    return re.sub(r'\s+', '-', name.strip().lower())
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					def add_simpleicon_source(cards, domains, web_protocol='https'):
 | 
				
			||||||
 | 
					    """
 | 
				
			||||||
 | 
					    For each card in portfolio_cards, check if an icon exists in the simpleicons server.
 | 
				
			||||||
 | 
					    If it does, add icon.source with the URL to the card entry.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    :param cards: List of card dictionaries (portfolio_cards)
 | 
				
			||||||
 | 
					    :param domains: Mapping of application_id to domain names
 | 
				
			||||||
 | 
					    :param web_protocol: Protocol to use (https or http)
 | 
				
			||||||
 | 
					    :return: New list of cards with icon.source set when available
 | 
				
			||||||
 | 
					    """
 | 
				
			||||||
 | 
					    # Determine simpleicons service domain
 | 
				
			||||||
 | 
					    simpleicons_domain = domains.get('simpleicons')
 | 
				
			||||||
 | 
					    if isinstance(simpleicons_domain, list):
 | 
				
			||||||
 | 
					        simpleicons_domain = simpleicons_domain[0]
 | 
				
			||||||
 | 
					    if not simpleicons_domain:
 | 
				
			||||||
 | 
					        raise AnsibleFilterError("Domain for 'simpleicons' not found in domains mapping")
 | 
				
			||||||
 | 
					    base_url = f"{web_protocol}://{simpleicons_domain}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    enhanced = []
 | 
				
			||||||
 | 
					    for card in cards:
 | 
				
			||||||
 | 
					        title = card.get('title', '')
 | 
				
			||||||
 | 
					        if not title:
 | 
				
			||||||
 | 
					            enhanced.append(card)
 | 
				
			||||||
 | 
					            continue
 | 
				
			||||||
 | 
					        # Create slug from title
 | 
				
			||||||
 | 
					        slug = slugify(title)
 | 
				
			||||||
 | 
					        icon_url = f"{base_url}/{slug}.svg"
 | 
				
			||||||
 | 
					        try:
 | 
				
			||||||
 | 
					            resp = requests.head(icon_url, timeout=2)
 | 
				
			||||||
 | 
					            if resp.status_code == 200:
 | 
				
			||||||
 | 
					                card.setdefault('icon', {})['source'] = icon_url
 | 
				
			||||||
 | 
					        except requests.RequestException:
 | 
				
			||||||
 | 
					            # Ignore network errors and move on
 | 
				
			||||||
 | 
					            pass
 | 
				
			||||||
 | 
					        enhanced.append(card)
 | 
				
			||||||
 | 
					    return enhanced
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					class FilterModule(object):
 | 
				
			||||||
 | 
					    """Ansible filter plugin to add simpleicons source URLs to portfolio cards"""
 | 
				
			||||||
 | 
					    def filters(self):
 | 
				
			||||||
 | 
					        return {
 | 
				
			||||||
 | 
					            'add_simpleicon_source': add_simpleicon_source,
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
@@ -24,3 +24,5 @@ galaxy_info:
 | 
				
			|||||||
  documentation: "https://github.com/kevinveenbirkenbach/portfolio#readme"
 | 
					  documentation: "https://github.com/kevinveenbirkenbach/portfolio#readme"
 | 
				
			||||||
  logo:
 | 
					  logo:
 | 
				
			||||||
    class: "fa-solid fa-briefcase"
 | 
					    class: "fa-solid fa-briefcase"
 | 
				
			||||||
 | 
					  run_after:
 | 
				
			||||||
 | 
					  - docker-simpleicons
 | 
				
			||||||
@@ -1,4 +1,5 @@
 | 
				
			|||||||
---
 | 
					---
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- name: "include docker-compose role"
 | 
					- name: "include docker-compose role"
 | 
				
			||||||
  include_role: 
 | 
					  include_role: 
 | 
				
			||||||
    name: docker-compose
 | 
					    name: docker-compose
 | 
				
			||||||
@@ -30,6 +31,13 @@
 | 
				
			|||||||
    portfolio_cards: "{{ lookup('docker_cards', 'roles') }}"
 | 
					    portfolio_cards: "{{ lookup('docker_cards', 'roles') }}"
 | 
				
			||||||
  when: run_once_docker_portfolio is not defined
 | 
					  when: run_once_docker_portfolio is not defined
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					- name: "Load images for applications feature simpleicons is enabled "
 | 
				
			||||||
 | 
					  set_fact:
 | 
				
			||||||
 | 
					    portfolio_cards: "{{ portfolio_cards | add_simpleicon_source(domains, web_protocol) }}"
 | 
				
			||||||
 | 
					  when:
 | 
				
			||||||
 | 
					    - (applications | is_feature_enabled('simpleicons',application_id))
 | 
				
			||||||
 | 
					    - run_once_docker_portfolio is not defined
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- name: Group docker cards
 | 
					- name: Group docker cards
 | 
				
			||||||
  set_fact:
 | 
					  set_fact:
 | 
				
			||||||
    portfolio_menu_data: "{{ lookup('docker_cards_grouped', portfolio_cards, portfolio_menu_categories) }}"
 | 
					    portfolio_menu_data: "{{ lookup('docker_cards_grouped', portfolio_cards, portfolio_menu_categories) }}"
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -102,7 +102,7 @@ company:
 | 
				
			|||||||
navigation:
 | 
					navigation:
 | 
				
			||||||
  header:
 | 
					  header:
 | 
				
			||||||
    children:
 | 
					    children:
 | 
				
			||||||
    - link: accounts.publishingchannels.children
 | 
					    - link: accounts.publishingchannels
 | 
				
			||||||
    - name: Contact
 | 
					    - name: Contact
 | 
				
			||||||
      description: Get in touch with {{ 'us' if service_provider.type == 'legal' else 'me' }} 
 | 
					      description: Get in touch with {{ 'us' if service_provider.type == 'legal' else 'me' }} 
 | 
				
			||||||
      icon:
 | 
					      icon:
 | 
				
			||||||
@@ -140,4 +140,10 @@ navigation:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
{% endif %}
 | 
					{% endif %}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    - name: Toggle Fullscreen
 | 
				
			||||||
 | 
					      description: Enter or exit fullscreen mode
 | 
				
			||||||
 | 
					      icon:
 | 
				
			||||||
 | 
					        class: fa-solid fa-expand-arrows-alt
 | 
				
			||||||
 | 
					      onclick: "toggleFullscreen()"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
{% include 'footer_menu.yaml.j2' %}
 | 
					{% include 'footer_menu.yaml.j2' %}
 | 
				
			||||||
@@ -2,6 +2,8 @@ features:
 | 
				
			|||||||
  matomo:           true
 | 
					  matomo:           true
 | 
				
			||||||
  css:              true
 | 
					  css:              true
 | 
				
			||||||
  portfolio_iframe: false
 | 
					  portfolio_iframe: false
 | 
				
			||||||
 | 
					  simpleicons:      true  # Activate Brand Icons for your groups
 | 
				
			||||||
 | 
					nasa_api_key:       false # Set api key to use the Nasa Picture of the Day as Background
 | 
				
			||||||
csp:
 | 
					csp:
 | 
				
			||||||
  whitelist:
 | 
					  whitelist:
 | 
				
			||||||
    script-src-elem:
 | 
					    script-src-elem:
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -4,7 +4,7 @@
 | 
				
			|||||||
    name: pkgmgr-install
 | 
					    name: pkgmgr-install
 | 
				
			||||||
  vars:
 | 
					  vars:
 | 
				
			||||||
    package_name: cymais-presentation
 | 
					    package_name: cymais-presentation
 | 
				
			||||||
    package_notify: docker compose up
 | 
					    # package_notify: docker compose up
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- name: Get path of cymais-presentation using pkgmgr
 | 
					- name: Get path of cymais-presentation using pkgmgr
 | 
				
			||||||
  command: pkgmgr path cymais-presentation
 | 
					  command: pkgmgr path cymais-presentation
 | 
				
			||||||
@@ -24,3 +24,8 @@
 | 
				
			|||||||
  vars:
 | 
					  vars:
 | 
				
			||||||
    domain:     "{{ domains | get_domain(application_id) }}"
 | 
					    domain:     "{{ domains | get_domain(application_id) }}"
 | 
				
			||||||
    http_port:   "{{ ports.localhost.http[application_id] }}"
 | 
					    http_port:   "{{ ports.localhost.http[application_id] }}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Hack because it wasn't possible to fix an handler bug in pkgmgr install
 | 
				
			||||||
 | 
					- name: „Trigger“ docker compose up
 | 
				
			||||||
 | 
					  command: /bin/true
 | 
				
			||||||
 | 
					  notify: docker compose up
 | 
				
			||||||
@@ -26,5 +26,5 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
- name: run the simpleicons tasks once
 | 
					- name: run the simpleicons tasks once
 | 
				
			||||||
  set_fact:
 | 
					  set_fact:
 | 
				
			||||||
    run_once_docker_portfolio: true
 | 
					    run_once_docker_simpleicon: true
 | 
				
			||||||
  when: run_once_docker_simpleicons is not defined
 | 
					  when: run_once_docker_simpleicons is not defined
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,7 +5,7 @@
 | 
				
			|||||||
    name: pkgmgr-install
 | 
					    name: pkgmgr-install
 | 
				
			||||||
  vars:
 | 
					  vars:
 | 
				
			||||||
    package_name: cymais-sphinx
 | 
					    package_name: cymais-sphinx
 | 
				
			||||||
    package_notify: docker compose up
 | 
					    # package_notify: docker compose up
 | 
				
			||||||
 | 
					
 | 
				
			||||||
- name: Get path of cymais-sphinx using pkgmgr
 | 
					- name: Get path of cymais-sphinx using pkgmgr
 | 
				
			||||||
  command: pkgmgr path cymais-sphinx
 | 
					  command: pkgmgr path cymais-sphinx
 | 
				
			||||||
@@ -21,3 +21,8 @@
 | 
				
			|||||||
  vars:
 | 
					  vars:
 | 
				
			||||||
    domain:     "{{ domains | get_domain(application_id) }}"
 | 
					    domain:     "{{ domains | get_domain(application_id) }}"
 | 
				
			||||||
    http_port:   "{{ ports.localhost.http[application_id] }}"
 | 
					    http_port:   "{{ ports.localhost.http[application_id] }}"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					# Hack because it wasn't possible to fix an handler bug in pkgmgr install
 | 
				
			||||||
 | 
					- name: „Trigger“ docker compose up
 | 
				
			||||||
 | 
					  command: /bin/true
 | 
				
			||||||
 | 
					  notify: docker compose up
 | 
				
			||||||
@@ -1,6 +1,6 @@
 | 
				
			|||||||
{% include 'roles/docker-compose/templates/base.yml.j2' %}
 | 
					{% include 'roles/docker-compose/templates/base.yml.j2' %}
 | 
				
			||||||
  application:
 | 
					  application:
 | 
				
			||||||
{% set container_port = 8008 %}
 | 
					{% set container_port = 8000 %}
 | 
				
			||||||
    build: 
 | 
					    build: 
 | 
				
			||||||
      context: {{ path_cymais_sphinx_output.stdout }}
 | 
					      context: {{ path_cymais_sphinx_output.stdout }}
 | 
				
			||||||
      dockerfile: {{ path_cymais_sphinx_output.stdout }}/Dockerfile
 | 
					      dockerfile: {{ path_cymais_sphinx_output.stdout }}/Dockerfile
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -33,6 +33,6 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
- name: run the {% endraw %}{{ application_id }}{% raw %} tasks once
 | 
					- name: run the {% endraw %}{{ application_id }}{% raw %} tasks once
 | 
				
			||||||
  set_fact:
 | 
					  set_fact:
 | 
				
			||||||
    run_once_docker_portfolio: true
 | 
					    run_once_docker_{% endraw %}{{ application_id }}{% raw %}: true
 | 
				
			||||||
  when: run_once_docker_{% endraw %}{{ application_id }}{% raw %} is not defined
 | 
					  when: run_once_docker_{% endraw %}{{ application_id }}{% raw %} is not defined
 | 
				
			||||||
{% endraw %}
 | 
					{% endraw %}
 | 
				
			||||||
		Reference in New Issue
	
	Block a user