Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve preview generation, matrix mentions and image support #27

Merged
merged 4 commits into from
Jun 5, 2024

Conversation

wm75
Copy link
Member

@wm75 wm75 commented Jun 3, 2024

This change redesigns the interface of plugins which are now expected to provide two methods:

  • format_content

    which takes the parsed markdown content and returns a (formatted_content, preview, warnings) tuple, in which

    • formatted_content is a plugin-specific object,
    • preview is the plugin's best string representation of what a post generated by it would look like
    • warnings is a string of any plugin-specific warning messages that were produced during processing of the content
  • create_post

    which takes the formatted_content generated by format_content and submits it as a post to the respective platform;
    returns a success, link tuple, where success can be true or false, and link is a link to the generated post on the platform or None if no link is available

Matrix mentions are now formatted much more according to the matrix specs (including the mentioned user's display name if it can be found) and will now display correctly in at least two clients (element and nheko). Likewise, images are now uploaded in a format compatible with both of these clients.

This is still incomplete as I haven't rewritten the bluesky, linkedin and slack plugins (which I cannot test) yet, but I hope the code and description are clear enough that you can complete the work @arash77 ?

wm75 and others added 3 commits June 3, 2024 23:52
This change redesigns the interface of plugins which are now expected to
provide two methods:

- format_content

  which takes the parsed markdown content and returns a
  (formatted_content, preview, warnings) tuple, in which
  - formatted_content is a plugin-specific object,
  - preview is the plugin's best string representation of what a post generated
    by it would look like
  - warnings is a string of any plugin-specific warning messages that were
    produced during processing of the content

- create_post

  which takes the formatted_content generated by format_content and
submits it as a post to the respective platform;
  returns a success, link tuple, where success can be true or false, and
link is a link to the generated post on the platform or None if no link
is available

Matrix mentions are now formatted much more according to the matrix
specs (including the mentioned user's display name if it can be found)
and will now display correctly in at least two clients (element and
nheko). Likewise, images are now uploaded in a format compatible with
both of these clients.
This commit updates the dependencies in the `requirements.txt` file. It also updates the GitHub Actions workflows (`preview.yml` and `publish_content.yml`) to use the latest versions of the `actions/checkout` and `actions/setup-python` actions. The Python version in the workflows is updated to `3.12` (this was necessary for  using `asyncio.Runner()`) . These changes aim to improve the overall functionality and compatibility of the project.
@arash77
Copy link
Collaborator

arash77 commented Jun 4, 2024

@wm75 Thank you. This is a great idea. I have rewritten the BlueSky and Slack plugins with the same functionality.
Additionally, I made some changes to the comment format to separate the post files in each comment and making each social media platform title more user-friendly.
Now, the text is wrapped with a (k/n) format at the end of each separated post. Also, it seems that using asyncio.Runner() requires Python 3.12, so I have updated the workflow files accordingly.

@wm75
Copy link
Member Author

wm75 commented Jun 5, 2024

Also, it seems that using asyncio.Runner() requires Python 3.12, so I have updated the workflow files accordingly.

Oh, hadn't thought of that, thanks for catching it!

and thanks for all the other work, I'll take a look now.

Copy link
Member Author

@wm75 wm75 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works very well, thanks @arash77!

@wm75
Copy link
Member Author

wm75 commented Jun 5, 2024

... and feel free to approve and merge

@arash77 arash77 merged commit 883012d into main Jun 5, 2024
1 check passed
@arash77 arash77 deleted the better-previews branch June 5, 2024 14:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants