Skip to content

Latest commit

 

History

History
148 lines (101 loc) · 8.73 KB

README.md

File metadata and controls

148 lines (101 loc) · 8.73 KB

Galaxy Social

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:
 - mastodon-eu-freiburg
 - matrix-eu-announce
 - bluesky-galaxyproject
 - linkedin-galaxyproject

mentions:
 mastodon-eu-freiburg:
  - [email protected]
 bluesky-galaxyproject:
  - galaxyproject.bsky.social
 matrix-eu-announce:
  - bgruening:matrix.org

hashtags:
 mastodon-eu-freiburg:
  - UseGalaxy
  - GalaxyProject
  - UniFreiburg
  - EOSC
  - EuroScienceGateway
 bluesky-galaxyproject:
  - UseGalaxy
  - GalaxyProject
  - UniFreiburg
  - EOSC
  - EuroScienceGateway
 linkedin-galaxyproject:
  - UseGalaxy
  - GalaxyProject
  - UniFreiburg
  - EOSC
  - EuroScienceGateway
---
Your text content goes here. (Markdown syntax will not pass to Bluesky, Mastodon, and Linkedin!)
For images just drag and drop them here. they will look like this:
![A](https://example.com/a.jpg)

Notes on the Template:

  • Everything between the two --- are metatags and should be in YAML format.

  • "media" (Required): Ensure the media name is implemented inside the plugins.yml.

  • "mentions" and "hashtags" (Optional): Follow the specified format as shown in the template.

  • "Your text content goes here." (Required): This is the content that will be posted to social media platforms.

    Note that some social media platforms do not support Markdown formatting, so use plain text only.

    Dividing long content into multiple threaded posts: when the character limit is reached on a social media, it will be divided into several posts as a thread. You can also define custom breakpoints for splitting the post by inserting 2 empty lines anywhere in the text. The second empty line will simply be removed for media that don't support content splitting.

  • "images" (Optional): You can include images using Markdown format at the end of the file like this: ![Alternative text](Link to the image). Alternatively, you can simply drag and drop an image from your PC while adding your file.

  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 GitHub action will run and 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 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 galaxy_social.yml: Finally, update the galaxy_social.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

  • Bluesky
  • Mastodon
  • Matrix: hashtags are included in the post but have no special function in matrix.
  • Slack: mentions and hashtags are not working!
  • Linkedin: mentions are not working!