mafl

repository·main·Indexed 20 days ago

https://github.com/hywax/mafl

A real-time, privacy-focused service for organizing a personalized interactive homepage. Mafl allows users to group services, add tags, and customize the interface with themes and icon packs. It supports deployment via Docker, Node.js, and Proxmox VE LXC, and includes core services such as IP API and Weather.

Tokens
14.5K
Snippets
75
Records
84
Agent score
72%

What's inside mafl

  1. Overview of Mafl

    main

    Mafl is a flexible tool designed for creating personalized homepages. It is specifically tailored for users managing home servers with multiple services.

    Key capabilities include:

    • Service Lists: Create and categorize lists of links to your various services.
    • Performance Tracking: Monitor the status or performance of specific services.
    • Dynamic Services: Connect to third-party APIs to fetch and display real-time information directly on service cards.
    • Secure API Requests: API requests for dynamic services are handled in a separate application layer, ensuring that sensitive information and API keys are hidden from the client side.
  2. Overview of Mafl services

    main

    Mafl is designed to be an interactive homepage where you can combine different services. Core services include:

    • Base: The fundamental service card upon which other services are built.
    • IP API: Displays information regarding your IP address.
    • Weather: Displays weather information for your location (via OpenWeatherMap).
  3. Define services (Flat or Grouped)

    main

    The services parameter is the core of the configuration. It supports two structures:

    1. Flat List: All services are at the same level.
    2. Groups: Services are organized under named categories.

    Each service requires a title and a link.

    # Flat List Example
    services:
      - title: Home Assistant
        description: Home automation
        link: https://home-assistant.home.local/
    
    # Grouped Example
    services:
      Group 1:
        - title: Home Assistant
          description: Home automation
          link: https://home-assistant.home.local/
  4. Use different icon types for services

    main

    Mafl supports several ways to define icons for your services:

    • Iconify: Use open-source vector icons from Iconify.
    • Emoji: Use any valid emoji.
    • URL: Provide a URL to a matching image.
    • Local: Reference custom images stored locally by their filename.
  5. Configure the OpenWeatherMap service

    main

    The OpenWeatherMap service retrieves weather data from the Open Weather Map API. To use this service, you must provide geographic coordinates (latitude and longitude), specify the measurement units, and provide a valid API key obtained from your Open Weather Map account.

    services:
      - type: openweathermap
        options:
          lat: 51.5085
          lon: -0.1257
        secrets:
          apiKey: YOUR_API_KEY
  6. Configure Mafl via config.yml

    main

    All application settings, including services, icons, language, and themes, are managed in a single config.yml file. This file must be transferred to the Docker container to apply settings. The services parameter is mandatory; without it, the homepage will not open.

    title: My Home Page
    services:
      - title: Home Assistant
        description: Home automation
        link: https://home-assistant.home.local/
  7. Add a new service

    main

    To add a new service that retrieves data from an external API, follow these five steps:

    1. Define the Service Interface: Extend BaseService in a declaration file (e.g., types/services.d.ts) to specify the service's configuration options.
    2. Create the Vue Component: Build a component (e.g., components/service/bitcoin.vue) using ServiceBase for the layout. Use the useServiceData composable to handle data fetching and lifecycle management. Call pauseUpdate within onBeforeUnmount to clean up.
    3. Add Translations: Add any static text used in the component to the translation files. You must provide en-US.json translations; others are optional. The project uses vue-i18n syntax.
    4. Implement Data Retrieval: Create a server-side API handler (e.g., server/api/services/bitcoin.ts) using defineEventHandler. Use getService<T>(event) to retrieve the service configuration and $fetch to call the external API.
    5. Update Documentation: Register the new service in the docs/services/ directory and the language-specific documentation directories.
    export interface BitcoinService extends BaseService {
      options?: {
        code: string
        interval?: number
      }
    }
    <template>
      <ServiceBase v-bind="props">
        <template #title>
          {{ $('service.bitcoin.title', { code: options.code }) }}
        </template>
        <template #description>
          {{ $('service.bitcoin.description', { rate: data?.rate || '0' }) }}
        </template>
      </ServiceBase>
    </template>
    
    <script setup lang="ts">
    import type { BitcoinService } from '~/types'
    
    const props = defineProps<BitcoinService>()
    const { data, pauseUpdate } = useServiceData<BitcoinService, { rate: string }>(props, {
      updateInterval: props?.options?.interval
    })
    
    onBeforeUnmount(pauseUpdate)
    </script>
    import type { BitcoinService } from '~/types'
    
    export default defineEventHandler(async (event): Promise<{ rate: string }> => {
      const service = await getService<BitcoinService>(event)
    
      try {
        const data = await $fetch('https://api.coindesk.com/v1/bpi/currentprice.json', {
          parseResponse: (text) => JSON.parse(text)
        })
    
        return {
          rate: data.bpi[service.option.code].rate
        }
      } catch (e) {
        logger.error(e)
      }
    
      return {
        rate: '-'
      }
    })
  8. Add a new service

    main

    To add a new service to the application, follow the technical instructions located in the development.md documentation. If you are proficient in JavaScript, the process is designed to be quick (estimated under 1 hour). If you cannot program, you can instead submit a feature request via GitHub issues.

    https://github.com/hywax/mafl/issues/new?assignees=&labels=feature+request&projects=&template=feature-request.yml&title=%5BFEATURE_REQUEST%5D+%3Ctitle%3E
  9. Configure custom favicons in Docker

    main

    To use your custom logos in Mafl, you must mount your local icons folder into the container at /app/public/favicons.

    You can do this by adding a volume mapping to your docker-compose.yml or by using the -v flag in a docker run command.

    version: '3.8'
    
    services:
      mafl:
        image: hywax/mafl
        restart: unless-stopped
        ports:
          - '3000:3000'
        volumes:
          - ./config.yml:/app/data/config.yml
          - ./favicons:/app/public/favicons
  10. Add your project to the Mafl Showcase

    main

    To contribute your own Mafl setup to the community showcase, follow these steps:

    1. Create a new issue on GitHub using the Showcase template.
    2. Fill in all the required fields in the issue template.
    3. It is highly recommended to share your config.yml file to help other users understand your setup.

    Important: Before sharing your config.yml, ensure you have removed all sensitive information and secrets.

    # Example: Prepare your config before sharing
    # Remove any lines containing passwords, API keys, or secrets
    # e.g., remove: 
    #   password: "my-secret-password"
    #   api_key: "12345-abcde"