Busy.org improve meta-description for sharing on social

in #utopian-io7 years ago (edited)

Note: Small enhancement tested, merged, working on a build issue to go live.


In the last weeks I've started blogging using Busy.org more. I often find I want to share an article to other friends via other sites and messengers, whether Telegram, Facebook, Twitter, ect.

The previews on these images are generated from meta-data on the Busy page:

U5dtvrn98Y4q9h9n9kbS3YyetKTCzyW_1680x8400.png

To me it is somewhat annoying how the text gets cut off at the end. Notice how it says "I guess I should be eating a I by kirkins"? In some cases this actually made it look like I had a typo in my article. Which is annoying when you're trying to get people to click through to your blog.

My solution was to create a new summary function which either returns 140 characters plus ... or if less than 141 charachters in length simply return all the text without a ....

export function postSummary(post, author) {
  let formattedPost = post.substring(0, 140);
  if (post.length > 140) formattedPost += '...';
  formattedPost += ` by ${author}`;
  return formattedPost;
}

The above would result in "I guess I should be eating a I... by kirkins" instead of the original without the ....

I was able to run this change locally and also as a Heroku instance generated by Busy. That instance was tested, approved, and merged.


Unfortunately, later I found out there was some sort of build issue surrounding the change.

I've looked into the build a bit but I'll probably need some assistance from someone at Busy.

Here is me building a fresh master:

git clone https://github.com/busyorg/busy
cd busy
yarn install
yarn run build
yarn start

When I run that I get Busy seems to be running on localhost:3000 but I get back the following in my terminal:

[nodemon] 1.14.11
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: busy.server.js
[nodemon] starting `node busy.server.js`
SSR error occured, falling back to bundled application instead Error: Request has timed out. It should take no longer than 5000ms.
    at Timeout._onTimeout (/tmp/busy/busy.server.js:9:32268)
    at ontimeout (timers.js:475:11)
    at tryOnTimeout (timers.js:310:5)
    at Timer.listOnTimeout (timers.js:270:5)

With my changed branch I do:

git clone https://github.com/kirkins/busy 
cd busy
git checkout cut_description
yarn install
yarn run build
yarn start

With this the application also seems to be running at localhost:3000 I get back some slightly different output but nothing that helps me to see a problem with my specific change.

[nodemon] 1.14.11
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: busy.server.js
[nodemon] starting `node busy.server.js`
Unable to find New Relic module configuration. A default
configuration file can be copied from /tmp/busy/node_modules/newrelic/lib/config.default.js
and put at /tmp/busy/newrelic.js. If you are not using file based config
please set the environment variable NEW_RELIC_NO_CONFIG_FILE=true
{"v":0,"level":30,"name":"newrelic_bootstrap","hostname":"philip-ThinkPad-T420","pid":5719,"time":"2018-03-28T14:57:37.597Z","msg":"Using New Relic for Node.js. Agent version: 1.40.0; Node version: v8.9.4."}
Unable to find New Relic module configuration. A default
configuration file can be copied from /tmp/busy/node_modules/newrelic/lib/config.default.js
and put at /tmp/busy/newrelic.js. If you are not using file based config
please set the environment variable NEW_RELIC_NO_CONFIG_FILE=true
{"v":0,"level":30,"name":"newrelic_bootstrap","hostname":"philip-ThinkPad-T420","pid":5719,"time":"2018-03-28T14:57:37.601Z","msg":"Module not enabled in configuration; not starting."}
SSR error occured, falling back to bundled application instead Error: Request has timed out. It should take no longer than 5000ms.
    at Timeout._onTimeout (/tmp/busy/busy.server.js:1:1484124)
    at ontimeout (timers.js:475:11)
    at tryOnTimeout (timers.js:310:5)
    at Timer.listOnTimeout (timers.js:270:5)

There is a slight difference in output but this is only related to a 3rd party logging system. Other than that the behavior in terminal and browser seems the exact same with and without my change.

So at this point it is difficult for my to progress with the build issue without getting more information from 9m90m.


Another small change in this commit, changing the meta-data for the Twitter account associated with the website, was previously pointing to @steemit:

<meta property="twitter:site" content={'@busyorg'} />

I'm actually not sure what the end effect of this is when it comes to users sharing Busy links on Twitter. If you know let me know in the comments!


Update: based on a comment from @fel1xw I have made a new PR using lodash to get the ball rolling on fixing the build issue and having this enhancement go live. Thanks for that.



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Your contribution cannot be approved because it does not follow the Utopian Rules.

Hi, this should not have been accepted, as it is a trivial code snippet. As @fel1xw pointed out, you could've just changed one line to achieve the same result.

You can contact us on Discord.
[utopian-moderator]

Hey @amosbastian, I just gave you a tip for your hard work on moderation. Upvote this comment to support the utopian moderators and increase your future rewards!

Edit moved to private chat on Discord.

Thanks, I will PM you on Discord.

Hey kirkins,

as lodash is already included in the project you could simply change the following line:

const desc = `${bodyText.substring(0, 140)} by ${author}`;

to:

const desc = `${_.truncate(bodyText, { length: 140 })} by ${author}`;

This would produce a string with ... at the end automatically, if you want to have 140 characters and then the dots, use { length: 143 }, otherwise it will to 137 characters and then the dots to be 140 characters in total.

And of course you first need to import it like: import _ from 'lodash'.
You can find the documentation here: https://lodash.com/docs/4.17.5#truncate

Best

Thanks, going to give it a try.

Great. You can give me a reply if it worked.

Anyway your implementation would work as well, but why reinventing the wheel? :P

I was thinking what I had should work. Either way I made a new PR based on your suggestion, thanks!

https://github.com/busyorg/busy/pull/1686

This time the build is passing. Thanks for mention me there! It looks like you need to rebase against latest master branch.

Thank you for the contribution. It has been approved.

You can contact us on Discord.
[utopian-moderator]

I wish I was a bit more skilled in this area. But some of these reasons is why i am not really a fan of busy

wow I have no coding stills and this is beyond me but hey cheers good job making things get better for everyone!

Interesting, greetings.

Thanks, welcome.

you to good

Hey @kirkins I am @utopian-io. I have just upvoted you!

Achievements

  • You have less than 500 followers. Just gave you a gift to help you succeed!
  • Seems like you contribute quite often. AMAZING!

Community-Driven Witness!

I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!

mooncryption-utopian-witness-gif

Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x

sneaky-ninja-sword-xs.jpg

Sneaky Ninja Attack! You have just been defended with a 9.64% upvote!
I was summoned by @kirkins. I have done their bidding and now I will vanish...


woosh

A portion of the proceeds from your bid was used in support of youarehope and tarc.


Abuse Policy
Rules
How to use Sneaky Ninja
How it works
Victim of grumpycat?

hmm... wondering I should remove the " - Busy", that is part of the title too?

Coin Marketplace

STEEM 0.20
TRX 0.15
JST 0.030
BTC 65651.70
ETH 2676.03
USDT 1.00
SBD 2.91