Skip to content

#118 Allow users to embed Medium posts with Liquid Tags#1161

Merged
benhalpern merged 2 commits intoforem:masterfrom
edisonywh:feature/medium-liquid-tag
Apr 17, 2019
Merged

#118 Allow users to embed Medium posts with Liquid Tags#1161
benhalpern merged 2 commits intoforem:masterfrom
edisonywh:feature/medium-liquid-tag

Conversation

@edisonywh
Copy link
Copy Markdown
Contributor

@edisonywh edisonywh commented Nov 20, 2018

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

  • Refactor
  • Feature
  • Bug Fix
  • Documentation Update

Description

  • Added new liquid tag - "{% medium https://medium.com}"
  • Added a scraper - MediumArticleRetrievalService which crawls the
    given Medium URL for informations needed for the liquid tag

Right now my implementation takes a full link, but we can choose to use handle + article ID. Open to suggestion here.

Related Tickets & Documents

#118

Mobile & Desktop Screenshots/Recordings (if there are UI changes)

11-20-923pm

11-20-923pm-1

03-15-1229AM

Added to documentation?

  • docs.dev.to
  • readme
  • no documentation needed

def whitelisted_image_host?(src)
# GitHub camo image won't parse but should be safe to host direct
src.start_with?("https://camo.githubusercontent.com/")
src.start_with?("https://camo.githubusercontent.com/") || src.start_with?("https://cdn-images-1.medium.com")
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I doubt medium would like us hotlinking their cdn

@Link2Twenty
Copy link
Copy Markdown
Contributor

ping @Zhao-Andy

@edisonywh edisonywh force-pushed the feature/medium-liquid-tag branch from 9866a68 to e720bea Compare March 14, 2019 16:30
@edisonywh edisonywh changed the title [WIP] #118 Allow users to embed Medium posts with Liquid Tags #118 Allow users to embed Medium posts with Liquid Tags Mar 14, 2019
@edisonywh
Copy link
Copy Markdown
Contributor Author

@Zhao-Andy can I get a review on this? (sorry it took so long too)

@Zhao-Andy Zhao-Andy self-requested a review March 14, 2019 16:45
@rhymes
Copy link
Copy Markdown
Contributor

rhymes commented Mar 14, 2019

Great job @edisonywh !

I have an odd question about the UI: shouldn't it be clear that the embed is from medium? Like this they look like regular dev.to posts, I guess I'm used to other embeds that visibly tell you where the content is coming from.

Just a thought.

@edisonywh
Copy link
Copy Markdown
Contributor Author

edisonywh commented Mar 14, 2019

@rhymes Ah good point, I just straight out copied from other css haha. Any tips on that? Don't want to break the design guideline

@rhymes
Copy link
Copy Markdown
Contributor

rhymes commented Mar 14, 2019

@edisonywh I googled a bit and it seems like they removed support for embeddable medium posts sometime ago and in the terms of service they say:

As for other parts of Medium, you may not copy or adapt any portion of our code or visual design elements (including logos) without express written permission from Medium unless otherwise permitted by law.

So I guess you can't add a medium logo in there :-(

Maybe a sort of subtitle/byline that says "from Medium.com" ?

@edisonywh
Copy link
Copy Markdown
Contributor Author

edisonywh commented Mar 14, 2019

So I guess you can't add a medium logo in there :-(

@rhymes I looked at their branding guideline post (posted in 2017), and upon downloading, the README full text is depicted below:

# Medium Logos
This repo contains versions of our logo and wordmark in popular formats. Feel free to
use these anywhere on the web with a few simple guidelines: Do not modify or alter the
Medium logo or use it in a confusing way, including suggesting sponsorship or endorsement
by Medium, or in a way that confuses Medium with another brand.

[For full brand guidelines read this.](https://medium.com/policy/logos-and-brand-guidelines-f1a01a733592)

If you have any questions, email us at yourfriends@medium.com.

Thanks

Looks like I can use the logo afterall? :)

EDIT:

Thoughts?

image

class MediumTag < LiquidTagBase
include ApplicationHelper
include ActionView::Helpers::TagHelper
include InlineSvg::ActionView::Helpers
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added this line for inline_svg to reuse the Medium icon that's already in codebase

@Link2Twenty
Copy link
Copy Markdown
Contributor

@edisonywh
Copy link
Copy Markdown
Contributor Author

@Link2Twenty I did not know that! Would that be the preferred way to do this?

@rhymes
Copy link
Copy Markdown
Contributor

rhymes commented Mar 16, 2019

I tried to download the JSON format and it contains invalid chars at the beginning, I suppose it's related to CORS and the fact that Medium doesn't advertise the format anywhere.

I'd stick to your version for the time being

@edisonywh
Copy link
Copy Markdown
Contributor Author

Yeah quick search says it's to prevent JSON hijacking?

https://stackoverflow.com/questions/2669690/why-does-google-prepend-while1-to-their-json-responses

@edisonywh
Copy link
Copy Markdown
Contributor Author

@Zhao-Andy is there anything else I can do to move this forward? :)

@jessleenyc
Copy link
Copy Markdown
Contributor

@edisonywh I think we'll want to adjust the design a bit more to make sure it really feels differentiated from DEV articles. Let me circle back w/ the team and get back to you.

end
end

Liquid::Template.register_tag("medium", MediumTag)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@edisonywh will you remove this line for now? we're going to mess with the design a tiny bit but would like to merge what you have so far into the codebase.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Sure thing! Will ping you again once I've done so

@pr-triage pr-triage bot added the PR: unreviewed bot applied label for PR's with no review label Mar 28, 2019
Copy link
Copy Markdown
Contributor

@jessleenyc jessleenyc left a comment

Choose a reason for hiding this comment

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

left a comment above!

- Added new liquid tag - "{% medium https://medium.com}"
- Added a scraper - `MediumArticleRetrievalService` which crawls the
given Medium URL for informations needed for the liquid tag
@edisonywh edisonywh force-pushed the feature/medium-liquid-tag branch from b860536 to a833f82 Compare March 29, 2019 15:20
@edisonywh
Copy link
Copy Markdown
Contributor Author

@jessleenyc updated and removed the register tag line. Feel free to ping me if there's anything else I can do to help!

Copy link
Copy Markdown
Contributor

@jessleenyc jessleenyc left a comment

Choose a reason for hiding this comment

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

lgtm!

we'll make some minor tweaks and then make it available soon!

@pr-triage pr-triage bot added PR: reviewed-approved bot applied label for PR's where reviewer approves changes and removed PR: unreviewed bot applied label for PR's with no review labels Mar 29, 2019
@benhalpern benhalpern merged commit 3d12535 into forem:master Apr 17, 2019
@pr-triage pr-triage bot removed the PR: reviewed-approved bot applied label for PR's where reviewer approves changes label Apr 17, 2019
@pr-triage pr-triage bot added the PR: merged bot applied label for PR's that are merged label Apr 17, 2019
@edisonywh edisonywh deleted the feature/medium-liquid-tag branch April 17, 2019 14:57
coreyja added a commit to coreyja/dev.to that referenced this pull request Apr 20, 2019
* master: (83 commits)
  Update gitdocs (forem#2500)
  Condense 'ask me anything' to 'ama' (forem#2428) [ci skip]
  Add user_signed_in? to cache key for styles (forem#2498)
  Added troubleshooting for byebug without readline issue (forem#2481)
  Fix some frontend linting issues (forem#2495) [ci skip]
  Fix <br/> in footer. (forem#2491)
  Remove extra param and add message for prefill (forem#2487)
  Make Cards Change Dynamically and add Reader/Follower Charts (forem#2488)
  Temporarily comment out random (forem#2486)
  Add nav buttons to pwa desktop (forem#2484)
  Feature/filtered charts (forem#2482)
  Add caching for historical data (forem#2476)
  There are installation sections for other OSes now. (forem#2480)
  Add inbox guidelines to users (forem#2473)
  Release Open Inbox (forem#2468)
  Convert underscores in article slugs properly (forem#2472)
  Update framework defaults to match those in Rails 5.1 (forem#2309)
  Enable random order for specs (forem#2466) [ci skip]
  forem#118 Allow users to embed Medium posts with Liquid Tags (forem#1161)
  Allow API to return top articles (forem#2469)
  ...

# Conflicts:
#	Envfile
#	app/models/user.rb
#	db/schema.rb
@mariocsee mariocsee mentioned this pull request May 14, 2019
2 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: merged bot applied label for PR's that are merged

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants