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:
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
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]
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
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!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Edit moved to private chat on Discord.
Thanks, I will PM you on Discord.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
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
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Thanks, going to give it a try.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Great. You can give me a reply if it worked.
Anyway your implementation would work as well, but why reinventing the wheel? :P
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
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
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
This time the build is passing. Thanks for mention me there! It looks like you need to rebase against latest
master
branch.Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Thank you for the contribution. It has been approved.
You can contact us on Discord.
[utopian-moderator]
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
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
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
wow I have no coding stills and this is beyond me but hey cheers good job making things get better for everyone!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Interesting, greetings.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Thanks, welcome.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
you to good
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Hey @kirkins I am @utopian-io. I have just upvoted you!
Achievements
Community-Driven Witness!
I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!
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
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
I was summoned by @kirkins. I have done their bidding and now I will vanish...
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?
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
hmm... wondering I should remove the
" - Busy"
, that is part of the title too?Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
you are good man and Purposeful
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit