Skip to content
This repository was archived by the owner on Sep 17, 2024. It is now read-only.

Wiki ENGLISH

José M. Requena Plens edited this page Dec 14, 2022 · 1 revision

Welcome to the mastodon_official_profiles repository wiki.

Here you can find information about the inner workings of the repository, the automation for generating informative texts and tables, etc.

How to collaborate?

Perform a fork and edit the repository in your account, when you have finished the changes propose changes in this repository so that they can be incorporated.

  • To add new accounts, edit the ".csv" file that corresponds to the data in each column (you can omit some, but name, mastodon account, country and creation date are mandatory). If the category or country does not yet exist in the database, create a new file or folder.

  • You can collaborate improving the code that automates the creation of README files or improving the dynamic table web

  • If you have any other input it will always be welcome, this is about building it as a community.

CSV data

The data is organized in csv files, each file corresponds to a category and these files are grouped in folders for each country. If you are going to add accounts to the database, edit the csv files in the country folders, the other csv files (MAIN.csv and MAIN_web.csv) are automatically regenerated by merging the country files.

You can also create new folders for countries or new files for categories, feel free to contribute anything.

Automation

Automation allows you to update the README files in the repository using the .csv files and other files such as CONTRIBUTORS.yml.

This automation is done using a script written in Python main.py and with GitHub Actions it is possible to run the script on the GitHub servers and thus keep everything updated instantly when, for example, a Pull Request is accepted. To run the script, this repository uses the workflow run_python.yml.

Workflow

What the workflow used in the automation performs is:

  1. Waits for any changes in the repository.
  2. Runs an Ubuntu system.
  3. Configure the system to use Python.
  4. Add installed packages to the cache to reduce execution time on future runs.
  5. Install the necessary packages listed in the file requirements.txt.
  6. Run the script main.py.
  7. Create the commit.
  8. Write the changes to the repository.

The complete workflow code is shown below.

name: Generate MAIN.CSV and README

on:
  push:
    branches: [ main ]
  workflow_dispatch:

permissions:
  contents: write

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
    # Check out repository under $GITHUB_WORKSPACE, so the job can access it.
    - uses: actions/checkout@v3

    # Run using Python 3.11
    - name: Set up Python 3.11
      uses: actions/setup-python@v4
      with:
        python-version: '3.11'
        cache: 'pip'
        architecture: 'x64'

    # Cache dependencies. From:
    # https://github.com/actions/cache/blob/master/examples.md#python---pip
    - uses: actions/cache@v3
      with:
        path: ~/.cache/pip
        key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
        restore-keys: |
          ${{ runner.os }}-pip-${ hashFiles('**/requirements.txt' }}-pip-

    # Install dependencies with `pip`
    - name: Install requirements
      run: |
        python3 -m pip install --upgrade pip setuptools wheel
        python3 -m pip install -r requirements.txt

    # Run Python script
    - name: Generate data
      run: |
        python3 --version
        python3 main.py

    # Commit files
    - name: commit files
      run: |
        git config --local user.email "[email protected]"
        git config --local user.name "jmrplens"
        git add -A
        git diff-index --quiet HEAD || (git commit -a -m "updated logs" --allow-empty)

    # Push changes to repo
    - name: push changes
      uses: ad-m/github-push-action@master
      with:
        github_token: ${{ secrets.GITHUB_TOKEN }}

Automated files

The files that are automatically generated are:

Some parts of these files are loaded from the .resources folder, such as the different parts of the README (header, body, footer, etc).

Tables

The tables showing the mastodon accounts in the README according to category and countries are generated with the _generate function found in the file makereadmes.py.

Contributors

The contributors table shown in the README is built from the data included in CONTRIBUTORS.yml. It is structured as follows:

  1. name - Name
  2. avatar - Picture to display
  3. github_user - If you are a GitHub user, adding your user will show a button to see the contributions made.
  4. links - A list of links: web, social networks, etc. The service should be written in lowercase: web, mastodon, instagram, etc.

It is important to keep the tabulation, otherwise the data will not load correctly. You can omit any data if you do not want to include it.

- name: Jaz-Michael King
  avatar: https://avatars.githubusercontent.com/u/3419832
  github_user: jazmichaelking
  links:
    web: https://jaz.co.uk/
    mastodon: https://toot.wales/@jaz
    linkedin: https://www.linkedin.com/in/jmking/
- name: Jorge Saturno
  avatar: https://avatars.githubusercontent.com/u/7603402
  github_user: jorgesat
  links:
    web: https://kumulonimb.us/
    mastodon: [https://red.niboe.info/@jorge,https://scholar.social/@jorge]
    orcid: https://orcid.org/0000-0002-3761-3957
- name: jmrplens
  avatar: https://avatars.githubusercontent.com/u/28966312
  github_user: jmrplens
  links:
    web: https://jmrplens.github.io/
    mastodon: https://red.niboe.info/@jmrplens
    pixelfed: https://pixelfed.social/jmrplens
    linkedin: https://www.linkedin.com/in/jmrplens
    scholar: https://scholar.google.com/citations?user=9b0kPaUAAAAJ
    work: https://www.i3m-stim.i3m.upv.es/research/ultrasound-medical-and-industrial-laboratory-umil/
- name: Lydia Gil
  avatar: https://static.mstdn.science/accounts/avatars/109/349/104/436/155/936/original/6811c637ba69ede6.jpg
  links:
    web: https://socialmediaeninvestigacion.com
    mastodon: https://mstdn.science/@TuSocialMedia
    linkedin: https://www.linkedin.com/in/lydiamargaritagil
    instagram: https://www.instagram.com/tusocialmedia/
    twitter: https://twitter.com/TuSocialMedia
    facebook: https://www.facebook.com/TuSocialMediaCiencia

The function that processes this data is located in makereadmes.py, the function is called _contributors_table, it is executed from the _makefooter function that is used in the functions to create the main README and the README in English and Spanish.

README's

As in the previous automations, the README files are generated with a function located in the script makereadmes.py.

In the case of the main README, the function that creates it is create_main_readme and the README_xx in English and Spanish are created by the create_localised_readme function.

Clone this wiki locally