usegalaxy-eu / galaxy-social

Repository for democratising of Galaxy's social media activity - encourage collaboration, editing, peer-review of toots 🐘 and more
Creative Commons Zero v1.0 Universal
3 stars 3 forks source link

# Galaxy Social

👇
Create new post

How to Create a Post

To create a post on Galaxy Social, follow these steps:

  1. Create a Branch: Begin by creating a branch in this repository or your forked repository.

  2. Add a New File: Within the "posts" folder (or sub-folders), create a new file with the extension ".md" and commit it to your branch.

  3. Use the Post Template: Utilize the following template for the post content:

---
media:
  - bluesky
  - mastodon
  - matrix
  - slack

mentions:
  bluesky:
    - a.bsky.social
  mastodon:
    - a
  matrix:
    - a:matrix.org

hashtags:
  bluesky:
    - a
    - b
  mastodon:
    - c
    - d
---
Your text content goes here.

![A](https://example.com/a.jpg)
![B](https://example.org/b.png)

Notes on the Template:

  1. Create a Pull Request: Once your post is ready, create a pull request to the main branch from another branch or from your fork

  2. Preview and Review: After each pull request, the "Create Preview" GitHub action will run. It will generate previews of the content as it would appear on each platform listed under "media" in a comment to the pull request and highlight any errors that need to be fixed before merging.

  3. Publish Your Content: Upon merging the pull request, the "Publish Content" GitHub action will run. The results will be added to processed_files.json in the processed_files branch.

By following these steps, you can effectively create and publish posts on Galaxy Social.

Add a New Social Media Platform

Expanding the capabilities of Galaxy Social by adding a new social media platform is a straightforward process. Follow these steps to integrate a new platform:

  1. Create a Plugin File: Begin by adding a Python file to the lib/plugins folder. This file should contain a class with a function named create_post(content, mentions, hashtags, images, alt_texts). This function will handle the process of sending announcements to the desired social media platform.

  2. Update plugins.yml: Next, update the plugins.yml file to include the new social media platform. Follow this template:

- name: name_of_the_media
  class: file_name.class_name
  enabled: true
  config:
    token: $TOKEN_SAVED_IN_PUBLISH_CONTENT
    room_id: "room_id"

Ensure to replace name_of_the_media with the name of the new platform, and file_name.class_name with the appropriate file and class name for the plugin. The name is then used in the media tag in the post file (posts/*.md) to determine the social media.

  1. Configuration: In the config section, specify any required variables for initializing the plugin class. This may include authentication tokens, room IDs, or other platform-specific parameters. Any configuration that needs to be securely passed with GitHub secrets should be prefixed with $ in order to be easily identifiable within the workflow YAML file.

  2. GitHub Secrets: Add any tokens or variables required for the plugin to GitHub secrets. This ensures sensitive information is securely stored. Refer to GitHub secrets documentation for guidance on creating secrets.

  3. Enable the Plugin: Simply set enabled: true to enable the new social media platform. This ensures that it will be implemented when creating posts.

  4. Update publish_content.yml: Finally, update the publish_content.yml file to include an environment variable referencing the token saved in GitHub secrets. Use the following template: (Don't put the prefixed $ in here)


---
env:
  TOKEN_SAVED_IN_PUBLISH_CONTENT: ${{ secrets.TOKEN_SAVED_IN_GITHUB_SECRETS }}

Replace TOKEN_SAVED_IN_GITHUB_SECRETS with the name of the secret containing the token for the new social media platform.

By following these steps, you can seamlessly integrate a new social media platform into Galaxy Social, expanding its reach and functionality.

Duplicate a Social Media Platform with Different Token

If you need to use the same social media platform with different authentication tokens, you can duplicate the entry in the plugins.yml file. Follow these steps:

  1. Duplicate Entry: Copy the entry for the social media platform in the plugins.yml file and paste it below the original entry.

  2. Update Name and Tokens: Change the name of the duplicated entry to reflect the new configuration, and replace the token with the new authentication token.

  3. Configuration: Adjust any other configuration parameters as needed for the duplicated entry.

  4. Use Name in Post: Remember that the name you specify in the plugins.yml file must also be used within the media tag when creating a post. Ensure consistency to link the post with the correct social media platform.

By following these steps, you can effectively duplicate a social media platform with a different token for specific use cases or configurations.

Run locally

You can execute this repository on your machine by running lib/galaxy_social.py with the argument --files Files ... or --folder FOLDER to process files, or add --preview to preview the file as markdown. Also there is --json-out processed_files.json that could be change where to save the json results output.

Remember to add the env variable that needed for each social media seperatly.

Social media implemented