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

feat: add support for blogpost from other (generic) platforms #1774

Closed
wants to merge 363 commits into from

Conversation

babblebey
Copy link
Contributor

@babblebey babblebey commented Oct 1, 2023

Description

This Pull Request adds support for blogpost from other platforms in highlights. Leverages the open-graph node library, fetches the open graph data from the given blogpost url provided as highlightLink and uses the image property on the data as the blogspot highlight type social image when posting new highlights.

Implementation Caveat πŸ€”

  • No Support for Auto-Summarize

This is specifically because in order to consume the auto-summarize function, the generateDevToBlogHighlightSummary (which is an auto-summary function for the DevTo blogpost) takes two(2) arguments namely the blogTitle and blogMarkdown (which is the blog post content). This implementation uses the open-graph to fetch meta data which satisfies only the blogTitle. There isn't a straight-forward or consistent or lightweight implementation (aside scrapping 🀫) to access the body content of this generic blog post.

In the absence of the body content of this blog post, I hence settled for implementing a notice of no-support for auto-summarize for the auto-summarize feature on the generic blog post for now.

Changes Made

  • Refactored all DevTo related components and functions, to reflect DevTo*** in its naming to make them more specific to dev.to blog post type
  • Added a fetchOGData endpoint in the /api route which fetches open-graph data for specified url
const og = require("open-graph");

export default async function handler(req: NextApiRequest, res: NextApiResponse) {
  const url = req.query.url;
  if (req.method === "GET") {
    og(url, (error: any, meta: {}) => {
      if (!error) {
        res.status(200).json({ response: meta });
      } else {
        res.status(200).json({ response: {} });
      }
    });
  }
}
  • Added GenericBlogOpenGraphImage component which consumes the fetchOGData endpoint, builds and sends response image as returned component node.
  • Added a isValidURL helper function to validate url input in the highlightLink field on highlight input form.
  • Integrated the the GenericBlogOpenGraphImage component and isValidURL function in appropriate base components.
  • Fixed edge case where repository are automatically tagged to blogposts without intentionally tagged repos, resulting in repositories url that do not exist.
  • Implemented a toast in attempt to add notification for auto-summarize not being supported for blogpost from these generic platform because we do not currently have any means of accessing the exact blog post body content which is one of the required parameter/content for auto-summarize.
const handleGenerateHighlightSummary = async () => {
  ....

  // πŸ•πŸ•πŸ• NOTICE HERE πŸ•πŸ•πŸ• 
  if (highlightLink && (!highlightLink.includes("github.com") || !highlightLink.includes("dev.to"))) {
    toast({
      description: "Auto-Summarize not supported for current link!",
      title: "Oops!",
      variant: "warning",
    });
    return;
  }

  ....
};

πŸ•

What type of PR is this? (check all applicable)

  • πŸ• Feature
  • πŸ› Bug Fix
  • πŸ“ Documentation Update
  • 🎨 Style
  • πŸ§‘β€πŸ’» Code Refactor
  • πŸ”₯ Performance Improvements
  • βœ… Test
  • πŸ€– Build
  • πŸ” CI
  • πŸ“¦ Chore (Release)
  • ⏩ Revert

Related Tickets & Documents

Fixes #1656

Mobile & Desktop Screenshots/Recordings

Writing a (Generic) Blogpost highlight type

screencast-localhost_3000-2023.10.15-04_00_37.webm

Blogpost (without tagged repos)

image

Blogpost (with tagged repos)

image

Demo: Toast for Not Supported Message for Auto-Summarize

screencast-localhost_3000-2023 10 15-02_54_52

Added tests?

  • πŸ‘ yes
  • πŸ™… no, because they aren't needed
  • πŸ™‹ no, because I need help

Added to documentation?

  • πŸ“œ README.md
  • πŸ““ docs.opensauced.pizza
  • πŸ• dev.to/opensauced
  • πŸ“• storybook
  • πŸ™… no documentation needed

[optional] Are there any post-deployment tasks we need to perform?

This PR adds a new package open-graph

[optional] What gif best describes this PR or how it makes you feel?

giphy (1)

@netlify
Copy link

netlify bot commented Oct 1, 2023

βœ… Deploy Preview for design-insights ready!

Name Link
πŸ”¨ Latest commit 3158b1f
πŸ” Latest deploy log https://app.netlify.com/sites/design-insights/deploys/65b84f8c1d0622000821cffe
😎 Deploy Preview https://deploy-preview-1774--design-insights.netlify.app
πŸ“± Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@netlify
Copy link

netlify bot commented Oct 1, 2023

βœ… Deploy Preview for oss-insights ready!

Built without sensitive environment variables

Name Link
πŸ”¨ Latest commit 551a6f4
πŸ” Latest deploy log https://app.netlify.com/sites/oss-insights/deploys/652b4a753ee167000813ee5f
😎 Deploy Preview https://deploy-preview-1774--oss-insights.netlify.app
πŸ“± Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@babblebey babblebey marked this pull request as ready for review October 15, 2023 03:05
Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

PR Compliance Checks

Thank you for your Pull Request! We have run several checks on this pull request in order to make sure it's suitable for merging into this project. The results are listed in the following section.

Watched Files

This pull request modifies specific files that require careful review by the maintainers.

Files Matched

  • npm-shrinkwrap.json
  • package.json

@OgDev-01 OgDev-01 requested a review from a team November 7, 2023 00:13
@OgDev-01 OgDev-01 added awaiting review merge conflicts Needs merge conflict resolved labels Nov 7, 2023
@OgDev-01
Copy link
Contributor

Hey @babblebey, would you mind fixing up the merge conflict before we proceed to reviewing this pr?

@jpmcb
Copy link
Member

jpmcb commented Nov 28, 2023

We've gotten some feedback that people want this feature: any updates here? Or if it's more or less ready to go we could merge beta onto @babblebey's branch

@babblebey
Copy link
Contributor Author

Hey @jpmcb, it's pretty much ready, I just gotta fix the conflicts 😁

Will do shortly 🀞🏾

Copy link

netlify bot commented Nov 28, 2023

❌ Deploy Preview for oss-insights failed.

Name Link
πŸ”¨ Latest commit 3158b1f
πŸ” Latest deploy log https://app.netlify.com/sites/oss-insights/deploys/65b84f8cb516b0000832e021

@babblebey
Copy link
Contributor Author

All set @jpmcb

Cc @OgDev-01

πŸ•

@bdougie bdougie removed the merge conflicts Needs merge conflict resolved label Nov 28, 2023
nickytonline and others added 15 commits December 13, 2023 15:08
## [1.80.0-beta.1](open-sauced/app@v1.79.3-beta.1...v1.80.0-beta.1) (2023-12-13)

### πŸ› Bug Fixes

* increase z-index of show latest pull request button ([d0b7722](open-sauced@d0b7722))
* now the add more button for adding more contributors to a list is the primary CTA ([09df01c](open-sauced@09df01c))
* now the add more button for adding more contributors to a list is the primary CTA ([open-sauced#2334](open-sauced#2334)) ([ef070f2](open-sauced@ef070f2))
* pull request button shows PRs now on a contributor card ([open-sauced#2277](open-sauced#2277)) ([a87bdff](open-sauced@a87bdff))

### πŸ• Features

* use GitHub API for user search box ([open-sauced#2331](open-sauced#2331)) ([152b933](open-sauced@152b933))
…contributors" while the contributor list is loading. (open-sauced#2339)
@BekahHW
Copy link
Member

BekahHW commented Jan 29, 2024

Hey @babblebey I'm going to move this to draft mode until you have time to work on it.

@BekahHW BekahHW marked this pull request as draft January 29, 2024 16:21
nickytonline and others added 17 commits January 29, 2024 11:25
## [1.85.0-beta.5](open-sauced/app@v1.85.0-beta.4...v1.85.0-beta.5) (2024-01-29)

### πŸ› Bug Fixes

* hydration issue for suggested repo list component ([open-sauced#2535](open-sauced#2535)) ([31f8c37](open-sauced@31f8c37))
* now checkboxes in the search for tracked repositories flow add or remove as expected ([open-sauced#2544](open-sauced#2544)) ([390c760](open-sauced@390c760))

### πŸ• Features

* created the repository stat card component ([open-sauced#2546](open-sauced#2546)) ([bc35e83](open-sauced@bc35e83))
@babblebey
Copy link
Contributor Author

Hey apologies @BekahHW, this proved super weird of a conflict to resolve, after many attempts at resolving, It kept coming back asking that I resolve over and over again.

I ended up moving for rebasing and that brought in all the 390 changes 😞

PR still works as it should for sure. I don't know exactly what impact the 390 changes would make on merge whenever it gets there, but I do recognize how uneasy it's become to review this PR now.... So kindly guide me here, will you say I keep this PR as is or would you prefer that I repatch this feature in another new PR that can remove the burden of the out-of-context 300+ file changes!?

Cc @OgDev-01 @jpmcb

@bdougie
Copy link
Member

bdougie commented Jan 30, 2024

At this point this is not reviewable and the PR is getting stale.

My recommendation is create a new PR from a new branch from beta and cherry picking the commits you actually need.

Going to close this PR since this will require git surgery or some serious fixing to get back to unity.

@bdougie bdougie closed this Jan 30, 2024
@babblebey babblebey deleted the feat/generic-blog-support branch January 30, 2024 13:32
@babblebey
Copy link
Contributor Author

git surgery πŸ˜‚πŸ€£

I should patch this in less than 24h now, and I just mistakenly clicked "Delete Branch" 🀦🏾

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merge conflicts Needs merge conflict resolved
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature: Allow users to post blogs from (RSS) multiple platforms