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

[InstagramBridge] Truncate long titles and use full text as content #961

Merged
merged 4 commits into from
Dec 12, 2018

Conversation

lorenzos
Copy link
Contributor

@lorenzos lorenzos commented Dec 11, 2018

Instagram posts' text can be very long used as feed items' title. This PR truncates titles over 120 characters, and uses the full text as items' content if truncated.

Possible changes I can make on this PR if you prefer:

  • Always put the full text in items' content, also if it was short enough to not be truncated in items' title.
  • Use a better truncation function that preserves words' integrity.

@logmanoriginal
Copy link
Contributor

Thanks for the PR!

Always put the full text in items' content, also if it was short enough to not be truncated in items' title.

It makes sense to be consistent for all items in a feed in my opinion.

Use a better truncation function that preserves words' integrity.

Does something like this work for you?

if(strlen($title) > 64)
$title = substr($title, 0, strpos(wordwrap($title, 64), "\n")) . '...';

Let me know if you want to update the PR, I have no objections merging it like it is.

@lorenzos
Copy link
Contributor Author

I had something different for the truncation on words, but I guess it's ok if already used in the Facebook bridge. Do you want to use a 64 chars limit as in Facebook, or keep my proposed 120?

Let me know if you want to update the PR

Sure, I will.

@logmanoriginal
Copy link
Contributor

Do you want to use a 64 chars limit as in Facebook, or keep my proposed 120?

If 120 works for you, it's fine by me. in the end it depends on how your feed reader displays the titles. Since I don't use Instagram, this is no issue for me :)

@lorenzos
Copy link
Contributor Author

lorenzos commented Dec 12, 2018

I think the PR is now ready to merge:

  • I modified the title truncation as you suggested, using wordwrap();
  • I made that regardless of actual text content length, so when posts have explicit wraps only the first line goes in the title, this usually leaves hastags and crap aside, check this for example;
  • full text content is now added after the image in every item, and new lines are preserved using nl2br().

@logmanoriginal logmanoriginal merged commit 758f37b into RSS-Bridge:master Dec 12, 2018
@logmanoriginal
Copy link
Contributor

Merged. Thanks for keeping it updated 👍

infominer33 pushed a commit to web-work-tools/rss-bridge that referenced this pull request Apr 17, 2020
…SS-Bridge#961)

- Truncate long titles and use full text as content (using only the first line of text content as title)
@lorenzos lorenzos deleted the instagram-truncate branch June 22, 2020 08:52
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